First public contribution.
1 // Copyright (c) 1996-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 @internalComponent - Internal Symbian test code
22 #ifndef __TDIRECTA_H__
23 #define __TDIRECTA_H__
26 #include <e32msgqueue.h>
28 #include "TGraphicsHarness.h"
32 class CColorAnimation;
34 class CScrollingTextDrawer;
35 class CDirectScreenAccessOld;
38 struct TDirectThreadParam
48 virtual void LogLeave(TInt aErr)=0;
49 virtual void Fail()=0;
50 virtual void Finished(TInt aId)=0;
51 virtual TDisplayMode DisplayMode(TInt aId)=0;
52 virtual TRgb BrushColorL(TInt aId,TInt& aColor,TBool& aFinished)=0;
53 virtual TInt TimerInterval(TInt aId)=0;
54 virtual void FailedReStart(TInt aId,TInt aReason)=0;
55 virtual TInt SlowStopping(TInt aId,TInt aCount)=0;
56 virtual void Log(const TText8* aFile, TInt aLine, TInt aSeverity,const TDesC& aString)=0;
58 CTBlankWindow* iCallBackWin;
61 class CTDirect : public CTWsGraphicsBase, public MAbortDirectScreenAccess, public MAnimCallBacks
70 eDirectControlSem=0x01,
71 eDirectWindowSem=0x02,
76 CTDirect(CTestStep* aStep);
81 void ChangeToNextScreenModeL();
82 void ChangeScreenScale();
84 TestState AnimateWindowL();
85 TestState AnimationDiesL();
86 TestState PackagingClassL();
87 TestState MultipleL();
88 TestState FailCodesL();
89 TestState ScrolingText1L();
91 TestState ScrolingText2L();
92 TestState ScrolingText3L();
93 TestState ScrolingText4L();
94 TestState DefectFix_KAA_5J3BLW_L();
95 TestState KillAnimationL();
96 TestState DSAWithScreenModeOffset1L();
97 TestState DSAWithScreenModeOffset2L();
98 TestState WindowPoistionRelativeToScreenL();
99 TestState ScreenModeScalingTestL();
100 TestState ScreenModeTestForScalingL();
101 TestState MultipleDSAsOnSameWindowL();
102 TestState TemporaryDeadlockL();
103 TestState RegionTrackingOnlyNotificationsL(TUint aId);
104 TestState MixDsaAndRegionTrackingOnlyL(TBool aWhoExitsLast);
105 TestState TryDifferentSupportedModesL();
107 //from CTGraphicsStep
108 virtual void RunTestCaseL(TInt aCurTestCase);
110 void ConstrucBlankWindowL();
111 void ScanTypeFacesL();
112 void InitialiseAnimationL();
113 void DestroyAnimation();
114 void ResetScreenSizeMode();
118 void ScrolingTextL(TInt aId,TRect aWinRect,TBool aStartThread,TInt aScreenMode=0);
119 void AnimTestL(TInt aId,TRect aWinRect,CTWinBase& aParent);
120 //Pure virtual function from MAbortDirectScreenAccess
121 void AbortNow(RDirectScreenAccess::TTerminationReasons aReason);
122 //Pure virtual functions from MAnimCallBacks
123 void LogLeave(TInt aErr);
125 void Finished(TInt aId);
126 void DeleteMoveWindow();
128 TDisplayMode DisplayMode(TInt aId);
129 TRgb BrushColorL(TInt aId,TInt& aColor,TBool& aFinished);
130 TInt TimerInterval(TInt aId);
131 void FailedReStart(TInt aId,TInt aReason);
132 TInt SlowStopping(TInt aId,TInt aCount);
133 void Log(const TText8* aFile, TInt aLine, TInt aSeverity,const TDesC& aString);
134 void SetScreenMode(TInt aMode,TPixelsAndRotation& aPixelsAndRotation);
135 void CreateAnimForScreenModeL(TInt aAnimIndex,CTWinBase& aParent,TRect aRect,TInt aId);
136 void BlankTopClientWindowL(CTBlankWindow& aBlankWindow,TRect aRect);
137 void TestDifferentOriginAndScaleL(TSizeMode &aMode,TPoint aOrigin);
138 void CheckForTemporaryDeadlock();
142 RSemaphore iControlSem;
143 RMsgQueueBase iControlQueue;
145 TRequestStatus iThreadStatus;
148 CTBlankWindow* iWin2;
149 CFbsScreenDevice* iScrDev;
154 CDirectScreenAccessOld* iDirect;
155 RRegion* iDrawingRegion;
161 TInt iLastMaxTextWidth;
162 TInt iFrameToSignalAfter;
166 CColorAnimation* iAnim;
167 CColorAnimation* iAnims[13];
169 CScrollText* iScroll;
171 TScreenModeEnforcement iModeBackup;
172 TThreadStartUp iFirstFunction;
173 TInt iNumThreadHandles;
174 CTBlankWindow* iBlankTopClientWin1;
175 CTBlankWindow* iBlankTopClientWin2;
176 CPeriodic* iChangeScreenModeTimer;
179 TPoint iCurrentScreenModeOrigin;
180 TSize iCurrentScreenModeScale;
183 CPeriodic* iScreenModeTimer;
184 TInt iIsScalingSupported;
186 TBool iTestJustFailed;
187 TBool iTestJustCompleted;
189 TBool iNextFrameFinished;
190 TBool iPackagingFinished;
194 class CDirectScreenAccessOld : public CActive
197 static CDirectScreenAccessOld* NewL(RWsSession& aWs,MAbortDirectScreenAccess& aAborter);
198 ~CDirectScreenAccessOld();
199 TInt Request(RRegion*& aRegion, RWindowBase& aWindow);
201 inline CDirectScreenAccessOld(RWsSession& aWs,MAbortDirectScreenAccess& aAborter)
202 : CActive(RDirectScreenAccess::EPriorityVeryHigh), iDirectAccess(aWs), iAborter(aAborter) {}
204 //Pure virtual functions from CActive
208 RDirectScreenAccess iDirectAccess;
209 MAbortDirectScreenAccess& iAborter;
213 class CColorAnimation : public CBase, public MDirectScreenAccess
224 static TInt DrawColorL(TAny* aAnimation);
225 static TInt IdlingL(TAny* aAnimation);
226 static CColorAnimation* NewL(TInt aScreenNumber,TInt aId,MAnimCallBacks& aCallBack,CTWinBase& aParent,TRect aExtent,TBool aStart,TBool aRegionTrackingOnly = EFalse);
227 inline CColorAnimation(TInt aScreenNumber,TInt aId,MAnimCallBacks& aCallBack) :iId(aId), iCallBack(aCallBack), iScreenNumber(aScreenNumber) {}
229 void ConstructL(CTWinBase& aParent,TRect aExtent,TBool aRegionTrackingOnly,TInt aTypeWindow=0,TInt aSingleWinForMultipleDSA=0);
230 void StartL(TBool aChildWindow=EFalse);
233 void BringWindowToFront();
234 void ChangeModeL(TDisplayMode aMode);
235 TBool inline IsTimerActive() {return iTimer->IsActive();}
236 inline MAnimCallBacks& CallBack() { return iCallBack; }
237 TPoint AbsoluteWindowPosition(TInt aWindowId=0);
238 inline CDirectScreenAccess* GetDrawer();
240 TBool TestGcAndScreenDeviceValues();
241 //inline TBool IsReadyToAbort(){return (iDrawer->iStatus!=KRequestPending);}
245 /*pure virtual function from MAbortDirectScreenAccess*/
246 void AbortNow(RDirectScreenAccess::TTerminationReasons aReason);
247 /*pure virtual function from MDirectScreenAccess*/
248 void Restart(RDirectScreenAccess::TTerminationReasons aReason);
251 CTBlankWindow* iWindow;
252 CTBlankWindow* iWindow2;
254 CDirectScreenAccess* iDrawer;
256 MAnimCallBacks& iCallBack;
261 TInt iSingleWinForMultipleDSA;
262 TBool iRegionTrackingOnly;
265 class CScrollingTextDrawer : public CBase
268 static CScrollingTextDrawer* NewL(TInt aScreenNumber,CFbsScreenDevice*& aDevice,CFbsBitGc& aGc);
269 ~CScrollingTextDrawer();
270 inline void SetScrollJump(TInt aJump) {iJump=aJump;}
271 void SetBottomOfTest(TInt aBottom);
274 inline CScrollingTextDrawer(CFbsScreenDevice*& aDevice,CFbsBitGc& aGc) : iDevice(aDevice), iGc(&aGc) {}
275 void ConstructL(TInt aScreenNumber);
278 CFbsScreenDevice*& iDevice;
279 CFbsScreenDevice* iFontDevice;
293 class CScrollText : public CBase, public MDirectScreenAccess
296 static TInt DrawText(TAny* aAnimation);
297 static CScrollText* NewL(TInt aScreenNumber,TInt aId,CTWindowGroup& aParent,TInt aScrollJump,TBool aStart=EFalse);
298 inline CScrollText(TInt aId,TInt aScrollJump,TInt aScreenNumber) :iId(aId), iScrollJump(aScrollJump), iScreenNumber(aScreenNumber) {}
300 void ConstructL(CTWindowGroup& aParent);
304 inline TBool IsRunning() {return iTimer->IsActive();}
305 inline void SetCountDown(TInt aCountDown) {iAbortCountDown=aCountDown; iCounting=ETrue;}
306 inline void SetBottomOfTest(TInt aBottom) {iTextDraw->SetBottomOfTest(aBottom);}
310 /*pure virtual function from MAbortDirectScreenAccess*/
311 void AbortNow(RDirectScreenAccess::TTerminationReasons aReason);
312 /*pure virtual function from MDirectScreenAccess*/
313 void Restart(RDirectScreenAccess::TTerminationReasons aReason);
316 CTBlankWindow* iWindow;
318 CDirectScreenAccess* iDrawer;
319 CScrollingTextDrawer* iTextDraw;
323 TInt iAbortCountDown;
329 A simple class based on CScrollText constructs a blank window that has
330 a blank window child, used for functional coverage testing of CWsClientWindow
332 class CWindowWithChild : public CBase, public MDirectScreenAccess
335 static CWindowWithChild* NewL(TInt aScreenNumber, CTWindowGroup& aParent,TBool aStart=EFalse);
336 inline CWindowWithChild(TInt aScreenNumber) : iScreenNumber(aScreenNumber) {}
338 void ConstructL(CTWindowGroup& aParent);
342 inline TBool IsRunning() {return iRunning;}
343 void PerformCoverageCalls();
344 RWindow *ChildWindow() {return iChildWindow->Win();}
347 /*pure virtual function from MAbortDirectScreenAccess*/
348 void AbortNow(RDirectScreenAccess::TTerminationReasons aReason);
349 /*pure virtual function from MDirectScreenAccess*/
350 void Restart(RDirectScreenAccess::TTerminationReasons aReason);
352 CTBlankWindow* iWindow;
353 CTWin * iChildWindow;
355 CDirectScreenAccess* iDrawer;
361 class CWsBase : public CBase
366 void ConstructL(TInt aScreenNumber,TInt aHandle);
367 void CreateBlankWindowL(RBlankWindow& iWin,TInt aHandle);
370 CWsScreenDevice *iScrDev;
374 class CAnimating : public CWsBase, public MAbortDirectScreenAccess
377 static TInt StartLC(TAny* aScreenNumber);
378 //static CAnimating* NewLC();
380 /*pure virtual function from MAbortDirectScreenAccess*/
381 void AbortNow(RDirectScreenAccess::TTerminationReasons aReason);
383 void ConstructL(TInt aScreenNumber);
385 void StartAnimatingL();
387 RSemaphore iControlSem;
388 RMsgQueueBase iControlQueue;
390 RBlankWindow iWindow;
391 CFbsScreenDevice* iScrDev;
394 CDirectScreenAccessOld* iDirect;
395 RRegion* iDrawingRegion;
400 class CMoveWindow : public CWsBase
403 static TInt StartLC(TAny* aScreenNumber);
404 static TInt StateChange(TAny* aMoveWin);
405 static TInt FlipChange(TAny*);
409 inline static CMoveWindow* Cast(TAny* aMoveWin) {return STATIC_CAST(CMoveWindow*,aMoveWin);}
411 void ConstructL(TInt aScreenNumber);
414 void ToggleDisplayMode();
417 CPeriodic* iFlipTimer;
418 CPeriodic* iStateTimer;
420 CWsScreenDevice* iDevice;
421 RBlankWindow iWindow;
422 TDisplayMode iDisplayMode;
423 RBackedUpWindow iBackUpWin;
430 TInt iStateCountDown;
435 class CBugFixColorAnimation : public CColorAnimation
438 static CBugFixColorAnimation* NewL(TInt aScreenNumber,TInt aId,MAnimCallBacks& aCallBack,CTWindowGroup& aParent,TRect aExtent,TBool aStart=EFalse);
439 ~CBugFixColorAnimation();
440 inline void Started() { iSem.Signal(); }
442 CBugFixColorAnimation(TInt aScreenNumber,TInt aId,MAnimCallBacks& aCallBack);
443 void ConstructL(CTWindowGroup& aParent,TRect aExtent);
445 /*pure virtual function from MAbortDirectScreenAccess*/
446 void AbortNow(RDirectScreenAccess::TTerminationReasons aReason);
447 /*pure virtual function from MDirectScreenAccess*/
448 void Restart(RDirectScreenAccess::TTerminationReasons aReason);
453 TDirectThreadParam iThreadParam;
457 class CRegionTrackingOnly : public CColorAnimation
460 static CRegionTrackingOnly* NewL(TInt aScreenNumber,TInt aId,MAnimCallBacks& aCallBack,CTWindowGroup& aParent,TRect aExtent,TBool aStart,TBool aOpenWindowInFrontDsa);
461 void ConstructL(CTWindowGroup& aParent,TRect aExtent,TBool aOpenWindowInFrontDsa);
462 ~CRegionTrackingOnly();
463 inline void Started() { iSem.Signal(); }
465 CRegionTrackingOnly(TInt aScreenNumber,TInt aId,MAnimCallBacks& aCallBack);
466 /*Overriding of bases class virtual functions*/
467 void AbortNow(RDirectScreenAccess::TTerminationReasons aReason);
468 void Restart(RDirectScreenAccess::TTerminationReasons aReason);
472 TBool iExpectedToAbort;
473 TDirectThreadParam iThreadParam;
478 class CPanicDirect : public CBase
481 static TInt DoTestOnNewScheduler(TInt aInt, TAny* aPtr);
482 static TInt DoTestOnNewSchedulerL(TInt aInt, TAny* aPtr);
484 inline CPanicDirect() {}
486 void ConstructL(TInt aScreenNumber, TInt aInt);
487 static void DoTestNowL(TInt aInt, TAny* aPtr);
493 CWsScreenDevice* iWsScrDev;
495 RBlankWindow iBlankWin;
496 RDirectScreenAccess iDirect;
497 TRequestStatus iDirectStatus;
500 TRequestStatus iTimerStatus;
501 TBool iDrawingAllowed;
502 CFbsScreenDevice* iScreenDevice;
504 TDisplayMode iDisplayMode;
505 CScrollingTextDrawer* iTextDraw;
510 class CTDirectStep : public CTGraphicsStep
515 //from CTGraphicsStep
516 virtual CTGraphicsBase* CreateTestL();
519 _LIT(KTDirectStep,"TDirect");