|
1 #include "e32base.h" |
|
2 #include "e32debug.h" |
|
3 |
|
4 #ifndef ALFMODULETEST_H |
|
5 #define ALFMODULETEST_H |
|
6 |
|
7 // Define this to build module testing enchanced version of ALF |
|
8 // #define USE_MODULE_TEST_HOOKS_FOR_ALF |
|
9 |
|
10 #if !defined(USE_MODULE_TEST_HOOKS_FOR_ALF) || !defined(AMT_CONTROL) |
|
11 |
|
12 #define AMT_FUNC(func) |
|
13 #define AMT_FUNC_EXC(func) |
|
14 #define AMT_FUNC_EXC_IF(cond, func) |
|
15 #define AMT_INC_COUNTER(member) |
|
16 #define AMT_DEC_COUNTER(member) |
|
17 #define AMT_SET_VALUE(member, val) |
|
18 #define AMT_GET_VALUE(x, member) |
|
19 #define AMT_INC_COUNTER_IF(cond, member) |
|
20 #define AMT_DEC_COUNTER_IF(cond, member) |
|
21 #define AMT_SET_VALUE_IF(cond, member, val) |
|
22 #define AMT_GET_VALUE_IF(cond, x, member) |
|
23 #define AMT_PRINT_STATE() |
|
24 |
|
25 #ifndef AMT_CONTROL |
|
26 #error "Error: you need to define AMT_CONTROL macro in your code to be able to use ALF module test system!" |
|
27 // The user have to define AMT_CONTROL, e.g. like this: |
|
28 // #define AMT_CONTROL() static_cast<CAlfModuleTestDataControl*>(Dll::Tls()) |
|
29 // or |
|
30 // #define AMT_CONTROL() iMyModuleTestDataControl |
|
31 // etc. |
|
32 #endif |
|
33 |
|
34 #else |
|
35 |
|
36 |
|
37 // *** Use these macros to access global memory chunk |
|
38 |
|
39 |
|
40 // Note: If you read/write a large block of data members, it is advisable not use the AMT_FUNC_EXC() based macros below. |
|
41 // Use Lock() and Unlock() around the block explicitely, and use AMT_FUNC() macro. |
|
42 // That is to avoid unnecessary nested lock-unlock sequences (even if nested locks are working ok). |
|
43 |
|
44 // Note: Be careful not to lock the the mutex for a long time as it will halt other processes if they are using the lock during that time! |
|
45 |
|
46 // Generic macros |
|
47 #define AMT_DATA() AMT_CONTROL()->iModuleTestData |
|
48 #define AMT_FUNC(func) if (AMT_DATA()->iIsEnabled) {func;} |
|
49 #define AMT_FUNC_EXC(func) {AMT_CONTROL()->Lock(); if (AMT_DATA()->iIsEnabled) {func;} AMT_CONTROL()->Unlock();} |
|
50 #define AMT_FUNC_EXC_IF(cond, func) {AMT_CONTROL()->Lock(); if (AMT_DATA()->iIsEnabled && (cond)) {func;} AMT_CONTROL()->Unlock();} |
|
51 |
|
52 // Single operation macros, that will do lock/unlock. |
|
53 #define AMT_INC_COUNTER(member) AMT_FUNC_EXC(AMT_DATA()->member++) |
|
54 #define AMT_DEC_COUNTER(member) AMT_FUNC_EXC(AMT_DATA()->member--) |
|
55 #define AMT_SET_VALUE(member, val) AMT_FUNC_EXC(AMT_DATA()->member=(val)) |
|
56 #define AMT_GET_VALUE(x, member) AMT_FUNC_EXC((x) = AMT_DATA()->member) |
|
57 #define AMT_PRINT_STATE() AMT_FUNC_EXC(AMT_DATA()->PrintState()) |
|
58 |
|
59 // Conditional single operation macros, that will do lock/unlock. |
|
60 #define AMT_INC_COUNTER_IF(cond, member) AMT_FUNC_EXC_IF((cond), AMT_DATA()->member++) |
|
61 #define AMT_DEC_COUNTER_IF(cond, member) AMT_FUNC_EXC_IF((cond), AMT_DATA()->member--) |
|
62 #define AMT_SET_VALUE_IF(cond, member, val) AMT_FUNC_EXC_IF((cond), AMT_DATA()->member=(val)) |
|
63 #define AMT_GET_VALUE_IF(cond, x, member) AMT_FUNC_EXC_IF((cond), (x) = AMT_DATA()->member) |
|
64 |
|
65 |
|
66 // *** Global object names |
|
67 _LIT(KAlfModuleTestChunkName, "ALF_MODULE_TEST_CHUNK"); |
|
68 _LIT(KAlfModuleTestMutexName, "ALF_MODULE_TEST_MUTEX"); |
|
69 |
|
70 /* |
|
71 * Class CAlfModuleTestData |
|
72 */ |
|
73 |
|
74 NONSHARABLE_CLASS(CAlfModuleTestData) : public CBase |
|
75 { |
|
76 public: |
|
77 void PrintState() |
|
78 { |
|
79 RDebug::Print(_L("*** ALF INTERNAL STATE ***")); |
|
80 RDebug::Print(_L("iTotalLayerCount[0]=%d"), iTotalLayerCount[0]); |
|
81 RDebug::Print(_L("iTotalLayerCount[1]=%d"), iTotalLayerCount[1]); |
|
82 RDebug::Print(_L("iCloneLayerCount=%d"), iCloneLayerCount); |
|
83 RDebug::Print(_L("iRsTotalNodeCount=%d"), iRsTotalNodeCount); |
|
84 RDebug::Print(_L("iRsWindowGroupNodeCount=%d"), iRsWindowGroupNodeCount); |
|
85 RDebug::Print(_L("iRsWindowNodeCount=%d"), iRsWindowNodeCount); |
|
86 RDebug::Print(_L("iRsAnimNodeCount=%d"), iRsAnimNodeCount); |
|
87 RDebug::Print(_L("iRsWindowNodeActivatedCount=%d"), iRsWindowNodeActivatedCount); |
|
88 RDebug::Print(_L("iRsNodeExtentChangedCount=%d"), iRsNodeExtentChangedCount); |
|
89 RDebug::Print(_L("iRsLatestNodeExtentRect= x:%d, y:%d, width=%d, height=%d"), |
|
90 iRsLatestNodeExtentRect.iTl.iX, iRsLatestNodeExtentRect.iTl.iY, |
|
91 iRsLatestNodeExtentRect.Width(), iRsLatestNodeExtentRect.Height()); |
|
92 RDebug::Print(_L("iRsTotalNodeFlagChangedCount=%d"), iRsTotalNodeFlagChangedCount); |
|
93 RDebug::Print(_L("iRsTotalNodeAttributeChangedCount=%d"), iRsTotalNodeAttributeChangedCount); |
|
94 RDebug::Print(_L("iTotalNodeCount=%d"), iTotalNodeCount); |
|
95 RDebug::Print(_L("iWindowGroupNodeCount=%d"), iWindowGroupNodeCount); |
|
96 RDebug::Print(_L("iWindowNodeCount=%d"), iWindowNodeCount); |
|
97 RDebug::Print(_L("iAnimNodeCount=%d"), iAnimNodeCount); |
|
98 RDebug::Print(_L("iWindowNodeActivatedCount=%d"), iWindowNodeActivatedCount); |
|
99 RDebug::Print(_L("iNodeExtentChangedCount=%d"), iNodeExtentChangedCount); |
|
100 RDebug::Print(_L("iLatestNodeExtentRect= x:%d, y:%d, width=%d, height=%d"), |
|
101 iLatestNodeExtentRect.iTl.iX, iLatestNodeExtentRect.iTl.iY, |
|
102 iLatestNodeExtentRect.Width(), iLatestNodeExtentRect.Height()); |
|
103 RDebug::Print(_L("iTotalNodeFlagChangedCount=%d"), iTotalNodeFlagChangedCount); |
|
104 RDebug::Print(_L("iTotalNodeAttributeChangedCount=%d"), iTotalNodeAttributeChangedCount); |
|
105 RDebug::Print(_L("iTotalVisualCount=%d"), iTotalVisualCount); |
|
106 RDebug::Print(_L("iVisibleVisualCount=%d"), iVisibleVisualCount); |
|
107 RDebug::Print(_L("iActiveVisualCount=%d"), iActiveVisualCount); |
|
108 RDebug::Print(_L("iPassiveVisualCount=%d"), iPassiveVisualCount); |
|
109 RDebug::Print(_L("iTextureCount=%d"), iTextureCount); |
|
110 RDebug::Print(_L("iRenderBufferCount=%d"), iRenderBufferCount); |
|
111 RDebug::Print(_L("iTotalControlGroupCount=%d"), iTotalControlGroupCount); |
|
112 RDebug::Print(_L("iVisualSizeChangedCount=%d"), iVisualSizeChangedCount); |
|
113 RDebug::Print(_L("iVisualPositionChangedCount=%d"), iVisualPositionChangedCount); |
|
114 RDebug::Print(_L("iLatestVisualExtentRect= x:%d, y:%d, width=%d, height=%d"), |
|
115 iLatestVisualExtentRect.iTl.iX, iLatestVisualExtentRect.iTl.iY, |
|
116 iLatestVisualExtentRect.Width(), iLatestVisualExtentRect.Height()); |
|
117 RDebug::Print(_L("iTotalVisualFlagChangedCount=%d"), iTotalVisualFlagChangedCount); |
|
118 RDebug::Print(_L("iTotalVisualAttributeChangedCount=%d"), iTotalVisualAttributeChangedCount); |
|
119 RDebug::Print(_L("*** ALF INTERNAL STATE ***")); |
|
120 } |
|
121 |
|
122 |
|
123 public: |
|
124 TBool iIsEnabled; // *** not yet implemented. For run-time enabling/disabling of the test system. |
|
125 |
|
126 // Alf Render Stage |
|
127 TInt iScreenCount; // *** not yet implemented |
|
128 TInt iTotalLayerCount[10]; // For each screen |
|
129 TInt iCloneLayerCount; // ** not yet implemented |
|
130 TInt iRsTotalNodeCount; |
|
131 TInt iRsWindowGroupNodeCount; |
|
132 TInt iRsWindowNodeCount; |
|
133 TInt iRsAnimNodeCount; |
|
134 TInt iRsWindowNodeActivatedCount; |
|
135 TInt iRsNodeExtentChangedCount; |
|
136 TRect iRsLatestNodeExtentRect; |
|
137 TInt iRsTotalNodeFlagChangedCount; |
|
138 TInt iRsTotalNodeAttributeChangedCount; |
|
139 // These are temporary variables for Alf Render Stage thread internal use only! |
|
140 TInt iARS_Temp1; |
|
141 TInt iARS_Temp2; |
|
142 TInt iARS_Temp3; |
|
143 TInt iARS_Temp4; |
|
144 |
|
145 // Alf Streamer |
|
146 TInt iTotalNodeCount; |
|
147 TInt iWindowGroupNodeCount; |
|
148 TInt iWindowNodeCount; |
|
149 TInt iAnimNodeCount; |
|
150 TInt iWindowNodeActivatedCount; |
|
151 TInt iNodeExtentChangedCount; |
|
152 TRect iLatestNodeExtentRect; |
|
153 TInt iTotalNodeFlagChangedCount; |
|
154 TInt iTotalNodeAttributeChangedCount; |
|
155 // These are temporary variables for Alf Streamer thread internal use only! |
|
156 TInt iAST_Temp1; |
|
157 TInt iAST_Temp2; |
|
158 TInt iAST_Temp3; |
|
159 TInt iAST_Temp4; |
|
160 |
|
161 // Alf Server |
|
162 TInt iTotalVisualCount; |
|
163 TInt iVisibleVisualCount; |
|
164 TInt iActiveVisualCount; |
|
165 TInt iPassiveVisualCount; |
|
166 TInt iTextureCount; // *** not yet implemented |
|
167 TInt iRenderBufferCount; // *** not yet implemented |
|
168 TInt iTotalControlGroupCount; |
|
169 TInt iVisualSizeChangedCount; |
|
170 TInt iVisualPositionChangedCount; |
|
171 TRect iLatestVisualExtentRect; |
|
172 TInt iTotalVisualFlagChangedCount; |
|
173 TInt iTotalVisualAttributeChangedCount; |
|
174 TInt iOrdinalChange; |
|
175 // These are temporary variables for Alf Server thread internal use only! |
|
176 TInt iASE_Temp1; |
|
177 TInt iASE_Temp2; |
|
178 TInt iASE_Temp3; |
|
179 TInt iASE_Temp4; |
|
180 }; |
|
181 |
|
182 |
|
183 /* |
|
184 * Class CAlfModuleTestDataControl |
|
185 */ |
|
186 NONSHARABLE_CLASS(CAlfModuleTestDataControl) : public CBase |
|
187 { |
|
188 public: |
|
189 /* |
|
190 * Destructor |
|
191 */ |
|
192 ~CAlfModuleTestDataControl() |
|
193 { |
|
194 iModuleTestMutex.Close(); |
|
195 iModuleTestChunk.Close(); |
|
196 } |
|
197 |
|
198 /* |
|
199 * Open global chunk and mutex created elsewhere |
|
200 */ |
|
201 TInt OpenGlobalObjects() |
|
202 { |
|
203 RDebug::Print(_L("CAlfModuleTestDataControl::OpenGlobalObjects().")); |
|
204 // Open global module testing chunk |
|
205 TBool isReadOnly = EFalse; |
|
206 TInt err = iModuleTestChunk.OpenGlobal(KAlfModuleTestChunkName, isReadOnly); |
|
207 if (!err) |
|
208 { |
|
209 // Create global module testing mutex |
|
210 err = iModuleTestMutex.OpenGlobal(KAlfModuleTestMutexName); |
|
211 if (!err) |
|
212 { |
|
213 iModuleTestData = reinterpret_cast<CAlfModuleTestData*>(iModuleTestChunk.Base()); |
|
214 } |
|
215 } |
|
216 RDebug::Print(_L("CAlfModuleTestDataControl::OpenGlobalObjects. ret=%d"), err); |
|
217 return err; |
|
218 } |
|
219 |
|
220 /* |
|
221 * Lock access to global memory |
|
222 */ |
|
223 void Lock() {iModuleTestMutex.Wait();} |
|
224 |
|
225 /* |
|
226 * Unlock access to global memory |
|
227 */ |
|
228 void Unlock() {iModuleTestMutex.Signal();} |
|
229 |
|
230 public: |
|
231 RChunk iModuleTestChunk; |
|
232 RMutex iModuleTestMutex; |
|
233 CAlfModuleTestData* iModuleTestData; // Not owned |
|
234 }; |
|
235 |
|
236 #endif |
|
237 |
|
238 #endif // ALFMODULETEST_H |
|
239 |
|
240 // End of File |