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