os/graphics/windowing/windowserver/test/tauto/tdirecta.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
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".
     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 __TDIRECTA_H__
    23 #define __TDIRECTA_H__
    24 
    25 #include "AUTO.H"
    26 #include <e32msgqueue.h>
    27 #include <time.h>
    28 #include "TGraphicsHarness.h"
    29 
    30 //#define LOGGING
    31 
    32 class CColorAnimation;
    33 class CScrollText;
    34 class CScrollingTextDrawer;
    35 class CDirectScreenAccessOld;
    36 
    37 
    38 struct TDirectThreadParam
    39 	{
    40 	TRect iRect;
    41 	TInt iScreenNumber;
    42 	TBool iIsInFront;
    43 	};
    44 
    45 class MAnimCallBacks
    46 	{
    47 public:
    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;
    57 public:
    58 	CTBlankWindow* iCallBackWin;
    59 	};
    60 
    61 class CTDirect : public CTWsGraphicsBase, public MAbortDirectScreenAccess, public MAnimCallBacks
    62 	{
    63 public:
    64 	enum
    65 		{
    66 		eDirectNumFrames=10
    67 		};
    68 	enum
    69 		{
    70 		eDirectControlSem=0x01,
    71 		eDirectWindowSem=0x02,
    72 		eFontSet=0x04,
    73 		eMultiAnim=0x08,
    74 		};
    75 public:
    76 	CTDirect(CTestStep* aStep);
    77 	~CTDirect();
    78 	void ConstructL();
    79 	TBool DrawFrame();
    80 	TBool Restart();
    81 	void ChangeToNextScreenModeL();
    82 	void ChangeScreenScale();
    83 	//The Tests
    84 	TestState AnimateWindowL();
    85 	TestState AnimationDiesL();
    86 	TestState PackagingClassL();
    87 	TestState MultipleL();
    88 	TestState FailCodesL();
    89 	TestState ScrolingText1L();
    90 	TestState RClassL();
    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();
   106 protected:
   107 //from 	CTGraphicsStep
   108 	virtual void RunTestCaseL(TInt aCurTestCase);
   109 private:
   110 	void ConstrucBlankWindowL();
   111 	void ScanTypeFacesL();
   112 	void InitialiseAnimationL();
   113 	void DestroyAnimation();
   114 	void ResetScreenSizeMode();
   115 	void StartDirect();
   116 	void SignalWindow();
   117 	void ModeSwitch();
   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);
   124 	void Fail();
   125 	void Finished(TInt aId);
   126 	void DeleteMoveWindow();
   127 	void DeleteScroll();
   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();
   139 private:
   140 	CProcess* iProcess;
   141 	CProcess* iMoveWin;
   142 	RSemaphore iControlSem;
   143 	RMsgQueueBase iControlQueue;
   144 	RSemaphore iWinSem;
   145 	TRequestStatus iThreadStatus;
   146 	TUint iFlags;
   147 	CTBlankWindow* iWin;
   148 	CTBlankWindow* iWin2;
   149 	CFbsScreenDevice* iScrDev;
   150 	CFbsBitGc* iGc;
   151 	CFont* iFont;
   152 	CPeriodic* iTimer;
   153 	CIdle* iRestart;
   154 	CDirectScreenAccessOld* iDirect;
   155 	RRegion* iDrawingRegion;
   156 	TSize iScrSize;
   157 	TRect iDrawRect;
   158 	TInt iDrawHeight;
   159 	TInt iFrameNo;
   160 	TInt iLastTextWidth;
   161 	TInt iLastMaxTextWidth;
   162 	TInt iFrameToSignalAfter;
   163 	TBool iDelay;
   164 	TBool iCancelNext;
   165 	TBool iWindowDead;
   166 	CColorAnimation* iAnim;
   167 	CColorAnimation* iAnims[13];
   168 	TInt iCount;
   169 	CScrollText* iScroll;
   170 	TInt iCycles;
   171 	TScreenModeEnforcement iModeBackup;
   172 	TThreadStartUp iFirstFunction;
   173 	TInt iNumThreadHandles;
   174 	CTBlankWindow* iBlankTopClientWin1;
   175 	CTBlankWindow* iBlankTopClientWin2;
   176 	CPeriodic* iChangeScreenModeTimer;
   177 	TInt iCurrentMode;
   178 	TInt iNumOfModes;
   179 	TPoint iCurrentScreenModeOrigin;
   180 	TSize iCurrentScreenModeScale;
   181 	TInt iNumAnimation;
   182 	TSizeMode iModeData;
   183 	CPeriodic* iScreenModeTimer;
   184 	TInt iIsScalingSupported;
   185 	TInt iNumOfCallBack;
   186 	TBool iTestJustFailed;
   187 	TBool iTestJustCompleted;
   188 	TInt iState;
   189 	TBool iNextFrameFinished;
   190 	TBool iPackagingFinished;
   191 	TBool iTimerRunning;
   192 	};
   193 
   194 class CDirectScreenAccessOld : public CActive
   195 	{
   196 public:
   197 	static CDirectScreenAccessOld* NewL(RWsSession& aWs,MAbortDirectScreenAccess& aAborter);
   198 	~CDirectScreenAccessOld();
   199 	TInt Request(RRegion*& aRegion, RWindowBase& aWindow);
   200 private:
   201 	inline CDirectScreenAccessOld(RWsSession& aWs,MAbortDirectScreenAccess& aAborter)
   202 		: CActive(RDirectScreenAccess::EPriorityVeryHigh), iDirectAccess(aWs), iAborter(aAborter) {}
   203 	void ConstructL();
   204 	//Pure virtual functions from CActive
   205 	void DoCancel();
   206 	void RunL();
   207 private:
   208 	RDirectScreenAccess iDirectAccess;
   209 	MAbortDirectScreenAccess& iAborter;
   210 	TBool iAborting;
   211 	};
   212 
   213 class CColorAnimation : public CBase, public MDirectScreenAccess
   214 	{
   215 public:
   216 	enum
   217 		{
   218 		eStopNow=EFalse,
   219 		eStopDelayed=ETrue,
   220 		eAbort=2,
   221 		eAbortAll,
   222 		};
   223 public:
   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) {}
   228 	~CColorAnimation();
   229 	void ConstructL(CTWinBase& aParent,TRect aExtent,TBool aRegionTrackingOnly,TInt aTypeWindow=0,TInt aSingleWinForMultipleDSA=0);
   230 	void StartL(TBool aChildWindow=EFalse);
   231 	void StartOrPanic();
   232 	void Stop();
   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();
   239 	void FinishTest();
   240 	TBool TestGcAndScreenDeviceValues();
   241 	//inline TBool IsReadyToAbort(){return (iDrawer->iStatus!=KRequestPending);}
   242 protected:
   243 	void DrawColorL();
   244 	void IdlingL();
   245 	/*pure virtual function from MAbortDirectScreenAccess*/
   246 	void AbortNow(RDirectScreenAccess::TTerminationReasons aReason);
   247 	/*pure virtual function from MDirectScreenAccess*/
   248 	void Restart(RDirectScreenAccess::TTerminationReasons aReason);
   249 private:
   250 	TInt iId;
   251 	CTBlankWindow* iWindow;
   252 	CTBlankWindow* iWindow2;
   253 	TSize iWinSize;
   254 	CDirectScreenAccess* iDrawer;
   255 	CPeriodic* iTimer;
   256 	MAnimCallBacks& iCallBack;
   257 	TInt iColor;
   258 	TInt iCount;
   259 	TUint iIdling;
   260 	TInt iScreenNumber;
   261 	TInt iSingleWinForMultipleDSA;
   262 	TBool iRegionTrackingOnly;
   263 	};
   264 
   265 class CScrollingTextDrawer : public CBase
   266 	{
   267 public:
   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);
   272 	void Scroll();
   273 private:
   274 	inline CScrollingTextDrawer(CFbsScreenDevice*& aDevice,CFbsBitGc& aGc) : iDevice(aDevice), iGc(&aGc) {}
   275 	void ConstructL(TInt aScreenNumber);
   276 	void CreateFontL();
   277 private:
   278 	CFbsScreenDevice*& iDevice;
   279 	CFbsScreenDevice* iFontDevice;
   280 	CFbsBitGc* iGc;
   281 	CFont* iFont;
   282 	TBuf<32> iText;
   283 	TRect iDrawRect;
   284 	TInt iDrawHeight;
   285 	TInt iCharWidth;
   286 	TInt iFirstChar;
   287 	TInt iJump;
   288 #if defined(LOGGING)
   289 	RWsSession iWs;
   290 #endif
   291 	};
   292 
   293 class CScrollText : public CBase, public MDirectScreenAccess
   294 	{
   295 public:
   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) {}
   299 	~CScrollText();
   300 	void ConstructL(CTWindowGroup& aParent);
   301 	void StartL();
   302 	void Stop();
   303 	void ContinueL();
   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);}
   307 private:
   308 	void ScrollText();
   309 	void DoContinueL();
   310 	/*pure virtual function from MAbortDirectScreenAccess*/
   311 	void AbortNow(RDirectScreenAccess::TTerminationReasons aReason);
   312 	/*pure virtual function from MDirectScreenAccess*/
   313 	void Restart(RDirectScreenAccess::TTerminationReasons aReason);
   314 private:
   315 	TInt iId;
   316 	CTBlankWindow* iWindow;
   317 	TSize iWinSize;
   318 	CDirectScreenAccess* iDrawer;
   319 	CScrollingTextDrawer* iTextDraw;
   320 	CPeriodic* iTimer;
   321 	TInt iScrollJump;
   322 	TBool iCounting;
   323 	TInt iAbortCountDown;
   324 	TInt iScreenNumber;
   325 	};
   326 
   327 	
   328 /**
   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
   331  */
   332 class CWindowWithChild : public CBase, public MDirectScreenAccess
   333 	{
   334 public:
   335 	static CWindowWithChild* NewL(TInt aScreenNumber, CTWindowGroup& aParent,TBool aStart=EFalse);
   336 	inline CWindowWithChild(TInt aScreenNumber) : iScreenNumber(aScreenNumber) {}
   337 	~CWindowWithChild();
   338 	void ConstructL(CTWindowGroup& aParent);
   339 	void StartL();
   340 	void Stop();
   341 	void ContinueL();
   342 	inline TBool IsRunning() {return iRunning;}
   343 	void PerformCoverageCalls();
   344 	RWindow *ChildWindow()    {return iChildWindow->Win();}
   345 private:
   346 	void DoContinueL();
   347 	/*pure virtual function from MAbortDirectScreenAccess*/
   348 	void AbortNow(RDirectScreenAccess::TTerminationReasons aReason);
   349 	/*pure virtual function from MDirectScreenAccess*/
   350 	void Restart(RDirectScreenAccess::TTerminationReasons aReason);
   351 private:
   352 	CTBlankWindow* iWindow;
   353 	CTWin * iChildWindow;
   354 	TSize iWinSize;
   355 	CDirectScreenAccess* iDrawer;
   356 	TInt iScreenNumber;
   357 	TBool iRunning;
   358 	};
   359 	
   360 	
   361 class CWsBase : public CBase
   362 	{
   363 public:
   364 protected:
   365 	~CWsBase();
   366 	void ConstructL(TInt aScreenNumber,TInt aHandle);
   367 	void CreateBlankWindowL(RBlankWindow& iWin,TInt aHandle);
   368 protected:
   369 	RWsSession iWs;
   370 	CWsScreenDevice *iScrDev;
   371 	RWindowGroup iGroup;
   372 	};
   373 
   374 class CAnimating : public CWsBase, public MAbortDirectScreenAccess
   375 	{
   376 public:
   377 	static TInt StartLC(TAny* aScreenNumber);
   378 	//static CAnimating* NewLC();
   379 	void DrawFrame();
   380 	/*pure virtual function from MAbortDirectScreenAccess*/
   381 	void AbortNow(RDirectScreenAccess::TTerminationReasons aReason);
   382 private:
   383 	void ConstructL(TInt aScreenNumber);
   384 	~CAnimating();
   385 	void StartAnimatingL();
   386 private:
   387 	RSemaphore iControlSem;
   388 	RMsgQueueBase iControlQueue;
   389 	TBool iSemCreated;
   390 	RBlankWindow iWindow;
   391 	CFbsScreenDevice* iScrDev;
   392 	CFbsBitGc* iGc;
   393 	TSize iScrSize;
   394 	CDirectScreenAccessOld* iDirect;
   395 	RRegion* iDrawingRegion;
   396 	CPeriodic* iTimer;
   397 	TInt iColor;
   398 	};
   399 
   400 class CMoveWindow : public CWsBase
   401 	{
   402 public:
   403 	static TInt StartLC(TAny* aScreenNumber);
   404 	static TInt StateChange(TAny* aMoveWin);
   405 	static TInt FlipChange(TAny*);
   406 	//Call Backs
   407 	void MoveWindow();
   408 private:
   409 	inline static CMoveWindow* Cast(TAny* aMoveWin) {return STATIC_CAST(CMoveWindow*,aMoveWin);}
   410 	~CMoveWindow();
   411 	void ConstructL(TInt aScreenNumber);
   412 	void CreateTimerL();
   413 	void StateChange();
   414 	void ToggleDisplayMode();
   415 	void FlipChange();
   416 private:
   417 	CPeriodic* iFlipTimer;
   418 	CPeriodic* iStateTimer;
   419 	CPeriodic* iTimer;
   420 	CWsScreenDevice* iDevice;
   421 	RBlankWindow iWindow;
   422 	TDisplayMode iDisplayMode;
   423 	RBackedUpWindow iBackUpWin;
   424 	CWindowGc* iGc;
   425 	TRect iBounceArea;
   426 	TSize iScrSize;
   427 	TPoint iTl;
   428 	TSize iSize;
   429 	TSize iDelta;
   430 	TInt iStateCountDown;
   431 	TInt iNumOfModes;
   432 	TInt iCurrentMode;
   433 	};
   434 
   435 class CBugFixColorAnimation : public CColorAnimation
   436 	{
   437 public:
   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(); }
   441 private:
   442 	CBugFixColorAnimation(TInt aScreenNumber,TInt aId,MAnimCallBacks& aCallBack);
   443 	void ConstructL(CTWindowGroup& aParent,TRect aExtent);
   444 private:
   445 	/*pure virtual function from MAbortDirectScreenAccess*/
   446 	void AbortNow(RDirectScreenAccess::TTerminationReasons aReason);
   447 	/*pure virtual function from MDirectScreenAccess*/
   448 	void Restart(RDirectScreenAccess::TTerminationReasons aReason);
   449 private:
   450 	CProcess* iThread;
   451 	CIdle* iTestFailed;
   452 	TRect iAnimRect;
   453 	TDirectThreadParam iThreadParam;
   454 	RSemaphore iSem;
   455 	};
   456 
   457 class CRegionTrackingOnly : public CColorAnimation
   458 	{
   459 public:
   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(); }
   464 private:
   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);
   469 private:
   470 	CProcess* iThread;
   471 	TRect iAnimRect;
   472 	TBool iExpectedToAbort;	
   473 	TDirectThreadParam iThreadParam;
   474 	RSemaphore iSem;
   475 	};
   476 
   477 /*CPanicDirect*/
   478  class CPanicDirect : public CBase
   479  	{
   480  public:
   481 	static TInt DoTestOnNewScheduler(TInt aInt, TAny* aPtr);
   482 	static TInt DoTestOnNewSchedulerL(TInt aInt, TAny* aPtr);
   483  private:
   484  	inline CPanicDirect() {}
   485  	~CPanicDirect();
   486  	void ConstructL(TInt aScreenNumber, TInt aInt);
   487 	static void DoTestNowL(TInt aInt, TAny* aPtr);
   488  	void TestL();
   489  	void DoDrawingL();
   490 private:
   491 	TInt iTestNo;
   492 	RWsSession iWs;
   493 	CWsScreenDevice* iWsScrDev;
   494 	RWindowGroup iGroup;
   495 	RBlankWindow iBlankWin;
   496 	RDirectScreenAccess iDirect;
   497 	TRequestStatus iDirectStatus;
   498 	RRegion* iRegion;
   499 	RTimer iTimer;
   500 	TRequestStatus iTimerStatus;
   501 	TBool iDrawingAllowed;
   502 	CFbsScreenDevice* iScreenDevice;
   503 	CFbsBitGc* iGc;
   504 	TDisplayMode iDisplayMode;
   505 	CScrollingTextDrawer* iTextDraw;
   506 	TInt iCount;
   507 	TInt iScreenNumber;
   508 	};
   509 
   510 class CTDirectStep : public CTGraphicsStep
   511 	{
   512 public:
   513 	CTDirectStep();
   514 protected:
   515 	//from CTGraphicsStep
   516 	virtual CTGraphicsBase* CreateTestL();
   517 	};
   518 
   519 _LIT(KTDirectStep,"TDirect");
   520 
   521 
   522 #endif