os/graphics/windowing/windowserver/test/tauto/TTransptAnim.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/windowing/windowserver/test/tauto/TTransptAnim.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,203 @@
     1.4 +
     1.5 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +// All rights reserved.
     1.7 +// This component and the accompanying materials are made available
     1.8 +// under the terms of "Eclipse Public License v1.0"
     1.9 +// which accompanies this distribution, and is available
    1.10 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +//
    1.12 +// Initial Contributors:
    1.13 +// Nokia Corporation - initial contribution.
    1.14 +//
    1.15 +// Contributors:
    1.16 +//
    1.17 +// Description:
    1.18 +//
    1.19 +
    1.20 +/**
    1.21 + @file
    1.22 + @test
    1.23 + @internalComponent - Internal Symbian test code
    1.24 +*/
    1.25 +#ifndef __TTRANSPTANIM__
    1.26 +#define __TTRANSPTANIM__
    1.27 +
    1.28 +#include <e32std.h>
    1.29 +#include <e32base.h>
    1.30 +#include <w32std.h>
    1.31 +#include "../tlib/testbase.h"
    1.32 +#include "AUTO.H"
    1.33 +#include "AUTODLL.H"
    1.34 +
    1.35 +enum
    1.36 +	{
    1.37 +	GraphicsWServ0483 = 0
    1.38 +	};
    1.39 +
    1.40 +class CTTestCase;
    1.41 +class CTransAnimTimer;
    1.42 +class CTTransparentAnim;
    1.43 +class CTTAnimation;
    1.44 +class MAnimationObserver;
    1.45 +
    1.46 +class CTTransparentAnim : public CTWsGraphicsBase
    1.47 +	{
    1.48 +public:
    1.49 +	static CTTestCase* CreateTestCaseL(CTTransparentAnim*, TInt);
    1.50 +public:
    1.51 +	CTTransparentAnim(CTestStep*);
    1.52 +	virtual ~CTTransparentAnim();
    1.53 +	void ConstructL();
    1.54 +
    1.55 +	void SetCurrent(CTTestCase*);
    1.56 +	CTTestCase* GetCurrent();
    1.57 +protected:
    1.58 +	virtual void RunTestCaseL(TInt);
    1.59 +	
    1.60 +private:
    1.61 +	CTTestCase* iCurrentTestCase;
    1.62 +	};
    1.63 +
    1.64 +class CTTransparentAnimStep : public CTGraphicsStep
    1.65 +	{
    1.66 +public:
    1.67 +	CTTransparentAnimStep();
    1.68 +
    1.69 +protected:
    1.70 +	virtual CTGraphicsBase* CreateTestL();
    1.71 +	};
    1.72 +
    1.73 +class CTransAnimTimer : public CTimer
    1.74 +	{
    1.75 +public:
    1.76 +	CTransAnimTimer();
    1.77 +	~CTransAnimTimer();
    1.78 +	void ConstructL();
    1.79 +	void Start(TTimeIntervalMicroSeconds32 aInterval,TCallBack aCallBack);
    1.80 +private:
    1.81 +	void RunL();
    1.82 +	TCallBack iCallBack;
    1.83 +	};
    1.84 +
    1.85 +class CTTAnimation
    1.86 +	{
    1.87 +public:
    1.88 +	CTTAnimation(CTWin*, TInt);
    1.89 +	~CTTAnimation();
    1.90 +	
    1.91 +	void StartL();
    1.92 +	TBool IsComplete();
    1.93 +	void SetCurrentFrameSet(TInt);
    1.94 +	CTWin* GetWindow();
    1.95 +	void Attach(MAnimationObserver*);
    1.96 +private:
    1.97 +	static TInt NextFrame(TAny*);
    1.98 +	void NextFrame();
    1.99 +
   1.100 +private:
   1.101 +	CTWin* iWin;
   1.102 +	MAnimationObserver* iObserver;
   1.103 +	RAnimDll iAnimDll;
   1.104 +	RTestAnim iDrawAnim;
   1.105 +	CTransAnimTimer iAnimTimer;
   1.106 +	TInt iFrameCount;
   1.107 +	TInt iCurrentFrameSet;
   1.108 +	TBool iIsComplete;
   1.109 +	TInt iDrawArg;
   1.110 +	};
   1.111 +
   1.112 +template <TBool AlphaTransparency = EFalse>
   1.113 +class CTAnimWin : public CTWin
   1.114 +	{
   1.115 +public:
   1.116 +	static CTWin* NewL(TPoint aPosition, TSize aSize)
   1.117 +		{
   1.118 +		CTAnimWin* w = new(ELeave) CTAnimWin();
   1.119 +	
   1.120 +		CleanupStack::PushL(w);
   1.121 +		w->ConstructL(aPosition, aSize);
   1.122 +		CleanupStack::Pop();
   1.123 +		
   1.124 +		return w;	
   1.125 +		}
   1.126 +public:
   1.127 +	virtual ~CTAnimWin(){}
   1.128 +
   1.129 +	void Draw(){}
   1.130 +private:
   1.131 +	CTAnimWin(){}
   1.132 +
   1.133 +	void ConstructL(TPoint aPoint, TSize aSize)
   1.134 +		{
   1.135 +		TRgb bgColor(150, 150, 150);
   1.136 +		ConstructExtLD(*TheClient->iGroup, aPoint, aSize);
   1.137 +		AssignGC(*TheClient->iGc);
   1.138 +		Win()->SetRequiredDisplayMode(EColor16MA);
   1.139 +		if (AlphaTransparency)
   1.140 +			{
   1.141 +			Win()->SetTransparencyAlphaChannel();
   1.142 +			bgColor.SetAlpha(150);
   1.143 +			}
   1.144 +		Win()->SetBackgroundColor(bgColor);
   1.145 +		Win()->Activate();
   1.146 +		}
   1.147 +	};
   1.148 +
   1.149 +//*****************************************************************************
   1.150 +class MAnimationObserver
   1.151 +	{
   1.152 +public:
   1.153 +	virtual void Update(CTTAnimation*) = 0;
   1.154 +	};
   1.155 +
   1.156 +class CTTestCase : public MAnimationObserver
   1.157 +	{
   1.158 +public:
   1.159 +	CTTestCase();
   1.160 +	virtual ~CTTestCase() {}
   1.161 +
   1.162 +	TBool IsAlreadyRunning();
   1.163 +	TBool IsComplete();
   1.164 +	void StartL();
   1.165 +	TBool HasFailed();
   1.166 +	void SetError(TInt);
   1.167 +	
   1.168 +	// Implemented for MAnimationObserver
   1.169 +	virtual void Update(CTTAnimation*);
   1.170 +	virtual void ConstructL() = 0;
   1.171 +	virtual TPtrC TestCaseName() = 0;
   1.172 +
   1.173 +protected:
   1.174 +	virtual void RunTestCaseL() = 0;
   1.175 +	void SetIsCompleted(TBool);
   1.176 +	
   1.177 +private:
   1.178 +	TInt iError;
   1.179 +	TBool iIsComplete;
   1.180 +	TBool iIsRunning;
   1.181 +	};
   1.182 +
   1.183 +class CTGraphicsWServ0483 : public CTTestCase
   1.184 +	{
   1.185 +public:
   1.186 +	static CTGraphicsWServ0483* NewL();
   1.187 +	
   1.188 +public:
   1.189 +	virtual ~CTGraphicsWServ0483();
   1.190 +	virtual void RunTestCaseL();
   1.191 +	
   1.192 +	void Update(CTTAnimation*);
   1.193 +	
   1.194 +protected:
   1.195 +	CTGraphicsWServ0483(){}
   1.196 +	virtual void ConstructL();
   1.197 +	virtual TPtrC TestCaseName();	
   1.198 +	
   1.199 +private:
   1.200 +	CTTAnimation* iAnim;
   1.201 +	CTTAnimation* iCheckAnim;
   1.202 +	};
   1.203 +
   1.204 +_LIT(KTTransparentAnimStep,"TTransparentAnim");
   1.205 +
   1.206 +#endif // __TTRANSPTANIM__