os/graphics/windowing/windowserver/test/tauto/TTransptAnim.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.
sl@0
     1
sl@0
     2
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
// All rights reserved.
sl@0
     4
// This component and the accompanying materials are made available
sl@0
     5
// under the terms of "Eclipse Public License v1.0"
sl@0
     6
// which accompanies this distribution, and is available
sl@0
     7
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
//
sl@0
     9
// Initial Contributors:
sl@0
    10
// Nokia Corporation - initial contribution.
sl@0
    11
//
sl@0
    12
// Contributors:
sl@0
    13
//
sl@0
    14
// Description:
sl@0
    15
//
sl@0
    16
sl@0
    17
/**
sl@0
    18
 @file
sl@0
    19
 @test
sl@0
    20
 @internalComponent - Internal Symbian test code
sl@0
    21
*/
sl@0
    22
#ifndef __TTRANSPTANIM__
sl@0
    23
#define __TTRANSPTANIM__
sl@0
    24
sl@0
    25
#include <e32std.h>
sl@0
    26
#include <e32base.h>
sl@0
    27
#include <w32std.h>
sl@0
    28
#include "../tlib/testbase.h"
sl@0
    29
#include "AUTO.H"
sl@0
    30
#include "AUTODLL.H"
sl@0
    31
sl@0
    32
enum
sl@0
    33
	{
sl@0
    34
	GraphicsWServ0483 = 0
sl@0
    35
	};
sl@0
    36
sl@0
    37
class CTTestCase;
sl@0
    38
class CTransAnimTimer;
sl@0
    39
class CTTransparentAnim;
sl@0
    40
class CTTAnimation;
sl@0
    41
class MAnimationObserver;
sl@0
    42
sl@0
    43
class CTTransparentAnim : public CTWsGraphicsBase
sl@0
    44
	{
sl@0
    45
public:
sl@0
    46
	static CTTestCase* CreateTestCaseL(CTTransparentAnim*, TInt);
sl@0
    47
public:
sl@0
    48
	CTTransparentAnim(CTestStep*);
sl@0
    49
	virtual ~CTTransparentAnim();
sl@0
    50
	void ConstructL();
sl@0
    51
sl@0
    52
	void SetCurrent(CTTestCase*);
sl@0
    53
	CTTestCase* GetCurrent();
sl@0
    54
protected:
sl@0
    55
	virtual void RunTestCaseL(TInt);
sl@0
    56
	
sl@0
    57
private:
sl@0
    58
	CTTestCase* iCurrentTestCase;
sl@0
    59
	};
sl@0
    60
sl@0
    61
class CTTransparentAnimStep : public CTGraphicsStep
sl@0
    62
	{
sl@0
    63
public:
sl@0
    64
	CTTransparentAnimStep();
sl@0
    65
sl@0
    66
protected:
sl@0
    67
	virtual CTGraphicsBase* CreateTestL();
sl@0
    68
	};
sl@0
    69
sl@0
    70
class CTransAnimTimer : public CTimer
sl@0
    71
	{
sl@0
    72
public:
sl@0
    73
	CTransAnimTimer();
sl@0
    74
	~CTransAnimTimer();
sl@0
    75
	void ConstructL();
sl@0
    76
	void Start(TTimeIntervalMicroSeconds32 aInterval,TCallBack aCallBack);
sl@0
    77
private:
sl@0
    78
	void RunL();
sl@0
    79
	TCallBack iCallBack;
sl@0
    80
	};
sl@0
    81
sl@0
    82
class CTTAnimation
sl@0
    83
	{
sl@0
    84
public:
sl@0
    85
	CTTAnimation(CTWin*, TInt);
sl@0
    86
	~CTTAnimation();
sl@0
    87
	
sl@0
    88
	void StartL();
sl@0
    89
	TBool IsComplete();
sl@0
    90
	void SetCurrentFrameSet(TInt);
sl@0
    91
	CTWin* GetWindow();
sl@0
    92
	void Attach(MAnimationObserver*);
sl@0
    93
private:
sl@0
    94
	static TInt NextFrame(TAny*);
sl@0
    95
	void NextFrame();
sl@0
    96
sl@0
    97
private:
sl@0
    98
	CTWin* iWin;
sl@0
    99
	MAnimationObserver* iObserver;
sl@0
   100
	RAnimDll iAnimDll;
sl@0
   101
	RTestAnim iDrawAnim;
sl@0
   102
	CTransAnimTimer iAnimTimer;
sl@0
   103
	TInt iFrameCount;
sl@0
   104
	TInt iCurrentFrameSet;
sl@0
   105
	TBool iIsComplete;
sl@0
   106
	TInt iDrawArg;
sl@0
   107
	};
sl@0
   108
sl@0
   109
template <TBool AlphaTransparency = EFalse>
sl@0
   110
class CTAnimWin : public CTWin
sl@0
   111
	{
sl@0
   112
public:
sl@0
   113
	static CTWin* NewL(TPoint aPosition, TSize aSize)
sl@0
   114
		{
sl@0
   115
		CTAnimWin* w = new(ELeave) CTAnimWin();
sl@0
   116
	
sl@0
   117
		CleanupStack::PushL(w);
sl@0
   118
		w->ConstructL(aPosition, aSize);
sl@0
   119
		CleanupStack::Pop();
sl@0
   120
		
sl@0
   121
		return w;	
sl@0
   122
		}
sl@0
   123
public:
sl@0
   124
	virtual ~CTAnimWin(){}
sl@0
   125
sl@0
   126
	void Draw(){}
sl@0
   127
private:
sl@0
   128
	CTAnimWin(){}
sl@0
   129
sl@0
   130
	void ConstructL(TPoint aPoint, TSize aSize)
sl@0
   131
		{
sl@0
   132
		TRgb bgColor(150, 150, 150);
sl@0
   133
		ConstructExtLD(*TheClient->iGroup, aPoint, aSize);
sl@0
   134
		AssignGC(*TheClient->iGc);
sl@0
   135
		Win()->SetRequiredDisplayMode(EColor16MA);
sl@0
   136
		if (AlphaTransparency)
sl@0
   137
			{
sl@0
   138
			Win()->SetTransparencyAlphaChannel();
sl@0
   139
			bgColor.SetAlpha(150);
sl@0
   140
			}
sl@0
   141
		Win()->SetBackgroundColor(bgColor);
sl@0
   142
		Win()->Activate();
sl@0
   143
		}
sl@0
   144
	};
sl@0
   145
sl@0
   146
//*****************************************************************************
sl@0
   147
class MAnimationObserver
sl@0
   148
	{
sl@0
   149
public:
sl@0
   150
	virtual void Update(CTTAnimation*) = 0;
sl@0
   151
	};
sl@0
   152
sl@0
   153
class CTTestCase : public MAnimationObserver
sl@0
   154
	{
sl@0
   155
public:
sl@0
   156
	CTTestCase();
sl@0
   157
	virtual ~CTTestCase() {}
sl@0
   158
sl@0
   159
	TBool IsAlreadyRunning();
sl@0
   160
	TBool IsComplete();
sl@0
   161
	void StartL();
sl@0
   162
	TBool HasFailed();
sl@0
   163
	void SetError(TInt);
sl@0
   164
	
sl@0
   165
	// Implemented for MAnimationObserver
sl@0
   166
	virtual void Update(CTTAnimation*);
sl@0
   167
	virtual void ConstructL() = 0;
sl@0
   168
	virtual TPtrC TestCaseName() = 0;
sl@0
   169
sl@0
   170
protected:
sl@0
   171
	virtual void RunTestCaseL() = 0;
sl@0
   172
	void SetIsCompleted(TBool);
sl@0
   173
	
sl@0
   174
private:
sl@0
   175
	TInt iError;
sl@0
   176
	TBool iIsComplete;
sl@0
   177
	TBool iIsRunning;
sl@0
   178
	};
sl@0
   179
sl@0
   180
class CTGraphicsWServ0483 : public CTTestCase
sl@0
   181
	{
sl@0
   182
public:
sl@0
   183
	static CTGraphicsWServ0483* NewL();
sl@0
   184
	
sl@0
   185
public:
sl@0
   186
	virtual ~CTGraphicsWServ0483();
sl@0
   187
	virtual void RunTestCaseL();
sl@0
   188
	
sl@0
   189
	void Update(CTTAnimation*);
sl@0
   190
	
sl@0
   191
protected:
sl@0
   192
	CTGraphicsWServ0483(){}
sl@0
   193
	virtual void ConstructL();
sl@0
   194
	virtual TPtrC TestCaseName();	
sl@0
   195
	
sl@0
   196
private:
sl@0
   197
	CTTAnimation* iAnim;
sl@0
   198
	CTTAnimation* iCheckAnim;
sl@0
   199
	};
sl@0
   200
sl@0
   201
_LIT(KTTransparentAnimStep,"TTransparentAnim");
sl@0
   202
sl@0
   203
#endif // __TTRANSPTANIM__