|
1 // Copyright (c) 2006-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 /** |
|
17 @file |
|
18 @test |
|
19 @internalComponent - Internal Symbian test code |
|
20 */ |
|
21 |
|
22 #ifndef __GRAPHICSPERFORMANCE_REDRAWING_H__ |
|
23 #define __GRAPHICSPERFORMANCE_REDRAWING_H__ |
|
24 |
|
25 #include "te_graphicsperformanceSuiteStepBase.h" |
|
26 #include <w32std.h> |
|
27 #include <test/ttmsgraphicsstep.h> |
|
28 |
|
29 class CWindow; |
|
30 class CWsClient; |
|
31 class CRedrawingTest; |
|
32 |
|
33 // List of test cases implemented |
|
34 // -*-* To add new test case add new enum to bottom of list |
|
35 enum TRedrawTestCase |
|
36 { |
|
37 ETwoWindowBitblt, // Test two windows with alpha bitblited images |
|
38 ETwoWindowBitbltMasked, // Test two windows with alpha bitblt masked images |
|
39 ETwoWindowManyBitmapsBitblt, // Test many small bitmaps in window with invaldate small area |
|
40 }; |
|
41 |
|
42 /** |
|
43 This class is an active object that receives redraw events from the windows server |
|
44 */ |
|
45 class CWsRedrawer : public CActive |
|
46 { |
|
47 public: |
|
48 CWsRedrawer(); |
|
49 void ConstructL(CWsClient* aClient); |
|
50 ~CWsRedrawer(); |
|
51 void IssueRequest(); |
|
52 |
|
53 // From CActive |
|
54 void DoCancel(); |
|
55 void RunL(); |
|
56 |
|
57 private: |
|
58 CWsClient* iClient; |
|
59 }; |
|
60 |
|
61 /** |
|
62 Window base abstract class. Derive from this class to introduce new types of windows |
|
63 */ |
|
64 class CWindow : public CBase |
|
65 { |
|
66 public: |
|
67 CWindow(CWsClient* aClient, TRedrawTestCase aTestCase); |
|
68 void ConstructL (const TRect& aRect, CWindow* aParent=0); |
|
69 ~CWindow(); |
|
70 |
|
71 RWindow& Window(); |
|
72 void Activate(); |
|
73 CWindowGc& SystemGc(); |
|
74 |
|
75 virtual void Draw(const TRect& aRect) = 0; |
|
76 |
|
77 protected: |
|
78 RWindow iWindow; // window server window |
|
79 TRect iRect; // rectangle re owning window |
|
80 CWsClient* iClient; // client including session and group |
|
81 TRedrawTestCase iTestCase; |
|
82 }; |
|
83 |
|
84 /** |
|
85 Main window used to draw background |
|
86 */ |
|
87 class CMainWindow : public CWindow |
|
88 { |
|
89 public: |
|
90 CMainWindow (CWsClient* aClient, TRedrawTestCase aTestCase); |
|
91 ~CMainWindow (); |
|
92 void ConstructL(const TRect& aRect, CWindow* aParent=0); |
|
93 void Draw (const TRect& aRect); |
|
94 |
|
95 private: |
|
96 CFbsBitmap* iBitmapImage; |
|
97 }; |
|
98 |
|
99 /** |
|
100 Test window for use in test cases |
|
101 */ |
|
102 class CTestWindow : public CWindow |
|
103 { |
|
104 public: |
|
105 CTestWindow(CWsClient* aClient, TRedrawTestCase aTestCase); |
|
106 void ConstructL (const TRect& aRect, CWindow* aParent=0); |
|
107 ~CTestWindow(); |
|
108 void Draw(const TRect& aRect); |
|
109 void AppInitiatedDraw(); |
|
110 |
|
111 private: |
|
112 TBool iBitmapFlag; // Flag to indicate which image to bitblt |
|
113 CFbsBitmap* iBitmap12bit; |
|
114 CFbsBitmap* iAlpha8bitMask; |
|
115 CFbsBitmap* iBitmapImage; |
|
116 CFbsBitmap* i16x16Icon; |
|
117 CFbsBitmap* i16x16IconMonochrome; |
|
118 }; |
|
119 |
|
120 /** |
|
121 The windows server client is an active object to run the redraw test cases |
|
122 */ |
|
123 class CWsClient : public CActive |
|
124 { |
|
125 public: |
|
126 CWsClient(CRedrawingTest& iTestSuite, TRedrawTestCase aTestCase); |
|
127 void ConstructL(); |
|
128 ~CWsClient(); |
|
129 CRedrawingTest& TestSuite() { return iTestSuite; } |
|
130 RWsSession& WsSession() { return iWs; } |
|
131 CWindowGc& Gc() { return *iGc; } |
|
132 RWindowGroup& WindowGroup() { return iGroup; } |
|
133 |
|
134 private: |
|
135 void ConstructMainWindowL(); |
|
136 void IssueRequest(); |
|
137 |
|
138 // From CActive |
|
139 void DoCancel(); |
|
140 void RunL(); |
|
141 |
|
142 // Nested class to handle test case in separate active object |
|
143 class CRedrawingTestActive : public CActive |
|
144 { |
|
145 public: |
|
146 CRedrawingTestActive(CWsClient& aClient); |
|
147 ~CRedrawingTestActive(); |
|
148 |
|
149 void ConstructL(); |
|
150 |
|
151 private: |
|
152 // From CActive |
|
153 void RunL(); |
|
154 void DoCancel(); |
|
155 |
|
156 void RequestComplete(); |
|
157 |
|
158 // Test cases |
|
159 void TestTwoWindowsBitBlt(); |
|
160 void TestInvalidateSmallArea(); |
|
161 |
|
162 private: |
|
163 CWsClient& iClient; |
|
164 TBool iFlipWindow; |
|
165 TInt iIterationCount; |
|
166 }; |
|
167 // End nested class CRedrawingTestActive |
|
168 |
|
169 private: |
|
170 RWsSession iWs; |
|
171 CWindowGc* iGc; |
|
172 RWindowGroup iGroup; |
|
173 CWsScreenDevice* iScreen; |
|
174 TRect iRect; |
|
175 |
|
176 CWsRedrawer* iRedrawer; |
|
177 CRedrawingTestActive* iTestActive; |
|
178 TRedrawTestCase iTestCase; |
|
179 CMainWindow* iMainWindow; |
|
180 CTestWindow* iTestWindow; |
|
181 CTestWindow* iTestWindow2; |
|
182 CRedrawingTest& iTestSuite; |
|
183 }; |
|
184 |
|
185 /** |
|
186 This the the test case derived from CTe_graphicsperformanceSuiteStepBase |
|
187 It will construct the rest of the framework |
|
188 */ |
|
189 class CRedrawingTest : public CTe_graphicsperformanceSuiteStepBase |
|
190 { |
|
191 public: |
|
192 CRedrawingTest(); |
|
193 ~CRedrawingTest(); |
|
194 inline CTProfiler& Profiler() const; |
|
195 private: |
|
196 // From CTestStep |
|
197 virtual TVerdict doTestStepPreambleL(); |
|
198 virtual TVerdict doTestStepL(); |
|
199 |
|
200 void RunRedrawWindowTestCaseL(const TDesC& aTestName, TRedrawTestCase aTestCase); |
|
201 |
|
202 private: |
|
203 CWsClient* iWsClient; |
|
204 }; |
|
205 |
|
206 _LIT(KRedrawingTest,"TRedrawing"); |
|
207 |
|
208 #endif //__GRAPHICSPERFORMANCE_REDRAWING_H__ |