1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/windowing/windowserver/test/tman/TMTScrMd.CPP Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,463 @@
1.4 +// Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Screen mode changing tests
1.18 +//
1.19 +//
1.20 +
1.21 +#include <e32std.h>
1.22 +#include <e32def_private.h>
1.23 +#include "W32STD.H"
1.24 +#include "../tlib/testbase.h"
1.25 +#include "TMAN.H"
1.26 +
1.27 +class CTimeWindow;
1.28 +
1.29 +class CQBlankWindow : public CBlankWindow
1.30 + {
1.31 +public:
1.32 + static TInt iInitialColor;
1.33 +public:
1.34 + //Virtual function from CTBaseWin
1.35 + void InitWin();
1.36 +public:
1.37 + static TSize iSize;
1.38 + TSglQueLink iLink;
1.39 + };
1.40 +
1.41 +class CFixScreenModeGroup : public CTWindowGroup
1.42 + {
1.43 +public:
1.44 + static TInt iNoClientWins;
1.45 +public:
1.46 + ~CFixScreenModeGroup();
1.47 + CFixScreenModeGroup(CTClient *aClient);
1.48 + void ConstructL();
1.49 +public:
1.50 + TSglQueLink iLink;
1.51 +private:
1.52 + TSglQue<CQBlankWindow> iWindows;
1.53 + };
1.54 +
1.55 +class CFlipClient : public CTClient
1.56 + {
1.57 +public:
1.58 + void ConstructL();
1.59 +private:
1.60 + };
1.61 +
1.62 +class CScreenModeTimes : public CTestBase
1.63 + {
1.64 +public:
1.65 + CScreenModeTimes();
1.66 + ~CScreenModeTimes();
1.67 + TestState DoTestL();
1.68 + void ConstructL();
1.69 + void DoTimings();
1.70 +private:
1.71 + void CreateGroupL(CTClient* aClient,TSglQue<CFixScreenModeGroup>& aQue);
1.72 + void DeleteGroups(TSglQue<CFixScreenModeGroup>& aQue);
1.73 + void BringToFront(TSglQue<CFixScreenModeGroup>& aQue);
1.74 +private:
1.75 + TScreenModeEnforcement iEnforcementMode;
1.76 + CInfoDialog* iDialogue;
1.77 + CTimeWindow* iInfoWindow;
1.78 + CFlipClient* iFlipClient;
1.79 + TSglQue<CFixScreenModeGroup> iNormalGroupQue;
1.80 + TSglQue<CFixScreenModeGroup> iFlipGroupQue;
1.81 + TInt iNoGroupWins;
1.82 + TInt iState;
1.83 + };
1.84 +
1.85 +class CTimeWindow : public CTTitledWindow
1.86 + {
1.87 +public:
1.88 + void Construct(CTestBase* aTest);
1.89 + void SetNumWindows(TInt aGroup,TInt aWin);
1.90 + void SetTime1(TTimeIntervalMicroSeconds& aTime);
1.91 + void SetTime2(TTimeIntervalMicroSeconds& aTime);
1.92 + void DoDraw();
1.93 + //virtual function from CTWinBase overridden by CTBaseWin
1.94 + void WinKeyL(const TKeyEvent &aKey,const TTime &aTime);
1.95 + //virtual functions from CTBaseWin
1.96 + void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc);
1.97 + void PointerL(const TPointerEvent &aPointer,const TTime &aTime);
1.98 + //virtual function from CTBaseWin overridden by CTTitledWindow
1.99 + void Draw();
1.100 +private:
1.101 + inline CScreenModeTimes* Test() {return STATIC_CAST(CScreenModeTimes*,iTest);}
1.102 + void UpdateString1();
1.103 + void UpdateString2();
1.104 + void UpdateString3();
1.105 +private:
1.106 + CTestBase* iTest;
1.107 + TInt iNumGroups;
1.108 + TInt iNumWins;
1.109 + TTimeIntervalMicroSeconds iTime1;
1.110 + TTimeIntervalMicroSeconds iTime2;
1.111 + TBuf<32> iString1;
1.112 + TBuf<32> iString2;
1.113 + TBuf<32> iString3;
1.114 + TBuf<32> iString4;
1.115 + TRect iRect1;
1.116 + TRect iRect2;
1.117 + TRect iRect3;
1.118 + TRect iRect4;
1.119 + TBool iPressed;
1.120 + TBool iExit;
1.121 + };
1.122 +
1.123 +
1.124 +TSize CQBlankWindow::iSize;
1.125 +TInt CQBlankWindow::iInitialColor;
1.126 +TInt CFixScreenModeGroup::iNoClientWins=0;
1.127 +
1.128 +
1.129 +GLDEF_C CTestBase *CreateScreenModeTimes()
1.130 + {
1.131 + return(new(ELeave) CScreenModeTimes());
1.132 + }
1.133 +
1.134 +
1.135 +//
1.136 +// CFlipClient
1.137 +//
1.138 +
1.139 +void CFlipClient::ConstructL()
1.140 + {
1.141 + CTClient::ConstructL();
1.142 + TPixelsAndRotation sizeAndRotation;
1.143 + iScreen->GetScreenModeSizeAndRotation(1,sizeAndRotation);
1.144 + iScreen->SetScreenSizeAndRotation(sizeAndRotation);
1.145 + }
1.146 +
1.147 +
1.148 +//
1.149 +// CTimeWindow
1.150 +//
1.151 +
1.152 +void CTimeWindow::Construct(CTestBase* aTest)
1.153 + {
1.154 + _LIT(Title,"StatusWindow");
1.155 + _LIT(String4,"Click here to finish");
1.156 + const TInt fontHeight=iFont->HeightInPixels();
1.157 + iTest=aTest;
1.158 + TWindowTitle title(Title);
1.159 + SetTitle(title);
1.160 + TInt yy=iTitleHeight+fontHeight+7;
1.161 + iRect1.SetRect(3,iTitleHeight+5,iSize.iWidth-1,yy);
1.162 + yy+=fontHeight/2;
1.163 + TInt yy1=yy+fontHeight+2;
1.164 + iRect2.SetRect(3,yy+3,iSize.iWidth-1,yy1);
1.165 + TInt yy2=yy1+iFont->HeightInPixels()+2;
1.166 + iRect3.SetRect(3,yy1+3,iSize.iWidth-1,yy2);
1.167 + yy2+=fontHeight/2;
1.168 + iRect4.SetRect(3,yy2+3,iSize.iWidth-1,yy2+iFont->HeightInPixels()+2);
1.169 + //
1.170 + iString4.Copy(String4);
1.171 + iExit=EFalse;
1.172 + }
1.173 +
1.174 +void CTimeWindow::SetUpL(TPoint aPos,TSize aSize,CTWinBase *aParent,CWindowGc &aGc)
1.175 + {
1.176 + CTTitledWindow::SetUpL(aPos,aSize,aParent,aGc);
1.177 + }
1.178 +
1.179 +void CTimeWindow::WinKeyL(const TKeyEvent &aKey,const TTime&)
1.180 + {
1.181 + switch(aKey.iCode)
1.182 + {
1.183 + case EKeyEscape:
1.184 + iTest->Request();
1.185 + break;
1.186 + default:;
1.187 + }
1.188 + }
1.189 +
1.190 +void CTimeWindow::PointerL(const TPointerEvent &aPointer,const TTime &aTime)
1.191 + {
1.192 + if (iRect2.Contains(aPointer.iPosition) || iRect3.Contains(aPointer.iPosition))
1.193 + {
1.194 + if (aPointer.iType==TPointerEvent::EButton1Down)
1.195 + iPressed=ETrue;
1.196 + }
1.197 + else if (iRect4.Contains(aPointer.iPosition))
1.198 + iExit=ETrue;
1.199 + else
1.200 + CTTitledWindow::PointerL(aPointer,aTime);
1.201 + if ((iExit||iPressed) && aPointer.iType==TPointerEvent::EButton1Up)
1.202 + {
1.203 + if (iExit)
1.204 + iTest->Request();
1.205 + else
1.206 + {
1.207 + Test()->DoTimings();
1.208 + DoDraw();
1.209 + }
1.210 + }
1.211 + }
1.212 +
1.213 +void CTimeWindow::Draw()
1.214 + {
1.215 + CTTitledWindow::Draw();
1.216 + TInt ascent=iFont->AscentInPixels()+1;
1.217 + iGc->DrawText(iString1,iRect1,ascent,CGraphicsContext::ELeft);
1.218 + iGc->DrawText(iString2,iRect2,ascent,CGraphicsContext::ELeft);
1.219 + iGc->DrawText(iString3,iRect3,ascent,CGraphicsContext::ELeft);
1.220 + iGc->DrawText(iString4,iRect4,ascent,CGraphicsContext::ELeft);
1.221 + }
1.222 +
1.223 +void CTimeWindow::DoDraw()
1.224 + {
1.225 + iGc->Activate(iWin);
1.226 + iGc->UseFont((CFont *)iFont);
1.227 + Draw();
1.228 + iGc->Deactivate();
1.229 + }
1.230 +
1.231 +void CTimeWindow::SetNumWindows(TInt aGroups,TInt aWins)
1.232 + {
1.233 + iNumGroups=aGroups;
1.234 + iNumWins=aWins;
1.235 + UpdateString1();
1.236 + }
1.237 +
1.238 +void CTimeWindow::UpdateString1()
1.239 + {
1.240 + _LIT(NumberWin,"Groups (2x)%d, Windows %d");
1.241 + iString1.Format(NumberWin,iNumGroups,iNumWins);
1.242 + }
1.243 +
1.244 +void CTimeWindow::SetTime1(TTimeIntervalMicroSeconds& aTime)
1.245 + {
1.246 + iTime1=aTime;
1.247 + UpdateString2();
1.248 + }
1.249 +
1.250 +void CTimeWindow::SetTime2(TTimeIntervalMicroSeconds& aTime)
1.251 + {
1.252 + iTime2=aTime;
1.253 + UpdateString3();
1.254 + }
1.255 +
1.256 +_LIT(TimeFormat,"Time%d = %d.%04dsecs");
1.257 +
1.258 +void CTimeWindow::UpdateString2()
1.259 + {
1.260 + TInt time = I64LOW(iTime1.Int64());
1.261 + iString2.Format(TimeFormat,1,time/1000000,(time%1000000)/100);
1.262 + }
1.263 +
1.264 +void CTimeWindow::UpdateString3()
1.265 + {
1.266 + TInt time = I64LOW(iTime2.Int64());
1.267 + iString3.Format(TimeFormat,2,time/1000000,(time%1000000)/100);
1.268 + }
1.269 +
1.270 +
1.271 +//
1.272 +// CQBlankWindow
1.273 +//
1.274 +
1.275 +void CQBlankWindow::InitWin()
1.276 + {
1.277 + SetColor(TRgb::Gray4(iInitialColor));
1.278 + iWin.SetSize(iSize);
1.279 + }
1.280 +
1.281 +
1.282 +//
1.283 +// CFixScreenModeGroup
1.284 +//
1.285 +
1.286 +CFixScreenModeGroup::~CFixScreenModeGroup()
1.287 + {
1.288 + GroupWin()->EnableReceiptOfFocus(EFalse);
1.289 + ClearCurrentWindow();
1.290 + CQBlankWindow* win;
1.291 + while (!iWindows.IsEmpty())
1.292 + {
1.293 + win=iWindows.First();
1.294 + iWindows.Remove(*win);
1.295 + delete win;
1.296 + }
1.297 + }
1.298 +
1.299 +CFixScreenModeGroup::CFixScreenModeGroup(CTClient *aClient) : CTWindowGroup(aClient), iWindows(_FOFF(CQBlankWindow,iLink))
1.300 + {}
1.301 +
1.302 +void CFixScreenModeGroup::ConstructL()
1.303 + {
1.304 + CTWindowGroup::ConstructL();
1.305 + CQBlankWindow* win;
1.306 + TInt ii;
1.307 + for(ii=0;ii<iNoClientWins;++ii)
1.308 + {
1.309 + win=new(ELeave) CQBlankWindow();
1.310 + CleanupStack::PushL(win);
1.311 + win->ConstructL(*this);
1.312 + win->Activate();
1.313 + win->AssignGC(*iClient->iGc);
1.314 + iWindows.AddLast(*win);
1.315 + CleanupStack::Pop(win);
1.316 + Client()->Flush();
1.317 + }
1.318 + SetCurrentWindow(iWindows.First());
1.319 + }
1.320 +
1.321 +/*void CFixScreenModeGroup::ScreenDeviceChanged()
1.322 + {
1.323 + iWindow->ScreenDeviceChanged();
1.324 + }*/
1.325 +
1.326 +
1.327 +//
1.328 +// CScreenModeTimes
1.329 +//
1.330 +
1.331 +_LIT(TestName,"Screen Mode Times");
1.332 +CScreenModeTimes::CScreenModeTimes() : CTestBase(TestName)
1.333 + ,iNormalGroupQue(_FOFF(CFixScreenModeGroup,iLink)),iFlipGroupQue(_FOFF(CFixScreenModeGroup,iLink))
1.334 + {}
1.335 +
1.336 +CScreenModeTimes::~CScreenModeTimes()
1.337 + {
1.338 + Client()->iGroup->GroupWin()->EnableScreenChangeEvents();
1.339 + Client()->iScreen->SetScreenMode(0);
1.340 + DeleteGroups(iNormalGroupQue);
1.341 + DeleteGroups(iFlipGroupQue);
1.342 + Client()->iGroup->SetCurrentWindow(NULL);
1.343 + delete iFlipClient;
1.344 + delete iInfoWindow;
1.345 + if (iEnforcementMode==ESizeEnforcementNone)
1.346 + Client()->iScreen->SetScreenModeEnforcement(ESizeEnforcementNone);
1.347 + }
1.348 +
1.349 +void CScreenModeTimes::ConstructL()
1.350 + {
1.351 + iEnforcementMode=Client()->iScreen->ScreenModeEnforcement();
1.352 + if (iEnforcementMode==ESizeEnforcementNone)
1.353 + Client()->iScreen->SetScreenModeEnforcement(ESizeEnforcementPixelsAndRotation);
1.354 + iDialogue=new(ELeave) CInfoDialog(Client()->iGroup,Client()->iGc);
1.355 + iDialogue->ConstructLD();
1.356 + iFlipClient=new(ELeave) CFlipClient();
1.357 + iFlipClient->ConstructL();
1.358 + Client()->iGroup->GroupWin()->DisableScreenChangeEvents();
1.359 + iNoGroupWins=12; //20;
1.360 + CFixScreenModeGroup::iNoClientWins=20; //30;
1.361 + TSize screenSize=Client()->iScreen->SizeInPixels();
1.362 + CQBlankWindow::iSize.iWidth=Max(screenSize.iHeight,screenSize.iWidth);
1.363 + CQBlankWindow::iSize.iHeight=CQBlankWindow::iSize.iWidth;
1.364 + TInt ii;
1.365 + for(ii=0;ii<iNoGroupWins;++ii)
1.366 + {
1.367 + CQBlankWindow::iInitialColor=1;
1.368 + CreateGroupL(Client(),iNormalGroupQue);
1.369 + CQBlankWindow::iInitialColor=2;
1.370 + CreateGroupL(iFlipClient,iFlipGroupQue);
1.371 + }
1.372 + Client()->iGroup->GroupWin()->SetOrdinalPosition(0);
1.373 + iInfoWindow=new(ELeave) CTimeWindow();
1.374 + iInfoWindow->SetUpL(TPoint(Max(Min(415,screenSize.iWidth-210),0),Min(50,screenSize.iHeight-180)),TSize(210,180),Client()->iGroup,*Client()->iGc);
1.375 + Client()->iGroup->SetCurrentWindow(iInfoWindow);
1.376 + iInfoWindow->Construct(this);
1.377 + iInfoWindow->WinTreeNode()->SetOrdinalPosition(1);
1.378 + iInfoWindow->SetNumWindows(iNoGroupWins,CFixScreenModeGroup::iNoClientWins);
1.379 +
1.380 + Client()->iGroup->GroupWin()->DisableScreenChangeEvents();
1.381 + Client()->iWs.SetAutoFlush(ETrue);
1.382 + iFlipClient->iWs.SetAutoFlush(ETrue);
1.383 + Client()->iWs.SetPointerCursorMode(EPointerCursorNone);
1.384 + }
1.385 +
1.386 +void CScreenModeTimes::CreateGroupL(CTClient *aClient,TSglQue<CFixScreenModeGroup>& aQue)
1.387 + {
1.388 + CFixScreenModeGroup* group;
1.389 + group=new(ELeave) CFixScreenModeGroup(aClient);
1.390 + CleanupStack::PushL(group);
1.391 + group->ConstructL();
1.392 + aQue.AddLast(*group);
1.393 + CleanupStack::Pop(group);
1.394 + }
1.395 +
1.396 +void CScreenModeTimes::DeleteGroups(TSglQue<CFixScreenModeGroup>& aQue)
1.397 + {
1.398 + CFixScreenModeGroup* group;
1.399 + while (!aQue.IsEmpty())
1.400 + {
1.401 + group=aQue.First();
1.402 + aQue.Remove(*group);
1.403 + delete group;
1.404 + }
1.405 + }
1.406 +
1.407 +void CScreenModeTimes::BringToFront(TSglQue<CFixScreenModeGroup>& aQue)
1.408 + {
1.409 + TSglQueIter<CFixScreenModeGroup> iter(aQue);
1.410 + CFixScreenModeGroup* group=iter++;
1.411 + group->GroupWin()->SetOrdinalPosition(0);
1.412 + while ((group=iter++)!=NULL)
1.413 + group->GroupWin()->SetOrdinalPosition(1);
1.414 + }
1.415 +
1.416 +void CScreenModeTimes::DoTimings()
1.417 + {
1.418 + //Timings 1 SCRDEV, DWsScreenDevice::CommandL, around call to SetScreenMode
1.419 + //Timings 2 GROUPWIN, CWsWindowGroup::SetScreenDeviceValidStates, around main body of function including calls to old way
1.420 + //Timings 3 CLIWIN, CWsTopClientWindow::SetScreenDeviceValidState, around call to ResetHiddenFlagAndAdjustRegions
1.421 + //Timings 3 GROUPWIN, CWsWindowGroup::SetScreenDeviceValidStates, around main body of function excluding calls to old way
1.422 + //Timings 4&5 CLIWIN, CWsClientWindow::ResetHiddenFlagAndAdjustRegions, going invisible and becomming visible sections
1.423 + Client()->iGroup->GroupWin()->SetOrdinalPosition(-2);
1.424 + Client()->Flush();
1.425 + TTime startTime;
1.426 + TTime middleTime;
1.427 + TTime endTime;
1.428 +__PROFILE_START(0);
1.429 + startTime.HomeTime();
1.430 + BringToFront(iNormalGroupQue);
1.431 + Client()->iScreen->SetScreenMode(1);
1.432 + middleTime.HomeTime();
1.433 + BringToFront(iFlipGroupQue);
1.434 + Client()->iScreen->SetScreenMode(0);
1.435 + endTime.HomeTime();
1.436 +__PROFILE_END(0);
1.437 +#if defined(__PROFILING__)
1.438 + TProfile profile;
1.439 + RDebug::ProfileResult(&profile,3,1);
1.440 + if (profile.iCount>0)
1.441 + iDialogue->TimerResults(0);
1.442 +#endif
1.443 + TTimeIntervalMicroSeconds time=middleTime.MicroSecondsFrom(startTime);
1.444 + iInfoWindow->SetTime1(time);
1.445 + time=endTime.MicroSecondsFrom(middleTime);
1.446 + iInfoWindow->SetTime2(time);
1.447 + Client()->iGroup->GroupWin()->SetOrdinalPosition(0);
1.448 +#if defined(__PROFILING__)
1.449 + if (profile.iCount>0)
1.450 + iDialogue->Display();
1.451 +#endif
1.452 + }
1.453 +
1.454 +TestState CScreenModeTimes::DoTestL()
1.455 + {
1.456 + switch(iState)
1.457 + {
1.458 + case 0:
1.459 + LogSubTest(_L("Time ScreenMode Changes"),1);
1.460 + DoTimings();
1.461 + iState++;
1.462 + return EContinue;
1.463 + default:
1.464 + return EFinished;
1.465 + }
1.466 + }