os/graphics/graphicsresourceservices/graphicsresourceimplementation/test/inc/tgraphicsresourceteststepbase.h
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.
16 #ifndef TGRAPHICSRESOURCETESTSTEPBASE_H
17 #define TGRAPHICSRESOURCETESTSTEPBASE_H
20 #include <test/testexecutestepbase.h>
21 #include <test/ttmsgraphicsstep.h>
22 #include <sgresource/sgimage.h>
23 #include "tgraphicsresourcemultiprocessthread.h"
25 _LIT(KSgTestGenericPanicCategory, "SGRES");
28 Default data stride used by RSgImage Create tests.
30 const TInt KCrossImageDataStride = 16;
32 const TInt64 KFakeDrawableId = 0xFFFFFFFFFFFFFFFF;
34 const TSgImageInfo KSgImageInfo1(TSize(), 0, 0);
35 const TSgImageInfo KSgImageInfo2(TSize(), 0, 0);
36 const TSgDrawableId KFakeSgDrawableId = {0xFFFFFFFFFFFFFFFF};
38 const TInt KSecondThreadMinHeapSize = 0x1000;
39 const TInt KSecondThreadMaxHeapSize = 0x5000;
41 class CTSgTestStepBase : public CTTMSGraphicsStep
44 CTSgTestStepBase(TBool aConformanceTests);
47 // common utility functions
48 static TBool CompareInfos(TSgImageInfo& info1, TSgImageInfo& info2);
49 static TInt CreateImageAndReturnCopy(RSgImage& aSgImage);
51 // from CTTMSGraphicsStep
52 inline void testBooleanTrue(TBool aCondition, const TText8* aFile, TInt aLine);
53 inline void testBooleanTrueWithErrorCode(TBool aCondition, TInt aErrorCode, const TText8* aFile, TInt aLine);
57 virtual TVerdict doTestStepPreambleL();
58 virtual TVerdict doTestStepPostambleL();
60 //common utility functions
61 void CreateImageL(RSgImage& aImage);
62 TInt CreateSecondProcessAndDoTestL(const TDesC &aProcessName, TSgProcessTestInfo& aTestInfo);
63 TInt CreateSecondThreadAndDoTestL(TSgThreadTestInfo aTestInfo);
64 void CreateSecondThreadAndCheckPanicL(TSgThreadTestInfo aTestInfo, TInt aPanicCode, TExitCategoryName aExitCategory, const TDesC &aThreadName);
65 void CreateSecondProcessAndCheckPanicL(TSgProcessTestInfo& aTestInfo, TInt aPanicCode, TExitCategoryName aExitCategory, const TDesC &aProcessName);
66 void CallGetPixelFormatsL(TUint32 aUsage);
67 void TestGetPixelFormatCompatibilityGuaranteesL();
68 TBool CheckPixelFormatPresent(TSgPixelFormat aPixelFormat);
69 void TestOpenDriverL();
70 void TestCloseDriver();
71 void CheckErrorL(TInt aExpectedErrorCode, TInt aActualErrorCode, const TText8* aFile, TInt aLine);
74 RThread iSecondThread;
75 TUint32* iDiagonalImageData;
76 TBool iEnableConformanceTests; //if ETrue runs the conformance tests, otherwise runs the OOM tests
78 RArray<TInt> iPixelFormatArray;
83 Utility class that contains the behaviour for second-thread testing.
85 class SgTestSecondThread
88 static TInt ThreadMainL(TSgThreadTestInfo* aInfo);
89 static TInt ThreadStart(TAny* aInfo);
91 //Second Thread Test Functions
92 static TInt OpenImage(TSgThreadTestInfo* aInfo, RSgDriver& aSgDriver);
93 static TInt OpenDrawable(TSgThreadTestInfo* aInfo);
94 static TInt OpenImageInvalid(TSgThreadTestInfo* aInfo);
95 static TInt OpenDrawableInvalid(TSgThreadTestInfo* aInfo);
96 static TInt PanicImageGetInterfaceInvalidHandle(RSgDriver& aSgDriver);
97 static TInt PanicImageGetInterfaceNoDriver(RSgDriver& aSgDriver);
98 static TInt PanicImageCloseInvalidHandle(RSgDriver& aSgDriver);
99 static TInt PanicImageCloseNoDriver(RSgDriver& aSgDriver);
100 static TInt PanicImageIdInvalidHandle(RSgDriver& aSgDriver);
101 static TInt PanicImageIdNoDriver(RSgDriver& aSgDriver);
102 static TInt PanicImageDrawableTypeInvalidHandle(RSgDriver& aSgDriver);
103 static TInt PanicImageDrawableTypeNoDriver(RSgDriver& aSgDriver);
104 static TInt PanicImageCreateInvalidHandle(RSgDriver& aSgDriver);
105 static TInt PanicImageGetInfoInvalidHandle(RSgDriver& aSgDriver);
106 static TInt PanicImageGetInfoNoDriver(RSgDriver& aSgDriver);
107 static TInt PanicImageGetAttributeInvalidHandle(RSgDriver& aSgDriver);
108 static TInt PanicImageGetAttributeNoDriver(RSgDriver& aSgDriver);
109 static TInt MultipleThreadStressTest(TSgThreadTestInfo* aInfo);
110 static void PanicAttributeArrayInvalidIndexL();
111 static void PanicAttributeArrayInvalidIndex2L();
112 static TInt CreatePassedImageL(RSgImage* aSgImage);
115 Test Interface used by RSgImage::GetInterface() tests.
117 class MTSgImage_Interface
120 enum { EInterfaceUid = 0x102858F0 };
122 virtual TAny* DataAddress() const = 0;
123 virtual TInt DataStride() const = 0;
126 //common variables and functions
127 const TInt KDiagonalImageSize = 400; //size in pixels
128 const TInt KDiagonalImageDataStride = 400 * 4;
130 const TUint16 KCrossImageData[] = {
131 0x7E0,0x7E0,0x7E0,0x000,0x000,0x7E0,0x7E0,0x7E0,
132 0x7E0,0x7E0,0x7E0,0x000,0x000,0x7E0,0x7E0,0x7E0,
133 0x7E0,0x7E0,0x7E0,0x000,0x000,0x7E0,0x7E0,0x7E0,
134 0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,
135 0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,
136 0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,
137 0x7E0,0x7E0,0x7E0,0x000,0x000,0x7E0,0x7E0,0x7E0,
138 0x7E0,0x7E0,0x7E0,0x000,0x000,0x7E0,0x7E0,0x7E0
141 #define TESTWITHFILENAMEANDLINENUMBERL(a, f, l) \
143 testBooleanTrue((a), f, l); \
146 inline void CTSgTestStepBase::testBooleanTrue(TBool aCondition, const TText8* aFile, TInt aLine)
148 MQCTest(aCondition, aFile, aLine);
151 inline void CTSgTestStepBase::testBooleanTrueWithErrorCode(TBool aCondition, TInt aErrorCode, const TText8* aFile, TInt aLine)
153 MQCTestWithErrorCode(aCondition, aErrorCode, aFile, aLine);
156 _LIT(KSecondProcess, "tgraphicsresourcesecondprocess2.exe");
158 _LIT(KSecondThread, "Test_GraphicsResource_SecondThread");
159 _LIT(KSecondThreadSemaphore, "Second Thread Semaphore");