|
1 // Copyright (c) 2000-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 // Screen mode changing tests |
|
15 // |
|
16 // |
|
17 |
|
18 #include <e32std.h> |
|
19 #include <e32def_private.h> |
|
20 #include "W32STD.H" |
|
21 #include "../tlib/testbase.h" |
|
22 #include "TMAN.H" |
|
23 |
|
24 class CTimeWindow; |
|
25 |
|
26 class CQBlankWindow : public CBlankWindow |
|
27 { |
|
28 public: |
|
29 static TInt iInitialColor; |
|
30 public: |
|
31 //Virtual function from CTBaseWin |
|
32 void InitWin(); |
|
33 public: |
|
34 static TSize iSize; |
|
35 TSglQueLink iLink; |
|
36 }; |
|
37 |
|
38 class CFixScreenModeGroup : public CTWindowGroup |
|
39 { |
|
40 public: |
|
41 static TInt iNoClientWins; |
|
42 public: |
|
43 ~CFixScreenModeGroup(); |
|
44 CFixScreenModeGroup(CTClient *aClient); |
|
45 void ConstructL(); |
|
46 public: |
|
47 TSglQueLink iLink; |
|
48 private: |
|
49 TSglQue<CQBlankWindow> iWindows; |
|
50 }; |
|
51 |
|
52 class CFlipClient : public CTClient |
|
53 { |
|
54 public: |
|
55 void ConstructL(); |
|
56 private: |
|
57 }; |
|
58 |
|
59 class CScreenModeTimes : public CTestBase |
|
60 { |
|
61 public: |
|
62 CScreenModeTimes(); |
|
63 ~CScreenModeTimes(); |
|
64 TestState DoTestL(); |
|
65 void ConstructL(); |
|
66 void DoTimings(); |
|
67 private: |
|
68 void CreateGroupL(CTClient* aClient,TSglQue<CFixScreenModeGroup>& aQue); |
|
69 void DeleteGroups(TSglQue<CFixScreenModeGroup>& aQue); |
|
70 void BringToFront(TSglQue<CFixScreenModeGroup>& aQue); |
|
71 private: |
|
72 TScreenModeEnforcement iEnforcementMode; |
|
73 CInfoDialog* iDialogue; |
|
74 CTimeWindow* iInfoWindow; |
|
75 CFlipClient* iFlipClient; |
|
76 TSglQue<CFixScreenModeGroup> iNormalGroupQue; |
|
77 TSglQue<CFixScreenModeGroup> iFlipGroupQue; |
|
78 TInt iNoGroupWins; |
|
79 TInt iState; |
|
80 }; |
|
81 |
|
82 class CTimeWindow : public CTTitledWindow |
|
83 { |
|
84 public: |
|
85 void Construct(CTestBase* aTest); |
|
86 void SetNumWindows(TInt aGroup,TInt aWin); |
|
87 void SetTime1(TTimeIntervalMicroSeconds& aTime); |
|
88 void SetTime2(TTimeIntervalMicroSeconds& aTime); |
|
89 void DoDraw(); |
|
90 //virtual function from CTWinBase overridden by CTBaseWin |
|
91 void WinKeyL(const TKeyEvent &aKey,const TTime &aTime); |
|
92 //virtual functions from CTBaseWin |
|
93 void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc); |
|
94 void PointerL(const TPointerEvent &aPointer,const TTime &aTime); |
|
95 //virtual function from CTBaseWin overridden by CTTitledWindow |
|
96 void Draw(); |
|
97 private: |
|
98 inline CScreenModeTimes* Test() {return STATIC_CAST(CScreenModeTimes*,iTest);} |
|
99 void UpdateString1(); |
|
100 void UpdateString2(); |
|
101 void UpdateString3(); |
|
102 private: |
|
103 CTestBase* iTest; |
|
104 TInt iNumGroups; |
|
105 TInt iNumWins; |
|
106 TTimeIntervalMicroSeconds iTime1; |
|
107 TTimeIntervalMicroSeconds iTime2; |
|
108 TBuf<32> iString1; |
|
109 TBuf<32> iString2; |
|
110 TBuf<32> iString3; |
|
111 TBuf<32> iString4; |
|
112 TRect iRect1; |
|
113 TRect iRect2; |
|
114 TRect iRect3; |
|
115 TRect iRect4; |
|
116 TBool iPressed; |
|
117 TBool iExit; |
|
118 }; |
|
119 |
|
120 |
|
121 TSize CQBlankWindow::iSize; |
|
122 TInt CQBlankWindow::iInitialColor; |
|
123 TInt CFixScreenModeGroup::iNoClientWins=0; |
|
124 |
|
125 |
|
126 GLDEF_C CTestBase *CreateScreenModeTimes() |
|
127 { |
|
128 return(new(ELeave) CScreenModeTimes()); |
|
129 } |
|
130 |
|
131 |
|
132 // |
|
133 // CFlipClient |
|
134 // |
|
135 |
|
136 void CFlipClient::ConstructL() |
|
137 { |
|
138 CTClient::ConstructL(); |
|
139 TPixelsAndRotation sizeAndRotation; |
|
140 iScreen->GetScreenModeSizeAndRotation(1,sizeAndRotation); |
|
141 iScreen->SetScreenSizeAndRotation(sizeAndRotation); |
|
142 } |
|
143 |
|
144 |
|
145 // |
|
146 // CTimeWindow |
|
147 // |
|
148 |
|
149 void CTimeWindow::Construct(CTestBase* aTest) |
|
150 { |
|
151 _LIT(Title,"StatusWindow"); |
|
152 _LIT(String4,"Click here to finish"); |
|
153 const TInt fontHeight=iFont->HeightInPixels(); |
|
154 iTest=aTest; |
|
155 TWindowTitle title(Title); |
|
156 SetTitle(title); |
|
157 TInt yy=iTitleHeight+fontHeight+7; |
|
158 iRect1.SetRect(3,iTitleHeight+5,iSize.iWidth-1,yy); |
|
159 yy+=fontHeight/2; |
|
160 TInt yy1=yy+fontHeight+2; |
|
161 iRect2.SetRect(3,yy+3,iSize.iWidth-1,yy1); |
|
162 TInt yy2=yy1+iFont->HeightInPixels()+2; |
|
163 iRect3.SetRect(3,yy1+3,iSize.iWidth-1,yy2); |
|
164 yy2+=fontHeight/2; |
|
165 iRect4.SetRect(3,yy2+3,iSize.iWidth-1,yy2+iFont->HeightInPixels()+2); |
|
166 // |
|
167 iString4.Copy(String4); |
|
168 iExit=EFalse; |
|
169 } |
|
170 |
|
171 void CTimeWindow::SetUpL(TPoint aPos,TSize aSize,CTWinBase *aParent,CWindowGc &aGc) |
|
172 { |
|
173 CTTitledWindow::SetUpL(aPos,aSize,aParent,aGc); |
|
174 } |
|
175 |
|
176 void CTimeWindow::WinKeyL(const TKeyEvent &aKey,const TTime&) |
|
177 { |
|
178 switch(aKey.iCode) |
|
179 { |
|
180 case EKeyEscape: |
|
181 iTest->Request(); |
|
182 break; |
|
183 default:; |
|
184 } |
|
185 } |
|
186 |
|
187 void CTimeWindow::PointerL(const TPointerEvent &aPointer,const TTime &aTime) |
|
188 { |
|
189 if (iRect2.Contains(aPointer.iPosition) || iRect3.Contains(aPointer.iPosition)) |
|
190 { |
|
191 if (aPointer.iType==TPointerEvent::EButton1Down) |
|
192 iPressed=ETrue; |
|
193 } |
|
194 else if (iRect4.Contains(aPointer.iPosition)) |
|
195 iExit=ETrue; |
|
196 else |
|
197 CTTitledWindow::PointerL(aPointer,aTime); |
|
198 if ((iExit||iPressed) && aPointer.iType==TPointerEvent::EButton1Up) |
|
199 { |
|
200 if (iExit) |
|
201 iTest->Request(); |
|
202 else |
|
203 { |
|
204 Test()->DoTimings(); |
|
205 DoDraw(); |
|
206 } |
|
207 } |
|
208 } |
|
209 |
|
210 void CTimeWindow::Draw() |
|
211 { |
|
212 CTTitledWindow::Draw(); |
|
213 TInt ascent=iFont->AscentInPixels()+1; |
|
214 iGc->DrawText(iString1,iRect1,ascent,CGraphicsContext::ELeft); |
|
215 iGc->DrawText(iString2,iRect2,ascent,CGraphicsContext::ELeft); |
|
216 iGc->DrawText(iString3,iRect3,ascent,CGraphicsContext::ELeft); |
|
217 iGc->DrawText(iString4,iRect4,ascent,CGraphicsContext::ELeft); |
|
218 } |
|
219 |
|
220 void CTimeWindow::DoDraw() |
|
221 { |
|
222 iGc->Activate(iWin); |
|
223 iGc->UseFont((CFont *)iFont); |
|
224 Draw(); |
|
225 iGc->Deactivate(); |
|
226 } |
|
227 |
|
228 void CTimeWindow::SetNumWindows(TInt aGroups,TInt aWins) |
|
229 { |
|
230 iNumGroups=aGroups; |
|
231 iNumWins=aWins; |
|
232 UpdateString1(); |
|
233 } |
|
234 |
|
235 void CTimeWindow::UpdateString1() |
|
236 { |
|
237 _LIT(NumberWin,"Groups (2x)%d, Windows %d"); |
|
238 iString1.Format(NumberWin,iNumGroups,iNumWins); |
|
239 } |
|
240 |
|
241 void CTimeWindow::SetTime1(TTimeIntervalMicroSeconds& aTime) |
|
242 { |
|
243 iTime1=aTime; |
|
244 UpdateString2(); |
|
245 } |
|
246 |
|
247 void CTimeWindow::SetTime2(TTimeIntervalMicroSeconds& aTime) |
|
248 { |
|
249 iTime2=aTime; |
|
250 UpdateString3(); |
|
251 } |
|
252 |
|
253 _LIT(TimeFormat,"Time%d = %d.%04dsecs"); |
|
254 |
|
255 void CTimeWindow::UpdateString2() |
|
256 { |
|
257 TInt time = I64LOW(iTime1.Int64()); |
|
258 iString2.Format(TimeFormat,1,time/1000000,(time%1000000)/100); |
|
259 } |
|
260 |
|
261 void CTimeWindow::UpdateString3() |
|
262 { |
|
263 TInt time = I64LOW(iTime2.Int64()); |
|
264 iString3.Format(TimeFormat,2,time/1000000,(time%1000000)/100); |
|
265 } |
|
266 |
|
267 |
|
268 // |
|
269 // CQBlankWindow |
|
270 // |
|
271 |
|
272 void CQBlankWindow::InitWin() |
|
273 { |
|
274 SetColor(TRgb::Gray4(iInitialColor)); |
|
275 iWin.SetSize(iSize); |
|
276 } |
|
277 |
|
278 |
|
279 // |
|
280 // CFixScreenModeGroup |
|
281 // |
|
282 |
|
283 CFixScreenModeGroup::~CFixScreenModeGroup() |
|
284 { |
|
285 GroupWin()->EnableReceiptOfFocus(EFalse); |
|
286 ClearCurrentWindow(); |
|
287 CQBlankWindow* win; |
|
288 while (!iWindows.IsEmpty()) |
|
289 { |
|
290 win=iWindows.First(); |
|
291 iWindows.Remove(*win); |
|
292 delete win; |
|
293 } |
|
294 } |
|
295 |
|
296 CFixScreenModeGroup::CFixScreenModeGroup(CTClient *aClient) : CTWindowGroup(aClient), iWindows(_FOFF(CQBlankWindow,iLink)) |
|
297 {} |
|
298 |
|
299 void CFixScreenModeGroup::ConstructL() |
|
300 { |
|
301 CTWindowGroup::ConstructL(); |
|
302 CQBlankWindow* win; |
|
303 TInt ii; |
|
304 for(ii=0;ii<iNoClientWins;++ii) |
|
305 { |
|
306 win=new(ELeave) CQBlankWindow(); |
|
307 CleanupStack::PushL(win); |
|
308 win->ConstructL(*this); |
|
309 win->Activate(); |
|
310 win->AssignGC(*iClient->iGc); |
|
311 iWindows.AddLast(*win); |
|
312 CleanupStack::Pop(win); |
|
313 Client()->Flush(); |
|
314 } |
|
315 SetCurrentWindow(iWindows.First()); |
|
316 } |
|
317 |
|
318 /*void CFixScreenModeGroup::ScreenDeviceChanged() |
|
319 { |
|
320 iWindow->ScreenDeviceChanged(); |
|
321 }*/ |
|
322 |
|
323 |
|
324 // |
|
325 // CScreenModeTimes |
|
326 // |
|
327 |
|
328 _LIT(TestName,"Screen Mode Times"); |
|
329 CScreenModeTimes::CScreenModeTimes() : CTestBase(TestName) |
|
330 ,iNormalGroupQue(_FOFF(CFixScreenModeGroup,iLink)),iFlipGroupQue(_FOFF(CFixScreenModeGroup,iLink)) |
|
331 {} |
|
332 |
|
333 CScreenModeTimes::~CScreenModeTimes() |
|
334 { |
|
335 Client()->iGroup->GroupWin()->EnableScreenChangeEvents(); |
|
336 Client()->iScreen->SetScreenMode(0); |
|
337 DeleteGroups(iNormalGroupQue); |
|
338 DeleteGroups(iFlipGroupQue); |
|
339 Client()->iGroup->SetCurrentWindow(NULL); |
|
340 delete iFlipClient; |
|
341 delete iInfoWindow; |
|
342 if (iEnforcementMode==ESizeEnforcementNone) |
|
343 Client()->iScreen->SetScreenModeEnforcement(ESizeEnforcementNone); |
|
344 } |
|
345 |
|
346 void CScreenModeTimes::ConstructL() |
|
347 { |
|
348 iEnforcementMode=Client()->iScreen->ScreenModeEnforcement(); |
|
349 if (iEnforcementMode==ESizeEnforcementNone) |
|
350 Client()->iScreen->SetScreenModeEnforcement(ESizeEnforcementPixelsAndRotation); |
|
351 iDialogue=new(ELeave) CInfoDialog(Client()->iGroup,Client()->iGc); |
|
352 iDialogue->ConstructLD(); |
|
353 iFlipClient=new(ELeave) CFlipClient(); |
|
354 iFlipClient->ConstructL(); |
|
355 Client()->iGroup->GroupWin()->DisableScreenChangeEvents(); |
|
356 iNoGroupWins=12; //20; |
|
357 CFixScreenModeGroup::iNoClientWins=20; //30; |
|
358 TSize screenSize=Client()->iScreen->SizeInPixels(); |
|
359 CQBlankWindow::iSize.iWidth=Max(screenSize.iHeight,screenSize.iWidth); |
|
360 CQBlankWindow::iSize.iHeight=CQBlankWindow::iSize.iWidth; |
|
361 TInt ii; |
|
362 for(ii=0;ii<iNoGroupWins;++ii) |
|
363 { |
|
364 CQBlankWindow::iInitialColor=1; |
|
365 CreateGroupL(Client(),iNormalGroupQue); |
|
366 CQBlankWindow::iInitialColor=2; |
|
367 CreateGroupL(iFlipClient,iFlipGroupQue); |
|
368 } |
|
369 Client()->iGroup->GroupWin()->SetOrdinalPosition(0); |
|
370 iInfoWindow=new(ELeave) CTimeWindow(); |
|
371 iInfoWindow->SetUpL(TPoint(Max(Min(415,screenSize.iWidth-210),0),Min(50,screenSize.iHeight-180)),TSize(210,180),Client()->iGroup,*Client()->iGc); |
|
372 Client()->iGroup->SetCurrentWindow(iInfoWindow); |
|
373 iInfoWindow->Construct(this); |
|
374 iInfoWindow->WinTreeNode()->SetOrdinalPosition(1); |
|
375 iInfoWindow->SetNumWindows(iNoGroupWins,CFixScreenModeGroup::iNoClientWins); |
|
376 |
|
377 Client()->iGroup->GroupWin()->DisableScreenChangeEvents(); |
|
378 Client()->iWs.SetAutoFlush(ETrue); |
|
379 iFlipClient->iWs.SetAutoFlush(ETrue); |
|
380 Client()->iWs.SetPointerCursorMode(EPointerCursorNone); |
|
381 } |
|
382 |
|
383 void CScreenModeTimes::CreateGroupL(CTClient *aClient,TSglQue<CFixScreenModeGroup>& aQue) |
|
384 { |
|
385 CFixScreenModeGroup* group; |
|
386 group=new(ELeave) CFixScreenModeGroup(aClient); |
|
387 CleanupStack::PushL(group); |
|
388 group->ConstructL(); |
|
389 aQue.AddLast(*group); |
|
390 CleanupStack::Pop(group); |
|
391 } |
|
392 |
|
393 void CScreenModeTimes::DeleteGroups(TSglQue<CFixScreenModeGroup>& aQue) |
|
394 { |
|
395 CFixScreenModeGroup* group; |
|
396 while (!aQue.IsEmpty()) |
|
397 { |
|
398 group=aQue.First(); |
|
399 aQue.Remove(*group); |
|
400 delete group; |
|
401 } |
|
402 } |
|
403 |
|
404 void CScreenModeTimes::BringToFront(TSglQue<CFixScreenModeGroup>& aQue) |
|
405 { |
|
406 TSglQueIter<CFixScreenModeGroup> iter(aQue); |
|
407 CFixScreenModeGroup* group=iter++; |
|
408 group->GroupWin()->SetOrdinalPosition(0); |
|
409 while ((group=iter++)!=NULL) |
|
410 group->GroupWin()->SetOrdinalPosition(1); |
|
411 } |
|
412 |
|
413 void CScreenModeTimes::DoTimings() |
|
414 { |
|
415 //Timings 1 SCRDEV, DWsScreenDevice::CommandL, around call to SetScreenMode |
|
416 //Timings 2 GROUPWIN, CWsWindowGroup::SetScreenDeviceValidStates, around main body of function including calls to old way |
|
417 //Timings 3 CLIWIN, CWsTopClientWindow::SetScreenDeviceValidState, around call to ResetHiddenFlagAndAdjustRegions |
|
418 //Timings 3 GROUPWIN, CWsWindowGroup::SetScreenDeviceValidStates, around main body of function excluding calls to old way |
|
419 //Timings 4&5 CLIWIN, CWsClientWindow::ResetHiddenFlagAndAdjustRegions, going invisible and becomming visible sections |
|
420 Client()->iGroup->GroupWin()->SetOrdinalPosition(-2); |
|
421 Client()->Flush(); |
|
422 TTime startTime; |
|
423 TTime middleTime; |
|
424 TTime endTime; |
|
425 __PROFILE_START(0); |
|
426 startTime.HomeTime(); |
|
427 BringToFront(iNormalGroupQue); |
|
428 Client()->iScreen->SetScreenMode(1); |
|
429 middleTime.HomeTime(); |
|
430 BringToFront(iFlipGroupQue); |
|
431 Client()->iScreen->SetScreenMode(0); |
|
432 endTime.HomeTime(); |
|
433 __PROFILE_END(0); |
|
434 #if defined(__PROFILING__) |
|
435 TProfile profile; |
|
436 RDebug::ProfileResult(&profile,3,1); |
|
437 if (profile.iCount>0) |
|
438 iDialogue->TimerResults(0); |
|
439 #endif |
|
440 TTimeIntervalMicroSeconds time=middleTime.MicroSecondsFrom(startTime); |
|
441 iInfoWindow->SetTime1(time); |
|
442 time=endTime.MicroSecondsFrom(middleTime); |
|
443 iInfoWindow->SetTime2(time); |
|
444 Client()->iGroup->GroupWin()->SetOrdinalPosition(0); |
|
445 #if defined(__PROFILING__) |
|
446 if (profile.iCount>0) |
|
447 iDialogue->Display(); |
|
448 #endif |
|
449 } |
|
450 |
|
451 TestState CScreenModeTimes::DoTestL() |
|
452 { |
|
453 switch(iState) |
|
454 { |
|
455 case 0: |
|
456 LogSubTest(_L("Time ScreenMode Changes"),1); |
|
457 DoTimings(); |
|
458 iState++; |
|
459 return EContinue; |
|
460 default: |
|
461 return EFinished; |
|
462 } |
|
463 } |