|
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 functions for alfutil.h |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // [INCLUDE FILES] |
|
21 #include <alf/alfutil.h> |
|
22 |
|
23 #include "testplatalfvisual.h" |
|
24 |
|
25 |
|
26 // CONSTANTS |
|
27 const TInt KArrayLen = 3; |
|
28 const TInt KLightPosArrayLen = 4; |
|
29 const TInt KDestMatArrayLen = 16; |
|
30 |
|
31 const TInt KGeneralNum = 256; |
|
32 |
|
33 const TInt KComponentsNum = 4; |
|
34 |
|
35 const TInt KRed = 16; // red |
|
36 const TInt KGreen = 24; // green |
|
37 const TInt KBlue = 32; // blue |
|
38 const TInt KAlpha = 255; // alpha |
|
39 |
|
40 const TInt KScreenW = 320; |
|
41 const TInt KScreenH = 200; |
|
42 const TInt KGeneralSize = 16; |
|
43 const TInt KScrBufSizeW = 160; |
|
44 const TInt KScrBufSizeH = 100; |
|
45 |
|
46 const TInt KSrcBufLen1 = KComponentsNum * KScreenW * KScreenH; |
|
47 const TInt KSrcBufLen2 = KComponentsNum * KScrBufSizeW * KScrBufSizeH; |
|
48 const TInt KDesBufLen = KComponentsNum * KGeneralSize * KGeneralSize; |
|
49 |
|
50 const TInt KTempSrcNum1 = KGeneralSize * KScrBufSizeW * KComponentsNum; |
|
51 const TInt KTempSrcNum2 = 2 * KGeneralSize * KScrBufSizeW * KComponentsNum; |
|
52 |
|
53 |
|
54 // ============================ MEMBER FUNCTIONS =============================== |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // CTestPlatAlfVisual::TestUtilPower2 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 TInt CTestPlatAlfVisual::TestUtilPower2( CStifItemParser& /*aItem*/ ) |
|
61 { |
|
62 // Print to UI |
|
63 _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" ); |
|
64 _LIT( KTestUtilPower2, "TestUtilPower2" ); |
|
65 TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestUtilPower2 ); |
|
66 // Print to log file |
|
67 iLog->Log( KTestUtilPower2 ); |
|
68 |
|
69 AlfUtil::Power2( 1 ); |
|
70 |
|
71 return KErrNone; |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // CTestPlatAlfVisual::TestUtilPower2RoundDown |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 TInt CTestPlatAlfVisual::TestUtilPower2RoundDown( CStifItemParser& /*aItem*/ ) |
|
79 { |
|
80 // Print to UI |
|
81 _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" ); |
|
82 _LIT( KTestUtilPower2RoundDown, "TestUtilPower2RoundDown" ); |
|
83 TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestUtilPower2RoundDown ); |
|
84 // Print to log file |
|
85 iLog->Log( KTestUtilPower2RoundDown ); |
|
86 |
|
87 AlfUtil::Power2RoundDown( 1 ); |
|
88 |
|
89 return KErrNone; |
|
90 } |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // CTestPlatAlfVisual::TestUtilInterpolate |
|
94 // ----------------------------------------------------------------------------- |
|
95 // |
|
96 TInt CTestPlatAlfVisual::TestUtilInterpolate( CStifItemParser& /*aItem*/ ) |
|
97 { |
|
98 // Print to UI |
|
99 _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" ); |
|
100 _LIT( KTestUtilInterpolate, "TestUtilInterpolate" ); |
|
101 TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestUtilInterpolate ); |
|
102 // Print to log file |
|
103 iLog->Log( KTestUtilInterpolate ); |
|
104 |
|
105 AlfUtil::Interpolate( 1.0, 1.0, 2.0 ); |
|
106 |
|
107 return KErrNone; |
|
108 } |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // CTestPlatAlfVisual::TestUtilWrapValue |
|
112 // ----------------------------------------------------------------------------- |
|
113 // |
|
114 TInt CTestPlatAlfVisual::TestUtilWrapValue( CStifItemParser& /*aItem*/ ) |
|
115 { |
|
116 // Print to UI |
|
117 _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" ); |
|
118 _LIT( KTestUtilWrapValue, "TestUtilWrapValue" ); |
|
119 TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestUtilWrapValue ); |
|
120 // Print to log file |
|
121 iLog->Log( KTestUtilWrapValue ); |
|
122 |
|
123 TReal32 value = 0.0; |
|
124 AlfUtil::WrapValue( value, 1.0, 1.0 );//aHigh - aLow <= 0 |
|
125 AlfUtil::WrapValue( value, 1.0, 2.0 );//aHigh - aLow > 0 && aValue < aLow |
|
126 value = 2.0; |
|
127 AlfUtil::WrapValue( value, 1.0, 2.0 );//aHigh - aLow > 0 && aValue >= aHigh |
|
128 value = 1.0; |
|
129 AlfUtil::WrapValue( value, 1.0, 2.0 );//aHigh - aLow > 0 && aValue >= aLow && aValue < aHigh |
|
130 |
|
131 return KErrNone; |
|
132 } |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // CTestPlatAlfVisual::TestUtilRandomInt |
|
136 // ----------------------------------------------------------------------------- |
|
137 // |
|
138 TInt CTestPlatAlfVisual::TestUtilRandomInt( CStifItemParser& /*aItem*/ ) |
|
139 { |
|
140 // Print to UI |
|
141 _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" ); |
|
142 _LIT( KTestUtilRandomInt, "TestUtilRandomInt" ); |
|
143 TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestUtilRandomInt ); |
|
144 // Print to log file |
|
145 iLog->Log( KTestUtilRandomInt ); |
|
146 |
|
147 AlfUtil::RandomInt( 1, 2 ); |
|
148 |
|
149 return KErrNone; |
|
150 } |
|
151 |
|
152 // ----------------------------------------------------------------------------- |
|
153 // CTestPlatAlfVisual::TestUtilRandomReal |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 TInt CTestPlatAlfVisual::TestUtilRandomReal( CStifItemParser& /*aItem*/ ) |
|
157 { |
|
158 // Print to UI |
|
159 _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" ); |
|
160 _LIT( KTestUtilRandomReal, "TestUtilRandomReal" ); |
|
161 TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestUtilRandomReal ); |
|
162 // Print to log file |
|
163 iLog->Log( KTestUtilRandomReal ); |
|
164 |
|
165 AlfUtil::RandomReal( 1.0, 3.0 ); |
|
166 |
|
167 return KErrNone; |
|
168 } |
|
169 |
|
170 // ----------------------------------------------------------------------------- |
|
171 // CTestPlatAlfVisual::TestUtilQuickLengthWithPoint |
|
172 // ----------------------------------------------------------------------------- |
|
173 // |
|
174 TInt CTestPlatAlfVisual::TestUtilQuickLengthWithPoint( CStifItemParser& /*aItem*/ ) |
|
175 { |
|
176 // Print to UI |
|
177 _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" ); |
|
178 _LIT( KTestUtilQuickLengthWithPoint, "TestUtilQuickLengthWithPoint" ); |
|
179 TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestUtilQuickLengthWithPoint ); |
|
180 // Print to log file |
|
181 iLog->Log( KTestUtilQuickLengthWithPoint ); |
|
182 |
|
183 TAlfRealPoint vector( 0.f, 1.f ); |
|
184 AlfUtil::QuickLength( vector );//Abs( aVector.iX ) < Abs( aVector.iY ) |
|
185 vector.iX = 2.0; |
|
186 AlfUtil::QuickLength( vector );//Abs( aVector.iX ) >= Abs( aVector.iY ) |
|
187 |
|
188 return KErrNone; |
|
189 } |
|
190 |
|
191 // ----------------------------------------------------------------------------- |
|
192 // CTestPlatAlfVisual::TestUtilQuickLength |
|
193 // ----------------------------------------------------------------------------- |
|
194 // |
|
195 TInt CTestPlatAlfVisual::TestUtilQuickLength( CStifItemParser& /*aItem*/ ) |
|
196 { |
|
197 // Print to UI |
|
198 _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" ); |
|
199 _LIT( KTestUtilQuickLength, "TestUtilQuickLength" ); |
|
200 TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestUtilQuickLength ); |
|
201 // Print to log file |
|
202 iLog->Log( KTestUtilQuickLength ); |
|
203 |
|
204 AlfUtil::QuickLength( 1.0, 2.0 );//Abs( aDx ) < Abs( aDy ) |
|
205 AlfUtil::QuickLength( 2.0, 1.0 );//Abs( aDx ) >= Abs( aDy ) |
|
206 |
|
207 return KErrNone; |
|
208 } |
|
209 |
|
210 // ----------------------------------------------------------------------------- |
|
211 // CTestPlatAlfVisual::TestUtilQuickNormalize |
|
212 // ----------------------------------------------------------------------------- |
|
213 // |
|
214 TInt CTestPlatAlfVisual::TestUtilQuickNormalize( CStifItemParser& /*aItem*/ ) |
|
215 { |
|
216 // Print to UI |
|
217 _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" ); |
|
218 _LIT( KTestUtilQuickNormalize, "TestUtilQuickNormalize" ); |
|
219 TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestUtilQuickNormalize ); |
|
220 // Print to log file |
|
221 iLog->Log( KTestUtilQuickNormalize ); |
|
222 |
|
223 TAlfRealPoint normal; |
|
224 AlfUtil::QuickNormalize( normal ); |
|
225 |
|
226 return KErrNone; |
|
227 } |
|
228 |
|
229 // ----------------------------------------------------------------------------- |
|
230 // CTestPlatAlfVisual::TestUtilQuickNormalizeWithVector |
|
231 // ----------------------------------------------------------------------------- |
|
232 // |
|
233 TInt CTestPlatAlfVisual::TestUtilQuickNormalizeWithVector( CStifItemParser& /*aItem*/ ) |
|
234 { |
|
235 // Print to UI |
|
236 _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" ); |
|
237 _LIT( KTestUtilQuickNormalizeWithVector, "TestUtilQuickNormalizeWithVector" ); |
|
238 TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestUtilQuickNormalizeWithVector ); |
|
239 // Print to log file |
|
240 iLog->Log( KTestUtilQuickNormalizeWithVector ); |
|
241 |
|
242 TReal32 vector[3] = { 1.0, 2.0, 3.0 }; |
|
243 AlfUtil::QuickNormalize( vector ); |
|
244 |
|
245 return KErrNone; |
|
246 } |
|
247 |
|
248 // ----------------------------------------------------------------------------- |
|
249 // CTestPlatAlfVisual::TestUtilCrossProduct |
|
250 // ----------------------------------------------------------------------------- |
|
251 // |
|
252 TInt CTestPlatAlfVisual::TestUtilCrossProduct( CStifItemParser& /*aItem*/ ) |
|
253 { |
|
254 // Print to UI |
|
255 _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" ); |
|
256 _LIT( KTestUtilCrossProduct, "TestUtilCrossProduct" ); |
|
257 TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestUtilCrossProduct ); |
|
258 // Print to log file |
|
259 iLog->Log( KTestUtilCrossProduct ); |
|
260 |
|
261 TReal32 vectorA[ KArrayLen ] = { 1.0, 2.0, 3.0 }; |
|
262 TReal32 vectorB[ KArrayLen ] = { 1.0, 2.0, 3.0 }; |
|
263 TReal32 product[ KArrayLen ]; |
|
264 AlfUtil::CrossProduct( vectorA, vectorB, product ); |
|
265 |
|
266 return KErrNone; |
|
267 } |
|
268 |
|
269 // ----------------------------------------------------------------------------- |
|
270 // CTestPlatAlfVisual::TestUtilNormalFromPoints |
|
271 // ----------------------------------------------------------------------------- |
|
272 // |
|
273 TInt CTestPlatAlfVisual::TestUtilNormalFromPoints( CStifItemParser& /*aItem*/ ) |
|
274 { |
|
275 // Print to UI |
|
276 _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" ); |
|
277 _LIT( KTestUtilNormalFromPoints, "TestUtilNormalFromPoints" ); |
|
278 TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestUtilNormalFromPoints ); |
|
279 // Print to log file |
|
280 iLog->Log( KTestUtilNormalFromPoints ); |
|
281 |
|
282 TReal32 points[ KArrayLen ][ KArrayLen ] = |
|
283 { |
|
284 { 1.0, 2.0, 3.0 }, |
|
285 { 1.0, 2.0, 3.0 }, |
|
286 { 1.0, 2.0, 3.0 } |
|
287 }; |
|
288 TReal32 normal[ KArrayLen ]; |
|
289 |
|
290 AlfUtil::NormalFromPoints( points, normal ); |
|
291 |
|
292 return KErrNone; |
|
293 } |
|
294 |
|
295 // ----------------------------------------------------------------------------- |
|
296 // CTestPlatAlfVisual::TestUtilShadowMatrix |
|
297 // ----------------------------------------------------------------------------- |
|
298 // |
|
299 TInt CTestPlatAlfVisual::TestUtilShadowMatrix( CStifItemParser& /*aItem*/ ) |
|
300 { |
|
301 // Print to UI |
|
302 _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" ); |
|
303 _LIT( KTestUtilShadowMatrix, "TestUtilShadowMatrix" ); |
|
304 TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestUtilShadowMatrix ); |
|
305 // Print to log file |
|
306 iLog->Log( KTestUtilShadowMatrix ); |
|
307 |
|
308 TReal32 planePoint[ KArrayLen ] = { 1.0, 2.0, 3.0 }; |
|
309 TReal32 planeNormal[ KArrayLen ] = { 1.0, 2.0, 3.0 }; |
|
310 TReal32 lightPos[ KLightPosArrayLen ] = { 1.0, 2.0, 3.0, 4.0 }; |
|
311 TReal32 destMat[ KDestMatArrayLen ]; |
|
312 |
|
313 AlfUtil::ShadowMatrix( planePoint, planeNormal, lightPos, destMat ); |
|
314 |
|
315 return KErrNone; |
|
316 } |
|
317 |
|
318 // ----------------------------------------------------------------------------- |
|
319 // CTestPlatAlfVisual::TestUtilFreeMemory |
|
320 // ----------------------------------------------------------------------------- |
|
321 // |
|
322 TInt CTestPlatAlfVisual::TestUtilFreeMemory( CStifItemParser& /*aItem*/ ) |
|
323 { |
|
324 // Print to UI |
|
325 _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" ); |
|
326 _LIT( KTestUtilFreeMemory, "TestUtilFreeMemory" ); |
|
327 TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestUtilFreeMemory ); |
|
328 // Print to log file |
|
329 iLog->Log( KTestUtilFreeMemory ); |
|
330 |
|
331 TUint totalMemo; |
|
332 AlfUtil::FreeMemory( &totalMemo ); |
|
333 |
|
334 return KErrNone; |
|
335 } |
|
336 |
|
337 // ----------------------------------------------------------------------------- |
|
338 // CTestPlatAlfVisual::TestUtilScreenSize |
|
339 // ----------------------------------------------------------------------------- |
|
340 // |
|
341 TInt CTestPlatAlfVisual::TestUtilScreenSize( CStifItemParser& /*aItem*/ ) |
|
342 { |
|
343 // Print to UI |
|
344 _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" ); |
|
345 _LIT( KTestUtilScreenSize, "TestUtilScreenSize" ); |
|
346 TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestUtilScreenSize ); |
|
347 // Print to log file |
|
348 iLog->Log( KTestUtilScreenSize ); |
|
349 |
|
350 AlfUtil::ScreenSize(); |
|
351 |
|
352 return KErrNone; |
|
353 } |
|
354 |
|
355 // ----------------------------------------------------------------------------- |
|
356 // CTestPlatAlfVisual::TestUtilNearestFontInTwipsL |
|
357 // ----------------------------------------------------------------------------- |
|
358 // |
|
359 TInt CTestPlatAlfVisual::TestUtilNearestFontInTwipsL( CStifItemParser& /*aItem*/ ) |
|
360 { |
|
361 // Print to UI |
|
362 _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" ); |
|
363 _LIT( KTestUtilNearestFontInTwipsL, "TestUtilNearestFontInTwipsL" ); |
|
364 TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestUtilNearestFontInTwipsL ); |
|
365 // Print to log file |
|
366 iLog->Log( KTestUtilNearestFontInTwipsL ); |
|
367 |
|
368 TFontSpec fontSpec; |
|
369 AlfUtil::NearestFontInTwipsL( fontSpec ); |
|
370 |
|
371 return KErrNone; |
|
372 } |
|
373 |
|
374 // ----------------------------------------------------------------------------- |
|
375 // CTestPlatAlfVisual::TestUtilReleaseFont |
|
376 // ----------------------------------------------------------------------------- |
|
377 // |
|
378 TInt CTestPlatAlfVisual::TestUtilReleaseFont( CStifItemParser& /*aItem*/ ) |
|
379 { |
|
380 // Print to UI |
|
381 _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" ); |
|
382 _LIT( KTestUtilReleaseFont, "TestUtilReleaseFont" ); |
|
383 TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestUtilReleaseFont ); |
|
384 // Print to log file |
|
385 iLog->Log( KTestUtilReleaseFont ); |
|
386 |
|
387 CFont* font = NULL; |
|
388 AlfUtil::ReleaseFont( font ); |
|
389 |
|
390 return KErrNone; |
|
391 } |
|
392 |
|
393 // ----------------------------------------------------------------------------- |
|
394 // CTestPlatAlfVisual::TestUtilLengthUnit |
|
395 // ----------------------------------------------------------------------------- |
|
396 // |
|
397 TInt CTestPlatAlfVisual::TestUtilLengthUnit( CStifItemParser& /*aItem*/ ) |
|
398 { |
|
399 // Print to UI |
|
400 _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" ); |
|
401 _LIT( KTestUtilLengthUnit, "TestUtilLengthUnit" ); |
|
402 TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestUtilLengthUnit ); |
|
403 // Print to log file |
|
404 iLog->Log( KTestUtilLengthUnit ); |
|
405 |
|
406 AlfUtil::LengthUnit(); |
|
407 |
|
408 return KErrNone; |
|
409 } |
|
410 |
|
411 // ----------------------------------------------------------------------------- |
|
412 // CTestPlatAlfVisual::TestUtilColorLightness |
|
413 // ----------------------------------------------------------------------------- |
|
414 // |
|
415 TInt CTestPlatAlfVisual::TestUtilColorLightness( CStifItemParser& /*aItem*/ ) |
|
416 { |
|
417 // Print to UI |
|
418 _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" ); |
|
419 _LIT( KTestUtilColorLightness, "TestUtilColorLightness" ); |
|
420 TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestUtilColorLightness ); |
|
421 // Print to log file |
|
422 iLog->Log( KTestUtilColorLightness ); |
|
423 |
|
424 TRgb color; |
|
425 AlfUtil::ColorLightness( color ); |
|
426 |
|
427 return KErrNone; |
|
428 } |
|
429 |
|
430 // ----------------------------------------------------------------------------- |
|
431 // CTestPlatAlfVisual::TestUtilScaleFbsBitmapL |
|
432 // ----------------------------------------------------------------------------- |
|
433 // |
|
434 TInt CTestPlatAlfVisual::TestUtilScaleFbsBitmapL( CStifItemParser& /*aItem*/ ) |
|
435 { |
|
436 // Print to UI |
|
437 _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" ); |
|
438 _LIT( KTestUtilScaleFbsBitmapL, "TestUtilScaleFbsBitmapL" ); |
|
439 TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestUtilScaleFbsBitmapL ); |
|
440 // Print to log file |
|
441 iLog->Log( KTestUtilScaleFbsBitmapL ); |
|
442 |
|
443 TSize sizeInPixels = TSize( KGeneralNum, KGeneralNum ); |
|
444 CFbsBitmap *srcBmp = new ( ELeave ) CFbsBitmap(); |
|
445 CleanupStack::PushL( srcBmp ); |
|
446 User::LeaveIfError( srcBmp->Create( sizeInPixels, EColor16M ) ); |
|
447 CFbsBitmap *scaledBmp = new ( ELeave ) CFbsBitmap(); |
|
448 CleanupStack::PushL( scaledBmp ); |
|
449 User::LeaveIfError( scaledBmp->Create( sizeInPixels, EColor16MA ) ); |
|
450 AlfUtil::ScaleFbsBitmapL( *srcBmp, *scaledBmp ); |
|
451 CleanupStack::PopAndDestroy( scaledBmp ); |
|
452 CleanupStack::PopAndDestroy( srcBmp ); |
|
453 |
|
454 return KErrNone; |
|
455 } |
|
456 |
|
457 // ----------------------------------------------------------------------------- |
|
458 // CTestPlatAlfVisual::TestUtilCombineMaskFbsBitmapL |
|
459 // ----------------------------------------------------------------------------- |
|
460 // |
|
461 TInt CTestPlatAlfVisual::TestUtilCombineMaskFbsBitmapL( CStifItemParser& /*aItem*/ ) |
|
462 { |
|
463 // Print to UI |
|
464 _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" ); |
|
465 _LIT( KTestUtilCombineMaskFbsBitmapL, "TestUtilCombineMaskFbsBitmapL" ); |
|
466 TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestUtilCombineMaskFbsBitmapL ); |
|
467 // Print to log file |
|
468 iLog->Log( KTestUtilCombineMaskFbsBitmapL ); |
|
469 |
|
470 TSize sizeInPixels = TSize( KGeneralNum, KGeneralNum ); |
|
471 CFbsBitmap *srcBmp = new ( ELeave ) CFbsBitmap(); |
|
472 CleanupStack::PushL( srcBmp ); |
|
473 User::LeaveIfError( srcBmp->Create( sizeInPixels, EColor16M ) ); |
|
474 CFbsBitmap *srcMaskBmp = new ( ELeave ) CFbsBitmap(); |
|
475 CleanupStack::PushL( srcMaskBmp ); |
|
476 User::LeaveIfError( srcMaskBmp->Create( sizeInPixels, EGray2 ) ); |
|
477 CFbsBitmap *combinedBmp = new ( ELeave ) CFbsBitmap; |
|
478 CleanupStack::PushL( combinedBmp ); |
|
479 User::LeaveIfError( combinedBmp->Create( sizeInPixels, EColor16MA ) ); |
|
480 |
|
481 AlfUtil::CombineMaskFbsBitmapL( *srcBmp, *srcMaskBmp, *combinedBmp ); |
|
482 CleanupStack::PopAndDestroy( combinedBmp ); |
|
483 CleanupStack::PopAndDestroy( srcMaskBmp ); |
|
484 CleanupStack::PopAndDestroy( srcBmp ); |
|
485 |
|
486 return KErrNone; |
|
487 } |
|
488 |
|
489 // ----------------------------------------------------------------------------- |
|
490 // CTestPlatAlfVisual::TestUtilCropFbsBitmapL |
|
491 // ----------------------------------------------------------------------------- |
|
492 // |
|
493 TInt CTestPlatAlfVisual::TestUtilCropFbsBitmapL( CStifItemParser& /*aItem*/ ) |
|
494 { |
|
495 // Print to UI |
|
496 _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" ); |
|
497 _LIT( KTestUtilCropFbsBitmapL, "TestUtilCropFbsBitmapL" ); |
|
498 TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestUtilCropFbsBitmapL ); |
|
499 // Print to log file |
|
500 iLog->Log( KTestUtilCropFbsBitmapL ); |
|
501 |
|
502 TSize sizeInPixels = TSize( KGeneralNum, KGeneralNum ); |
|
503 CFbsBitmap *srcBmp = new ( ELeave ) CFbsBitmap(); |
|
504 CleanupStack::PushL( srcBmp ); |
|
505 User::LeaveIfError( srcBmp->Create( sizeInPixels, EColor16M ) ); |
|
506 CFbsBitmap *cropedBmp = new ( ELeave ) CFbsBitmap(); |
|
507 CleanupStack::PushL( cropedBmp ); |
|
508 User::LeaveIfError( cropedBmp->Create( sizeInPixels, EGray2 ) ); |
|
509 TPoint cropPos; |
|
510 AlfUtil::CropFbsBitmapL( *srcBmp, *cropedBmp, cropPos ); |
|
511 CleanupStack::PopAndDestroy( cropedBmp ); |
|
512 CleanupStack::PopAndDestroy( srcBmp ); |
|
513 |
|
514 return KErrNone; |
|
515 } |
|
516 |
|
517 // ----------------------------------------------------------------------------- |
|
518 // CTestPlatAlfVisual::TestUtilScaleImageL |
|
519 // ----------------------------------------------------------------------------- |
|
520 // |
|
521 TInt CTestPlatAlfVisual::TestUtilScaleImageL( CStifItemParser& /*aItem*/ ) |
|
522 { |
|
523 // Print to UI |
|
524 _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" ); |
|
525 _LIT( KTestUtilScaleImageL, "TestUtilScaleImageL" ); |
|
526 TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestUtilScaleImageL ); |
|
527 // Print to log file |
|
528 iLog->Log( KTestUtilScaleImageL ); |
|
529 |
|
530 TUint8* srcBuf = new TUint8[ KSrcBufLen1 ]; |
|
531 STIF_ASSERT_NOT_NULL( srcBuf ); |
|
532 CleanupStack::PushL( srcBuf ); |
|
533 // fill with |
|
534 for ( TInt t = 0; t < KSrcBufLen1; ) |
|
535 { |
|
536 srcBuf[t++] = KRed; // red |
|
537 srcBuf[t++] = KGreen; // green |
|
538 srcBuf[t++] = KBlue; // blue |
|
539 srcBuf[t++] = KAlpha; // alpha |
|
540 } |
|
541 |
|
542 // try to allocate dummy image buffer for 320x200 image |
|
543 TUint8* desBuf = new TUint8[ KDesBufLen ]; |
|
544 STIF_ASSERT_NOT_NULL( desBuf ); |
|
545 CleanupStack::PushL( desBuf ); |
|
546 // fill with zero pixels |
|
547 for ( TInt t = 0; t < KDesBufLen; t++ ) |
|
548 { |
|
549 desBuf[t] = 0; |
|
550 } |
|
551 TSize srcSize = TSize( KScreenW, KScreenH ); |
|
552 TSize desSize = TSize( KGeneralSize, KGeneralSize ); |
|
553 AlfUtil::ScaleImage( KComponentsNum, srcSize, srcBuf, desSize, desBuf ); |
|
554 CleanupStack::PopAndDestroy( desBuf ); |
|
555 CleanupStack::PopAndDestroy( srcBuf ); |
|
556 |
|
557 return KErrNone; |
|
558 } |
|
559 |
|
560 // ----------------------------------------------------------------------------- |
|
561 // CTestPlatAlfVisual::TestUtilCropImageL |
|
562 // ----------------------------------------------------------------------------- |
|
563 // |
|
564 TInt CTestPlatAlfVisual::TestUtilCropImageL( CStifItemParser& /*aItem*/ ) |
|
565 { |
|
566 // Print to UI |
|
567 _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" ); |
|
568 _LIT( KTestUtilCropImageL, "TestUtilCropImageL" ); |
|
569 TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestUtilCropImageL ); |
|
570 // Print to log file |
|
571 iLog->Log( KTestUtilCropImageL ); |
|
572 |
|
573 TUint8* srcBuf = new TUint8[ KSrcBufLen2 ]; |
|
574 STIF_ASSERT_NOT_NULL( srcBuf ); |
|
575 CleanupStack::PushL( srcBuf ); |
|
576 // fill with |
|
577 for ( TInt t = 0; t < KSrcBufLen2; ) |
|
578 { |
|
579 // fill the target crop area a bit differently |
|
580 if ( ( t >= KTempSrcNum1 ) && ( t <= KTempSrcNum2 ) ) |
|
581 { |
|
582 srcBuf[t++] = KRed; // red |
|
583 srcBuf[t++] = KGreen; // green |
|
584 srcBuf[t++] = KBlue; // blue |
|
585 srcBuf[t++] = KAlpha; // alpha |
|
586 } |
|
587 else |
|
588 { |
|
589 srcBuf[t++] = 1; // red |
|
590 srcBuf[t++] = 1; // green |
|
591 srcBuf[t++] = 1; // blue |
|
592 srcBuf[t++] = 1; // alpha |
|
593 } |
|
594 } |
|
595 |
|
596 // try to allocate dummy image buffer for 160x100 image |
|
597 TUint8* desBuf = new TUint8[ KDesBufLen ]; |
|
598 STIF_ASSERT_NOT_NULL( desBuf ); |
|
599 CleanupStack::PushL( desBuf ); |
|
600 // fill with zero pixels |
|
601 for (TInt t = 0; t< KDesBufLen; t++) |
|
602 { |
|
603 desBuf[t] = 0; |
|
604 } |
|
605 TSize srcBufSize = TSize( KScrBufSizeW, KScrBufSizeH ); |
|
606 TPoint cropOffset = TPoint( 0, KGeneralSize ); |
|
607 TSize croppedSize = TSize( KGeneralSize, KGeneralSize ); |
|
608 AlfUtil::CropImage( KComponentsNum, srcBufSize, srcBuf, cropOffset, croppedSize, desBuf ); |
|
609 CleanupStack::PopAndDestroy( desBuf ); |
|
610 CleanupStack::PopAndDestroy( srcBuf ); |
|
611 |
|
612 return KErrNone; |
|
613 } |
|
614 |
|
615 // ----------------------------------------------------------------------------- |
|
616 // CTestPlatAlfVisual::TestUtilTagMatches |
|
617 // ----------------------------------------------------------------------------- |
|
618 // |
|
619 TInt CTestPlatAlfVisual::TestUtilTagMatches( CStifItemParser& /*aItem*/ ) |
|
620 { |
|
621 // Print to UI |
|
622 _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" ); |
|
623 _LIT( KTestUtilTagMatches, "TestUtilTagMatches" ); |
|
624 TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestUtilTagMatches ); |
|
625 // Print to log file |
|
626 iLog->Log( KTestUtilTagMatches ); |
|
627 |
|
628 _LIT8( KTagTxt, "Caption" ); |
|
629 _LIT8( KTagsColonSeparatedTxt, "Test:Caption" ); |
|
630 AlfUtil::TagMatches( KTagsColonSeparatedTxt, KTagTxt ); |
|
631 |
|
632 return KErrNone; |
|
633 } |
|
634 |
|
635 // ----------------------------------------------------------------------------- |
|
636 // CTestPlatAlfVisual::TestUtilConvertBitmapToDisplayModeLCL |
|
637 // ----------------------------------------------------------------------------- |
|
638 // |
|
639 TInt CTestPlatAlfVisual::TestUtilConvertBitmapToDisplayModeLCL( CStifItemParser& /*aItem*/ ) |
|
640 { |
|
641 // Print to UI |
|
642 _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" ); |
|
643 _LIT( KTestUtilConvertBitmapToDisplayModeLCL, "TestUtilConvertBitmapToDisplayModeLCL" ); |
|
644 TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestUtilConvertBitmapToDisplayModeLCL ); |
|
645 // Print to log file |
|
646 iLog->Log( KTestUtilConvertBitmapToDisplayModeLCL ); |
|
647 |
|
648 TSize sizeInPixels = TSize( KGeneralNum, KGeneralNum ); |
|
649 CFbsBitmap *srcBmp = new ( ELeave ) CFbsBitmap(); |
|
650 CleanupStack::PushL( srcBmp ); |
|
651 User::LeaveIfError( srcBmp->Create( sizeInPixels, EColor16M ) ); |
|
652 CFbsBitmap* desBmp = AlfUtil::ConvertBitmapToDisplayModeLC( *srcBmp, EGray2 ); |
|
653 CleanupStack::PopAndDestroy( desBmp ); |
|
654 CleanupStack::PopAndDestroy( srcBmp ); |
|
655 |
|
656 return KErrNone; |
|
657 } |
|
658 |
|
659 // ----------------------------------------------------------------------------- |
|
660 // CTestPlatAlfVisual::TestUtilThemeItemIdL |
|
661 // ----------------------------------------------------------------------------- |
|
662 // |
|
663 TInt CTestPlatAlfVisual::TestUtilThemeItemIdL( CStifItemParser& /*aItem*/ ) |
|
664 { |
|
665 // Print to UI |
|
666 _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" ); |
|
667 _LIT( KTestUtilThemeItemIdL, "TestUtilThemeItemIdL" ); |
|
668 TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestUtilThemeItemIdL ); |
|
669 // Print to log file |
|
670 iLog->Log( KTestUtilThemeItemIdL ); |
|
671 |
|
672 _LIT( KTxtNone, "None" ); |
|
673 AlfUtil::ThemeItemIdL( *iAlfEnv, KTxtNone ); |
|
674 |
|
675 return KErrNone; |
|
676 } |
|
677 |
|
678 |
|
679 // [End of File] |