|
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_INC_COUNTER(member) |
|
15 #define AMT_DEC_COUNTER(member) |
|
16 #define AMT_SET_VALUE(member, val) |
|
17 #define AMT_GET_VALUE(x, member) |
|
18 #define AMT_PRINT_STATE() |
|
19 |
|
20 #ifndef AMT_CONTROL |
|
21 #error "Error: you need to define AMT_CONTROL macro in your code to be able to use ALF module test system!" |
|
22 // The user have to define AMT_CONTROL, e.g. like this: |
|
23 // #define AMT_CONTROL() static_cast<CAlfModuleTestDataControl*>(Dll::Tls()) |
|
24 // or |
|
25 // #define AMT_CONTROL() iMyModuleTestDataControl |
|
26 #endif |
|
27 |
|
28 #else |
|
29 |
|
30 |
|
31 // *** Use these macros to access global memory chunk |
|
32 |
|
33 |
|
34 // Note: If you read/write a large block of data members, it is advisable not use the AMT_FUNC_EXC() based macros below. |
|
35 // Use Lock() and Unlock() around the block explicitely, and use AMT_FUNC() macro. |
|
36 // That is to avoid unnecessary nested lock-unlock sequences (even if nested locks are working ok). |
|
37 |
|
38 // 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! |
|
39 |
|
40 // Generic macros |
|
41 #define AMT_DATA() AMT_CONTROL()->iModuleTestData |
|
42 #define AMT_FUNC(func) if (AMT_DATA()->iIsEnabled) {func;} |
|
43 #define AMT_FUNC_EXC(func) {AMT_CONTROL()->Lock(); if (AMT_DATA()->iIsEnabled) {func;} AMT_CONTROL()->Unlock();} |
|
44 |
|
45 // Single operation macros, that will do lock/unlock. |
|
46 #define AMT_INC_COUNTER(member) AMT_FUNC_EXC(AMT_DATA()->member++) |
|
47 #define AMT_DEC_COUNTER(member) AMT_FUNC_EXC(AMT_DATA()->member--) |
|
48 #define AMT_SET_VALUE(member, val) AMT_FUNC_EXC(AMT_DATA()->member=(val)) |
|
49 #define AMT_GET_VALUE(x, member) AMT_FUNC_EXC((x) = AMT_DATA()->member) |
|
50 #define AMT_PRINT_STATE() AMT_FUNC_EXC(AMT_DATA()->PrintState()) |
|
51 |
|
52 // *** Global object names |
|
53 _LIT(KAlfModuleTestChunkName, "ALF_MODULE_TEST_CHUNK"); |
|
54 _LIT(KAlfModuleTestMutexName, "ALF_MODULE_TEST_MUTEX"); |
|
55 |
|
56 /* |
|
57 * Class CAlfModuleTestData |
|
58 */ |
|
59 |
|
60 NONSHARABLE_CLASS(CAlfModuleTestData) : public CBase |
|
61 { |
|
62 public: |
|
63 void PrintState() |
|
64 { |
|
65 RDebug::Print(_L("*** ALF INTERNAL STATE ***")); |
|
66 RDebug::Print(_L("iTotalLayerCount[0]=%d"), iTotalLayerCount[0]); |
|
67 RDebug::Print(_L("iTotalLayerCount[1]=%d"), iTotalLayerCount[1]); |
|
68 RDebug::Print(_L("iCloneLayerCount=%d"), iCloneLayerCount); |
|
69 RDebug::Print(_L("iTotalNodeCount=%d"), iTotalNodeCount); |
|
70 RDebug::Print(_L("iWindowGroupNodeCount=%d"), iWindowGroupNodeCount); |
|
71 RDebug::Print(_L("iWindowNodeCount=%d"), iWindowNodeCount); |
|
72 RDebug::Print(_L("iAnimNodeCount=%d"), iAnimNodeCount); |
|
73 RDebug::Print(_L("iTotalVisualCount=%d"), iTotalVisualCount); |
|
74 RDebug::Print(_L("iVisibleVisualCount=%d"), iVisibleVisualCount); |
|
75 RDebug::Print(_L("iActiveVisualCount=%d"), iActiveVisualCount); |
|
76 RDebug::Print(_L("iPassiveVisualCount=%d"), iPassiveVisualCount); |
|
77 RDebug::Print(_L("iTextureCount=%d"), iTextureCount); |
|
78 RDebug::Print(_L("iRenderBufferCount=%d"), iRenderBufferCount); |
|
79 RDebug::Print(_L("*** ALF INTERNAL STATE ***")); |
|
80 } |
|
81 |
|
82 |
|
83 public: |
|
84 TBool iIsEnabled; // *** not yet implemented. For run-time enabling/disabling of the test system. |
|
85 |
|
86 // Alf Render Stage |
|
87 TInt iScreenCount; // *** not yet implemented |
|
88 TInt iTotalLayerCount[10]; // For each screen |
|
89 TInt iCloneLayerCount; // ** not yet implemented |
|
90 |
|
91 // Alf Streamer |
|
92 TInt iTotalNodeCount; // *** not yet implemented |
|
93 TInt iWindowGroupNodeCount; // *** not yet implemented |
|
94 TInt iWindowNodeCount; // *** not yet implemented |
|
95 TInt iAnimNodeCount; // *** not yet implemented |
|
96 |
|
97 // Alf Server |
|
98 TInt iTotalVisualCount; // *** not yet implemented |
|
99 TInt iVisibleVisualCount; // *** not yet implemented |
|
100 TInt iActiveVisualCount; // Active visual count |
|
101 TInt iPassiveVisualCount; // Passive visual count |
|
102 TInt iTextureCount; // *** not yet implemented |
|
103 TInt iRenderBufferCount; // *** not yet implemented |
|
104 }; |
|
105 |
|
106 |
|
107 /* |
|
108 * Class CAlfModuleTestDataControl |
|
109 */ |
|
110 NONSHARABLE_CLASS(CAlfModuleTestDataControl) : public CBase |
|
111 { |
|
112 public: |
|
113 /* |
|
114 * Destructor |
|
115 */ |
|
116 ~CAlfModuleTestDataControl() |
|
117 { |
|
118 iModuleTestMutex.Close(); |
|
119 iModuleTestChunk.Close(); |
|
120 } |
|
121 |
|
122 /* |
|
123 * Open global chunk and mutex created elsewhere |
|
124 */ |
|
125 TInt OpenGlobalObjects() |
|
126 { |
|
127 // Open global module testing chunk |
|
128 TBool isReadOnly = EFalse; |
|
129 TInt err = iModuleTestChunk.OpenGlobal(KAlfModuleTestChunkName, isReadOnly); |
|
130 if (!err) |
|
131 { |
|
132 // Create global module testing mutex |
|
133 err = iModuleTestMutex.OpenGlobal(KAlfModuleTestMutexName); |
|
134 if (!err) |
|
135 { |
|
136 iModuleTestData = reinterpret_cast<CAlfModuleTestData*>(iModuleTestChunk.Base()); |
|
137 } |
|
138 } |
|
139 RDebug::Print(_L("CAlfModuleTestDataControl::OpenGlobalObjects. err=%d"), err); |
|
140 return err; |
|
141 } |
|
142 |
|
143 /* |
|
144 * Lock access to global memory |
|
145 */ |
|
146 void Lock() {iModuleTestMutex.Wait();} |
|
147 |
|
148 /* |
|
149 * Unlock access to global memory |
|
150 */ |
|
151 void Unlock() {iModuleTestMutex.Signal();} |
|
152 |
|
153 public: |
|
154 RChunk iModuleTestChunk; |
|
155 RMutex iModuleTestMutex; |
|
156 CAlfModuleTestData* iModuleTestData; // Not owned |
|
157 }; |
|
158 |
|
159 #endif |
|
160 |
|
161 #endif // ALFMODULETEST_H |
|
162 |
|
163 // End of File |