|
1 /* |
|
2 * Copyright (c) 2002 - 2007 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: Test AknBitmapAnimation.h |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // [INCLUDE FILES] |
|
21 #include <e32svr.h> |
|
22 #include <stifparser.h> |
|
23 #include <stiftestinterface.h> |
|
24 #include <aknbitmapanimation.h> |
|
25 #include <w32std.h> |
|
26 #include <bmpancli.h> |
|
27 #include <barsread.h> |
|
28 #include <coeaui.h> |
|
29 #include <avkon.rsg> |
|
30 #include <aknsconstants.h> |
|
31 #include <testsdkanimation.rsg> |
|
32 |
|
33 #include "testsdkacontrol.h" |
|
34 #include "testsdkanimation.h" |
|
35 |
|
36 // ============================ MEMBER FUNCTIONS =============================== |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // CTestSDKAnimation::Delete |
|
40 // Delete here all resources allocated and opened from test methods. |
|
41 // Called from destructor. |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 void CTestSDKAnimation::Delete() |
|
45 { |
|
46 |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CTestSDKAnimation::RunMethodL |
|
51 // Run specified method. Contains also table of test mothods and their names. |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 TInt CTestSDKAnimation::RunMethodL( |
|
55 CStifItemParser& aItem ) |
|
56 { |
|
57 |
|
58 static TStifFunctionInfo const KFunctions[] = |
|
59 { |
|
60 ENTRY( "TestBANewL", CTestSDKAnimation::TestBANewL ), |
|
61 ENTRY( "TestBADeconstructorL", CTestSDKAnimation::TestBADeconstructorL ), |
|
62 ENTRY( "TestBAAnimationL", CTestSDKAnimation::TestBAAnimationL ), |
|
63 ENTRY( "TestBABitmapAnimDataL", CTestSDKAnimation::TestBABitmapAnimDataL ), |
|
64 ENTRY( "TestBACancelAnimationL", CTestSDKAnimation::TestBACancelAnimationL ), |
|
65 ENTRY( "TestBASetFrameIndexL", CTestSDKAnimation::TestBASetFrameIndexL ), |
|
66 ENTRY( "TestBASetFrameIntervalL", CTestSDKAnimation::TestBASetFrameIntervalL ), |
|
67 ENTRY( "TestBAStartAnimationL", CTestSDKAnimation::TestBAStartAnimationL ), |
|
68 ENTRY( "TestBASetScaleModeForAnimationFramesL", CTestSDKAnimation::TestBASetScaleModeForAnimationFramesL ), |
|
69 ENTRY( "TestBASetScaleModeForAnimationBackgroundFrameL", CTestSDKAnimation::TestBASetScaleModeForAnimationBackgroundFrameL ), |
|
70 ENTRY( "TestBAExcludeAnimationFramesFromCacheL", CTestSDKAnimation::TestBAExcludeAnimationFramesFromCacheL ), |
|
71 ENTRY( "TestBAConstructFromSkinL", CTestSDKAnimation::TestBAConstructFromSkinL ), |
|
72 ENTRY( "TestBAConstructFromResourceL", CTestSDKAnimation::TestBAConstructFromResourceL ), |
|
73 ENTRY( "TestBAMinimumSizeL", CTestSDKAnimation::TestBAMinimumSizeL ), |
|
74 |
|
75 // [test cases entries] |
|
76 |
|
77 }; |
|
78 |
|
79 const TInt count = sizeof( KFunctions ) / sizeof( TStifFunctionInfo ); |
|
80 |
|
81 return RunInternalL( KFunctions, count, aItem ); |
|
82 |
|
83 } |
|
84 |
|
85 /* class CAknBitmapAnimation */ |
|
86 // ----------------------------------------------------------------------------- |
|
87 // CTestSDKAnimation::TestBANewL |
|
88 // ----------------------------------------------------------------------------- |
|
89 TInt CTestSDKAnimation::TestBANewL( CStifItemParser& /*aItem*/ ) |
|
90 { |
|
91 CAknBitmapAnimation* bitmapanimation = CAknBitmapAnimation::NewL(); |
|
92 CleanupStack::PushL( bitmapanimation ); |
|
93 |
|
94 STIF_ASSERT_NOT_NULL( bitmapanimation ); |
|
95 |
|
96 CleanupStack::PopAndDestroy( bitmapanimation ); |
|
97 |
|
98 return KErrNone; |
|
99 |
|
100 } |
|
101 |
|
102 // ----------------------------------------------------------------------------- |
|
103 // CTestSDKAnimation::TestBADeconstructorL |
|
104 // ----------------------------------------------------------------------------- |
|
105 TInt CTestSDKAnimation::TestBADeconstructorL( CStifItemParser& /*aItem*/ ) |
|
106 { |
|
107 CAknBitmapAnimation* bitmapanimation = CAknBitmapAnimation::NewL(); |
|
108 CleanupStack::PushL( bitmapanimation ); |
|
109 |
|
110 STIF_ASSERT_NOT_NULL( bitmapanimation ); |
|
111 |
|
112 CleanupStack::Pop( bitmapanimation ); |
|
113 delete bitmapanimation; |
|
114 |
|
115 return KErrNone; |
|
116 |
|
117 } |
|
118 |
|
119 // ----------------------------------------------------------------------------- |
|
120 // CTestSDKAnimation::TestBAAnimationL |
|
121 // ----------------------------------------------------------------------------- |
|
122 TInt CTestSDKAnimation::TestBAAnimationL( CStifItemParser& /*aItem*/ ) |
|
123 { |
|
124 CAknBitmapAnimation* bitmapanimation = CAknBitmapAnimation::NewL(); |
|
125 CleanupStack::PushL( bitmapanimation ); |
|
126 |
|
127 STIF_ASSERT_NOT_NULL( bitmapanimation ); |
|
128 |
|
129 RBitmapAnim& bitmapanim = bitmapanimation->Animation(); |
|
130 STIF_ASSERT_NOT_NULL( &bitmapanim ); |
|
131 |
|
132 CleanupStack::PopAndDestroy( bitmapanimation ); |
|
133 |
|
134 return KErrNone; |
|
135 |
|
136 } |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // CTestSDKAnimation::TestBABitmapAnimDataL |
|
140 // ----------------------------------------------------------------------------- |
|
141 TInt CTestSDKAnimation::TestBABitmapAnimDataL( CStifItemParser& /*aItem*/ ) |
|
142 { |
|
143 CAknBitmapAnimation* bitmapanimation = CAknBitmapAnimation::NewL(); |
|
144 CleanupStack::PushL( bitmapanimation ); |
|
145 |
|
146 STIF_ASSERT_NOT_NULL( bitmapanimation ); |
|
147 |
|
148 CBitmapAnimClientData* clientdata = bitmapanimation->BitmapAnimData(); |
|
149 |
|
150 STIF_ASSERT_NOT_NULL( clientdata ); |
|
151 |
|
152 CleanupStack::PopAndDestroy( bitmapanimation ); |
|
153 |
|
154 return KErrNone; |
|
155 |
|
156 } |
|
157 |
|
158 // ----------------------------------------------------------------------------- |
|
159 // CTestSDKAnimation::TestBACancelAnimationL |
|
160 // ----------------------------------------------------------------------------- |
|
161 TInt CTestSDKAnimation::TestBACancelAnimationL( CStifItemParser& /*aItem*/ ) |
|
162 { |
|
163 CTestControl* control = CTestControl::NewL(); |
|
164 CleanupStack::PushL( control ); |
|
165 |
|
166 CCoeEnv::Static()->AppUi()->AddToStackL( control ); |
|
167 |
|
168 control->TestCancelL(); |
|
169 |
|
170 CCoeEnv::Static()->AppUi()->RemoveFromStack( control ); |
|
171 |
|
172 CleanupStack::PopAndDestroy( control ); |
|
173 |
|
174 return KErrNone; |
|
175 |
|
176 } |
|
177 |
|
178 // ----------------------------------------------------------------------------- |
|
179 // CTestSDKAnimation::TestBASetFrameIndexL |
|
180 // ----------------------------------------------------------------------------- |
|
181 TInt CTestSDKAnimation::TestBASetFrameIndexL( CStifItemParser& /*aItem*/ ) |
|
182 { |
|
183 CTestControl* control = CTestControl::NewL(); |
|
184 CleanupStack::PushL( control ); |
|
185 |
|
186 CCoeEnv::Static()->AppUi()->AddToStackL( control ); |
|
187 |
|
188 control->SetFrameIndexL( 0 ); |
|
189 |
|
190 CCoeEnv::Static()->AppUi()->RemoveFromStack( control ); |
|
191 |
|
192 CleanupStack::PopAndDestroy( control ); |
|
193 |
|
194 return KErrNone; |
|
195 |
|
196 } |
|
197 |
|
198 // ----------------------------------------------------------------------------- |
|
199 // CTestSDKAnimation::TestBASetFrameIntervalL |
|
200 // ----------------------------------------------------------------------------- |
|
201 TInt CTestSDKAnimation::TestBASetFrameIntervalL( CStifItemParser& /*aItem*/ ) |
|
202 { |
|
203 CTestControl* control = CTestControl::NewL(); |
|
204 CleanupStack::PushL( control ); |
|
205 |
|
206 CCoeEnv::Static()->AppUi()->AddToStackL( control ); |
|
207 |
|
208 const TInt frameIntervalInMilliSeconds = 1500; |
|
209 control->SetFrameIntervalL(frameIntervalInMilliSeconds); |
|
210 |
|
211 CCoeEnv::Static()->AppUi()->RemoveFromStack( control ); |
|
212 |
|
213 CleanupStack::PopAndDestroy( control ); |
|
214 |
|
215 return KErrNone; |
|
216 |
|
217 } |
|
218 |
|
219 // ----------------------------------------------------------------------------- |
|
220 // CTestSDKAnimation::TestBAStartAnimationL |
|
221 // ----------------------------------------------------------------------------- |
|
222 TInt CTestSDKAnimation::TestBAStartAnimationL( CStifItemParser& /*aItem*/ ) |
|
223 { |
|
224 CTestControl* control = CTestControl::NewL(); |
|
225 CleanupStack::PushL( control ); |
|
226 |
|
227 CCoeEnv::Static()->AppUi()->AddToStackL( control ); |
|
228 |
|
229 control->TestRunL(); |
|
230 |
|
231 CCoeEnv::Static()->AppUi()->RemoveFromStack( control ); |
|
232 |
|
233 CleanupStack::PopAndDestroy( control ); |
|
234 |
|
235 return KErrNone; |
|
236 |
|
237 } |
|
238 |
|
239 // ----------------------------------------------------------------------------- |
|
240 // CTestSDKAnimation::TestBASetScaleModeForAnimationFramesL |
|
241 // ----------------------------------------------------------------------------- |
|
242 TInt CTestSDKAnimation::TestBASetScaleModeForAnimationFramesL( CStifItemParser& /*aItem*/ ) |
|
243 { |
|
244 CAknBitmapAnimation* bitmapanimation = CAknBitmapAnimation::NewL(); |
|
245 CleanupStack::PushL( bitmapanimation ); |
|
246 |
|
247 STIF_ASSERT_NOT_NULL( bitmapanimation ); |
|
248 |
|
249 TScaleMode mode = TScaleMode( EAspectRatioPreserved ); |
|
250 bitmapanimation->SetScaleModeForAnimationFrames( mode ); |
|
251 |
|
252 CleanupStack::PopAndDestroy( bitmapanimation ); |
|
253 |
|
254 return KErrNone; |
|
255 |
|
256 } |
|
257 |
|
258 // ----------------------------------------------------------------------------- |
|
259 // CTestSDKAnimation::TestBASetScaleModeForAnimationBackgroundFrameL |
|
260 // ----------------------------------------------------------------------------- |
|
261 TInt CTestSDKAnimation::TestBASetScaleModeForAnimationBackgroundFrameL( CStifItemParser& /*aItem*/ ) |
|
262 { |
|
263 CAknBitmapAnimation* bitmapanimation = CAknBitmapAnimation::NewL(); |
|
264 CleanupStack::PushL( bitmapanimation ); |
|
265 |
|
266 STIF_ASSERT_NOT_NULL( bitmapanimation ); |
|
267 |
|
268 TScaleMode mode = TScaleMode( EAspectRatioPreserved ); |
|
269 bitmapanimation->SetScaleModeForAnimationBackgroundFrame( mode ); |
|
270 |
|
271 CleanupStack::PopAndDestroy( bitmapanimation ); |
|
272 |
|
273 return KErrNone; |
|
274 |
|
275 } |
|
276 |
|
277 // ----------------------------------------------------------------------------- |
|
278 // CTestSDKAnimation::TestBAExcludeAnimationFramesFromCacheL |
|
279 // ----------------------------------------------------------------------------- |
|
280 TInt CTestSDKAnimation::TestBAExcludeAnimationFramesFromCacheL( CStifItemParser& /*aItem*/ ) |
|
281 { |
|
282 CAknBitmapAnimation* bitmapanimation = CAknBitmapAnimation::NewL(); |
|
283 CleanupStack::PushL( bitmapanimation ); |
|
284 |
|
285 STIF_ASSERT_NOT_NULL( bitmapanimation ); |
|
286 |
|
287 bitmapanimation->ExcludeAnimationFramesFromCache(); |
|
288 |
|
289 CleanupStack::PopAndDestroy( bitmapanimation ); |
|
290 |
|
291 return KErrNone; |
|
292 |
|
293 } |
|
294 |
|
295 // ----------------------------------------------------------------------------- |
|
296 // CTestSDKAnimation::TestBAConstructFromSkinL |
|
297 // ----------------------------------------------------------------------------- |
|
298 TInt CTestSDKAnimation::TestBAConstructFromSkinL( CStifItemParser& /*aItem*/ ) |
|
299 { |
|
300 CAknBitmapAnimation* bitmapanimation = CAknBitmapAnimation::NewL(); |
|
301 CleanupStack::PushL( bitmapanimation ); |
|
302 |
|
303 STIF_ASSERT_NOT_NULL( bitmapanimation ); |
|
304 |
|
305 TBool flag = bitmapanimation->ConstructFromSkinL( KAknsIIDQsnBgScreen ); |
|
306 STIF_ASSERT_FALSE( flag ); |
|
307 |
|
308 CleanupStack::PopAndDestroy( bitmapanimation ); |
|
309 |
|
310 return KErrNone; |
|
311 |
|
312 } |
|
313 |
|
314 // ----------------------------------------------------------------------------- |
|
315 // CTestSDKAnimation::TestBAConstructFromResourceL |
|
316 // ----------------------------------------------------------------------------- |
|
317 TInt CTestSDKAnimation::TestBAConstructFromResourceL( CStifItemParser& /*aItem*/ ) |
|
318 { |
|
319 CTestControl* control = CTestControl::NewL(); |
|
320 CleanupStack::PushL( control ); |
|
321 |
|
322 CCoeEnv::Static()->AppUi()->AddToStackL( control ); |
|
323 |
|
324 control->TestRunL(); |
|
325 |
|
326 CCoeEnv::Static()->AppUi()->RemoveFromStack( control ); |
|
327 |
|
328 CleanupStack::PopAndDestroy( control ); |
|
329 |
|
330 return KErrNone; |
|
331 |
|
332 } |
|
333 |
|
334 // ----------------------------------------------------------------------------- |
|
335 // CTestSDKAnimation::TestBAMinimumSizeL |
|
336 // ----------------------------------------------------------------------------- |
|
337 TInt CTestSDKAnimation::TestBAMinimumSizeL( CStifItemParser& /*aItem*/ ) |
|
338 { |
|
339 CAknBitmapAnimation* bitmapanimation = CAknBitmapAnimation::NewL(); |
|
340 CleanupStack::PushL( bitmapanimation ); |
|
341 |
|
342 STIF_ASSERT_NOT_NULL( bitmapanimation ); |
|
343 |
|
344 TSize size = bitmapanimation->MinimumSize(); |
|
345 |
|
346 TPoint point( size.AsPoint() ); |
|
347 |
|
348 STIF_ASSERT_EQUALS( 0, point.iX ); |
|
349 STIF_ASSERT_EQUALS( 0, point.iY ); |
|
350 |
|
351 CleanupStack::PopAndDestroy( bitmapanimation ); |
|
352 |
|
353 return KErrNone; |
|
354 |
|
355 } |
|
356 |
|
357 // [End of File] |