|
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 alftexture.h |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // [INCLUDE FILES] |
|
21 #include <alf/alftexture.h> |
|
22 #include <alf/alfbitmapprovider.h> |
|
23 |
|
24 #include "testplatalfvisual.h" |
|
25 |
|
26 |
|
27 // CONSTANTS |
|
28 const TInt KExistingTextureId = 1000; |
|
29 |
|
30 const TInt KProvidedBitmapWidth = 64; |
|
31 const TInt KProvidedBitmapHeight = 64; |
|
32 |
|
33 _LIT( KImageName, "OneExistingTexture" ); |
|
34 |
|
35 |
|
36 // FORWARD DECLARATION |
|
37 class CTestBmpProvider : public CBase, public MAlfBitmapProvider |
|
38 { |
|
39 public: |
|
40 /** |
|
41 * Provide a bitmap and mask from the given UID. |
|
42 * This method should create a bitmap and its mask, usually by loading it from disk. |
|
43 */ |
|
44 void ProvideBitmapL(TInt /*aId*/, CFbsBitmap*& aBitmap, CFbsBitmap*& aBitmapMask) |
|
45 { |
|
46 aBitmap = new ( ELeave ) CFbsBitmap; |
|
47 aBitmapMask = new ( ELeave ) CFbsBitmap; |
|
48 TSize bmpSize( KProvidedBitmapWidth, KProvidedBitmapHeight ); |
|
49 aBitmap->Create( bmpSize, EColor64K ); |
|
50 aBitmapMask->Create( bmpSize, EGray256 ); |
|
51 } |
|
52 }; |
|
53 |
|
54 |
|
55 // ============================ MEMBER FUNCTIONS =============================== |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CTestPlatAlfVisual::TestTextureGetMethods |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 TInt CTestPlatAlfVisual::TestTextureGetMethods( CStifItemParser& /*aItem*/ ) |
|
62 { |
|
63 // Print to UI |
|
64 _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" ); |
|
65 _LIT( KTestTextureGetMethods, "TestTextureGetMethods" ); |
|
66 TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestTextureGetMethods ); |
|
67 // Print to log file |
|
68 iLog->Log( KTestTextureGetMethods ); |
|
69 |
|
70 CAlfTexture* texture = &( iAlfEnv->TextureManager().BlankTexture() ); |
|
71 texture->Id(); |
|
72 texture->ServerHandle(); |
|
73 texture->FileName(); |
|
74 texture->HasContent(); |
|
75 texture->MaxTextureSize(); |
|
76 texture->Size(); |
|
77 texture->IsAnimated(); |
|
78 texture->Priority(); |
|
79 texture->AutoSizeParams(); |
|
80 texture->RefCountingEnabled(); |
|
81 texture->RefCountingAction(); |
|
82 |
|
83 return KErrNone; |
|
84 } |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // CTestPlatAlfVisual::TestTextureAnimation |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 TInt CTestPlatAlfVisual::TestTextureAnimation( CStifItemParser& /*aItem*/ ) |
|
91 { |
|
92 // Print to UI |
|
93 _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" ); |
|
94 _LIT( KTestTextureAnimation, "TestTextureAnimation" ); |
|
95 TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestTextureAnimation ); |
|
96 // Print to log file |
|
97 iLog->Log( KTestTextureAnimation ); |
|
98 |
|
99 CAlfTexture* texture = &( iAlfEnv->TextureManager().BlankTexture() ); |
|
100 texture->StartAnimation(); |
|
101 texture->StopAnimation(); |
|
102 |
|
103 return KErrNone; |
|
104 } |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CTestPlatAlfVisual::TestTextureSetMethodsL |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 TInt CTestPlatAlfVisual::TestTextureSetMethodsL( CStifItemParser& /*aItem*/ ) |
|
111 { |
|
112 // Print to UI |
|
113 _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" ); |
|
114 _LIT( KTestTextureSetMethodsL, "TestTextureSetMethodsL" ); |
|
115 TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestTextureSetMethodsL ); |
|
116 // Print to log file |
|
117 iLog->Log( KTestTextureSetMethodsL ); |
|
118 |
|
119 CTestBmpProvider* bmpProvider = new ( ELeave ) CTestBmpProvider; |
|
120 CleanupStack::PushL( bmpProvider ); |
|
121 iAlfEnv->TextureManager().DefineFileNameL( |
|
122 KExistingTextureId, KImageName ); |
|
123 CAlfTexture* texture = &( iAlfEnv->TextureManager().CreateTextureL( |
|
124 KExistingTextureId, bmpProvider, EAlfTextureFlagAutoSize ) ); |
|
125 texture->SetPriority( texture->Priority() ); |
|
126 texture->SetAutoSizeParams( texture->AutoSizeParams() ); |
|
127 texture->EnableRefCounting( texture->RefCountingEnabled() ); |
|
128 texture->SetRefCountingAction( texture->RefCountingAction() ); |
|
129 |
|
130 TAlfTextureAutoSizeParams newparams = texture->AutoSizeParams(); |
|
131 newparams.SetSizeLowerThreshold( TAlfTextureAutoSizeParams::EHigh ); |
|
132 texture->SetAutoSizeParams(newparams); |
|
133 TAlfTextureAutoSizeParams resultparams = texture->AutoSizeParams(); |
|
134 TInt target = TAlfTextureAutoSizeParams::EHigh; |
|
135 STIF_ASSERT_EQUALS( target, resultparams.SizeLowerThreshold() ); |
|
136 |
|
137 CleanupStack::PopAndDestroy( bmpProvider ); |
|
138 |
|
139 |
|
140 return KErrNone; |
|
141 } |
|
142 |
|
143 |
|
144 // [End of File] |