os/graphics/graphicsresourceservices/graphicsresourceimplementation/test/src/tgraphicsresourceteststepbase.cpp
Update contrib.
1 // Copyright (c) 2007-2009 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
22 #include "tgraphicsresourceteststepbase.h"
25 CTSgTestStepBase::CTSgTestStepBase(TBool aConformanceTests) :
26 iEnableConformanceTests(aConformanceTests)
30 CTSgTestStepBase::~CTSgTestStepBase()
32 iSecondThread.Close();
33 iPixelFormatArray.Close();
34 User::Free(iDiagonalImageData);
39 Overrides of base class virtual
40 @leave Gets system wide error code
41 @return - TVerdict code
43 TVerdict CTSgTestStepBase::doTestStepPreambleL()
45 // Set the logger to shared so that secondary threads can write to the log
46 User::LeaveIfError(Logger().ShareAuto());
47 SetTestStepResult(EPass);
48 iDiagonalImageData = static_cast<TUint32*>(User::AllocL(KDiagonalImageSize * KDiagonalImageDataStride));
49 // Populate iDiagonalImageData with green diagonal from top-left to bottom-right on white background
50 Mem::Fill(iDiagonalImageData, KDiagonalImageSize * KDiagonalImageDataStride, 0xFF);
51 for (TInt i = 0; i < KDiagonalImageSize; ++i)
53 iDiagonalImageData[i * (KDiagonalImageSize + 1)] = 0xFF00FF00;
55 return TestStepResult();
59 Override of base class virtual
60 @leave Gets system wide error code
61 @return - TVerdict code
63 TVerdict CTSgTestStepBase::doTestStepPostambleL()
65 User::Free(iDiagonalImageData);
66 iDiagonalImageData = NULL;
67 return TestStepResult();
71 Creates an image with some predefined parameters.
72 @param aImage output image handle
73 @leave Gets system wide error code
75 void CTSgTestStepBase::CreateImageL(RSgImage& aImage)
78 info.iSizeInPixels = TSize(8, 8);
79 info.iUsage = ESgUsageBitOpenVgImage;
80 info.iPixelFormat = EUidPixelFormatRGB_565;
82 CheckErrorL(KErrNone, aImage.Create(info, KCrossImageData, KCrossImageDataStride), (TText8*)__FILE__, __LINE__);
86 Creates a second process and do some tests in it.
87 @param aProcessName The name of the new process
88 @param aTestInfo The information for the tests
89 @return A bitwise mask of test passes (never an error code)
90 @leave Gets system wide error code
92 TInt CTSgTestStepBase::CreateSecondProcessAndDoTestL(const TDesC &aProcessName, TSgProcessTestInfo& aTestInfo)
94 // Create a second process
96 TInt err = process.Create(aProcessName, KNullDesC);
97 User::LeaveIfError(err);
98 CleanupClosePushL(process);
100 // Specify the id passed to the second process
101 TPckg<TSgProcessTestInfo> ptr(aTestInfo);
102 TESTL(KErrNone == process.SetParameter(KSecondProcessParametersSlot, ptr));
104 // Kick off the second process and wait for it to complete
105 // The actual testing is done in the second process
106 TRequestStatus status = KRequestPending;
107 process.Logon(status);
109 User::WaitForRequest(status);
111 // exitreason could either be a negative error code or a bitwise
112 // mask of test passes.
113 TInt exitreason = process.ExitReason();
115 CleanupStack::PopAndDestroy();
117 if (exitreason < KErrNone)
119 INFO_PRINTF2(_L("The second process returned error code %d"), exitreason);
128 Creates a second process, runs the requested test and ensures that
129 the specified panic occurs.
131 @param aTestInfo The specification for this test
132 @param aPanicCode The expected panic code
133 @param aExitCategory The expected panic category
134 @param aProcessName The name of the new process
136 @leave One of the system wide error codes
138 void CTSgTestStepBase::CreateSecondProcessAndCheckPanicL(TSgProcessTestInfo& aTestInfo, TInt aPanicCode, TExitCategoryName aExitCategory, const TDesC &aProcessName)
140 // Create a second process
142 User::LeaveIfError(process.Create(aProcessName, KNullDesC));
143 CleanupClosePushL(process);
145 // Specify the id passed to the second process
146 TPckg<TSgProcessTestInfo> ptr(aTestInfo);
147 TESTL(KErrNone == process.SetParameter(KSecondProcessParametersSlot, ptr));
149 // Kick off the second process and wait for it to complete
150 // The actual testing is done in the second process
151 TRequestStatus status = KRequestPending;
152 process.Logon(status);
154 User::WaitForRequest(status);
156 if(EExitPanic != process.ExitType())
158 ERR_PRINTF3(_L("Expected exit type: %d, Actual exit type: %d"), EExitPanic, process.ExitType());
162 if(aPanicCode != process.ExitReason())
164 ERR_PRINTF3(_L("Expected panic code: %d, Actual panic code: %d"), aPanicCode, process.ExitReason());
168 TExitCategoryName secondProcessExitCategory = process.ExitCategory();
169 if(aExitCategory != secondProcessExitCategory)
171 ERR_PRINTF3(_L("Expected panic category: %S, Actual panic category: %S"), &aExitCategory, &secondProcessExitCategory);
175 CleanupStack::PopAndDestroy();
179 Creates a second thread and do some tests in it.
180 @param aTestInfo The information for the tests
181 @leave Gets system wide error code
183 TInt CTSgTestStepBase::CreateSecondThreadAndDoTestL(TSgThreadTestInfo aTestInfo)
187 User::LeaveIfError(sem.CreateGlobal(KSecondThreadSemaphore, 0, EOwnerThread));
188 CleanupClosePushL(sem);
190 aTestInfo.iTestStep = this;
192 User::LeaveIfError(iSecondThread.Create(KSecondThread, SgTestSecondThread::ThreadStart, KDefaultStackSize, KSecondThreadMinHeapSize, KSecondThreadMaxHeapSize, &aTestInfo));
193 // Launch second thread
194 TRequestStatus statusSecondThread;
195 iSecondThread.Logon(statusSecondThread);
196 iSecondThread.SetPriority(EPriorityLess);
197 iSecondThread.Resume();
199 User::WaitForRequest(statusSecondThread);
201 TExitCategoryName exitCategory = iSecondThread.ExitCategory();
202 if (exitCategory.Compare(_L("Kill")) != 0)
204 ERR_PRINTF2(_L("Second thread terminated with reason category '%S'"), &exitCategory);
205 SetTestStepResult(EFail);
207 TInt result = iSecondThread.ExitReason();
210 CleanupStack::PopAndDestroy(1, &sem);
211 iSecondThread.Close();
217 Creates a second thread and do some panic tests in it.
218 @param aTestInfo The information for the tests
219 @param aPanicCode The expected panic code
220 @param aExitCategory The expected panic category
221 @param aThreadName The name of the new thread
222 @leave Gets system wide error code
224 void CTSgTestStepBase::CreateSecondThreadAndCheckPanicL(TSgThreadTestInfo aTestInfo, TInt aPanicCode, TExitCategoryName aExitCategory, const TDesC &aThreadName)
226 aTestInfo.iTestStep = this;
227 User::LeaveIfError(iSecondThread.Create(aThreadName, SgTestSecondThread::ThreadStart, KDefaultStackSize, KSecondThreadMinHeapSize, KSecondThreadMaxHeapSize, &aTestInfo));
229 // Launch second thread
230 TRequestStatus statusSecondThread;
231 iSecondThread.Logon(statusSecondThread);
232 iSecondThread.SetPriority(EPriorityLess);
233 iSecondThread.Resume();
235 User::WaitForRequest(statusSecondThread);
237 if(EExitPanic != iSecondThread.ExitType())
239 ERR_PRINTF3(_L("Expected exit type: %d, Actual exit type: %d"), EExitPanic, iSecondThread.ExitType());
243 if(aPanicCode != iSecondThread.ExitReason())
245 ERR_PRINTF3(_L("Expected panic code: %d, Actual panic code: %d"), aPanicCode, iSecondThread.ExitReason());
249 TExitCategoryName secondThreadExitCategory = iSecondThread.ExitCategory();
250 if(aExitCategory != secondThreadExitCategory)
252 ERR_PRINTF3(_L("Expected panic category: %S, Actual panic category: %S"), &aExitCategory, &secondThreadExitCategory);
257 iSecondThread.Close();
261 Gets the supporting pixel formats according to the specified usage bit.
262 @leave Gets system wide error code
264 void CTSgTestStepBase::CallGetPixelFormatsL(TUint32 aUsage)
266 iPixelFormatArray.Reset();
267 CheckErrorL(KErrNone, RSgImage::GetPixelFormats(aUsage, iPixelFormatArray), (TText8*)__FILE__, __LINE__);
271 Checks the pixel formats returned against the compatibility guarantee table.
272 @leave Gets system wide error code
274 void CTSgTestStepBase::TestGetPixelFormatCompatibilityGuaranteesL()
276 _LIT(KLibOpenGLES2, "libGLESv2.dll");
279 TBool supportGLES2 = (lib.Load(KLibOpenGLES2) == KErrNone);
282 // OpenVG - Mandatory support
283 CallGetPixelFormatsL(ESgUsageBitOpenVgImage);
284 TEST(CheckPixelFormatPresent(ESgPixelFormatARGB_8888_PRE));
285 TEST(CheckPixelFormatPresent(ESgPixelFormatARGB_8888));
286 TEST(CheckPixelFormatPresent(ESgPixelFormatXRGB_8888));
287 TEST(CheckPixelFormatPresent(ESgPixelFormatRGB_565));
288 TEST(CheckPixelFormatPresent(ESgPixelFormatA_8));
289 CallGetPixelFormatsL(ESgUsageBitOpenVgSurface);
290 TEST(CheckPixelFormatPresent(ESgPixelFormatARGB_8888_PRE));
291 TEST(CheckPixelFormatPresent(ESgPixelFormatXRGB_8888));
292 TEST(CheckPixelFormatPresent(ESgPixelFormatRGB_565));
294 // OpenGL ES - Not mandatory, but should cause no errors.
295 CallGetPixelFormatsL(ESgUsageBitOpenGlesTexture2D);
296 CallGetPixelFormatsL(ESgUsageBitOpenGlesSurface);
298 // OpenGL ES 2 - Mandatory if present.
299 CallGetPixelFormatsL(ESgUsageBitOpenGles2Texture2D);
302 TEST(CheckPixelFormatPresent(ESgPixelFormatARGB_8888_PRE));
303 TEST(CheckPixelFormatPresent(ESgPixelFormatARGB_8888));
304 TEST(CheckPixelFormatPresent(ESgPixelFormatXRGB_8888));
305 TEST(CheckPixelFormatPresent(ESgPixelFormatRGB_565));
306 TEST(CheckPixelFormatPresent(ESgPixelFormatA_8));
308 CallGetPixelFormatsL(ESgUsageBitOpenGles2Surface);
311 TEST(CheckPixelFormatPresent(ESgPixelFormatARGB_8888_PRE));
312 TEST(CheckPixelFormatPresent(ESgPixelFormatXRGB_8888));
313 TEST(CheckPixelFormatPresent(ESgPixelFormatRGB_565));
316 iPixelFormatArray.Reset();
320 Helper function to check if a certain pixel format is present
321 in the pixel formats array retrieved by CallGetPixelFormatsL().
323 @param aPixelFormat The pixelformat to check
324 @return ETrue if the pixel format is present, otherwise EFalse
325 @see CTsgTestStepBase::CallGetPixelFormats()
327 TBool CTSgTestStepBase::CheckPixelFormatPresent(TSgPixelFormat aPixelFormat)
329 for(TInt i=0; i<iPixelFormatArray.Count(); ++i)
331 if(aPixelFormat == iPixelFormatArray[i])
340 Helper function to test the equivalence of two TSgImageInfo structures.
342 @param aInfo1 A TSgImageInfo structure to compare.
343 @param aInfo2 A TSgImageInfo structure to compare (may have extra usage bits).
345 @return ETrue if the two are equivalent, EFalse otherwise.
347 TBool CTSgTestStepBase::CompareInfos(TSgImageInfo& aInfo1, TSgImageInfo& aInfo2)
349 return (aInfo1.iPixelFormat == aInfo2.iPixelFormat
350 && aInfo1.iSizeInPixels == aInfo2.iSizeInPixels
351 // check that all requested usage bits are set in the returned usage bits
352 && !(aInfo1.iUsage & ~aInfo2.iUsage));
356 Wrapper function to open the graphics resource driver.
357 Only opens the driver if the test step has been constructed for use
358 as the conformance tests.
360 @leave One of the system wide error codes
362 void CTSgTestStepBase::TestOpenDriverL()
364 if (iEnableConformanceTests)
365 CheckErrorL(KErrNone, iSgDriver.Open(), (TText8*)__FILE__, __LINE__);
369 Wrapper function to close the graphics resource driver.
371 Only closes the driver if the test step has been constructed for use
372 as the conformance tests.
374 void CTSgTestStepBase::TestCloseDriver()
376 if (iEnableConformanceTests)
381 Creates an image with specified parameters.
382 @param aImage output image handle
383 @return KErrNone if the image was created successfully, otherwise one of the system-wide error codes
385 TInt CreateImageWithParameters(TInt aWidth, TInt aHeight, TUidPixelFormat aPixelFormat, TUint32 aUsage, RSgImage& aImage)
388 info.iSizeInPixels = TSize(aWidth, aHeight);
389 info.iPixelFormat = aPixelFormat;
390 info.iUsage = aUsage;
391 return aImage.Create(info, NULL, 0);
395 Second thread entry function.
397 TInt SgTestSecondThread::ThreadStart(TAny* aInfo)
401 CTrapCleanup* cleanupStack = CTrapCleanup::New();
407 TSgThreadTestInfo* testInfo = static_cast<TSgThreadTestInfo*>(aInfo);
410 TInt openSem = sem.OpenGlobal(KSecondThreadSemaphore, EOwnerThread);
412 TInt result = KErrNone;
413 TRAPD(leaveCode, result = SgTestSecondThread::ThreadMainL(testInfo));
414 if (KErrNone == openSem)
420 if (leaveCode != KErrNone)
422 testInfo->iTestStep->ERR_PRINTF2(_L("Second thread caused Leave (%d)"), leaveCode);
423 testInfo->iTestStep->SetTestStepResult(EFail);
435 Run the test contained within the TSgresTestInfo object. A new thread is
436 created for each test and only one of the cases in the switch statements
439 The first switch statement contains tests that must have no driver open,
440 the second set require an open driver to initiate the test but may
441 close it part way through.
443 @param aInfo The parameters for the test
444 @return One of the system wide error codes or an enumeration of passed tests.
446 TInt SgTestSecondThread::ThreadMainL(TSgThreadTestInfo* aInfo)
450 TSgresTestCase testcase = ((TSgThreadTestInfo*)aInfo)->iTestCase;
453 CleanupClosePushL(driver);
454 TInt ret = driver.Open();
455 if(KErrNoMemory == ret)
459 //test cases without the need of an initialised driver
462 case ESgresSecondThreadPanicDrawableOpenNoDriver:
465 RSgDrawable drawable;
466 drawable.Open(KFakeSgDrawableId); // should panic with SGRES 1
469 case ESgresSecondThreadPanicImageOpenNoDriver:
473 image.Open(KFakeSgDrawableId); // should panic with SGRES 1
476 case ESgresSecondThreadPanicImageCreateNoDriver1:
480 image.Create(KSgImageInfo1, NULL, 0); // should panic with SGRES 1
484 case ESgresSecondThreadPanicImageCreateNoDriver2:
489 image.Create(KSgImageInfo1, tempImage); // should panic with SGRES 1
493 case ESgresSecondThreadOpenImage:
494 result = OpenImage(((TSgThreadTestInfo*)aInfo), driver);
496 case ESgresSecondThreadOpenDrawable:
497 result = OpenDrawable(((TSgThreadTestInfo*)aInfo));
499 case ESgresSecondThreadOpenImageInvalid:
500 result = OpenImageInvalid(((TSgThreadTestInfo*)aInfo));
502 case ESgresSecondThreadOpenDrawableInvalid:
503 result = OpenDrawableInvalid(((TSgThreadTestInfo*)aInfo));
505 case ESgresSecondThreadPanicImageGetInterfaceInvalidHandle:
506 result = PanicImageGetInterfaceInvalidHandle(driver);
508 case ESgresSecondThreadPanicImageGetInterfaceNoDriver:
509 result = PanicImageGetInterfaceNoDriver(driver);
511 case ESgresSecondThreadPanicImageCloseInvalidHandle:
512 result = PanicImageCloseInvalidHandle(driver);
514 case ESgresSecondThreadPanicImageCloseNoDriver:
515 result = PanicImageCloseNoDriver(driver);
517 case ESgresSecondThreadPanicImageIdInvalidHandle:
518 result = PanicImageIdInvalidHandle(driver);
520 case ESgresSecondThreadPanicImageIdNoDriver:
521 result = PanicImageIdNoDriver(driver);
523 case ESgresSecondThreadPanicImageDrawableTypeInvalidHandle:
524 result = PanicImageDrawableTypeInvalidHandle(driver);
526 case ESgresSecondThreadPanicImageDrawableTypeNoDriver:
527 result = PanicImageDrawableTypeNoDriver(driver);
529 case ESgresSecondThreadPanicImageCreateInvalidHandle:
530 result = PanicImageCreateInvalidHandle(driver);
532 case ESgresSecondThreadPanicImageGetInfoInvalidHandle:
533 result = PanicImageGetInfoInvalidHandle(driver);
535 case ESgresSecondThreadPanicImageGetInfoNoDriver:
536 result = PanicImageGetInfoNoDriver(driver);
538 case ESgresSecondThreadPanicImageGetAttributeInvalidHandle:
539 result = PanicImageGetAttributeInvalidHandle(driver);
541 case ESgresSecondThreadPanicImageGetAttributeNoDriver:
542 result = PanicImageGetAttributeNoDriver(driver);
544 case ESgresMultipleThreadStressTest:
545 result = MultipleThreadStressTest(((TSgThreadTestInfo*)aInfo));
547 case ESgresSecondThreadPanicAttributeArrayInvalidIndex:
548 PanicAttributeArrayInvalidIndexL();
550 case ESgresSecondThreadPanicAttributeArrayInvalidIndex2:
551 PanicAttributeArrayInvalidIndex2L();
553 case ESgresSecondThreadOpenPassedDriver:
554 result = ((TSgThreadTestInfo*)aInfo)->iSgDriver->Open();
556 case ESgresSecondThreadClosePassedDriver:
557 ((TSgThreadTestInfo*)aInfo)->iSgDriver->Close();
559 case ESgresSecondThreadCreatePassedImage:
560 result = CreatePassedImageL(((TSgThreadTestInfo*)aInfo)->iSgImage);
562 case ESgresSecondThreadOpenPassedImage:
563 ((TSgThreadTestInfo*)aInfo)->iSgImage->Open(((TSgThreadTestInfo*)aInfo)->iDrawableId);
565 case ESgresSecondThreadClosePassedImage:
566 ((TSgThreadTestInfo*)aInfo)->iSgImage->Close();
570 CleanupStack::PopAndDestroy(&driver);
576 Checks the function for the passed error codes and logs an error if the codes do not match.
577 If run under OOM testing, this function will leave if KErrNoMemory or KErrNoGraphicsMemory was
578 the actual error; this is essential for OOM testing.
580 @leave One of the System Wide Error Codes
582 @param aExpectedErrorCode The expected error code to check against
583 @param aActualErrorCode The actual error code
584 @param aFile The filename to use when reporting the error
585 @param aLine The line number to use when reporting the error
587 void CTSgTestStepBase::CheckErrorL(TInt aExpectedErrorCode, TInt aActualErrorCode, const TText8* aFile, TInt aLine)
589 if (iEnableConformanceTests)
591 TESTWITHFILENAMEANDLINENUMBERL(aExpectedErrorCode == aActualErrorCode, aFile, aLine);
595 //OOM Tests Enabled - Also test for KErrNoMemory/KErrNoGraphicsMemory
596 TESTWITHFILENAMEANDLINENUMBERL((aExpectedErrorCode == aActualErrorCode) || (KErrNoMemory == aActualErrorCode) || (KErrNoGraphicsMemory == aActualErrorCode), aFile, aLine);
597 if (aActualErrorCode == KErrNoMemory || aActualErrorCode == KErrNoGraphicsMemory)
599 User::Leave(aActualErrorCode);
604 Implementation of SecondThread test ESgresSecondThreadOpenImage
606 @return One of the system wide error codes or an enumeration of passed tests.
608 @param TSgresTestInfo* The test parameters
609 @param RSgDriver An open RSgDriver for the test code to use
611 TInt SgTestSecondThread::OpenImage(TSgThreadTestInfo* aInfo, RSgDriver& aSgDriver)
615 TInt err = image.Open(aInfo->iDrawableId);
616 if(KErrNoMemory == err)
622 result |= EFirstTestPassed;
625 if(KErrNone == image.GetInfo(info))
627 result |= ESecondTestPassed;
629 if(CTSgTestStepBase::CompareInfos(aInfo->iImageInfo, info))
631 result |= EThirdTestPassed;
633 TSgDrawableId id = image.Id();
634 if(id != KSgNullDrawableId)
636 result |= EFourthTestPassed;
638 if(id == aInfo->iDrawableId)
640 result |= EFifthTestPassed;
642 TInt attribVal = KMaxTInt;
643 TUid uid = { 0x12345678 };
644 if (KErrNotSupported == image.GetAttribute(uid, attribVal))
646 result |= ESixthTestPassed;
648 if (KErrArgument == image.GetAttribute(KNullUid, attribVal))
650 result |= ESeventhTestPassed;
654 if (KErrBadHandle == image.GetAttribute(uid, attribVal))
656 result |= EEighthTestPassed;
663 Implementation of SecondThread test ESgresSecondThreadOpenDrawable
665 @return One of the system wide error codes or an enumeration of passed tests.
667 @param TSgresTestInfo* The test parameters
669 TInt SgTestSecondThread::OpenDrawable(TSgThreadTestInfo* aInfo)
672 RSgDrawable drawable;
673 TInt err = drawable.Open(aInfo->iDrawableId);
674 if(KErrNoMemory == err)
676 result = KErrNoMemory;
681 result |= EFirstTestPassed;
683 TSgDrawableId id = drawable.Id();
684 if(id != KSgNullDrawableId)
686 result |= ESecondTestPassed;
688 if(id == aInfo->iDrawableId)
690 result |= EThirdTestPassed;
697 Implementation of SecondThread test ESgresSecondThreadOpenImageInvalid
699 @return One of the system wide error codes or an enumeration of passed tests.
701 @param TSgresTestInfo* The test parameters
703 TInt SgTestSecondThread::OpenImageInvalid(TSgThreadTestInfo* aInfo)
708 info.iSizeInPixels = TSize(8, 8);
709 info.iPixelFormat = EUidPixelFormatRGB_565;
710 info.iUsage = ESgUsageBitOpenVgImage;
712 TInt err = image.Create(info, KCrossImageData, KCrossImageDataStride);
713 if(KErrNoMemory == err)
719 result |= EFirstTestPassed;
723 TSgDrawableId id = aInfo->iDrawableId;
724 err = image.Open(id);
725 if(KErrNoMemory == err)
731 result |= ESecondTestPassed;
736 err = image.Open(KSgNullDrawableId);
737 if(KErrNoMemory == err)
741 if(KErrArgument == err)
743 result |= EThirdTestPassed;
747 // non-existing drawable id
748 err = image.Open(KFakeSgDrawableId);
749 if(KErrNoMemory == err)
753 if(KErrNotFound == err)
755 result |= EFourthTestPassed;
759 err = image.Open(id);
760 if(KErrNoMemory == err)
766 result |= EFifthTestPassed;
774 Implementation of SecondThread test ESgresSecondThreadOpenDrawableInvalid
776 @return One of the system wide error codes or an enumeration of passed tests.
778 @param TSgresTestInfo* The test parameters
780 TInt SgTestSecondThread::OpenDrawableInvalid(TSgThreadTestInfo* aInfo)
783 RSgDrawable drawable;
784 TInt err = drawable.Open(KSgNullDrawableId);
785 if(KErrNoMemory == err)
789 if(KErrArgument == err)
791 result |= EFirstTestPassed;
795 // non-existing drawable id
796 err = drawable.Open(KFakeSgDrawableId);
797 if (KErrNoMemory == err)
802 if(KErrNotFound == err)
804 result |= ESecondTestPassed;
808 // open a non-sharable image - should succeed
809 err = drawable.Open(aInfo->iDrawableId);
811 if(KErrNoMemory == err)
817 result |= EThirdTestPassed;
819 if (KErrInUse == drawable.Open(aInfo->iDrawableId))
821 result |= EFourthTestPassed;
831 Implementation of SecondThread test ESgresSecondThreadPanicImageGetInterfaceInvalidHandle
833 @panic SGRES2 If the test is successful
835 @return One of the system wide error codes.
837 @param RSgDriver An open RSgDriver for the test code to use
839 TInt SgTestSecondThread::PanicImageGetInterfaceInvalidHandle(RSgDriver& aSgDriver)
842 TInt result = CTSgTestStepBase::CreateImageAndReturnCopy(image);
844 MTSgImage_Interface* swInterface = NULL;
845 result = image.GetInterface(swInterface); //should panic with SGRES 3
852 Implementation of SecondThread test ESgresSecondThreadPanicImageGetInterfaceNoDriver
854 @panic SGRES1 If the test is successful
856 @return One of the system wide error codes
858 @param RSgDriver An open RSgDriver for the test code to use
860 TInt SgTestSecondThread::PanicImageGetInterfaceNoDriver(RSgDriver& aSgDriver)
863 TInt result = CTSgTestStepBase::CreateImageAndReturnCopy(image);
866 MTSgImage_Interface* swInterface = NULL;
867 image.GetInterface(swInterface); // should panic with SGRES 1
872 Implementation of SecondThread test ESgresSecondThreadPanicImageCloseInvalidHandle
874 @panic SGRES2 If the test is successful
876 @return One of the system wide error codes
878 @param RSgDriver An open RSgDriver for the test code to use
880 TInt SgTestSecondThread::PanicImageCloseInvalidHandle(RSgDriver& aSgDriver)
883 TInt result = CTSgTestStepBase::CreateImageAndReturnCopy(image);
885 image.Close(); //should panic with SGRES 3
891 Implementation of SecondThread test ESgresSecondThreadPanicImageCloseNoDriver
893 @panic SGRES1 If the test is successful
895 @return One of the system wide error codes
897 @param RSgDriver An open RSgDriver for the test code to use
899 TInt SgTestSecondThread::PanicImageCloseNoDriver(RSgDriver& aSgDriver)
902 TInt result = CTSgTestStepBase::CreateImageAndReturnCopy(image);
904 image.Close(); // should panic with SGRES 1
909 Implementation of SecondThread test ESgresSecondThreadPanicImageIdIvalidHandle
911 @panic SGRES2 If the test is successful
913 @return One of the system wide error codes
915 @param RSgDriver An open RSgDriver for the test code to use
917 TInt SgTestSecondThread::PanicImageIdInvalidHandle(RSgDriver& aSgDriver)
920 TInt result = CTSgTestStepBase::CreateImageAndReturnCopy(image);
922 image.Id(); //should panic with SGRES 3
928 Implementation of SecondThread test ESgresSecondThreadPanicImageIdNoDriver
930 @panic SGRES1 If the test is successful
932 @return One of the system wide error codes
934 @param RSgDriver An open RSgDriver for the test code to use
936 TInt SgTestSecondThread::PanicImageIdNoDriver(RSgDriver& aSgDriver)
939 TInt result = CTSgTestStepBase::CreateImageAndReturnCopy(image);
942 image.Id(); // should panic with SGRES 1
947 Implementation of SecondThread test ESgresSecondThreadPanicImageDrawableTypeInvalidHandle
949 @panic SGRES2 If the test is successful
951 @return One of the system wide error codes
953 @param RSgDriver An open RSgDriver for the test code to use
955 TInt SgTestSecondThread::PanicImageDrawableTypeInvalidHandle(RSgDriver& aSgDriver)
958 TInt result = CTSgTestStepBase::CreateImageAndReturnCopy(image);
960 image.DrawableType(); //should panic with SGRES 3
967 Implementation of SecondThread test ESgresSecondThreadPanicImageDrawableTypeNoDriver
969 @panic SGRES1 If the test is successful
971 @return One of the system wide error codes
973 @param RSgDriver An open RSgDriver for the test code to use
975 TInt SgTestSecondThread::PanicImageDrawableTypeNoDriver(RSgDriver& aSgDriver)
978 TInt result = CTSgTestStepBase::CreateImageAndReturnCopy(image);
980 image.DrawableType(); // should panic with SGRES 1
985 Implementation of SecondThread test ESgresSecondThreadPanicImageCreateInvalidHandle
987 @panic SGRES3 If the test is successful
989 @return One of the system wide error codes
991 @param RSgDriver An open RSgDriver for the test code to use
993 TInt SgTestSecondThread::PanicImageCreateInvalidHandle(RSgDriver& aSgDriver)
996 TInt result = CTSgTestStepBase::CreateImageAndReturnCopy(image);
1000 image.GetInfo(info);
1001 newImage.Create(info, image); //should panic with SGRES 3
1007 Implementation of SecondThread test ESgresSecondThreadPanicImageGetInfoInvalidHandle
1009 @panic SGRES3 If the test is successful
1011 @return One of the system wide error codes
1013 @param RSgDriver An open RSgDriver for the test code to use
1015 TInt SgTestSecondThread::PanicImageGetInfoInvalidHandle(RSgDriver& aSgDriver)
1018 TInt result = CTSgTestStepBase::CreateImageAndReturnCopy(image);
1020 TSgImageInfo anotherInfo;
1021 image.GetInfo(anotherInfo); //should panic with SGRES 3
1027 Implementation of SecondThread test ESgresSecondThreadPanicImageNoDriver
1029 @panic SGRES1 If the test is successful
1031 @return One of the system wide error codes or an enumeration of passed tests.
1033 @param RSgDriver An open RSgDriver for the test code to use
1035 TInt SgTestSecondThread::PanicImageGetInfoNoDriver(RSgDriver& aSgDriver)
1038 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageBitOpenVgImage, image);
1043 RSgImage anotherImage;
1044 Mem::Copy(&anotherImage, &image, sizeof(image));
1047 TSgImageInfo anotherInfo;
1048 anotherImage.GetInfo(anotherInfo); // should panic with SGRES 1
1053 Implementation of SecondThread test ESgresSecondThreadPanicImageGetAttributeInvalidHandle
1055 @panic SGRES3 If the test is successful
1057 @return One of the system wide error codes
1059 @param RSgDriver An open RSgDriver for the test code to use
1061 TInt SgTestSecondThread::PanicImageGetAttributeInvalidHandle(RSgDriver& aSgDriver)
1064 TInt result = CTSgTestStepBase::CreateImageAndReturnCopy(image);
1066 TInt attrib = KMaxTInt;
1067 image.GetAttribute(TUid::Uid(1), attrib); //Should panic with SGRES 3
1074 Implementation of SecondThread test ESgresSecondThreadPanicImageGetAttributeNoDriver
1076 @panic SGRES1 If the test is successful
1078 @return One of the system wide error codes
1080 @param RSgDriver An open RSgDriver for the test code to use
1082 TInt SgTestSecondThread::PanicImageGetAttributeNoDriver(RSgDriver& aSgDriver)
1085 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageBitOpenVgImage, image);
1090 RSgImage anotherImage;
1091 Mem::Copy(&anotherImage, &image, sizeof(image));
1094 TInt attrib = KMaxTInt;
1095 TUid uid = { 0x12345678 };
1096 anotherImage.GetAttribute(uid, attrib); //Should panic with SGRES 1
1101 Implementation of SecondThread test ESgresSecondThreadMultipleThreadStressTest
1103 @return One of the system wide error codes
1105 @param TSgresTestInfo* The test parameters
1107 TInt SgTestSecondThread::MultipleThreadStressTest(TSgThreadTestInfo* aInfo)
1111 for (TInt i = 0; i < 1000 && result == KErrNone; ++i)
1113 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageBitOpenVgImage, image);
1114 if (KErrNone != ret)
1120 const TInt KMaxOpenCount = 100;
1121 RSgImage images[KMaxOpenCount];
1122 TInt count = Math::Random() % KMaxOpenCount;
1123 for (TInt k = 0; k < count; ++k)
1125 ret = images[k].Open(aInfo->iDrawableId);
1126 if (KErrNone != ret)
1133 for (TInt k = 0; k < count; ++k)
1142 Implementation of SecondThread test ESgresSecondThreadPanicAttributeArrayInvalidIndex
1144 @panic SGRES4 If the test is successful
1146 @param TSgresTestInfo* The test parameters
1148 void SgTestSecondThread::PanicAttributeArrayInvalidIndexL()
1150 TSgAttributeArray<5> attribArray;
1151 TSgAttribute attrib = attribArray[6]; //Should panic with SGRES 4
1155 Implementation of SecondThread test ESgresSecondThreadPanicAttributeArrayInvalidIndex2
1157 @panic SGRES4 If the test is successful
1159 @param TSgresTestInfo* The test parameters
1161 void SgTestSecondThread::PanicAttributeArrayInvalidIndex2L()
1163 TSgAttributeArray<5> attribArray;
1164 TSgAttribute attrib = attribArray[-1]; //Should panic with SGRES 4
1168 Implementation of SecondThread test ESgresSecondThreadPanicDriverCloseOpenResources
1170 @return One of the system wide error codes
1172 @param RSgImage* A closed or uninitialised RSgImage to use for image creation
1174 TInt SgTestSecondThread::CreatePassedImageL(RSgImage* aSgImage)
1177 info.iSizeInPixels = TSize(8, 8);
1178 info.iUsage = ESgUsageBitOpenVgImage;
1179 info.iPixelFormat = EUidPixelFormatRGB_565;
1181 return aSgImage->Create(info, KCrossImageData, KCrossImageDataStride);
1185 Helper function which Creates an RSgImage and copies to into another RSgImage
1186 using Mem::Copy; the target of the copy is returned in the open state.
1188 @param aSgImage An uninitialised image which will have an SgImage Mem::Copied into it.
1189 @return One of the system wide error codes.
1191 TInt CTSgTestStepBase::CreateImageAndReturnCopy(RSgImage& aSgImage)
1194 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageBitOpenVgImage, image);
1199 Mem::Copy(&aSgImage, &image, sizeof(image));