|
1 /* |
|
2 * Copyright (c) 2006-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: test case for CEikFormattedCellListBox |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 #include <w32std.h> |
|
27 #include <eikenv.h> |
|
28 #include <aknlists.h> |
|
29 #include <barsread.h> |
|
30 #include <akndef.h> |
|
31 #include <aknsconstants.h> |
|
32 #include <eiktxlbm.h> |
|
33 #include <eikfrlbd.h> |
|
34 |
|
35 #include "bctestlistcolumnbasecase.h" |
|
36 #include "bctestlistformatbasecase.h" |
|
37 #include "bctestlistcontainer.h" |
|
38 #include "bctestlist.hrh" |
|
39 #include <bctestlist.rsg> |
|
40 #include <bctestlist.mbg> |
|
41 |
|
42 _LIT( KFormatBaseCreate, "Create CEikFormattedCellListBox" ); |
|
43 |
|
44 _LIT( KFormatTest1, "CEikFormattedCellListBox::UseLogicalToVisualConversion" ); |
|
45 _LIT( KFormatTest2, "CEikFormattedCellListBox::FocusChanged" ); |
|
46 _LIT( KFormatTest3, "CEikFormattedCellListBox::GetColorUseListL" ); |
|
47 _LIT( KFormatTest4, "CEikFormattedCellListBox::HandleResourceChange" ); |
|
48 |
|
49 _LIT( KFormatItemDrawerTest1, "CFormattedCellListBoxItemDrawer::ClearAllPropertiesL" ); |
|
50 _LIT( KFormatItemDrawerTest2, "CFormattedCellListBoxItemDrawer::SetPropertiesL" ); |
|
51 _LIT( KFormatItemDrawerTest3, "CFormattedCellListBoxItemDrawer::ItemWidthInPixels" ); |
|
52 _LIT( KFormatItemDrawerTest4, "CFormattedCellListBoxItemDrawer::DrawItemMark" ); |
|
53 |
|
54 _LIT( KFormateDataTest1, "CFormattedCellListBoxData::SetSkinEnabledL" ); |
|
55 _LIT( KFormateDataTest2, "CFormattedCellListBoxData::SetSkinHighlightFrame" ); |
|
56 _LIT( KFormateDataTest3, "CFormattedCellListBoxData::SetSkinPopupFrame" ); |
|
57 _LIT( KFormateDataTest4, "CFormattedCellListBoxData::SetSkinPopupFramePosition" ); |
|
58 _LIT( KFormateDataTest5, "CFormattedCellListBoxData::UseLogicalToVisualConversion" ); |
|
59 _LIT( KFormateDataTest6, "CFormattedCellListBoxData::SetRespectFocus" ); |
|
60 _LIT( KFormateDataTest7, "CFormattedCellListBoxData::EnableMarqueeL" ); |
|
61 _LIT( KFormateDataTest8, "CFormattedCellListBoxData::SetSubCellFontForRowL" ); |
|
62 _LIT( KFormateDataTest9, "CFormattedCellListBoxData::SetDrawBackground" ); |
|
63 _LIT( KFormateDataTest10, "CFormattedCellListBoxData::SetMarqueeParams" ); |
|
64 _LIT( KFormateDataTest11, "CFormattedCellListBoxData::SetSubcellUnderlined" ); |
|
65 _LIT( KFormateDataTest12, "CFormattedCellListBoxData::ConstructLD" ); |
|
66 _LIT( KFormateDataTest13, "CFormattedCellListBoxData::HighlightAnim" ); |
|
67 _LIT( KFormateDataTest14, "CFormattedCellListBoxData::SetHighlightAnimBackgroundDrawer" ); |
|
68 _LIT( KFormateDataTest15, "CFormattedCellListBoxData::AboutToDrawHighlightAnim" ); |
|
69 _LIT( KFormateDataTest16, "CFormGraphicListBoxData::NewL" ); |
|
70 _LIT( KFormateDataTest17, "CFormGraphicListBoxData::Draw" ); |
|
71 _LIT( KFormateDataTest18, "CPopupFormattedListBoxData::NewL" ); |
|
72 _LIT( KFormateDataTest19, "CFormGraphicListBoxData::Draw" ); |
|
73 _LIT( KFormatDataTestText, "Test text for draw" ); |
|
74 |
|
75 // ======== MEMBER FUNCTIONS ======== |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // Symbian 2nd static Constructor |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 CBCTestListFormatBaseCase* CBCTestListFormatBaseCase::NewL( |
|
82 CBCTestListContainer* aContainer, CEikonEnv* aEikEnv ) |
|
83 { |
|
84 CBCTestListFormatBaseCase* self = new( ELeave ) CBCTestListFormatBaseCase( |
|
85 aContainer, aEikEnv ); |
|
86 CleanupStack::PushL( self ); |
|
87 self->ConstructL(); |
|
88 CleanupStack::Pop( self ); |
|
89 return self; |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // C++ default constructor |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 CBCTestListFormatBaseCase::CBCTestListFormatBaseCase( CBCTestListContainer* aContainer, |
|
97 CEikonEnv* aEikEnv ) |
|
98 : CBCTestListBaseCase( aContainer, aEikEnv ) |
|
99 { |
|
100 } |
|
101 |
|
102 // --------------------------------------------------------------------------- |
|
103 // Destructor |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 CBCTestListFormatBaseCase::~CBCTestListFormatBaseCase() |
|
107 { |
|
108 } |
|
109 |
|
110 // --------------------------------------------------------------------------- |
|
111 // Symbian 2nd Constructor |
|
112 // --------------------------------------------------------------------------- |
|
113 // |
|
114 void CBCTestListFormatBaseCase::ConstructL() |
|
115 { |
|
116 BuildScriptL(); |
|
117 } |
|
118 |
|
119 // --------------------------------------------------------------------------- |
|
120 // CBCTestListFormatBaseCase::BuildScriptL |
|
121 // --------------------------------------------------------------------------- |
|
122 // |
|
123 void CBCTestListFormatBaseCase::BuildScriptL() |
|
124 { |
|
125 for ( TInt i=0; i <= EBCTestCmdOutline50 - EBCTestCmdOutline48; i++ ) |
|
126 { |
|
127 AddTestL( LeftCBA, REP( Down, 7 ), KeyOK, TEND ); |
|
128 AddTestL( REP( Down, i ), KeyOK, TEND ); |
|
129 } |
|
130 } |
|
131 |
|
132 // --------------------------------------------------------------------------- |
|
133 // CBCTestListFormatBaseCase::RunL |
|
134 // --------------------------------------------------------------------------- |
|
135 // |
|
136 void CBCTestListFormatBaseCase::RunL( TInt aCmd ) |
|
137 { |
|
138 if ( aCmd < EBCTestCmdOutline48 || aCmd > EBCTestCmdOutline50 ) |
|
139 { |
|
140 return; |
|
141 } |
|
142 ReleaseCase(); |
|
143 PrepareCaseL(); |
|
144 switch ( aCmd ) |
|
145 { |
|
146 case EBCTestCmdOutline48: |
|
147 TestFormatListL(); |
|
148 break; |
|
149 case EBCTestCmdOutline49: |
|
150 TestFormatItemDrawerL(); |
|
151 break; |
|
152 case EBCTestCmdOutline50: |
|
153 TestFormatListDataL(); |
|
154 break; |
|
155 default: |
|
156 break; |
|
157 } |
|
158 } |
|
159 |
|
160 // --------------------------------------------------------------------------- |
|
161 // CBCTestListFormatBaseCase::PrepareCaseL |
|
162 // --------------------------------------------------------------------------- |
|
163 // |
|
164 void CBCTestListFormatBaseCase::PrepareCaseL() |
|
165 { |
|
166 iListBox = new( ELeave ) CAknDoubleStyle2ListBox(); |
|
167 AssertNotNullL( iListBox, KFormatBaseCreate ); |
|
168 |
|
169 CDesCArray* textArray = iEikEnv->ReadDesCArrayResourceL( |
|
170 R_BCTESTLIST_DOUBLE2_ITEM ); |
|
171 |
|
172 if ( iListBox ) |
|
173 { |
|
174 if ( textArray ) |
|
175 { |
|
176 SetListBoxFromInnerDescriptionL( iListBox, |
|
177 EAknListBoxSelectionList, textArray ); |
|
178 } |
|
179 SetGraphicIconL( iListBox ); |
|
180 |
|
181 iContainer->SetControl( iListBox ); |
|
182 } |
|
183 } |
|
184 |
|
185 // --------------------------------------------------------------------------- |
|
186 // CBCTestListFormatBaseCase::ReleaseCaseL |
|
187 // --------------------------------------------------------------------------- |
|
188 // |
|
189 void CBCTestListFormatBaseCase::ReleaseCase() |
|
190 { |
|
191 iContainer->ResetControl(); |
|
192 iListBox = NULL; |
|
193 } |
|
194 |
|
195 // --------------------------------------------------------------------------- |
|
196 // CBCTestListFormatBaseCase::TestFormatListL |
|
197 // --------------------------------------------------------------------------- |
|
198 // |
|
199 void CBCTestListFormatBaseCase::TestFormatListL() |
|
200 { |
|
201 iListBox->UseLogicalToVisualConversion( ETrue ); |
|
202 iListBox->UseLogicalToVisualConversion( EFalse ); |
|
203 AssertTrueL( ETrue, KFormatTest1 ); |
|
204 |
|
205 iListBox->FocusChanged( EDrawNow ); |
|
206 iListBox->FocusChanged( ENoDrawNow ); |
|
207 AssertTrueL( ETrue, KFormatTest2 ); |
|
208 |
|
209 TInt granularity = 4; |
|
210 CArrayFixFlat<TCoeColorUse>* colorUseList = new( ELeave ) |
|
211 CArrayFixFlat<TCoeColorUse>( granularity ); |
|
212 CleanupStack::PushL( colorUseList ); |
|
213 iListBox->GetColorUseListL( *colorUseList ); |
|
214 AssertTrueL( ( colorUseList->Count() > 0 ), KFormatTest3 ); |
|
215 colorUseList->Reset(); |
|
216 CleanupStack::PopAndDestroy( colorUseList ); |
|
217 |
|
218 iListBox->HandleResourceChange( KAknsMessageSkinChange ); |
|
219 iListBox->HandleResourceChange( KEikDynamicLayoutVariantSwitch ); |
|
220 AssertTrueL( ETrue, KFormatTest4 ); |
|
221 } |
|
222 |
|
223 // --------------------------------------------------------------------------- |
|
224 // CBCTestListFormatBaseCase::TestFormatItemDrawerL |
|
225 // --------------------------------------------------------------------------- |
|
226 // |
|
227 void CBCTestListFormatBaseCase::TestFormatItemDrawerL() |
|
228 { |
|
229 CFormattedCellListBoxItemDrawer* itemDrawer = iListBox->ItemDrawer(); |
|
230 |
|
231 itemDrawer->ClearAllPropertiesL(); |
|
232 AssertTrueL( ETrue, KFormatItemDrawerTest1 ); |
|
233 |
|
234 TListItemProperties itemProp; |
|
235 itemProp.SetBold( ETrue ); |
|
236 itemProp.SetItalics( ETrue ); |
|
237 itemProp.SetUnderlined( ETrue ); |
|
238 itemProp.SetDimmed( ETrue ); |
|
239 itemProp.SetColor( KRgbGray ); |
|
240 itemProp.SetSeparatorAfter( ETrue ); |
|
241 itemDrawer->SetPropertiesL( 0, itemProp ); |
|
242 AssertTrueL( ETrue, KFormatItemDrawerTest2 ); |
|
243 |
|
244 TInt width = itemDrawer->ItemWidthInPixels( 0 ); |
|
245 AssertTrueL( ETrue, KFormatItemDrawerTest3 ); |
|
246 |
|
247 TPoint pt( 0, 0 ); |
|
248 itemDrawer->DrawItemMark( ETrue, EFalse, pt ); |
|
249 AssertTrueL( ETrue, KFormatItemDrawerTest4 ); |
|
250 } |
|
251 |
|
252 // --------------------------------------------------------------------------- |
|
253 // CBCTestListFormatBaseCase::TestFormatListDataL |
|
254 // --------------------------------------------------------------------------- |
|
255 // |
|
256 void CBCTestListFormatBaseCase::TestFormatListDataL() |
|
257 { |
|
258 CFormattedCellListBoxData* data = |
|
259 iListBox->ItemDrawer()->FormattedCellData(); |
|
260 |
|
261 data->SetSkinEnabledL( ETrue ); |
|
262 TBool skin = data->SkinEnabled(); |
|
263 AssertTrueL( skin, KFormateDataTest1 ); |
|
264 |
|
265 TAknsItemID id; |
|
266 id.Set( KAknsIIDDefault ); |
|
267 data->SetSkinHighlightFrame( &id, &id ); |
|
268 AssertTrueL( ETrue, KFormateDataTest2 ); |
|
269 |
|
270 data->SetSkinPopupFrame( &id, &id ); |
|
271 AssertTrueL( ETrue, KFormateDataTest3 ); |
|
272 |
|
273 TRect rect = iContainer->Rect(); |
|
274 TRect innerRect( rect.iTl.iX + 2, rect.iTl.iY + 2, rect.iBr.iX - 2, |
|
275 rect.iBr.iY - 2 ); |
|
276 data->SetSkinPopupFramePosition( rect, innerRect ); |
|
277 AssertTrueL( ETrue, KFormateDataTest4 ); |
|
278 |
|
279 data->UseLogicalToVisualConversion( ETrue ); |
|
280 AssertTrueL( ETrue, KFormateDataTest5 ); |
|
281 |
|
282 data->SetRespectFocus( ETrue ); |
|
283 AssertTrueL( ETrue, KFormateDataTest6 ); |
|
284 |
|
285 data->EnableMarqueeL( ETrue ); |
|
286 AssertTrueL( ETrue, KFormateDataTest7 ); |
|
287 |
|
288 data->SetSubCellFontForRowL( 0, 0, iEikEnv->NormalFont() ); |
|
289 AssertTrueL( ETrue, KFormateDataTest8 ); |
|
290 |
|
291 data->SetDrawBackground( ETrue ); |
|
292 AssertTrueL( ETrue, KFormateDataTest9 ); |
|
293 |
|
294 data->SetMarqueeParams( 1, 6, 1000000, 100000 ); |
|
295 AssertTrueL( ETrue, KFormateDataTest10 ); |
|
296 |
|
297 TBitFlags32 flags; |
|
298 data->SetSubcellUnderlined( flags ); |
|
299 AssertTrueL( ETrue, KFormateDataTest11 ); |
|
300 #ifdef __S60_32__ |
|
301 iListBox->SetCurrentItemIndex( 2 );//item 3; |
|
302 |
|
303 TUint32 tInt = data->CurrentItemTextWasClipped(); |
|
304 _LIT( KColumnDataTest35, |
|
305 "Test CurrentItemTextWasClipped() at short item." ); |
|
306 AssertTrueL( ETrue, KColumnDataTest35 ); |
|
307 iListBox->SetCurrentItemIndex( 3 );//item 4; |
|
308 tInt = data->CurrentItemTextWasClipped(); |
|
309 _LIT( KColumnDataTest36, |
|
310 "Test CurrentItemTextWasClipped() at long item." ); |
|
311 AssertTrueL( ETrue, KColumnDataTest36 ); |
|
312 iListBox->DrawNow(); |
|
313 #endif //__S60_32__ |
|
314 CBCTestListFormatData* bcData = new( ELeave ) |
|
315 CBCTestListFormatData(); |
|
316 CleanupStack::PushL( bcData ); |
|
317 bcData->TestConstructLD( id ); |
|
318 AssertTrueL( ETrue, KFormateDataTest12 ); |
|
319 |
|
320 CleanupStack::PopAndDestroy( bcData ); |
|
321 |
|
322 iContainer->ActivateGc(); |
|
323 CWindowGc& gc = iContainer->SystemGc(); |
|
324 DrawCaseL( gc ); |
|
325 iContainer->DeactivateGc(); |
|
326 } |
|
327 |
|
328 // --------------------------------------------------------------------------- |
|
329 // CBCTestListFormatBaseCase::DrawCaseL |
|
330 // --------------------------------------------------------------------------- |
|
331 // |
|
332 void CBCTestListFormatBaseCase::DrawCaseL( CWindowGc& aGc ) |
|
333 { |
|
334 CFormattedCellListBoxData* data = |
|
335 iListBox->ItemDrawer()->FormattedCellData(); |
|
336 data->HighlightAnim(); |
|
337 AssertTrueL( ETrue, KFormateDataTest13 ); |
|
338 |
|
339 data->SetHighlightAnimBackgroundDrawer( &iDrawer ); |
|
340 AssertTrueL( ETrue, KFormateDataTest14 ); |
|
341 |
|
342 data->AboutToDrawHighlightAnim(); |
|
343 AssertTrueL( ETrue, KFormateDataTest15 ); |
|
344 |
|
345 TListItemProperties itemProp; |
|
346 itemProp.SetBold( ETrue ); |
|
347 itemProp.SetItalics( ETrue ); |
|
348 itemProp.SetUnderlined( ETrue ); |
|
349 itemProp.SetDimmed( ETrue ); |
|
350 itemProp.SetColor( KRgbGray ); |
|
351 itemProp.SetSeparatorAfter( ETrue ); |
|
352 TSize size = iListBox->ItemDrawer()->ItemCellSize(); |
|
353 TRect rect( iContainer->Rect().iTl.iX, iContainer->Rect().iTl.iY, |
|
354 iContainer->Rect().iTl.iX + size.iWidth, |
|
355 iContainer->Rect().iTl.iY + size.iHeight ); |
|
356 const CFormattedCellListBoxData::TColors& colors = |
|
357 data->SubCellColors( 0 ); |
|
358 TPtrC text( KFormatDataTestText ); |
|
359 |
|
360 CFormGraphicListBoxData* graphicData = |
|
361 CFormGraphicListBoxData::NewL(); |
|
362 CleanupStack::PushL( graphicData ); |
|
363 AssertNotNullL( graphicData, KFormateDataTest16 ); |
|
364 graphicData->Draw( itemProp, aGc, &text, rect, ETrue, colors ); |
|
365 AssertTrueL( ETrue, KFormateDataTest17 ); |
|
366 CleanupStack::PopAndDestroy( graphicData ); |
|
367 |
|
368 CPopupFormattedListBoxData* popupData = |
|
369 CPopupFormattedListBoxData::NewL(); |
|
370 CleanupStack::PushL( popupData ); |
|
371 AssertNotNullL( popupData, KFormateDataTest18 ); |
|
372 popupData->Draw( itemProp, aGc, &text, rect, ETrue, colors ); |
|
373 AssertTrueL( ETrue, KFormateDataTest19 ); |
|
374 CleanupStack::PopAndDestroy( popupData ); |
|
375 } |
|
376 |
|
377 // --------------------------------------------------------------------------- |
|
378 // CBCTestListFormatBaseCase::GraphicIconL |
|
379 // --------------------------------------------------------------------------- |
|
380 // |
|
381 void CBCTestListFormatBaseCase::GraphicIconL( CArrayPtr<CGulIcon>* aIcons ) |
|
382 { |
|
383 if ( aIcons ) |
|
384 { |
|
385 CreateIconAndAddToArrayL( |
|
386 aIcons, KBCTestListMifFileName, |
|
387 EMbmBctestlistQgn_indi_marked_add, |
|
388 EMbmBctestlistQgn_indi_marked_add_mask ); |
|
389 CreateIconAndAddToArrayL( |
|
390 aIcons, KBCTestListMbmFileName, |
|
391 EMbmBctestlistGolgo3, |
|
392 EMbmBctestlistGolgo3_mask ); |
|
393 } |
|
394 } |
|
395 |
|
396 // ======== MEMBER FUNCTIONS ======== |
|
397 // CBCTestListFormatData |
|
398 |
|
399 // --------------------------------------------------------------------------- |
|
400 // Constructor |
|
401 // --------------------------------------------------------------------------- |
|
402 // |
|
403 CBCTestListFormatData::CBCTestListFormatData() |
|
404 { |
|
405 } |
|
406 |
|
407 // --------------------------------------------------------------------------- |
|
408 // Destructor |
|
409 // --------------------------------------------------------------------------- |
|
410 // |
|
411 CBCTestListFormatData::~CBCTestListFormatData() |
|
412 { |
|
413 } |
|
414 |
|
415 // --------------------------------------------------------------------------- |
|
416 // CBCTestListFormatData::ConstructLD |
|
417 // --------------------------------------------------------------------------- |
|
418 // |
|
419 void CBCTestListFormatData::TestConstructLD( |
|
420 const TAknsItemID& aAnimationIID ) |
|
421 { |
|
422 CFormattedCellListBoxData::ConstructLD( aAnimationIID ); |
|
423 } |
|
424 |
|
425 // ======== MEMBER FUNCTIONS ======== |
|
426 // TBCTestListFormatAnimBgDrawer |
|
427 |
|
428 // --------------------------------------------------------------------------- |
|
429 // TBCTestListFormatAnimBgDrawer::DrawHighlightAnimBackground |
|
430 // --------------------------------------------------------------------------- |
|
431 // |
|
432 TBool TBCTestListFormatAnimBgDrawer:: |
|
433 DrawHighlightAnimBackground( CFbsBitGc& ) const |
|
434 { |
|
435 return ETrue; |
|
436 } |