lafagnosticuifoundation/animation/tef/AnimationTestStep.h
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 // Copyright (c) 2005-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  @internalComponent - Internal Symbian test code 
       
    19 */
       
    20 
       
    21 
       
    22 #ifndef __ANIMATIONTESTSTEP_H__
       
    23 #define __ANIMATIONTESTSTEP_H__
       
    24 
       
    25 #include <test/testexecutestepbase.h>
       
    26 #include <f32file.h>
       
    27 
       
    28 #include <w32std.h>
       
    29 #include <charconv.h>
       
    30 
       
    31 #include "ActiveTestStep.h"
       
    32 #include "ActiveWait.h"
       
    33 #include "TestWindows.h"
       
    34 #include "TestEventHandler.h"
       
    35 #include "TestRedrawHandler.h"
       
    36 
       
    37 _LIT(KTestFailed, "Test failed");
       
    38 _LIT(KTestFailedF, "Test failed with %d");
       
    39 _LIT(KRectsDiffer, "Compared areas differ");
       
    40 _LIT(KColorCount, "Wrong number of colors");
       
    41 _LIT(KColorCountF, "Color count out by %d");
       
    42 
       
    43 // Helper functions for error reporting.
       
    44 #define ANIM_INFO1(m)	{ Log(m); INFO_PRINTF1(m); }
       
    45 #define ANIM_WARN1(m)	{ Log(m); WARN_PRINTF1(m); }
       
    46 #define ANIM_ERR1(m)	{ Log(m); ERR_PRINTF1(m); }
       
    47 
       
    48 #define ANIMTESTERR(x)	{ if(x < KErrNone) { Log(KTestFailed); ERR_PRINTF2(KTestFailedF, x); SetTestStepResult(EFail); } }
       
    49 #define ANIMTESTRECT(r1,r2) { if(!RectCompare(r1,r2)) { Log(KRectsDiffer); ERR_PRINTF1(KRectsDiffer); SetTestStepResult(EFail); } }
       
    50 #define ANIMTESTCOLORSL(r,c1,c2) { TInt c = CountColorsL(r,c1,c2); if(c!=0) { Log(KColorCount); ERR_PRINTF2(KColorCountF, c); SetTestStepResult(EFail); } }
       
    51 
       
    52 //
       
    53 // Windows:
       
    54 //
       
    55 const TInt KMaxLogWinLines = 12;
       
    56 
       
    57 class CAnimBackdropWindow : public CTestWindow
       
    58 	{
       
    59 public:
       
    60 	CAnimBackdropWindow(RWsSession& aWs, CTestWindowGroup& aGroup, CWindowGc& aGc);
       
    61 	};
       
    62 
       
    63 class CAnimationTestWindow : public CTestWindow
       
    64 	{
       
    65 public:
       
    66 	CAnimationTestWindow(RWsSession& aWs, CTestWindowGroup& aGroup, CWindowGc& aGc, CWsScreenDevice& aScreen);
       
    67 	~CAnimationTestWindow();
       
    68 	void DrawL();
       
    69 	void AppendText(const TDesC& aText);
       
    70 	void Clear();
       
    71 	CWsScreenDevice& iScreen;
       
    72 	CFbsFont* iFont;
       
    73 protected:
       
    74 	TInt iNumLines;
       
    75 	TInt iFirstLine;
       
    76 	TBuf<40> iText[KMaxLogWinLines];
       
    77 	};
       
    78 
       
    79 //
       
    80 // The test:
       
    81 // This test does not perform any tests on the visual output.  It is useful
       
    82 // for other issues, but it is also a good base for manual testing.
       
    83 //
       
    84 class CAnimationTestStep : public CActiveTestStep
       
    85 	{
       
    86 public:
       
    87 	CAnimationTestStep();
       
    88 	~CAnimationTestStep();
       
    89 
       
    90 	void InitialiseL();
       
    91 protected:
       
    92 	void Log(const TDesC& aText);
       
    93 	void ClearLog();
       
    94 	void Wait(TInt aDelay);
       
    95 	void WaitForRedrawsToFinish();
       
    96 	
       
    97 	CTestWindowGroup* GroupWin()	{ return iGroupWin; }
       
    98 	CWsScreenDevice* Screen()		{ return iScreen; }
       
    99 	CWindowGc* Gc()					{ return iGc; }
       
   100 	RWsSession& Ws()				{ return iWs; }
       
   101 	RFs& Fs()						{ return iFs; }
       
   102 	TBool RectCompare(const TRect& a, const TRect& b);
       
   103 	TInt CountColorsL(const TRect& aRect, TInt aMin, TInt aMax);
       
   104 protected:
       
   105 	CActiveWait* iWaiter;
       
   106 	CAnimationTestWindow* iAnimTestWin;
       
   107 	CAnimBackdropWindow* iAnimBackdropWin;
       
   108 	
       
   109 	RWsSession iWs;
       
   110 	RFs iFs;
       
   111 	CWsScreenDevice* iScreen;
       
   112 	CWindowGc* iGc;
       
   113 
       
   114 	CCnvCharacterSetConverter* iConverter;
       
   115 	TInt iConverterState;
       
   116 	CTestEventHandler* iEventHandler;
       
   117 	CTestRedrawHandler* iRedrawHandler;
       
   118 	CTestWindowGroup* iGroupWin;
       
   119 	TSize iStepWinSize;
       
   120 	TRgb iBackgroundColor1;
       
   121 	TRgb iBackgroundColor2;
       
   122 	TDisplayMode iDisplayMode;
       
   123 	RArray<TUint> iColors;
       
   124 	};
       
   125 
       
   126 #endif //__ANIMATIONTESTSTEP_H__