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