windowing/windowserver/tauto/openwfc/AUTO.H
changeset 116 171fae344dd4
parent 103 2717213c588a
equal deleted inserted replaced
103:2717213c588a 116:171fae344dd4
     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 // Header for window server auto test code
       
    15 // 
       
    16 //
       
    17 
       
    18 
       
    19 #ifndef __AUTO_H__
       
    20 #define __AUTO_H__
       
    21 
       
    22 #include <e32std.h>
       
    23 #include <e32math.h>
       
    24 #include "../../SERVER/w32cmd.h"
       
    25 #include <w32std.h>
       
    26 #include "../tlib/testbase.h"
       
    27 #include <wsautotest.mbg>
       
    28 #include "TGraphicsHarness.h"
       
    29 #include "../../SERVER/openwfc/panics.h"
       
    30 
       
    31 #define DISABLE_FAIL_DIALOG
       
    32 
       
    33 #define TEST_BITMAP_NAME _L("Z:\\WSTEST\\WSAUTOTEST.MBM")
       
    34 
       
    35 #define SCREEN_MODE_TESTING
       
    36 
       
    37 #define LOG_MESSAGE(p) LogMessage(((TText8*)__FILE__), __LINE__,(p))
       
    38 #define LOG_MESSAGE2(p1,p2) LogMessage(((TText8*)__FILE__), __LINE__,(p1),(p2))
       
    39 #define LOG_MESSAGE3(p1,p2,p3) LogMessage(((TText8*)__FILE__), __LINE__,(p1),(p2),(p3))
       
    40 #define LOG_MESSAGE4(p1,p2,p3,p4) LogMessage(((TText8*)__FILE__), __LINE__,(p1),(p2),(p3),(p4))
       
    41 #define LOG_MESSAGE5(p1,p2,p3,p4,p5) LogMessage(((TText8*)__FILE__), __LINE__,(p1),(p2),(p3),(p4),(p5))
       
    42 #define LOG_MESSAGE6(p1,p2,p3,p4,p5,p6) LogMessage(((TText8*)__FILE__), __LINE__,(p1),(p2),(p3),(p4),(p5),(p6))
       
    43 #define LOG_MESSAGE7(p1,p2,p3,p4,p5,p6,p7) LogMessage(((TText8*)__FILE__), __LINE__,(p1),(p2),(p3),(p4),(p5),(p6),(p7))
       
    44 
       
    45 // MB 23\11\04 The heap size was only 4k which was causing DSA step 7 to fail on HW.
       
    46 // Increased heap size to 8k
       
    47 // 23/02/2009 Again failing with no memory due to COLOR16MAP used. 
       
    48 // Increased heap size to 16k
       
    49 LOCAL_D const TUint KOtherProcHeapSize=0x4000;
       
    50 LOCAL_D const TInt KAutoTestPriority=-20;
       
    51 
       
    52 TBool DoCheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2,const TRect &aRect);
       
    53 TBool DoCheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2,const TRect &aRect, TUint aFlags);
       
    54 TBool DoCheckRectRWin(RWindowBase &aWin1,RWindowBase &aWin2,const TRect &aRect);
       
    55 TBool DoCheckRectRWin(RWindowBase &aWin1,RWindowBase &aWin2,const TRect &aRect, TUint aFlags);
       
    56 TBool DoCheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2);
       
    57 TBool DoCheckRect(TPoint aPos1,TPoint aPos2,TSize aSize);
       
    58 
       
    59 _LIT(KWSERV,"WSERV");
       
    60 _LIT(KW32,"W32");
       
    61 _LIT(KPlatsecBegin,"*PlatSec* ERROR - BEGIN NEGATIVE PLATSEC TESTING");
       
    62 _LIT(KPlatsecEnd,"*PlatSec* ERROR - END NEGATIVE PLATSEC TESTING");
       
    63 _LIT(KTestFontTypefaceName,"DejaVu Sans Condensed");
       
    64 
       
    65 class TestClient;
       
    66 class CMinWin;
       
    67 class CTWsGraphicsBase;
       
    68 
       
    69 enum TestState
       
    70 	{
       
    71 	EInvalid,
       
    72 	ENext,
       
    73 	EWait,
       
    74 	EFinished
       
    75 	};
       
    76 
       
    77 enum TAutoPanics
       
    78 	{
       
    79 	EAutoPanicTestFailed,
       
    80 	EAutoPanicPanicFailed,
       
    81 	EAutoPanicTestRectsIndex,
       
    82 	EAutoPanicTestRectsSection,
       
    83 	EAutoPanicUnexpectedLeave,
       
    84 	EAutoPanicTestBrushesIndex,
       
    85 	EAutoPanicWindowType,
       
    86 	EAutoPanicTooManyDownKeys,
       
    87 	EAutoPanicInvalidEvent,
       
    88 	EAutoFadeWindow,
       
    89 	EAutoPanicWrongTest,
       
    90 	EAutoPanicAnimError,
       
    91 	ETManPanicPcFailed,		              //Panic use in a test copied from TMan
       
    92 	EAutoPanicTestError,	              //Test returned bad return type
       
    93 	EAutoPanicDirect,		              //Direct Screen Access logic state error
       
    94 	EAutoPanicScanCapital,	              //Scan codes must not be lower case letters
       
    95 	EAutoPanicRedrawStoring,              //Inconsistent Redraw Storing Behaviour
       
    96  	EAutoPanicRecalledCreateTestBaseL,    //Called CreateTestBaseL twice
       
    97  	EAutoPanicHeartBeatCursorRect,        //Invalid size of rectangle in ChangeTransAndCheckHeartBeat
       
    98 	EAutoPanicGroupWinHasChild,           //Main test group window has child at start of test
       
    99   	EAutoPanicPanicSetTrans,              //Error setting transparency during panic tests
       
   100   	EAutoPanicNoDigitiser,                //Pointer event when the configuration has no digitiser
       
   101 	};
       
   102 
       
   103 enum TPanicExitReasons
       
   104 	{
       
   105 	EWsExitReasonBad,
       
   106 	EWsExitReasonFinished,
       
   107 	};
       
   108 
       
   109 enum TAutoLeaves
       
   110 	{
       
   111 	ETestPassed=0,
       
   112 	ETestFailed=1,
       
   113 	};
       
   114 
       
   115 typedef TInt (*TPanicFunction)(TInt aInt, TAny *aPtr);
       
   116 
       
   117 struct SPanicParams
       
   118 	{
       
   119 	TInt num;
       
   120 	TPanicFunction func;
       
   121 	TAny *ptr;
       
   122 	};
       
   123 
       
   124 class LogWindow : public CTWin
       
   125 	{
       
   126 	enum
       
   127 		{
       
   128 		EDummyValue=-9999
       
   129 		};
       
   130 public:
       
   131 	LogWindow();
       
   132 	void ConstructL(CTWinBase& aParent);
       
   133 	void Draw();
       
   134 	void DrawSubTitle();
       
   135 	void DrawMessage();
       
   136 	void LogTest(const TDesC &aTitle,TInt aNum);
       
   137 	const TDesC& LogSubTest(const TDesC &aTitle,TInt aNum);
       
   138 	const TDesC& LogMessage(TBool aLog,const TDesC& aText,TInt aNum=EDummyValue);
       
   139 private:
       
   140 	TBuf<0x40> iTestTitle;
       
   141 	TBuf<0x40> iSubTitle;
       
   142 	TBuf<0x40> iMessage;
       
   143 	TInt iTitleHeight;
       
   144 	};
       
   145 
       
   146 class CTestBase;
       
   147 
       
   148 /** 
       
   149 This class is a window that is used to fake a border around the TestWindow defined below.
       
   150 It simply draws an opaque black window on top of which the TestWindow will be drawn giving the illusion
       
   151 there is a border.
       
   152 
       
   153 @see TestWindow
       
   154 @internalComponent
       
   155 @released
       
   156 */
       
   157 class CBorderWindow : public CTWin
       
   158 	{
       
   159 public:
       
   160 	CBorderWindow();
       
   161 	void ConstructL(CTWinBase& aParent);
       
   162 	void Draw();
       
   163 	};
       
   164 
       
   165 class TestWindow : public CTWin
       
   166 	{
       
   167 public:
       
   168 	TestWindow();
       
   169 	~TestWindow();
       
   170 	void Draw();
       
   171 	void SetUpL(TPoint aPos, TSize aSize, CTWinBase* aParent, CWindowGc& aGc);
       
   172 	void ClearWin();
       
   173 	void SetBorderExt(TPoint aPos, TSize aSize);
       
   174 	CBorderWindow* GetBorderWin();
       
   175 private:
       
   176 	CBorderWindow* iBorderWin;
       
   177 	};
       
   178 
       
   179 /**
       
   180 This class used to run each individual test before the migration to TEF.
       
   181 Now it doesn't do much and should probably be refactored.
       
   182 
       
   183 @internalComponent
       
   184 @released
       
   185 */
       
   186 class CTestDriver : public CBase
       
   187 	{
       
   188 public:
       
   189 	/** Factory function that returns a class derived from CTestDriver */
       
   190 	static CTestDriver* CreateL(TInt aScreenNumber);
       
   191 	virtual ~CTestDriver();
       
   192 	
       
   193 protected:
       
   194 	CTestDriver(TInt aScreenNumber);
       
   195 	
       
   196 public:
       
   197 	virtual void DoDisplayDialog(TDesC& timeBuf,TDesC& testReport) = 0;
       
   198 
       
   199 	void TestComplete2();
       
   200 	void DestroyTest();
       
   201 
       
   202 	inline TInt ScreenNumber() {return iScreenNumber;}
       
   203 	inline TInt NumberOfScreens() {return iNumberOfScreens;}
       
   204 
       
   205 public:
       
   206 	CTestBase *iTest;
       
   207 	TInt iSubTestNum;
       
   208 	static TInt iTestNum;
       
   209 protected:
       
   210 	TTime iStartTime;
       
   211 	TInt iScreenNumber;
       
   212 	TInt iTestSize;
       
   213 	TInt iNumberOfScreens;
       
   214 	};
       
   215 
       
   216 /** Variant of CTestDriver used when the tests are run on the primary screen.
       
   217 
       
   218 @internalComponent
       
   219 @released
       
   220 */
       
   221 class CTestDriverPrimary: public CTestDriver
       
   222 	{
       
   223 public:
       
   224 	CTestDriverPrimary(TInt aScreenNumber);
       
   225 	void DoDisplayDialog(TDesC& timeBuf,TDesC& testReport);
       
   226 	};
       
   227 
       
   228 /** Variant of CTestDriver used when the tests are run on a secondary screen.
       
   229 
       
   230 @internalComponent
       
   231 @released
       
   232 */
       
   233 class CTestDriverSecondary : public CTestDriver
       
   234 	{
       
   235 public:
       
   236 	CTestDriverSecondary(TInt aScreenNumber);
       
   237 	void DoDisplayDialog(TDesC& timeBuf,TDesC& testReport);
       
   238 	};
       
   239 
       
   240 /** List of rectangles use by TGDI.CPP and TRECTLIST.CPP.
       
   241 
       
   242 Since only 2 tests make use of this shouldn't it be moved outside of the framework?
       
   243 
       
   244 @internalComponent
       
   245 @released
       
   246 */
       
   247 class TTestRects
       
   248 	{
       
   249 private:
       
   250 	enum TRectListLimits
       
   251 		{
       
   252 		EMaxRectFromList=64,
       
   253 		EMaxRectZeroSize=73,
       
   254 		EMaxRectWide=83,
       
   255 		EMaxRectHigh=93
       
   256 		};
       
   257 		
       
   258 public:
       
   259 	void Construct(const RWindow &aWindow);
       
   260 	TInt Count1() const;
       
   261 	TInt Count2() const;
       
   262 	TInt Count3() const;
       
   263 	TRect operator[](TInt aIndex);
       
   264 	static void ResetSeed();
       
   265 private:
       
   266 	TInt Rnd(TInt aSize);
       
   267 	TInt RndMax(TInt aSize);
       
   268 	TInt RectCoord(TInt aSection,TInt aSize);
       
   269 	void RectCoordPair(TInt &aTl, TInt &aBr, TInt aSection, TInt aSize);
       
   270 	
       
   271 private:
       
   272 	TSize iSize;
       
   273 	static TRect iList[64];
       
   274 	static TInt64 iSeed;
       
   275 	};
       
   276 
       
   277 /**
       
   278 @internalComponent
       
   279 @released
       
   280 */
       
   281 class CBitmap : public CBase
       
   282 	{
       
   283 public:
       
   284 	static CBitmap* NewLC(const TSize& aSizeInPixels,TDisplayMode aDispMode);
       
   285 	static CBitmap* NewL(const TSize& aSizeInPixels,TDisplayMode aDispMode);
       
   286 	static CBitmap* NewL(TInt aHandle);
       
   287 	static CBitmap* NewL(TDesC& aFileName);
       
   288 	~CBitmap();
       
   289 	inline CFbsBitmap& Bitmap() const {return *iBitmap;}
       
   290 	inline CFbsBitmapDevice& Device() const {return *iDevice;}
       
   291 	inline CFbsBitGc& Gc() const {return *iGc;}
       
   292 private:
       
   293 	static CBitmap* NewLC(TInt aHandle,const TSize& aSizeInPixels,TDisplayMode aDispMode);
       
   294 	void ConstructL(TInt aHandle,const TSize& aSizeInPixels,TDisplayMode aDispMode);
       
   295 private:
       
   296 	CFbsBitmap* iBitmap;
       
   297 	CFbsBitmapDevice* iDevice;
       
   298 	CFbsBitGc* iGc;
       
   299 	};
       
   300 
       
   301 /*TPartialRedrawType*/
       
   302 enum TPartialRedrawType
       
   303 	{
       
   304 	//redraw store type is not yet determined.
       
   305 	EPartialRedraw_Unknown,
       
   306 	//redraw store is discarded on invalidation and begin-redraw on a smaller rect.
       
   307 	EPartialRedraw_None,
       
   308 	// redraw store is preserved on invalidation and begin-redraw on a smaller rect.
       
   309 	EPartialRedraw_PreserveStoredCmds,
       
   310 	// redraw store is appended with partial redraw commands, and old redraw store is suitably modified.
       
   311 	EPartialRedraw_FullRedrawSupport
       
   312 	};
       
   313 
       
   314 class CTestBase : public CBase
       
   315 	{
       
   316 public:
       
   317 	enum TPriorites
       
   318 		{
       
   319 		EAutoTestPriority=KAutoTestPriority
       
   320 		};
       
   321 	enum TTestLevel
       
   322 		{
       
   323 		ELevelQuick,		// Quick check on main cases for each function
       
   324 		ELevelNormal,		// Suitable test level for internal release
       
   325 		ELevelRelease,		// Thorough test suitable for official releases
       
   326 		ELevelMega,			// Really OTT, takes forever to run, leave it going over the weekend sort of tests
       
   327 		};
       
   328 public:
       
   329 	CTestBase(const TDesC &aTitle,CTWsGraphicsBase* aTestBase);
       
   330 	~CTestBase();
       
   331 	void StartTestL(TInt aNum, CTestDriver* aDriver, TTestLevel aLevel);
       
   332 	void LogSubTest(const TDesC &aTitle);
       
   333 	void LogMessage(TInt aValue);
       
   334 	void LogSubState(TInt aSubState);
       
   335 	TInt LaunchPanicThread(RThread &aThread, SPanicParams *aPtr);
       
   336 	TInt TestPanicL(SPanicParams *aPtr, TInt aExitReason, const TDesC &aCategory, TBool* aTestFinished=NULL);
       
   337 	TInt TestPanicL(TPanicFunction aFunction, TInt aExitReason, TInt aInt, TAny *aPtr, const TDesC &aCategory, TBool* aTestFinished=NULL);
       
   338 	TInt TestWsPanicL(TPanicFunction aFunction, TClientPanic aExitReason, TInt aInt, TAny *aPtr=NULL, TBool* aTestFinished=NULL);
       
   339 	TInt TestW32PanicL(TPanicFunction aFunction, TW32Panic aExitReason, TInt aInt, TAny *aPtr, TBool* aTestFinished=NULL);
       
   340 	TInt TestWservPanicL(TPanicFunction aFunction, TWservPanic aExitReason, TInt aInt, TAny *aPtr);
       
   341 	void TriggerFail();
       
   342 	static void DrawTestBackground(TBool aInvertColours, const TSize &aSize, TInt aGrays=16);
       
   343 	inline CTestDriver* Driver();
       
   344 	void SimulatePointer(TRawEvent::TType aType, TInt aX, TInt aY);
       
   345 	TBool ConfigurationSupportsPointerEventTesting() const;
       
   346 	void SimulateEvent(TRawEvent::TType aType);
       
   347 	void LogColors(const CBitmapDevice& aDevice,TPoint aBasePoint, TPoint aStartPoint, TPoint aEndPoint);
       
   348 	void LogColors4(const CBitmapDevice& aDevice,TPoint aStartPoint,TInt aLen);
       
   349 	inline TInt ScreenNumber() {return iScreenNumber;}
       
   350 	TPartialRedrawType RedrawStoreTypeL();
       
   351 	TBool IsFullRomL();
       
   352 	void SimulateKeyDownUpWithModifiers(TInt aScanCode,TUint aModifiers);
       
   353 	void SimulatePointerDownUp(TInt aX, TInt aY);
       
   354 	void SimulateKeyDownUp(TInt aScanCode);
       
   355 	void SimulateKey(TRawEvent::TType aType, TInt aScanCode);
       
   356 	void DelayIfFullRomL();
       
   357 	void SetUpMember(TSpriteMember &aMember);
       
   358 	void AbortL();
       
   359 	void LogLeave(TInt aErr);
       
   360 	void CloseAllPanicWindows();
       
   361 	const TSize& StdTestWindowSize();
       
   362 	TInt MaxGrays() const;
       
   363 	TInt MaxColors() const;
       
   364 	TInt SaveScreen(const TDesC& aFileName);
       
   365 	TInt SaveScreen(const TDesC& aFileName,const TSize& aScreenSize,TDisplayMode aColorDepth);
       
   366 protected:
       
   367 	void UpdateTestResults(TInt aNoOfTest, TInt aNoOfTestPass);
       
   368 	void SaveScreenL(const TDesC& aFileName,const TSize& aScreenSize,TDisplayMode aColorDepth);
       
   369 public:
       
   370 	static TInt iNumberTestsPass;
       
   371 	static TInt iNumberTests;
       
   372 	TInt iState;
       
   373 	TInt iScreenNumber;
       
   374 	static TInt iScreenNo;
       
   375 	TTestRects iTestRects;
       
   376 	static TRect iNormalPointerCursorArea;
       
   377 	TBuf<0x40> iSubTitle;
       
   378 	TTestLevel iTestLevel;
       
   379 	static TInt iNumberOfGrpWndsOnPrimaryScreenWithZeroPriority; // Will be used in TGWHANDLE test.
       
   380 protected:
       
   381 	CTestDriver* iDriver;
       
   382 private:
       
   383 	TBuf<0x40> iTitle;
       
   384 	CTWsGraphicsBase* iTestBase;
       
   385 	/** 
       
   386 	Several tests use 3 windows : one is a log window, one is a reference window 
       
   387 	and one is the actual output of the test. All these windows have the same width which is roughly
       
   388 	1/3 of the screen. They also have the same height which is roughly equal to the screen height.
       
   389 	*/
       
   390 	TSize iStdTestWindowSize;
       
   391 	CMinWin* iMinWin;
       
   392 	TInt iTestNum;
       
   393 	TBool iFail;	// Used to trigger failures to test test code.
       
   394 	TInt iThreadNumber;
       
   395 	/** 
       
   396 	The type of redraw store in use. Static members so that	RedrawStoreTypeL computes
       
   397 	this value only once and then returns the cached result as this remains the same for
       
   398 	the entire test run.
       
   399 	*/
       
   400 	static TPartialRedrawType iRedrawType;
       
   401 	/** The number of greys available in the richest grey mode. */
       
   402 	static TInt iMaxGrays;
       
   403 	/** The number of colours available in the richest supported colour mode. */
       
   404 	static TInt iMaxColors;
       
   405 	};
       
   406 
       
   407 class CTWsGraphicsBase : public CTGraphicsBase
       
   408 	{
       
   409 public:
       
   410 	CTWsGraphicsBase(CTestStep* aStep);
       
   411 	~CTWsGraphicsBase();
       
   412 	void CreateTestBaseL(CTTMSGraphicsStep* aTmsStep);
       
   413 	inline CTestBase *TestBase() const {return(iTest);};
       
   414 	void TestComplete();
       
   415 	void LogMessage(const TText8* aFile,TInt aLine,TRefByValue<const TDesC> aFmt,...);
       
   416 	TInt GetScreenFromIni() const;
       
   417 protected:
       
   418 	void CheckRect(TPoint aPos1,TPoint aPos2,TSize aSize, const TDesC *aErrorMsg=NULL);
       
   419 	void CheckRect(TPoint aPos1,TPoint aPos2,TSize aSize, const TDesC &aErrorMsg);
       
   420 	void CheckRectNoMatch(TPoint aPos1,TPoint aPos2,TSize aSize, const TDesC *aErrorMsg=NULL);
       
   421 	void CheckRectNoMatch(TPoint aPos1,TPoint aPos2,TSize aSize, const TDesC &aErrorMsg);
       
   422 	void CheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2, const TDesC *aErrorMsg=NULL);
       
   423 	void CheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2, const TDesC &aErrorMsg);
       
   424 	void CheckRectNoMatch(CTBaseWin *aWin1,CTBaseWin *aWin2, const TDesC *aErrorMsg=NULL);
       
   425 	void CheckRectNoMatch(CTBaseWin *aWin1,CTBaseWin *aWin2, const TDesC &aErrorMsg);
       
   426 	TBool CheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2,const TRect &aRect, const TDesC *aErrorMsg=NULL);
       
   427 	TBool CheckRect(CTBaseWin *aWin1,CTBaseWin *aWin2,const TRect &aRect, const TDesC &aErrorMsg);
       
   428 	void CheckRectNoMatch(CTBaseWin *aWin1,CTBaseWin *aWin2,const TRect &aRect, const TDesC *aErrorMsg=NULL);
       
   429 	void CheckRectNoMatch(CTBaseWin *aWin1,CTBaseWin *aWin2,const TRect &aRect, const TDesC &aErrorMsg);
       
   430 	TBool CompareWindows(const TDesC *aErrorMsg=NULL);
       
   431 	TBool CompareWindows(const TDesC &aErrorMsg);
       
   432 	void CompareWindows(const TRect &aRect, const TDesC *aErrorMsg=NULL);
       
   433 	void CompareWindows(const TRect &aRect, const TDesC &aErrorMsg);
       
   434 	void CompareWindowsSoftFailWinscw(const TText8* aFile, TInt aLine);
       
   435 	const TSize& StdTestWindowSize();
       
   436 	TInt MaxGrays() const;
       
   437 	TInt MaxColors() const;
       
   438 private:
       
   439 	TBool CheckRetValue(TBool aPass,const TDesC* aErrorMsg,const TDesC& aErrorFunction);
       
   440 protected:
       
   441 	CTestBase* iTest;
       
   442 	CTTMSGraphicsStep* iTmsStep;
       
   443 	};
       
   444 
       
   445 class TestWindowGroup : public CTWindowGroup
       
   446 	{
       
   447 public:
       
   448 	TestWindowGroup(CTClient *aClient);
       
   449 	void BecomeOwning();
       
   450 	void KeyL(const TKeyEvent &aKey,const TTime &aTime);
       
   451 	void KeyDownL(const TKeyEvent &aKey,const TTime &aTime);
       
   452 	void KeyUpL(const TKeyEvent &aKey,const TTime &aTime);
       
   453 	};
       
   454 
       
   455 class TestClient : public CTClient
       
   456 	{
       
   457 public:
       
   458 	TestClient();
       
   459 	~TestClient();
       
   460 	void ConstructL();	// virtual from CTClient
       
   461 	void KeyL(const TKeyEvent &aKey,const TTime &aTime);
       
   462 	void Shutdown();
       
   463 	inline CTestDriver* Driver();
       
   464 	TBool WaitForEvent();
       
   465 	TBool IsEventWaiting();
       
   466 	void LogAvailableScreenModeL();
       
   467 	void TestWsSetBufferSizeL();
       
   468 	void TestWsSetMaxBufferSizeL();
       
   469 	inline LogWindow& StdLogWindow() {return *iStdLogWindow;}
       
   470 	void SetTestClientScreenMode(TInt aMode);
       
   471 	void UpdateTestClientScreenMode();
       
   472 public:
       
   473 	RArray<TInt> iScreenModes;
       
   474 	
       
   475 private:
       
   476 	/**
       
   477 	Several tests use 3 windows : one is a log window, one is a reference window 
       
   478 	and one is the actual output of the test. This member is the log window.
       
   479 	*/
       
   480 	LogWindow* iStdLogWindow;
       
   481 	CTestDriver* iDriver;
       
   482 	};
       
   483 
       
   484 class TThreadStartUp
       
   485 	{
       
   486 public:
       
   487 	TThreadStartUp() :iInitFunction(0), iParam(0) {}
       
   488 	TThreadStartUp(TThreadFunction aInitFunction,TAny* aParam) :iInitFunction(aInitFunction), iParam(aParam) {}
       
   489 public:
       
   490 	TThreadFunction iInitFunction;	   //The call to this fn will prepare a cleanup stack, but this function should not leave.
       
   491 	TAny* iParam;
       
   492 	};
       
   493 
       
   494 #if defined(__WINS__)
       
   495 	const TOwnerType KOwnerType=EOwnerThread;
       
   496 #else
       
   497 	const TOwnerType KOwnerType=EOwnerProcess;
       
   498 #endif
       
   499 
       
   500 typedef TBuf<32> TBufArg;
       
   501 
       
   502 class CProcess : public CBase
       
   503 	{
       
   504 public:
       
   505 	enum
       
   506 		{
       
   507 		eProcessPriortyTest,
       
   508 		eProcessKeyTest,
       
   509 		eProcessDirectTest,
       
   510 		eProcessMultiDisplayTest,
       
   511 		eNumProcessCalls		//Must be last one
       
   512 		};
       
   513 	struct TInitialFunction
       
   514 		{
       
   515 		inline TInitialFunction(const TDesC& aParam,TThreadFunction aFunction) :iParam(aParam), iFunction(aFunction) {}
       
   516 		TBuf<16> iParam;
       
   517 		TThreadFunction iFunction;
       
   518 		};
       
   519 public:
       
   520 	static TInt Start(const TWinCommand& aParam);
       
   521 	static CProcess* NewL(TInt aFunctionNo,TInt aScreenNumber=KDefaultScreen);
       
   522 	static CProcess* NewTL(TInt aFunctionNo,TInt aScreenNumber=KDefaultScreen,TRequestStatus* aClientRequestStatus = NULL);
       
   523 	static CProcess* NewThreadL(const TDesC& aName,TThreadFunction aFunction,TThreadStartUp* aPtr
       
   524 																							,TRequestStatus* aStatus);
       
   525 	static CProcess* NewThreadL(const TDesC& aName,TThreadStartUp* aPtr);
       
   526 	static CProcess* NewThreadRendezvousL(const TDesC& aName,TThreadFunction aFunction,TThreadStartUp* aPtr,TRequestStatus* aLogonStatus,TRequestStatus& aRendezvousStatus);
       
   527 	static CProcess* NewThreadRendezvousL(const TDesC& aName,TThreadStartUp* aPtr,TRequestStatus& aRendezvousStatus);
       
   528 
       
   529 	static CProcess* NewSimpleThreadL(const TDesC& aName,TThreadStartUp* aPtr,TRequestStatus* aStatus=NULL);
       
   530 	void ConstructL(TInt aFunctionNo,TInt aScreenNumber=KDefaultScreen);
       
   531 	void ConstructTL(TInt aFunctionNo,TInt aScreenNumber=KDefaultScreen,TRequestStatus* aStatus=NULL);
       
   532 	void ConstructL(const TDesC& aName,TThreadFunction aFunction,TThreadStartUp* aPtr,TRequestStatus* aStatus);
       
   533 	void ConstructRendezvousL(const TDesC& aName,TThreadFunction aFunction,TThreadStartUp* aPtr,TRequestStatus* aLogonStatus,TRequestStatus& aRendezvousStatus);
       
   534 
       
   535 	~CProcess();
       
   536 	void Logon(TRequestStatus& aStatus) const;
       
   537 	void Terminate(TInt aReason);
       
   538 	TBool StillAlive();
       
   539 	void LeaveIfDied();
       
   540 	static TBool ProcessDied(TInt aScreenNo=KDefaultScreen);
       
   541 private:
       
   542 	enum
       
   543 		{
       
   544 		eOtherCreated=0x0001,
       
   545 		eThreadCreated=0x0002,
       
   546 		};
       
   547 private:
       
   548 	static TInt ThreadInit(TAny *aPtr);
       
   549 	static void InitialiseL(TThreadStartUp* aPtr);
       
   550 	static TInt SimpleThreadInit(TAny *aPtr);
       
   551 	void Close();
       
   552 	static void GetProcArg(const TWinCommand& aParam,TBufArg& aProcArg);
       
   553 	static void GetScreenArg(const TWinCommand& aParam, TInt& aScreenArg);
       
   554 
       
   555 private:
       
   556 	TUint iCreated;
       
   557 	RProcess iOther;
       
   558 	RThread iThread;
       
   559 	static TInitialFunction iFunctions[eNumProcessCalls];
       
   560 	};
       
   561 
       
   562 GLREF_D TestWindow* BaseWin;
       
   563 GLREF_D TestWindow* TestWin;
       
   564 GLREF_D TestClient* TheClient;
       
   565 GLREF_D CWindowGc* TheGc;
       
   566 
       
   567 GLREF_C void AutoPanic(TInt aPanic);
       
   568 GLREF_C void CleanUpWindow(TAny *aWindow);
       
   569 GLREF_C void PushWindowL(RWindowTreeNode *aWindow);
       
   570 GLREF_C TBool OpacityAndAlphaSupportedL();
       
   571 GLREF_C TInt TransparencySupportedL();
       
   572 GLREF_C TInt CheckScalingSupportedOrNot();
       
   573 GLREF_C TBool CheckNonZeroOriginsSupportedOrNot();
       
   574 GLREF_C TPoint PhysicalToLogical(TPoint aPhysicalPtMinusOrigin,TSize aScale);
       
   575 GLREF_C TPtrC DisplayModeAsString(TDisplayMode aMode);
       
   576 GLREF_C TBool LossyCheckBlankBitmap(const CFbsBitmap& aBitmap, const TRect aArea, const TRgb aCheckColor, TBool aLossyCompare=ETrue);
       
   577 GLREF_C TBool LossyCompareBitmap(const CFbsBitmap& aBitmap1, const CFbsBitmap& aBitmap2, const TRect aCompareRect, TBool aLossyCompare=ETrue);
       
   578 GLDEF_C TBool LossyCompareBitmapRecord(CFbsBitmap& aBitmap1, CFbsBitmap& aBitmap2, const TRect aCompareRect, TBool aLossyCompare, TInt& aPixelsDifferent, CTestExecuteLogger& aLogger);
       
   579 GLREF_C TBool LossyCheckBlankWindow(const CWsScreenDevice& aScreen, CFbsBitmap& aBitmap, const TRect aArea, const TRgb aCheckColor);
       
   580 GLREF_C TBool LossyCompareWindow(const CWsScreenDevice& aScreen, CFbsBitmap& aBitmap1, CFbsBitmap& aBitmap2, const TRect aCompareRect);
       
   581 
       
   582 #define LogText(S) {_LIT(String__LINE__,S); Logger.Log(String__LINE__);}
       
   583 #define LogFormat(S) {Logger.Log(S);}
       
   584 
       
   585 inline CTestDriver* CTestBase::Driver()
       
   586 	{
       
   587 	return iDriver;
       
   588 	}
       
   589 
       
   590 class CTransWindow : public CBlankWindow
       
   591 	{
       
   592 public:
       
   593 	static CTransWindow* NewL(RPointerArray<CTransWindow>& aWindows,TRgb aColor,TRect aPos);
       
   594 	static CTransWindow* NewL(CTWinBase* aParent,TRgb aColor,TRect aPos,TDisplayMode* aDisplayMode);
       
   595 	static CTransWindow* NewL(CTWinBase* aParent,TRgb aColor,TDisplayMode* aDisplayMode);
       
   596 	void ToggleVisibility();
       
   597 	static void SetOrdinal(RPointerArray<CTransWindow>& aWindows,TInt aOldPos,TInt aNewPos);
       
   598 	inline TRgb Color() {return iCol;}
       
   599 	inline TBool IsVisible() {return iVisible;}
       
   600 	void SetShadowDisabled(TBool aState);
       
   601 	inline TBool IsShadowing() {return iShadowing;}
       
   602 	inline TBool ShadowHeight() {return iShadowHight;}
       
   603 	inline void SetPosOffset(TPoint aOffset) {iPosOffset=aOffset;}
       
   604 	virtual void Draw();
       
   605 	void SetDrawOpaque(TBool aDrawOpaque) { iDrawOpaque = aDrawOpaque; }
       
   606 	TBool DrawOpaque() const { return iDrawOpaque; }
       
   607 	//Virtual functions from CTWinBase overridden in CTBaseWin
       
   608 	void AdjustShadow(TInt aAdjust);
       
   609 	TPoint Position() const;
       
   610 	inline TInt TransparentError() {return iError;}
       
   611 private:
       
   612 	CTransWindow(TRgb aColor) :CBlankWindow(aColor), iVisible(ETrue) {}
       
   613 	//Virtual function from CTBaseWin
       
   614 	void InitWin();
       
   615 private:
       
   616 	TBool iVisible;
       
   617 	TBool iShadowing;
       
   618 	TBool iDrawOpaque;
       
   619 	TInt iShadowHight;
       
   620 	TPoint iPosOffset;
       
   621 	TInt iError;
       
   622 	};
       
   623 
       
   624 class CMinWin : public CBase
       
   625 	{
       
   626 public:
       
   627 	CMinWin(TInt aScreenNo);
       
   628 	~CMinWin();
       
   629 	void ConstructL();
       
   630 	void Draw(const TRect& aRect);
       
   631 private:
       
   632 	RWsSession iWs;
       
   633 	RWindow iWin;
       
   634 	RWindowGroup iGroup;
       
   635 	CWsScreenDevice* iScr;
       
   636 	TInt iScreenNo;
       
   637 	TRect iRect;
       
   638 	CWindowGc* iGc;
       
   639 	};
       
   640 
       
   641 class CTimeOut : public CTimer
       
   642 	{
       
   643 public:
       
   644 	inline CTimeOut(): CTimer((EPriorityLow+EPriorityIdle)/2) {}
       
   645 	void ConstructL();
       
   646 	void Start(TTimeIntervalMicroSeconds32 aInterval,TCallBack aCallBack);
       
   647 	//Pure virtual from CActive
       
   648 	void RunL();
       
   649 private:
       
   650 	TCallBack iCallBack;
       
   651 	};
       
   652 
       
   653 #define COMPARE_WINDOWS_SOFTFAIL_WINSCW	CompareWindowsSoftFailWinscw((TText8*)__FILE__, __LINE__)
       
   654 
       
   655 #define __WS_CONSTRUCT_STEP__(a) \
       
   656 	CT##a##Step::CT##a##Step() \
       
   657 	{ \
       
   658 	SetTestStepName(KT##a##Step); \
       
   659 	SetLogHeapInfo(ETrue); \
       
   660 	} \
       
   661 	 \
       
   662 CTGraphicsBase* CT##a##Step::CreateTestL() \
       
   663 	{ \
       
   664 	CTWsGraphicsBase* test=new (ELeave) CT##a (this); \
       
   665  	test->CreateTestBaseL(this);\
       
   666 	return test;\
       
   667 	} 
       
   668 
       
   669 #endif