|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef TGRAPHICSRESOURCETESTSTEPBASE_H |
|
17 #define TGRAPHICSRESOURCETESTSTEPBASE_H |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <test/testexecutestepbase.h> |
|
21 #include <test/ttmsgraphicsstep.h> |
|
22 #include <sgresource/sgimage.h> |
|
23 #include "tgraphicsresourcemultiprocessthread.h" |
|
24 |
|
25 _LIT(KSgTestGenericPanicCategory, "SGRES"); |
|
26 |
|
27 /** |
|
28 Default data stride used by RSgImage Create tests. |
|
29 */ |
|
30 const TInt KCrossImageDataStride = 16; |
|
31 |
|
32 const TInt64 KFakeDrawableId = 0xFFFFFFFFFFFFFFFF; |
|
33 |
|
34 const TSgImageInfo KSgImageInfo1(TSize(), 0, 0); |
|
35 const TSgImageInfo KSgImageInfo2(TSize(), 0, 0); |
|
36 const TSgDrawableId KFakeSgDrawableId = {0xFFFFFFFFFFFFFFFF}; |
|
37 |
|
38 const TInt KSecondThreadMinHeapSize = 0x1000; |
|
39 const TInt KSecondThreadMaxHeapSize = 0x5000; |
|
40 |
|
41 class CTSgTestStepBase : public CTTMSGraphicsStep |
|
42 { |
|
43 public: |
|
44 CTSgTestStepBase(TBool aConformanceTests); |
|
45 ~CTSgTestStepBase(); |
|
46 |
|
47 // common utility functions |
|
48 static TBool CompareInfos(TSgImageInfo& info1, TSgImageInfo& info2); |
|
49 static TInt CreateImageAndReturnCopy(RSgImage& aSgImage); |
|
50 |
|
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); |
|
54 |
|
55 protected: |
|
56 // From CTestStep |
|
57 virtual TVerdict doTestStepPreambleL(); |
|
58 virtual TVerdict doTestStepPostambleL(); |
|
59 |
|
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); |
|
72 |
|
73 protected: |
|
74 RThread iSecondThread; |
|
75 TUint32* iDiagonalImageData; |
|
76 TBool iEnableConformanceTests; //if ETrue runs the conformance tests, otherwise runs the OOM tests |
|
77 private: |
|
78 RArray<TInt> iPixelFormatArray; |
|
79 RSgDriver iSgDriver; |
|
80 }; |
|
81 |
|
82 /** |
|
83 Utility class that contains the behaviour for second-thread testing. |
|
84 */ |
|
85 class SgTestSecondThread |
|
86 { |
|
87 public: |
|
88 static TInt ThreadMainL(TSgThreadTestInfo* aInfo); |
|
89 static TInt ThreadStart(TAny* aInfo); |
|
90 |
|
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); |
|
113 }; |
|
114 /** |
|
115 Test Interface used by RSgImage::GetInterface() tests. |
|
116 */ |
|
117 class MTSgImage_Interface |
|
118 { |
|
119 public: |
|
120 enum { EInterfaceUid = 0x102858F0 }; |
|
121 public: |
|
122 virtual TAny* DataAddress() const = 0; |
|
123 virtual TInt DataStride() const = 0; |
|
124 }; |
|
125 |
|
126 //common variables and functions |
|
127 const TInt KDiagonalImageSize = 400; //size in pixels |
|
128 const TInt KDiagonalImageDataStride = 400 * 4; |
|
129 |
|
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 |
|
139 }; |
|
140 |
|
141 #define TESTWITHFILENAMEANDLINENUMBERL(a, f, l) \ |
|
142 {\ |
|
143 testBooleanTrue((a), f, l); \ |
|
144 } |
|
145 |
|
146 inline void CTSgTestStepBase::testBooleanTrue(TBool aCondition, const TText8* aFile, TInt aLine) |
|
147 { |
|
148 MQCTest(aCondition, aFile, aLine); |
|
149 } |
|
150 |
|
151 inline void CTSgTestStepBase::testBooleanTrueWithErrorCode(TBool aCondition, TInt aErrorCode, const TText8* aFile, TInt aLine) |
|
152 { |
|
153 MQCTestWithErrorCode(aCondition, aErrorCode, aFile, aLine); |
|
154 } |
|
155 |
|
156 _LIT(KSecondProcess, "tgraphicsresourcesecondprocess2.exe"); |
|
157 |
|
158 _LIT(KSecondThread, "Test_GraphicsResource_SecondThread"); |
|
159 _LIT(KSecondThreadSemaphore, "Second Thread Semaphore"); |
|
160 |
|
161 #endif |