|
1 // Copyright (c) 1995-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 // Functions to act as bench marks for various window server features |
|
15 // |
|
16 // |
|
17 |
|
18 #include "TTIME.H" |
|
19 |
|
20 void SetUp(RWindowTreeNode &aParent, RBlankWindow &aBlank, const TPoint &aPos, const TSize &aSize, TInt aColor) |
|
21 { |
|
22 aBlank.Construct(aParent,ENullWsHandle); |
|
23 aBlank.SetColor(TRgb::Gray256(aColor)); |
|
24 aBlank.SetExtent(aPos, aSize); |
|
25 aBlank.SetShadowHeight(1); |
|
26 aBlank.Activate(); |
|
27 } |
|
28 |
|
29 void doMovingWindowTest(TInt aMode, TInt aOwningGroup) |
|
30 { |
|
31 RWsSession ws; |
|
32 ws.Connect(); |
|
33 CWsScreenDevice *device=new(ELeave) CWsScreenDevice(ws); |
|
34 device->Construct(); |
|
35 TPoint pos(10,10); |
|
36 TSize size(100,100); |
|
37 TSize scrSize(device->SizeInPixels()); |
|
38 RBlankWindow blank(ws); |
|
39 RWindowGroup group(ws); |
|
40 group.Construct(ENullWsHandle); |
|
41 group.SetOwningWindowGroup(aOwningGroup); |
|
42 // |
|
43 RBlankWindow back(ws); |
|
44 SetUp(group, back, TPoint(0,0),TSize(640,240), 255); |
|
45 // |
|
46 RBlankWindow blank2(ws); |
|
47 RBlankWindow blank3(ws); |
|
48 RBlankWindow blank4(ws); |
|
49 RBlankWindow blank5(ws); |
|
50 if (aMode==1) |
|
51 { |
|
52 SetUp(group, blank2, TPoint(10,10),TSize(240,150), 128); |
|
53 SetUp(blank2, blank3, TPoint(10,10),TSize(220,130), 255); |
|
54 SetUp(group, blank4, TPoint(340,-10),TSize(200,70), 64); |
|
55 SetUp(group, blank5, TPoint(390,-10),TSize(30,250), 128); |
|
56 } |
|
57 // |
|
58 SetUp(group, blank,pos,size, 128); |
|
59 // |
|
60 for(pos.iX=10;pos.iX<(scrSize.iWidth-10-size.iWidth);pos.iX+=1) |
|
61 { |
|
62 blank.SetPosition(pos); |
|
63 // ws.Flush(); |
|
64 } |
|
65 // |
|
66 if (aMode==1) |
|
67 { |
|
68 blank2.Close(); |
|
69 blank3.Close(); |
|
70 blank4.Close(); |
|
71 blank5.Close(); |
|
72 } |
|
73 blank.Close(); |
|
74 back.Close(); |
|
75 group.Close(); |
|
76 delete device; |
|
77 ws.Close(); |
|
78 } |
|
79 |
|
80 TInt MovingWindowTest1Func(TInt aOwningGroup) |
|
81 { |
|
82 doMovingWindowTest(0,aOwningGroup); |
|
83 return(KErrNone); |
|
84 } |
|
85 |
|
86 GLDEF_D TTimeTestHeader MovingWindowTest1={_S("Moving window test 1"),MovingWindowTest1Func}; |
|
87 |
|
88 TInt MovingWindowTest2Func(TInt aOwningGroup) |
|
89 { |
|
90 doMovingWindowTest(1,aOwningGroup); |
|
91 return(KErrNone); |
|
92 } |
|
93 |
|
94 GLDEF_D TTimeTestHeader MovingWindowTest2={_S("Moving window test 2"),MovingWindowTest2Func}; |
|
95 |
|
96 TInt CreateAndDestroy(TInt aOwningGroup) |
|
97 { |
|
98 RWsSession ws; |
|
99 ws.Connect(); |
|
100 CWsScreenDevice *device=new(ELeave) CWsScreenDevice(ws); |
|
101 device->Construct(); |
|
102 RWindowGroup group(ws); |
|
103 group.Construct(ENullWsHandle); |
|
104 group.SetOwningWindowGroup(aOwningGroup); |
|
105 // |
|
106 for (TInt count=0;count<100;count++) |
|
107 { |
|
108 RBlankWindow blank(ws); |
|
109 blank.Construct(group,ENullWsHandle); |
|
110 blank.SetExtent(TPoint(10,10), TSize(20,20)); |
|
111 blank.Activate(); |
|
112 blank.Close(); |
|
113 } |
|
114 group.Close(); |
|
115 delete device; |
|
116 ws.Close(); |
|
117 return(KErrNone); |
|
118 } |
|
119 |
|
120 GLDEF_D TTimeTestHeader WindowCreateDestroy={_S("Window create destroy"),CreateAndDestroy}; |
|
121 |
|
122 // |
|
123 |
|
124 TInt WindowCreate2(TInt aOwningGroup) |
|
125 { |
|
126 enum {KNumWindows=20}; |
|
127 RWsSession ws; |
|
128 ws.Connect(); |
|
129 CWsScreenDevice *device=new(ELeave) CWsScreenDevice(ws); |
|
130 device->Construct(); |
|
131 RWindowGroup group(ws); |
|
132 group.Construct(ENullWsHandle); |
|
133 group.SetOwningWindowGroup(aOwningGroup); |
|
134 RBlankWindow shield(ws); |
|
135 shield.Construct(group,ENullWsHandle); |
|
136 shield.Activate(); |
|
137 CWindowGc *gc=new(ELeave) CWindowGc(device); |
|
138 User::LeaveIfError(gc->Construct()); |
|
139 // |
|
140 for(TInt times=0;times<2;times++) |
|
141 { |
|
142 #if 1 |
|
143 TSize size(200,100); |
|
144 RBlankWindow win[KNumWindows]; |
|
145 TInt count; |
|
146 for (count=0;count<KNumWindows;count++) |
|
147 { |
|
148 win[count]=RBlankWindow(ws); |
|
149 win[count].Construct(group,ENullWsHandle); |
|
150 win[count].SetExtent(TPoint(count<<2,count<<3), size); |
|
151 win[count].SetShadowHeight(1); |
|
152 win[count].SetColor(TRgb::Gray4(count&3)); |
|
153 win[count].Activate(); |
|
154 } |
|
155 #else |
|
156 TSize size(400,200); |
|
157 RBackedUpWindow win[KNumWindows]; |
|
158 TInt count; |
|
159 for (count=0;count<KNumWindows;count++) |
|
160 { |
|
161 win[count]=RBackedUpWindow(ws); |
|
162 win[count].Construct(group,EGray2,ENullWsHandle); |
|
163 win[count].SetExtent(TPoint(count<<2,count<<3), size); |
|
164 win[count].SetShadowHeight(1); |
|
165 gc->Activate(win[count]); |
|
166 gc->SetBrushColor(TRgb::Gray4(count&3)); |
|
167 gc->Clear(); |
|
168 gc->Deactivate(); |
|
169 win[count].Activate(); |
|
170 } |
|
171 #endif |
|
172 ws.Flush(); |
|
173 for (count=0;count<KNumWindows;count++) |
|
174 { |
|
175 win[count].SetOrdinalPosition(0); |
|
176 ws.Flush(); |
|
177 } |
|
178 for (count=0;count<KNumWindows;count++) |
|
179 { |
|
180 win[count].Close(); |
|
181 ws.Flush(); |
|
182 } |
|
183 } |
|
184 shield.Close(); |
|
185 group.Close(); |
|
186 delete device; |
|
187 ws.Close(); |
|
188 return(KErrNone); |
|
189 } |
|
190 |
|
191 GLDEF_D TTimeTestHeader StackedWindowCreate={_S("Stacked window creating"),WindowCreate2}; |
|
192 |
|
193 TInt BackedUpWindowCreateTest(TInt aOwningGroup) |
|
194 { |
|
195 RWsSession ws; |
|
196 ws.Connect(); |
|
197 CWsScreenDevice *device=new(ELeave) CWsScreenDevice(ws); |
|
198 device->Construct(); |
|
199 RWindowGroup group(ws); |
|
200 group.Construct(ENullWsHandle); |
|
201 group.SetOwningWindowGroup(aOwningGroup); |
|
202 RBlankWindow shield(ws); |
|
203 shield.Construct(group,ENullWsHandle); |
|
204 shield.Activate(); |
|
205 CWindowGc *gc=new(ELeave) CWindowGc(device); |
|
206 User::LeaveIfError(gc->Construct()); |
|
207 // |
|
208 RWindow win; |
|
209 TInt count; |
|
210 for (count=0;count<100;count++) |
|
211 { |
|
212 win=RWindow(ws); |
|
213 win.Construct(group,ENullWsHandle); |
|
214 win.EnableBackup(); |
|
215 win.SetExtent(TPoint(10,10), TSize(200,100)); |
|
216 win.Activate(); |
|
217 ws.Flush(); |
|
218 win.Close(); |
|
219 } |
|
220 shield.Close(); |
|
221 group.Close(); |
|
222 delete device; |
|
223 ws.Close(); |
|
224 return(KErrNone); |
|
225 } |
|
226 |
|
227 GLDEF_D TTimeTestHeader BackedUpWindowCreate={_S("Backed up window creating"),BackedUpWindowCreateTest}; |
|
228 |
|
229 TInt BackedUpWindowMenuTest(TInt aOwningGroup) |
|
230 // |
|
231 // Test designed to emulate menus |
|
232 // |
|
233 { |
|
234 RWsSession ws; |
|
235 ws.Connect(); |
|
236 CWsScreenDevice *device=new(ELeave) CWsScreenDevice(ws); |
|
237 device->Construct(); |
|
238 RWindowGroup group(ws); |
|
239 group.Construct(ENullWsHandle); |
|
240 group.SetOwningWindowGroup(aOwningGroup); |
|
241 RBlankWindow shield(ws); |
|
242 shield.Construct(group,ENullWsHandle); |
|
243 shield.Activate(); |
|
244 CWindowGc *gc=new(ELeave) CWindowGc(device); |
|
245 User::LeaveIfError(gc->Construct()); |
|
246 // |
|
247 RWindow win; |
|
248 win=RWindow(ws); |
|
249 win.Construct(group,ENullWsHandle); |
|
250 win.EnableBackup(); |
|
251 win.Activate(); |
|
252 TInt count; |
|
253 TInt state=0; |
|
254 for (count=0;count<200;count++) |
|
255 { |
|
256 win.SetVisible(EFalse); |
|
257 if (state==0) |
|
258 { |
|
259 state=1; |
|
260 win.SetExtent(TPoint(10,10), TSize(200,160)); |
|
261 } |
|
262 else |
|
263 { |
|
264 state=0; |
|
265 win.SetExtent(TPoint(100,10), TSize(150,200)); |
|
266 } |
|
267 win.SetVisible(ETrue); |
|
268 win.BeginRedraw(); |
|
269 gc->Activate(win); |
|
270 gc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
271 gc->SetBrushColor(TRgb::Gray4((state+1))); |
|
272 gc->Clear(); |
|
273 gc->Deactivate(); |
|
274 win.EndRedraw(); |
|
275 ws.Flush(); |
|
276 } |
|
277 win.Close(); |
|
278 shield.Close(); |
|
279 group.Close(); |
|
280 delete device; |
|
281 ws.Close(); |
|
282 return(KErrNone); |
|
283 } |
|
284 |
|
285 GLDEF_D TTimeTestHeader MenuEmulationCreate={_S("Menu emulation"),BackedUpWindowMenuTest}; |
|
286 |
|
287 TInt BackedUpWindowMenuTest2(TInt aOwningGroup) |
|
288 { |
|
289 CFbsBitmap *bitmaps[1000]; |
|
290 TInt index; |
|
291 for(index=0;index<1000;index++) |
|
292 { |
|
293 bitmaps[index]=new(ELeave) CFbsBitmap(); |
|
294 bitmaps[index]->Create(TSize(10,10),EGray4); |
|
295 } |
|
296 BackedUpWindowMenuTest(aOwningGroup); |
|
297 for(index=0;index<1000;index++) |
|
298 delete bitmaps[index]; |
|
299 return(KErrNone); |
|
300 } |
|
301 |
|
302 GLDEF_D TTimeTestHeader MenuEmulationCreate2={_S("Menu emulation 2"),BackedUpWindowMenuTest2}; |