os/graphics/graphicsresourceservices/graphicsresource/test/tgraphicsresourceteststepbase.cpp
First public contribution.
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 - Internal Symbian test code
22 #include "tgraphicsresourceteststepbase.h"
25 CTSgTestStepBase::CTSgTestStepBase()
29 CTSgTestStepBase::~CTSgTestStepBase()
31 iSecondThread.Close();
35 Overrides of base class virtual
36 @leave Gets system wide error code
37 @return - TVerdict code
39 TVerdict CTSgTestStepBase::doTestStepPreambleL()
41 SetTestStepResult(EPass);
42 return TestStepResult();
46 Override of base class virtual
47 @leave Gets system wide error code
48 @return - TVerdict code
50 TVerdict CTSgTestStepBase::doTestStepPostambleL()
52 return TestStepResult();
56 Override of function from CTestStep so that each test failure is reported in output.
58 EXPORT_C void CTSgTestStepBase::testBooleanTrue(TBool aCondition, const TText8* aFile, TInt aLine)
60 TRAP_IGNORE(testBooleanTrueL(aCondition, aFile, aLine, ETrue));
64 Creates an image with some predefined parametres.
65 @param aImage output image handle
66 @leave Gets system wide error code
68 void CTSgTestStepBase::CreateImageL(RSgImage& aImage)
71 info.iSizeInPixels = TSize(8, 8);
72 info.iUsage = ESgUsageDirectGdiSource;
73 info.iPixelFormat = EUidPixelFormatRGB_565;
74 info.iCpuAccess = ESgCpuAccessReadWrite;
75 info.iShareable = ETrue;
77 CheckErrorL(KErrNone, aImage.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
81 Creates an image collection with some predefined parametres.
82 @param aCollection output image collection handle
83 @leave Gets system wide error code
85 void CTSgTestStepBase::CreateImageCollectionL(RSgImageCollection& aCollection)
88 info.iSizeInPixels = TSize(8, 8);
89 info.iUsage = ESgUsageDirectGdiSource;
90 info.iPixelFormat = EUidPixelFormatRGB_565;
91 info.iCpuAccess = ESgCpuAccessReadWrite;
92 CheckErrorL(KErrNone, aCollection.Create(info, KNumImagesInCollection), (TText8*)__FILE__, __LINE__);
93 TEST(!aCollection.IsNull());
97 Creates a second process and do some tests in it.
98 @param aProcessName The name of the new process
99 @param aTestInfo The information for the tests
100 @leave Gets system wide error code
102 TInt CTSgTestStepBase::CreateSecondProcessAndDoTestL(const TDesC &aProcessName, TSgresTestInfo& aTestInfo)
104 // Create a second process
106 User::LeaveIfError(process.Create(aProcessName, KNullDesC));
107 CleanupClosePushL(process);
109 // Specify the test for the second process
110 TESTL(KErrNone == process.SetParameter(KSecondProcessFunctionSlot, ((TSgresTestInfo)aTestInfo).iTestCase));
111 // Specify the id passed to the second process
112 TPckg<TSgresTestInfo> ptr(aTestInfo);
114 TESTL(KErrNone == process.SetParameter(KSecondProcessParametersSlot, ptr));
115 // Kick off the second process and wait for it to complete
116 // The actual testing is done in the second process
117 TRequestStatus status = KRequestPending;
118 process.Logon(status);
120 User::WaitForRequest(status);
122 TInt exitreason = process.ExitReason();
124 CleanupStack::PopAndDestroy();
131 Creates a second thread and do some tests in it.
132 @param aTestInfo The information for the tests
133 @leave Gets system wide error code
135 TInt CTSgTestStepBase::CreateSecondThreadAndDoTestL(TSgresTestInfo aTestInfo)
139 User::LeaveIfError(sem.CreateGlobal(KSecondThreadSemaphore, 0, EOwnerThread));
140 CleanupClosePushL(sem);
142 User::LeaveIfError(iSecondThread.Create(KSecondThread, SecondThreadStart, KDefaultStackSize, &User::Heap(), &aTestInfo));
143 // Launch second thread
144 TRequestStatus statusSecondThread;
145 iSecondThread.Logon(statusSecondThread);
146 iSecondThread.SetPriority(EPriorityLess);
147 iSecondThread.Resume();
149 User::WaitForRequest(statusSecondThread);
151 TInt result = iSecondThread.ExitReason();
154 CleanupStack::PopAndDestroy(1, &sem);
155 iSecondThread.Close();
161 Creates a second thread and do some panic tests in it.
162 @param aTestInfo The information for the tests
163 @param aPanicCode The expected panic code
164 @param aExitCategory The expected panic category
165 @param aThreadName The name of the new thread
166 @leave Gets system wide error code
168 void CTSgTestStepBase::CreateSecondThreadAndCheckPanicL(TSgresTestInfo aTestInfo, TInt aPanicCode, TExitCategoryName aExitCategory, const TDesC &aThreadName)
170 User::LeaveIfError(iSecondThread.Create(aThreadName, SecondThreadStart, KDefaultStackSize, 0x100, 0x100, &aTestInfo));
171 // Launch second thread
172 TRequestStatus statusSecondThread;
173 iSecondThread.Logon(statusSecondThread);
174 iSecondThread.SetPriority(EPriorityLess);
175 iSecondThread.Resume();
177 User::WaitForRequest(statusSecondThread);
179 if(EExitPanic != iSecondThread.ExitType())
181 ERR_PRINTF3(_L("Expected exit type: %d, Actual exit type: %d"), EExitPanic, iSecondThread.ExitType());
185 if(aPanicCode != iSecondThread.ExitReason())
187 ERR_PRINTF3(_L("Expected panic code: %d, Actual panic code: %d"), aPanicCode, iSecondThread.ExitReason());
191 TExitCategoryName secondThreadExitCategory = iSecondThread.ExitCategory();
192 if(aExitCategory != secondThreadExitCategory)
194 ERR_PRINTF3(_L("Expected panic category: %S, Actual panic category: %S"), &aExitCategory, &secondThreadExitCategory);
198 //close the driver if the second thread exited with type EExitKill
199 //assumming the second thread only calls SgDriver::Open() once
200 if(iSecondThread.ExitType() != EExitKill)
206 iSecondThread.Close();
210 Creates a second process and do some panic tests in it.
211 @param aTestInfo The information for the tests
212 @param aPanicCode The expected panic code
213 @param aExitCategory The expected panic category
214 @param aProcessName The name of the new process
215 @leave Gets system wide error code
217 void CTSgTestStepBase::CreateSecondProcessAndCheckPanicL(TSgresTestInfo aTestInfo, TInt aPanicCode, TExitCategoryName aExitCategory, const TDesC &aProcessName)
219 // Create a second process
221 User::LeaveIfError(process.Create(KSecondProcess, aProcessName));
222 CleanupClosePushL(process);
224 // Specify the test for the second process
225 TESTL(KErrNone == process.SetParameter(KSecondProcessFunctionSlot, ((TSgresTestInfo)aTestInfo).iTestCase));
226 // Specify the id passed to the second process
227 TPckg<TSgresTestInfo> ptr(aTestInfo);
229 TESTL(KErrNone == process.SetParameter(KSecondProcessParametersSlot, ptr));
230 // Kick off the second process and wait for it to complete
231 // The actual testing is done in the second process
232 TRequestStatus status;
233 process.Logon(status);
235 User::WaitForRequest(status);
237 if(EExitPanic != process.ExitType())
239 ERR_PRINTF3(_L("Expected exit type: %d, Actual exit type: %d"), EExitPanic, process.ExitType());
242 if(aPanicCode != process.ExitReason())
244 ERR_PRINTF3(_L("Expected panic code: %d, Actual panic code: %d"), aPanicCode, process.ExitReason());
248 _LIT(KMemoryLeakCategory, "SGALLOC");
249 TExitCategoryName processExitCategory = process.ExitCategory();
251 if (aExitCategory != KMemoryLeakCategory)
253 matchCategory = aExitCategory == processExitCategory;
257 matchCategory = processExitCategory.Left(KMemoryLeakCategory().Length()) == KMemoryLeakCategory;
261 ERR_PRINTF3(_L("Expected panic category: %S, Actual panic category: %S"), &aExitCategory, &processExitCategory);
265 CleanupStack::PopAndDestroy();
269 Gets the supporting pixel formats according to the specified cpu access, usage, shareability and screen id flags.
270 @leave Gets system wide error code
272 void CTSgTestStepBase::CallGetPixelFormatsL(TSgCpuAccess aCpuAccess, TUint32 aUsage, TBool aShareable, TInt aScreenId)
275 info.iCpuAccess = aCpuAccess;
276 info.iUsage = aUsage;
277 info.iShareable = aShareable;
278 info.iScreenId = aScreenId;
279 info.iSizeInPixels = TSize(10, 10);
280 iPixelFormatCount = KMaxPixelFormats;
281 Mem::FillZ(iPixelFormatArray, KMaxPixelFormats * sizeof(TUidPixelFormat));
282 CheckErrorL(KErrNone, RSgImage::GetPixelFormats(info, iPixelFormatArray, iPixelFormatCount), (TText8*)__FILE__, __LINE__);
286 Checks the pixel formats returned against the compatibility guarantee table.
287 @leave Gets system wide error code
289 void CTSgTestStepBase::TestGetPixelFormatCompatibilityGuaranteesL()
291 CallGetPixelFormatsL(ESgCpuAccessNone, ESgUsageDirectGdiSource, ETrue, KSgScreenIdAny);
292 CheckPixelFormatPresent(EUidPixelFormatARGB_8888_PRE);
293 CheckPixelFormatPresent(EUidPixelFormatXRGB_8888);
294 CheckPixelFormatPresent(EUidPixelFormatRGB_565);
296 CallGetPixelFormatsL(ESgCpuAccessReadWrite, ESgUsageDirectGdiSource, ETrue, KSgScreenIdMain);
297 CheckPixelFormatPresent(EUidPixelFormatARGB_8888_PRE);
298 CheckPixelFormatPresent(EUidPixelFormatXRGB_8888);
299 CheckPixelFormatPresent(EUidPixelFormatRGB_565);
301 CallGetPixelFormatsL(ESgCpuAccessNone, ESgUsageDirectGdiSource|ESgUsageDirectGdiTarget, ETrue, KSgScreenIdMain);
302 CheckPixelFormatPresent(EUidPixelFormatARGB_8888_PRE);
303 CheckPixelFormatPresent(EUidPixelFormatXRGB_8888);
305 CallGetPixelFormatsL(ESgCpuAccessNone, ESgUsageDirectGdiSource|ESgUsageOpenGlesTarget, ETrue, KSgScreenIdMain);
306 CheckPixelFormatPresent(EUidPixelFormatARGB_8888_PRE);
307 CheckPixelFormatPresent(EUidPixelFormatXRGB_8888);
309 CallGetPixelFormatsL(ESgCpuAccessNone, ESgUsageDirectGdiSource|ESgUsageOpenVgTarget, ETrue, KSgScreenIdMain);
310 CheckPixelFormatPresent(EUidPixelFormatARGB_8888_PRE);
311 CheckPixelFormatPresent(EUidPixelFormatXRGB_8888);
313 CallGetPixelFormatsL(ESgCpuAccessNone, ESgUsageDirectGdiSource|ESgUsageOpenGles2Target, ETrue, KSgScreenIdMain);
314 CheckPixelFormatPresent(EUidPixelFormatARGB_8888_PRE);
315 CheckPixelFormatPresent(EUidPixelFormatXRGB_8888);
319 Helper function to check if a certain pixel format is present
320 in the returned pixel formats array.
321 @param aPixelFormat The pixelformat to check
323 void CTSgTestStepBase::CheckPixelFormatPresent(TUidPixelFormat aPixelFormat)
325 for(TInt i=0; i<iPixelFormatCount; ++i)
327 if(aPixelFormat == iPixelFormatArray[i])
336 Helper function to test the equivalence of two TSgImageInfo structures.
338 @see CTDirectGdiContextTarget::CompareInfos
339 @param aInfo1 A TSgImageInfo structure to compare.
340 @param aInfo2 A TSgImageInfo structure to compare.
342 @return ETrue if the two are identical, EFalse otherwise.
344 TBool CTSgTestStepBase::CompareInfos(TSgImageInfo& aInfo1, TSgImageInfo& aInfo2)
346 TBool result = EFalse;
347 if(aInfo1.iCpuAccess == aInfo2.iCpuAccess
348 && aInfo1.iPixelFormat == aInfo2.iPixelFormat
349 && aInfo1.iScreenId == aInfo2.iScreenId
350 && aInfo1.iShareable == aInfo2.iShareable
351 && aInfo1.iSizeInPixels == aInfo2.iSizeInPixels
352 && aInfo1.iUsage | aInfo2.iUsage
353 && aInfo1.iUserAttributeCount == aInfo2.iUserAttributeCount)
355 for(TInt i=0; i<aInfo1.iUserAttributeCount; ++i)
357 if(aInfo1.iUserAttributes[i].iUid != aInfo2.iUserAttributes[i].iUid)
368 Wrapper function to open the graphics resource driver and puts an cleanup item
369 on the cleanup stack.
370 @leave Gets system wide error code
372 void CTSgTestStepBase::TestOpenDriverL()
374 CheckErrorL(KErrNone, SgDriver::Open(), (TText8*)__FILE__, __LINE__);
375 CleanupStack::PushL(TCleanupItem((TCleanupOperation)CloseDriverWhenLeave, NULL));
379 Wrapper function to close the graphics resource driver.
381 void CTSgTestStepBase::TestCloseDriver()
383 CleanupStack::PopAndDestroy();
387 Creates an image with specified parametres.
388 @param aImage output image handle
389 @return KErrNone if the image was created successfully, otherwise one of the system-wide error codes
391 TInt CreateImageWithParameters(TInt aWidth, TInt aHeight, TUidPixelFormat aPixelFormat, TUint32 aUsage, TBool aShareable, TSgCpuAccess aCpuAccess, RSgImage& aImage)
394 info.iSizeInPixels = TSize(aWidth, aHeight);
395 info.iPixelFormat = aPixelFormat;
396 info.iUsage = aUsage;
397 info.iCpuAccess = aCpuAccess;
398 info.iShareable = aShareable;
399 return aImage.Create(info, NULL, 0);
403 Creates an image collection with some predefined parametres.
404 @param aCollection output image collection handle
405 @return KErrNone if the image was created successfully, otherwise one of the system-wide error codes
407 TInt CreateImageCollectionWithParameters(TInt aWidth, TInt aHeight, TUidPixelFormat aPixelFormat, TUint32 aUsage, TBool aShareable, TSgCpuAccess aCpuAccess, RSgImageCollection& aCollection)
410 info.iSizeInPixels = TSize(aWidth, aHeight);
411 info.iPixelFormat = aPixelFormat;
412 info.iUsage = aUsage;
413 info.iCpuAccess = aCpuAccess;
414 info.iShareable = aShareable;
415 return aCollection.Create(info, KNumImagesInCollection);
420 Second thread entry function.
422 TInt CTSgTestStepBase::SecondThreadStart(TAny* aInfo)
424 TInt procHandles1 =0;
425 TInt threadHandles1=0;
426 RThread().HandleCount(procHandles1, threadHandles1);
432 TInt openSem = sem.OpenGlobal(KSecondThreadSemaphore, EOwnerThread);
434 TSgresTestCase testcase = ((TSgresTestInfo*)aInfo)->iTestCase;
437 RSgDrawable drawable;
441 const TAny* dataAddressRead;
442 TAny* dataAddressWrite;
444 TSgDrawableId fakeid = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF};
446 //test cases without the need of an initialised driver
449 case ESgresSecondThreadPanicResourceCountNoDriver:
451 SgDriver::ResourceCount(); // should panic with SGRES 5
454 case ESgresSecondThreadPanicAllocMarkStartNoDriver:
456 SgDriver::AllocMarkStart(); // should panic with SGRES 5
459 case ESgresSecondThreadPanicAllocMarkEndNoDriver:
461 SgDriver::AllocMarkEnd(0); // should panic with SGRES 5
464 case ESgresSecondThreadPanicSetAllocFailNoDriver:
466 SgDriver::SetAllocFail(RAllocator::EFailNext, 1); // should panic with SGRES 5
469 case ESgresSecondThreadPanicDrawableOpenNoDriver:
471 drawable.Open(KSgNullDrawableId); // should panic with SGRES 5
474 case ESgresSecondThreadPanicImageOpenNoDriver1:
476 image.Open(KSgNullDrawableId); // should panic with SGRES 5
479 case ESgresSecondThreadPanicImageOpenNoDriver2:
481 image.Open(KSgNullDrawableId, ESgDoNotRestrictUsage); // should panic with SGRES 5
484 case ESgresSecondThreadPanicImageCreateNoDriver1:
486 image.Create(info1, NULL, 0); // should panic with SGRES 5
489 case ESgresSecondThreadPanicImageCreateNoDriver2:
492 image.Create(info1, tempImage); // should panic with SGRES 5
495 case ESgresSecondThreadPanicImageGetPixelFormatsNoDriver:
498 RSgImage::GetPixelFormats(info1, NULL, count); // should panic with SGRES 5
501 case ESgresSecondThreadPanicImageCollectionCreateNoDriver1:
503 RSgImageCollection c;
504 c.Create(info1, 0); // should panic with SGRES 5
507 case ESgresSecondThreadPanicImageCollectionCreateNoDriver2:
509 RSgImageCollection c;
510 c.Create(NULL, 0, NULL, 0); // should panic with SGRES 5
517 TInt ret = SgDriver::Open();
518 if(KErrNoMemory == ret)
527 case ESgresSecondThreadOpenImage:
529 TInt err = image.Open(((TSgresTestInfo*)aInfo)->iDrawableId);
530 if(KErrNoMemory == err)
532 result = KErrNoMemory;
537 result |= EFirstTestPassed;
539 if(KErrNone == image.GetInfo(info2))
541 result |= ESecondTestPassed;
543 info1 = ((TSgresTestInfo*)aInfo)->iImageInfo;
544 if(CompareInfos(info1, info2))
546 result |= EThirdTestPassed;
549 if(id != KSgNullDrawableId)
551 result |= EFourthTestPassed;
553 if(id == ((TSgresTestInfo*)aInfo)->iDrawableId)
555 result |= EFifthTestPassed;
559 case ESgresSecondThreadOpenDrawable:
561 TInt err = drawable.Open(((TSgresTestInfo*)aInfo)->iDrawableId);
562 if(KErrNoMemory == err)
564 result = KErrNoMemory;
569 result |= EFirstTestPassed;
572 if(id != KSgNullDrawableId)
574 result |= ESecondTestPassed;
576 if(id == ((TSgresTestInfo*)aInfo)->iDrawableId)
578 result |= EThirdTestPassed;
582 case ESgresSecondThreadOpenImageInvalid:
585 info.iSizeInPixels = TSize(8, 8);
586 info.iUsage = ESgUsageDirectGdiSource;
587 info.iPixelFormat = EUidPixelFormatRGB_565;
588 info.iCpuAccess = ESgCpuAccessReadWrite;
590 TInt err = image.Create(info, KImageData, 16);
591 if(KErrNoMemory == err)
593 result = KErrNoMemory;
598 result |= EFirstTestPassed;
602 id = ((TSgresTestInfo*)aInfo)->iDrawableId;
603 err = image.Open(id);
604 if(KErrNoMemory == err)
606 result = KErrNoMemory;
611 result |= ESecondTestPassed;
616 err = image.Open(KSgNullDrawableId);
617 if(KErrNoMemory == err)
619 result = KErrNoMemory;
622 if(KErrArgument == err)
624 result |= EThirdTestPassed;
628 // non-existing drawable id
629 err = image.Open(fakeid);
630 if(KErrNoMemory == err)
632 result = KErrNoMemory;
635 if(KErrNotFound == err)
637 result |= EFourthTestPassed;
641 // open a non-sharable image
642 err = image.Open(id);
643 if(KErrNoMemory == err)
645 result = KErrNoMemory;
650 result |= EFifthTestPassed;
655 case ESgresSecondThreadOpenDrawableInvalid:
658 TInt err = drawable.Open(KSgNullDrawableId);
659 if(KErrNoMemory == err)
661 result = KErrNoMemory;
664 if(KErrArgument == err)
666 result |= EFirstTestPassed;
670 // non-existing drawable id
671 err = drawable.Open(fakeid);
672 if(KErrNoMemory == err)
674 result = KErrNoMemory;
678 if(KErrNotFound == err)
680 result |= ESecondTestPassed;
684 // open a non-sharable image - should succeed
685 id = ((TSgresTestInfo*)aInfo)->iDrawableId;
686 err = drawable.Open(id);
687 if(KErrNoMemory == err)
689 result = KErrNoMemory;
694 result |= EThirdTestPassed;
698 if(KErrInUse == drawable.Open(id))
700 result |= EFourthTestPassed;
705 case ESgresSecondThreadMapImage:
707 id = ((TSgresTestInfo*)aInfo)->iDrawableId;
708 TInt err = image.Open(id);
709 if(KErrNoMemory == err)
711 result = KErrNoMemory;
716 result |= EFirstTestPassed;
718 if(KErrNone == image.MapReadOnly(dataAddressRead, dataStride))
720 result |= ESecondTestPassed;
722 if(KErrNone == image.Unmap())
724 result |= EThirdTestPassed;
726 if(KErrNone == image.MapWriteOnly(dataAddressWrite, dataStride))
728 result |= EFourthTestPassed;
730 if(KErrNone == image.Unmap())
732 result |= EFifthTestPassed;
734 if(KErrNone == image.MapReadWrite(dataAddressWrite, dataStride))
736 result |= ESixthTestPassed;
738 if(KErrNone == image.Unmap())
740 result |= ESeventhTestPassed;
744 case ESgresSecondThreadUnmapImage:
746 id = ((TSgresTestInfo*)aInfo)->iDrawableId;
747 TInt err = image.Open(id);
748 if(KErrNoMemory == err)
750 result = KErrNoMemory;
755 result |= EFirstTestPassed;
757 if(KErrNone == image.Unmap())
759 result |= ESecondTestPassed;
763 case ESgresSecondThreadPanicImageGetInterfaceInvalidHandle:
766 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image);
772 RSgImage anotherImage;
773 anotherImage = image;
776 MSgImage_Sw* swInterface = NULL;
777 ret = anotherImage.GetInterface(swInterface); //should panic with SGRES 2
781 case ESgresSecondThreadPanicImageGetInterfaceNoDriver:
784 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image);
790 RSgImage anotherImage;
791 anotherImage = image;
795 MSgImage_Sw* swInterface = NULL;
796 anotherImage.GetInterface(swInterface); // should panic with SGRES 5
799 case ESgresSecondThreadPanicImageCloseInvalidHandle:
802 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image);
808 RSgImage anotherImage;
809 anotherImage = image;
812 anotherImage.Close(); //should panic with SGRES 2
816 case ESgresSecondThreadPanicImageCloseNoDriver:
819 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image);
825 RSgImage anotherImage;
826 anotherImage = image;
829 anotherImage.Close(); // should panic with SGRES 5
832 case ESgresSecondThreadPanicImageIdInvalidHandle:
835 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image);
841 RSgImage anotherImage;
842 anotherImage = image;
845 anotherImage.Id(); //should panic with SGRES 2
849 case ESgresSecondThreadPanicImageIdNoDriver:
852 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image);
858 RSgImage anotherImage;
859 anotherImage = image;
862 anotherImage.Id(); // should panic with SGRES 5
865 case ESgresSecondThreadPanicImageDrawableTypeInvalidHandle:
868 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image);
874 RSgImage anotherImage;
875 anotherImage = image;
878 anotherImage.DrawableType(); //should panic with SGRES 2
882 case ESgresSecondThreadPanicImageDrawableTypeNoDriver:
885 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image);
891 RSgImage anotherImage;
892 anotherImage = image;
895 anotherImage.DrawableType(); // should panic with SGRES 5
898 case ESgresSecondThreadPanicImageCreateInvalidHandle:
901 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image);
907 RSgImage anotherImage;
908 anotherImage = image;
914 newImage.Create(info, anotherImage); //should panic with SGRES 3
918 case ESgresSecondThreadPanicImageGetInfoInvalidHandle:
921 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image);
927 RSgImage anotherImage;
928 anotherImage = image;
931 TSgImageInfo anotherInfo;
932 anotherImage.GetInfo(anotherInfo); //should panic with SGRES 3
936 case ESgresSecondThreadPanicImageGetInfoNoDriver:
939 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image);
945 RSgImage anotherImage;
946 anotherImage = image;
949 TSgImageInfo anotherInfo;
950 anotherImage.GetInfo(anotherInfo); // should panic with SGRES 5
953 case ESgresSecondThreadPanicImageMapReadOnlyInvalidHandle:
956 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image);
962 RSgImage anotherImage;
963 anotherImage = image;
966 anotherImage.MapReadOnly(dataAddressRead, dataStride); //should panic with SGRES 3
970 case ESgresSecondThreadPanicImageMapReadOnlyNoDriver:
973 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image);
979 RSgImage anotherImage;
980 anotherImage = image;
983 anotherImage.MapReadOnly(dataAddressRead, dataStride); // should panic with SGRES 5
986 case ESgresSecondThreadPanicImageMapWriteOnlyInvalidHandle:
989 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image);
995 RSgImage anotherImage;
996 anotherImage = image;
999 anotherImage.MapWriteOnly(dataAddressWrite, dataStride); //should panic with SGRES 3
1003 case ESgresSecondThreadPanicImageMapWriteOnlyNoDriver:
1006 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image);
1012 RSgImage anotherImage;
1013 anotherImage = image;
1016 anotherImage.MapWriteOnly(dataAddressWrite, dataStride); // should panic with SGRES 5
1019 case ESgresSecondThreadPanicImageMapReadWriteInvalidHandle:
1022 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image);
1028 RSgImage anotherImage;
1029 anotherImage = image;
1032 anotherImage.MapReadWrite(dataAddressWrite, dataStride); //should panic with SGRES 3
1036 case ESgresSecondThreadPanicImageMapReadWriteNoDriver:
1039 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image);
1045 RSgImage anotherImage;
1046 anotherImage = image;
1049 anotherImage.MapReadWrite(dataAddressWrite, dataStride); // should panic with SGRES 5
1052 case ESgresSecondThreadPanicImageUnmapInvalidHandle:
1055 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image);
1061 RSgImage anotherImage;
1062 anotherImage = image;
1065 anotherImage.Unmap(); //should panic with SGRES 3
1069 case ESgresSecondThreadPanicImageUnmapNoDriver:
1072 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image);
1078 RSgImage anotherImage;
1079 anotherImage = image;
1082 anotherImage.Unmap(); // should panic with SGRES 5
1085 case ESgresSecondThreadPanicImageCollectionCloseInvalidHandle:
1087 RSgImageCollection collection;
1088 TInt ret = CreateImageCollectionWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, EFalse, ESgCpuAccessReadWrite, collection);
1095 RSgImageCollection anotherCollection;
1096 anotherCollection = collection;
1098 anotherCollection.Close(); //should panic with SGRES 4
1102 case ESgresSecondThreadPanicImageCollectionCloseNoDriver:
1104 RSgImageCollection collection;
1105 TInt ret = CreateImageCollectionWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, EFalse, ESgCpuAccessReadWrite, collection);
1112 RSgImageCollection anotherCollection;
1113 anotherCollection = collection;
1116 anotherCollection.Close(); // should panic with SGRES 5
1119 case ESgresSecondThreadPanicImageCollectionSurfaceIdInvalidHandle:
1121 RSgImageCollection collection;
1122 TInt ret = CreateImageCollectionWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, EFalse, ESgCpuAccessReadWrite, collection);
1129 RSgImageCollection anotherCollection;
1130 anotherCollection = collection;
1132 anotherCollection.SurfaceId(); //should panic with SGRES 4
1136 case ESgresSecondThreadPanicImageCollectionSurfaceIdNoDriver:
1138 RSgImageCollection collection;
1139 TInt ret = CreateImageCollectionWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, EFalse, ESgCpuAccessReadWrite, collection);
1146 RSgImageCollection anotherCollection;
1147 anotherCollection = collection;
1150 anotherCollection.SurfaceId(); // should panic with SGRES 5
1153 case ESgresSecondThreadPanicImageCollectionGetInfoInvalidHandle:
1155 RSgImageCollection collection;
1156 TInt ret = CreateImageCollectionWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, EFalse, ESgCpuAccessReadWrite, collection);
1163 RSgImageCollection anotherCollection;
1164 anotherCollection = collection;
1166 TSgImageInfo anotherInfo;
1167 anotherCollection.GetInfo(anotherInfo); //should panic with SGRES 4
1171 case ESgresSecondThreadPanicImageCollectionGetInfoNoDriver:
1173 RSgImageCollection collection;
1174 TInt ret = CreateImageCollectionWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, EFalse, ESgCpuAccessReadWrite, collection);
1181 RSgImageCollection anotherCollection;
1182 anotherCollection = collection;
1184 TSgImageInfo anotherInfo;
1186 anotherCollection.GetInfo(anotherInfo); // should panic with SGRES 5
1189 case ESgresSecondThreadPanicImageCollectionCountInvalidHandle:
1191 RSgImageCollection collection;
1192 TInt ret = CreateImageCollectionWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, EFalse, ESgCpuAccessReadWrite, collection);
1199 RSgImageCollection anotherCollection;
1200 anotherCollection = collection;
1202 anotherCollection.Count(); //should panic with SGRES 4
1206 case ESgresSecondThreadPanicImageCollectionCountNoDriver:
1208 RSgImageCollection collection;
1209 TInt ret = CreateImageCollectionWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, EFalse, ESgCpuAccessReadWrite, collection);
1216 RSgImageCollection anotherCollection;
1217 anotherCollection = collection;
1220 anotherCollection.Count(); // should panic with SGRES 5
1223 case ESgresSecondThreadPanicImageCollectionOpenImageInvalidHandle:
1225 RSgImageCollection collection;
1226 TInt ret = CreateImageCollectionWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, EFalse, ESgCpuAccessReadWrite, collection);
1233 RSgImageCollection anotherCollection;
1234 anotherCollection = collection;
1237 anotherCollection.OpenImage(0, image); //should panic with SGRES 4
1241 case ESgresSecondThreadPanicImageCollectionOpenImageNoDriver:
1243 RSgImageCollection collection;
1244 TInt ret = CreateImageCollectionWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, EFalse, ESgCpuAccessReadWrite, collection);
1251 RSgImageCollection anotherCollection;
1252 anotherCollection = collection;
1256 anotherCollection.OpenImage(0, image); // should panic with SGRES 5
1259 case ESgresMultipleThreadStressTest:
1261 for (TInt i = 0; i < 1000 && result == KErrNone; ++i)
1263 TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image);
1264 if (KErrNone != ret)
1269 const TInt KMaxOpenCount = 100;
1270 RSgImage images[KMaxOpenCount];
1271 TInt count = Math::Random() % KMaxOpenCount;
1272 for (TInt k = 0; k < count; ++k)
1274 ret = images[k].Open(((TSgresTestInfo*)aInfo)->iDrawableId);
1275 if (KErrNone != ret)
1282 for (TInt k = 0; k < count; ++k)
1294 if (KErrNone == openSem)
1300 TInt procHandles2 =0;
1301 TInt threadHandles2=0;
1302 RThread().HandleCount(procHandles2,threadHandles2);
1303 if (threadHandles1 != threadHandles2)
1305 result = KErrGeneral; // Thread-owned handles not closed
1312 Static function used by the cleanup item to close the driver.
1314 void CTSgTestStepBase::CloseDriverWhenLeave(TAny* /*aInfo*/)
1320 Checks the function for the passed error codes and logs an error if the codes do not match.
1321 If the test is running out of memory tests, KErrNoMemory is also an expected error code and
1322 the function would just leave with KErrNoMemory in that case.
1324 @param aExpectedErrorCode The expected error code to check against
1325 @param aActualErrorCode The actual error code
1326 @param aFile The filename to use when reporting the error
1327 @param aLine The line number to use when reporting the error
1329 void CTSgTestStepBase::CheckErrorL(TInt aExpectedErrorCode, TInt aActualErrorCode, const TText8* aFile, TInt aLine)
1331 if(iRunningOomTests && KErrNoMemory == aActualErrorCode)
1333 User::Leave(KErrNoMemory);
1335 TESTWITHFILENAMEANDLINENUMBERL(aExpectedErrorCode == aActualErrorCode, aFile, aLine);
1339 Out of memory tests.
1341 void CTSgTestStepBase::TestOOM()
1344 TInt err = KErrNone;
1346 iRunningOomTests = ETrue;
1349 SgDriver::SetAllocFail(RAllocator::EFailNext, ++tryCount);
1350 TRAP(err, DoMemoryTestsL());
1352 while(err == KErrNoMemory);
1354 SgDriver::SetAllocFail(RAllocator::ENone, 0);
1355 iRunningOomTests = EFalse;
1357 INFO_PRINTF2(_L("- server succeeded at private heap failure rate of %i\n"), tryCount);
1361 Specifies which functions to run in out of memory conditions.
1362 To be overridden by the derived test classes.
1364 void CTSgTestStepBase::DoMemoryTestsL()