|
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 api of alf_core_toolkit |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // [INCLUDE FILES] |
|
21 #include <e32svr.h> |
|
22 #include <stifparser.h> |
|
23 #include <stiftestinterface.h> |
|
24 #include <uiacceltk/huienv.h> |
|
25 #include <uiacceltk/huicontrol.h> |
|
26 #include <uiacceltk/huiimagebrush.h> |
|
27 |
|
28 #include "testuiaifcoretoolkit.h" |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // CTestUiAifCoreToolkit::TestCHIBNewL |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 TInt CTestUiAifCoreToolkit::TestCHIBNewL( CStifItemParser& /*aItem*/ ) |
|
35 { |
|
36 |
|
37 // Print to UI |
|
38 _LIT( KTestuiaifcoretoolkit, "testuiaifcoretoolkit" ); |
|
39 _LIT( KCHuiIMageBrush, "In TestCHIBNewL" ); |
|
40 TestModuleIf().Printf( 0, KTestuiaifcoretoolkit, KCHuiIMageBrush ); |
|
41 // Print to log file |
|
42 iLog->Log( KCHuiIMageBrush ); |
|
43 |
|
44 THuiImage* image = new( ELeave ) THuiImage(); |
|
45 CleanupStack::PushL( image ); |
|
46 CHuiImageBrush* brush = CHuiImageBrush::NewL( *image ); |
|
47 CleanupStack::PushL( brush ); |
|
48 STIF_ASSERT_NOT_NULL( brush ); |
|
49 CleanupStack::PopAndDestroy( brush ); |
|
50 CleanupStack::PopAndDestroy( image ); |
|
51 |
|
52 return KErrNone; |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CTestUiAifCoreToolkit::TestCHIBNewLCL |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 TInt CTestUiAifCoreToolkit::TestCHIBNewLCL( CStifItemParser& /*aItem*/ ) |
|
60 { |
|
61 |
|
62 // Print to UI |
|
63 _LIT( KTestuiaifcoretoolkit, "testuiaifcoretoolkit" ); |
|
64 _LIT( KCHuiIMageBrush, "In TestCHIBNewLCL" ); |
|
65 TestModuleIf().Printf( 0, KTestuiaifcoretoolkit, KCHuiIMageBrush ); |
|
66 // Print to log file |
|
67 iLog->Log( KCHuiIMageBrush ); |
|
68 |
|
69 THuiImage* image = new( ELeave ) THuiImage(); |
|
70 CleanupStack::PushL( image ); |
|
71 CHuiImageBrush* brush = CHuiImageBrush::NewLC( *image ); |
|
72 CleanupStack::Pop(); |
|
73 STIF_ASSERT_NOT_NULL( brush ); |
|
74 CleanupStack::PopAndDestroy( image ); |
|
75 |
|
76 return KErrNone; |
|
77 } |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // CTestUiAifCoreToolkit::TestCHIBSetScaleModeL |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 TInt CTestUiAifCoreToolkit::TestCHIBSetScaleModeL( CStifItemParser& /*aItem*/ ) |
|
84 { |
|
85 |
|
86 // Print to UI |
|
87 _LIT( KTestuiaifcoretoolkit, "testuiaifcoretoolkit" ); |
|
88 _LIT( KCHuiIMageBrush, "In TestCHIBSetScaleModeL" ); |
|
89 TestModuleIf().Printf( 0, KTestuiaifcoretoolkit, KCHuiIMageBrush ); |
|
90 // Print to log file |
|
91 iLog->Log( KCHuiIMageBrush ); |
|
92 |
|
93 THuiImage* image = new( ELeave ) THuiImage(); |
|
94 CleanupStack::PushL( image ); |
|
95 CHuiImageBrush* brush = CHuiImageBrush::NewL( *image ); |
|
96 CleanupStack::PushL( brush ); |
|
97 STIF_ASSERT_NOT_NULL( brush ); |
|
98 brush->SetScaleMode( CHuiImageVisual::EScaleNormal ); |
|
99 CleanupStack::PopAndDestroy( brush ); |
|
100 CleanupStack::PopAndDestroy( image ); |
|
101 |
|
102 return KErrNone; |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CTestUiAifCoreToolkit::TestCHIBSetImageL |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 TInt CTestUiAifCoreToolkit::TestCHIBSetImageL( CStifItemParser& /*aItem*/ ) |
|
110 { |
|
111 |
|
112 // Print to UI |
|
113 _LIT( KTestuiaifcoretoolkit, "testuiaifcoretoolkit" ); |
|
114 _LIT( KCHuiIMageBrush, "In TestCHIBSetImageL" ); |
|
115 TestModuleIf().Printf( 0, KTestuiaifcoretoolkit, KCHuiIMageBrush ); |
|
116 // Print to log file |
|
117 iLog->Log( KCHuiIMageBrush ); |
|
118 |
|
119 THuiImage* image = new( ELeave ) THuiImage(); |
|
120 CleanupStack::PushL( image ); |
|
121 CHuiImageBrush* brush = CHuiImageBrush::NewL( *image ); |
|
122 CleanupStack::PushL( brush ); |
|
123 STIF_ASSERT_NOT_NULL( brush ); |
|
124 brush->SetImage( *image ); |
|
125 CleanupStack::PopAndDestroy( brush ); |
|
126 CleanupStack::PopAndDestroy( image ); |
|
127 |
|
128 return KErrNone; |
|
129 } |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // CTestUiAifCoreToolkit::TestCHIBSetBordersL |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 TInt CTestUiAifCoreToolkit::TestCHIBSetBordersL( CStifItemParser& /*aItem*/ ) |
|
136 { |
|
137 |
|
138 // Print to UI |
|
139 _LIT( KTestuiaifcoretoolkit, "testuiaifcoretoolkit" ); |
|
140 _LIT( KCHuiIMageBrush, "In TestCHIBSetBordersL" ); |
|
141 TestModuleIf().Printf( 0, KTestuiaifcoretoolkit, KCHuiIMageBrush ); |
|
142 // Print to log file |
|
143 iLog->Log( KCHuiIMageBrush ); |
|
144 |
|
145 THuiImage* image = new( ELeave ) THuiImage(); |
|
146 CleanupStack::PushL( image ); |
|
147 CHuiImageBrush* brush = CHuiImageBrush::NewL( *image ); |
|
148 CleanupStack::PushL( brush ); |
|
149 STIF_ASSERT_NOT_NULL( brush ); |
|
150 STIF_ASSERT_TRUE( !brush->BorderDrawingEnabled() ); |
|
151 brush->SetBorders( 1, 1, 1, 1 ); |
|
152 STIF_ASSERT_TRUE( brush->BorderDrawingEnabled() ); |
|
153 CleanupStack::PopAndDestroy( brush ); |
|
154 CleanupStack::PopAndDestroy( image ); |
|
155 |
|
156 return KErrNone; |
|
157 } |
|
158 |
|
159 // ----------------------------------------------------------------------------- |
|
160 // CTestUiAifCoreToolkit::TestCHIBBorderDrawingEnabledL |
|
161 // ----------------------------------------------------------------------------- |
|
162 // |
|
163 TInt CTestUiAifCoreToolkit::TestCHIBBorderDrawingEnabledL( CStifItemParser& /*aItem*/ ) |
|
164 { |
|
165 |
|
166 // Print to UI |
|
167 _LIT( KTestuiaifcoretoolkit, "testuiaifcoretoolkit" ); |
|
168 _LIT( KCHuiIMageBrush, "In TestCHIBBorderDrawingEnabledL" ); |
|
169 TestModuleIf().Printf( 0, KTestuiaifcoretoolkit, KCHuiIMageBrush ); |
|
170 // Print to log file |
|
171 iLog->Log( KCHuiIMageBrush ); |
|
172 |
|
173 THuiImage* image = new( ELeave ) THuiImage(); |
|
174 CleanupStack::PushL( image ); |
|
175 CHuiImageBrush* brush = CHuiImageBrush::NewL( *image ); |
|
176 CleanupStack::PushL( brush ); |
|
177 STIF_ASSERT_NOT_NULL( brush ); |
|
178 STIF_ASSERT_FALSE( brush->BorderDrawingEnabled() ); |
|
179 CleanupStack::PopAndDestroy( brush ); |
|
180 CleanupStack::PopAndDestroy( image ); |
|
181 |
|
182 return KErrNone; |
|
183 } |
|
184 |
|
185 // ----------------------------------------------------------------------------- |
|
186 // CTestUiAifCoreToolkit::TestCHIBCenterDrawingEnabledL |
|
187 // ----------------------------------------------------------------------------- |
|
188 // |
|
189 TInt CTestUiAifCoreToolkit::TestCHIBCenterDrawingEnabledL( CStifItemParser& /*aItem*/ ) |
|
190 { |
|
191 |
|
192 // Print to UI |
|
193 _LIT( KTestuiaifcoretoolkit, "testuiaifcoretoolkit" ); |
|
194 _LIT( KCHuiIMageBrush, "In TestCHIBCenterDrawingEnabledL" ); |
|
195 TestModuleIf().Printf( 0, KTestuiaifcoretoolkit, KCHuiIMageBrush ); |
|
196 // Print to log file |
|
197 iLog->Log( KCHuiIMageBrush ); |
|
198 |
|
199 THuiImage* image = new( ELeave ) THuiImage(); |
|
200 CleanupStack::PushL( image ); |
|
201 CHuiImageBrush* brush = CHuiImageBrush::NewL( *image ); |
|
202 CleanupStack::PushL( brush ); |
|
203 STIF_ASSERT_NOT_NULL( brush ); |
|
204 brush->CenterDrawingEnabled(); |
|
205 CleanupStack::PopAndDestroy( brush ); |
|
206 CleanupStack::PopAndDestroy( image ); |
|
207 |
|
208 return KErrNone; |
|
209 } |
|
210 |
|
211 // ----------------------------------------------------------------------------- |
|
212 // CTestUiAifCoreToolkit::TestCHIBExpandVisualRectL |
|
213 // ----------------------------------------------------------------------------- |
|
214 // |
|
215 TInt CTestUiAifCoreToolkit::TestCHIBExpandVisualRectL( CStifItemParser& /*aItem*/ ) |
|
216 { |
|
217 |
|
218 // Print to UI |
|
219 _LIT( KTestuiaifcoretoolkit, "testuiaifcoretoolkit" ); |
|
220 _LIT( KCHuiIMageBrush, "In TestCHIBExpandVisualRectL" ); |
|
221 TestModuleIf().Printf( 0, KTestuiaifcoretoolkit, KCHuiIMageBrush ); |
|
222 // Print to log file |
|
223 iLog->Log( KCHuiIMageBrush ); |
|
224 |
|
225 THuiImage* image = new( ELeave ) THuiImage(); |
|
226 CleanupStack::PushL( image ); |
|
227 CHuiImageBrush* brush = CHuiImageBrush::NewL( *image ); |
|
228 CleanupStack::PushL( brush ); |
|
229 STIF_ASSERT_NOT_NULL( brush ); |
|
230 |
|
231 TRect rect(10, 10, 30, 20); |
|
232 brush->SetBorders(5, 5, 5, 5); |
|
233 brush->ExpandVisualRect(rect); |
|
234 |
|
235 STIF_ASSERT_TRUE(rect.iTl.iX == 5); |
|
236 STIF_ASSERT_TRUE(rect.iTl.iY == 5); |
|
237 |
|
238 STIF_ASSERT_TRUE(rect.iBr.iX == 35); |
|
239 STIF_ASSERT_TRUE(rect.iBr.iY == 25); |
|
240 |
|
241 CleanupStack::PopAndDestroy( brush ); |
|
242 CleanupStack::PopAndDestroy( image ); |
|
243 |
|
244 return KErrNone; |
|
245 } |
|
246 |
|
247 // ----------------------------------------------------------------------------- |
|
248 // CTestUiAifCoreToolkit::TestCHIBDrawL |
|
249 // ----------------------------------------------------------------------------- |
|
250 // |
|
251 TInt CTestUiAifCoreToolkit::TestCHIBDrawL( CStifItemParser& /*aItem*/ ) |
|
252 { |
|
253 |
|
254 // Print to UI |
|
255 _LIT( KTestuiaifcoretoolkit, "testuiaifcoretoolkit" ); |
|
256 _LIT( KCHuiIMageBrush, "In TestCHIBDrawL" ); |
|
257 TestModuleIf().Printf( 0, KTestuiaifcoretoolkit, KCHuiIMageBrush ); |
|
258 // Print to log file |
|
259 iLog->Log( KCHuiIMageBrush ); |
|
260 |
|
261 THuiImage* image = new( ELeave ) THuiImage(); |
|
262 CleanupStack::PushL( image ); |
|
263 CHuiImageBrush* brush = CHuiImageBrush::NewL( *image ); |
|
264 CleanupStack::PushL( brush ); |
|
265 STIF_ASSERT_NOT_NULL( brush ); |
|
266 CHuiVisual* visual = CHuiVisual::AddNewL( *iHuiControl ); |
|
267 CHuiEnv::RefreshCallBack( iHuiEnv ); |
|
268 CHuiGc* gc = &iHuiEnv->Skin().Context(); |
|
269 brush->Draw( *gc, *visual ); |
|
270 CleanupStack::PopAndDestroy( brush ); |
|
271 CleanupStack::PopAndDestroy( image ); |
|
272 |
|
273 return KErrNone; |
|
274 } |