|
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 list classes in eikstd |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <w32std.h> |
|
20 #include <eikenv.h> |
|
21 #include <aknlists.h> |
|
22 #include <aknscontrolcontext.h> |
|
23 #include <eikedwin.h> |
|
24 #include <s32file.h> |
|
25 #include <eiklbm.h> |
|
26 #include <barsread.h> |
|
27 #include <bamatch.h> |
|
28 |
|
29 #include "bctestlisteiklistcase.h" |
|
30 #include "bctestlistcontainer.h" |
|
31 #include "bctestlist.hrh" |
|
32 #include <bctestlist.rsg> |
|
33 |
|
34 _LIT( KStreamName, "c:\\BCTestLog\\test.txt" ); |
|
35 _LIT( KEikTestText, "Test text" ); |
|
36 |
|
37 _LIT( KListBoxDataCreate, "Create CListBoxData" ); |
|
38 _LIT( KTextItemDrawerCreate, "Create CTextListItemDrawer" ); |
|
39 _LIT( KTextListCreate, "Create CEikTextListBox" ); |
|
40 _LIT( KSnakingListCreate, "Create CEikSnakingTextListBox" ); |
|
41 |
|
42 _LIT( KListDataTest1, "CListBoxData::SkinBackgroundControlContext" ); |
|
43 _LIT( KListDataTest2, "CListBoxData::FontBoundValues" ); |
|
44 _LIT( KListDataTest3, "CListBoxData::SetFontHeight" ); |
|
45 _LIT( KListDataTest4, "CListBoxData::ConstructFontL" ); |
|
46 _LIT( KListDataTest5, "CListBoxData::RegenerateFontsL" ); |
|
47 _LIT( KListDataTest6, "CListBoxData::UpdateFontBoundValues" ); |
|
48 _LIT( KListDataTest7, "CListBoxData::CFontsWithStyle::SetFontStyle" ); |
|
49 _LIT( KListDataTest8, "CListBoxData::CFontsWithStyle::FontStyle" ); |
|
50 _LIT( KListDataTest9, "CListBoxData::SetSearchStringL" ); |
|
51 _LIT( KListDataTest10, "CListBoxData::IsSearchString" ); |
|
52 _LIT( KListDataTest11, "CListBoxData::DrawItem" ); |
|
53 _LIT( KEikSearchString, "abc" ); |
|
54 |
|
55 _LIT( KTestListModelTest1, "CTextListBoxModel::TestItemArrayOwnershipType" ); |
|
56 |
|
57 _LIT( KListBoxEditorTest1, "CEikListBoxEditor::SetFont" ); |
|
58 _LIT( KListBoxEditorTest2, "CEikListBoxEditor::StartEditingL" ); |
|
59 _LIT( KListBoxEditorTest3, "CEikListBoxEditor::SetListBoxEditorObserver" ); |
|
60 _LIT( KListBoxEditorTest4, "CEikListBoxEditor::OfferKeyEventL" ); |
|
61 _LIT( KListBoxEditorTest5, "CEikListBoxEditor::ItemText" ); |
|
62 _LIT( KListBoxEditorTest6, "CEikListBoxEditor::WriteInternalStateL" ); |
|
63 _LIT( KListBoxEditorTest7, "CEikListBoxEditor::UpdateModelL" ); |
|
64 |
|
65 _LIT( KListItemDrawerTest1, "CListItemDrawer::MatcherCursorRect" ); |
|
66 _LIT( KListItemDrawerTest2, "CListItemDrawer::MatcherCursorAscent" ); |
|
67 _LIT( KListItemDrawerTest3, "CListItemDrawer::SetSkinEnabledL" ); |
|
68 _LIT( KListItemDrawerTest4, "CListItemDrawer::SkinBackgroundControlContext" ); |
|
69 _LIT( KListItemDrawerTest5, "CListItemDrawer::SetSkinEnabledL" ); |
|
70 _LIT( KListItemDrawerTest6, "CListItemDrawer::SetFont" ); |
|
71 _LIT( KListItemDrawerTest7, "CListItemDrawer::Font" ); |
|
72 _LIT( KListItemDrawerTest8, "CTextListItemDrawer::Font" ); |
|
73 _LIT( KListItemDrawerTest9, "CListItemDrawer::SetMarkColumnWidth" ); |
|
74 _LIT( KListItemDrawerTest10, "CListItemDrawer::SetMarkGutter" ); |
|
75 _LIT( KListItemDrawerTest11, "CListItemDrawer::MarkGutter" ); |
|
76 _LIT( KListItemDrawerTest12, "CListItemDrawer::MarkColumn" ); |
|
77 _LIT( KListItemDrawerTest13, "CListItemDrawer::DrawItemMark" ); |
|
78 _LIT( KListItemDrawerTest14, "CListItemDrawer::MinimumCellSize" ); |
|
79 _LIT( KListItemDrawerTest15, "CListItemDrawer::ItemWidthInPixels" ); |
|
80 _LIT( KListItemDrawerTest16, "CListItemDrawer::SetSymbolFont" ); |
|
81 _LIT( KListItemDrawerTest17, "CTextListItemDrawer::MatcherCursorRect" ); |
|
82 _LIT( KListItemDrawerTest18, "CTextListItemDrawer::MatcherCursorAscent" ); |
|
83 _LIT( KListItemDrawerTest19, "CTextListItemDrawer::SetSearchStringL" ); |
|
84 _LIT( KListItemDrawerTest20, "CTextListItemDrawer::DrawItemText" ); |
|
85 |
|
86 _LIT( KListViewTest1, "CListBoxView::ToggleItemL" ); |
|
87 _LIT( KListViewTest2, "CListBoxView::SetAnchor" ); |
|
88 _LIT( KListViewTest3, "CListBoxView::DeselectRangeL" ); |
|
89 _LIT( KListViewTest4, "CListBoxView::ScrollToMakeItemVisible" ); |
|
90 _LIT( KListViewTest5, "CListBoxView::SetPaintedSelection" ); |
|
91 _LIT( KListViewTest6, "CListBoxView::SetTextColor" ); |
|
92 _LIT( KListViewTest7, "CListBoxView::TextColor" ); |
|
93 _LIT( KListViewTest8, "CListBoxView::DrawEmptyList" ); |
|
94 _LIT( KListViewTest9, "CListBoxView::SetSelectionIndexesL" ); |
|
95 _LIT( KListViewTest10, "CListBoxView::GetSelectionIndexesL" ); |
|
96 |
|
97 _LIT( KTextItemDrawerMatchText, "Add Items" ); |
|
98 |
|
99 _LIT( KTextListTest1, "CEikListBox::SetScrollBarFrame" ); |
|
100 _LIT( KTextListTest2, "CEikListBox::ConstructL" ); |
|
101 _LIT( KTextListTest3, "CEikListBox::Reset" ); |
|
102 _LIT( KTextListTest4, "CEikListBox::CreateMatchBufferL" ); |
|
103 _LIT( KTextListTest5, "CEikListBox::MatchBuffer" ); |
|
104 _LIT( KTextListTest6, "CEikListBox::ClearMatchBuffer" ); |
|
105 _LIT( KTextListTest7, "CEikListBox::CalcWidthBasedOnNumOfChars" ); |
|
106 _LIT( KTextListTest8, "CEikListBox::CalcWidthBasedOnRequiredItemWidth" ); |
|
107 _LIT( KTextListTest9, "CEikListBox::CalcHeightBasedOnNumOfItems" ); |
|
108 _LIT( KTextListTest10, "CEikListBox::MinimumSize" ); |
|
109 _LIT( KTextListTest11, "CEikListBox::CalcSizeInPixels" ); |
|
110 _LIT( KTextListTest12, "CEikListBox::SetViewRectFromClientRect" ); |
|
111 _LIT( KTextListTest13, "CEikListBox::CalculatePopoutRect" ); |
|
112 _LIT( KTextListTest14, "CEikListBox::BottomItemIndex" ); |
|
113 _LIT( KTextListTest15, "CEikListBox::SetTopItemIndex" ); |
|
114 _LIT( KTextListTest16, "CEikListBox::AdjustTopItemIndex" ); |
|
115 _LIT( KTextListTest17, "CEikListBox::SetCurrentItemIndexAndDraw" ); |
|
116 _LIT( KTextListTest18, "CEikListBox::SetListBoxObserver" ); |
|
117 _LIT( KTextListTest19, "CEikListBox::MakeViewClassInstanceL" ); |
|
118 _LIT( KTextListTest20, "CEikListBox::DrawMatcherCursor" ); |
|
119 _LIT( KTextListTest21, "CEikListBox::InterItemGap" ); |
|
120 _LIT( KTextListTest22, "CEikListBox::CreateScrollBarFrameLayout" ); |
|
121 _LIT( KTextListTest23, "CEikListBox::HorizScrollGranularityInPixels" ); |
|
122 _LIT( KTextListTest24, "CEikListBox::SetViewRectHeightAdjustment" ); |
|
123 _LIT( KTextListTest25, "CEikListBox::VerticalInterItemGap" ); |
|
124 _LIT( KTextListTest26, "CEikListBox::SetSelectionIndexesL" ); |
|
125 _LIT( KTextListTest27, "CEikListBox::SelectionIndexes" ); |
|
126 _LIT( KTextListTest28, "CEikListBox::IsMultiselection" ); |
|
127 _LIT( KTextListTest29, "CEikListBox::ClearSelection" ); |
|
128 _LIT( KTextListTest30, "CEikListBox::HandleLeftArrowKeyL" ); |
|
129 _LIT( KTextListTest31, "CEikListBox::HandleRightArrowKeyL" ); |
|
130 _LIT( KTextListTest32, "CEikListBox::OfferKeyEventL" ); |
|
131 _LIT( KTextListTest33, "CEikListBox::HorizontalNudgeValue" ); |
|
132 _LIT( KTextListTest34, "CEikListBox::HandleScrollEventL" ); |
|
133 _LIT( KTextListTest35, "CEikListBox::HandleDragEventL" ); |
|
134 _LIT( KTextListTest36, "CEikListBox::SimulateArrowKeyEventL" ); |
|
135 _LIT( KTextListTest37, "CEikListBox::SetDimmed" ); |
|
136 _LIT( KTextListTest38, "CEikListBox::UndoLastChar" ); |
|
137 _LIT( KTextListTest39, "CEikListBox::SetShortcutValueFromPrevList" ); |
|
138 _LIT( KTextListTest40, "CEikListBox::ShortcutValueForNextList" ); |
|
139 _LIT( KTextListTest41, "CEikListBox::HighlightRect" ); |
|
140 _LIT( KTextListTest42, "CEikListBox::MatchTypedCharL" ); |
|
141 _LIT( KTextListTest43, "CEikListBox::LastCharMatched" ); |
|
142 _LIT( KTextListTest44, "CEikListBox::SetLaunchingButton" ); |
|
143 _LIT( KTextListTest45, "CEikListBox::EventModifiers" ); |
|
144 _LIT( KTextListTest46, "CEikListBox::ReasonForFocusLostL" ); |
|
145 _LIT( KTextListTest47, "CEikListBox::EditItemL" ); |
|
146 _LIT( KTextListTest48, "CEikListBox::StopEditingL" ); |
|
147 _LIT( KTextListTest49, "CEikListBox::HandleItemAdditionL" ); |
|
148 _LIT( KTextListTest50, "CEikListBox::HandleItemRemovalL" ); |
|
149 _LIT( KTextListTest51, "CEikListBox::HandleItemRemovalL()" ); |
|
150 _LIT( KTextListTest52, "CEikTextListBox::Model" ); |
|
151 _LIT( KTextListTest53, "CEikTextListBox::WriteInternalStateL" ); |
|
152 _LIT( KTextListTest54, "CEikTextListBox::ConstructFromResourceL" ); |
|
153 _LIT( KEikAddItem, "One added text" ); |
|
154 |
|
155 _LIT( KSnakingViewTest1, "CSnakingListBoxView::VisibleWidth" ); |
|
156 _LIT( KSnakingViewTest2, "CSnakingListBoxView::HScroll" ); |
|
157 _LIT( KSnakingViewTest3, "CSnakingListBoxView::SetItemHeight" ); |
|
158 _LIT( KSnakingViewTest4, "CSnakingListBoxView::CalculateHScrollOffsetSoItemIsVisible" ); |
|
159 |
|
160 _LIT( KSnakingTest1, "CEikSnakingListBox::MakeViewClassInstanceL" ); |
|
161 _LIT( KSnakingTest2, "CEikSnakingListBox::SetColumnWidth" ); |
|
162 _LIT( KSnakingTest3, "CEikSnakingListBox::ColumnWidth" ); |
|
163 _LIT( KSnakingTest4, "CEikSnakingListBox::HandleLeftArrowKeyL" ); |
|
164 _LIT( KSnakingTest5, "CEikSnakingListBox::HandleRightArrowKeyL" ); |
|
165 _LIT( KSnakingTest6, "CEikSnakingListBox::HorizontalNudgeValue" ); |
|
166 _LIT( KSnakingTest7, "CEikSnakingListBox::HorizScrollGranularityInPixels" ); |
|
167 _LIT( KSnakingTest8, "CEikSnakingListBox::SetTopItemIndex" ); |
|
168 _LIT( KSnakingTest9, "CEikSnakingListBox::AdjustTopItemIndex" ); |
|
169 _LIT( KSnakingTest10, "CEikSnakingListBox::SizeChanged" ); |
|
170 _LIT( KSnakingTest11, "CEikSnakingListBox::HandleDragEventL" ); |
|
171 _LIT( KSnakingTest12, "CEikSnakingListBox::HandleViewRectSizeChangeL" ); |
|
172 _LIT( KSnakingTest13, "CEikSnakingListBox::MoveToNextOrPreviousItemL" ); |
|
173 _LIT( KSnakingTest14, "CEikSnakingListBox::RestoreClientRectFromViewRect" ); |
|
174 _LIT( KSnakingTest15, "CEikSnakingListBox::AdjustRectHeightToWholeNumberOfItems" ); |
|
175 _LIT( KSnakingTest16, "CEikSnakingListBox::GetColorUseListL" ); |
|
176 _LIT( KSnakingTest17, "CEikSnakingTextListBox::GetColorUseListL" ); |
|
177 _LIT( KSnakingTest18, "CEikSnakingListBox::HandlePointerEventL" ); |
|
178 _LIT( KSnakingTest19, "CEikSnakingTextListBox::HandlePointerEventL" ); |
|
179 _LIT( KSnakingTest20, "CEikSnakingListBox::HandleResourceChange" ); |
|
180 _LIT( KSnakingTest21, "CEikSnakingTextListBox::HandleResourceChange" ); |
|
181 _LIT( KSnakingTest22, "CEikSnakingTextListBox::Model" ); |
|
182 |
|
183 |
|
184 // ======== MEMBER FUNCTIONS ======== |
|
185 |
|
186 // --------------------------------------------------------------------------- |
|
187 // Symbian 2nd static Constructor |
|
188 // --------------------------------------------------------------------------- |
|
189 // |
|
190 CBCTestListEiklistCase* CBCTestListEiklistCase::NewL( |
|
191 CBCTestListContainer* aContainer, CEikonEnv* aEikEnv ) |
|
192 { |
|
193 CBCTestListEiklistCase* self = new( ELeave ) CBCTestListEiklistCase( |
|
194 aContainer, aEikEnv ); |
|
195 CleanupStack::PushL( self ); |
|
196 self->ConstructL(); |
|
197 CleanupStack::Pop( self ); |
|
198 return self; |
|
199 } |
|
200 |
|
201 // --------------------------------------------------------------------------- |
|
202 // C++ default constructor |
|
203 // --------------------------------------------------------------------------- |
|
204 // |
|
205 CBCTestListEiklistCase::CBCTestListEiklistCase( CBCTestListContainer* aContainer, |
|
206 CEikonEnv* aEikEnv ) |
|
207 : CBCTestListBaseCase( aContainer, aEikEnv ) |
|
208 { |
|
209 } |
|
210 |
|
211 // --------------------------------------------------------------------------- |
|
212 // Destructor |
|
213 // --------------------------------------------------------------------------- |
|
214 // |
|
215 CBCTestListEiklistCase::~CBCTestListEiklistCase() |
|
216 { |
|
217 ReleaseCase(); |
|
218 } |
|
219 |
|
220 // --------------------------------------------------------------------------- |
|
221 // Symbian 2nd Constructor |
|
222 // --------------------------------------------------------------------------- |
|
223 // |
|
224 void CBCTestListEiklistCase::ConstructL() |
|
225 { |
|
226 BuildScriptL(); |
|
227 } |
|
228 |
|
229 // --------------------------------------------------------------------------- |
|
230 // CBCTestListEiklistCase::BuildScriptL |
|
231 // --------------------------------------------------------------------------- |
|
232 // |
|
233 void CBCTestListEiklistCase::BuildScriptL() |
|
234 { |
|
235 for ( TInt i=0; i <= EBCTestCmdOutline55 - EBCTestCmdOutline51; i++ ) |
|
236 { |
|
237 AddTestL( LeftCBA, REP( Down, 8 ), KeyOK, TEND ); |
|
238 AddTestL( REP( Down, i ), KeyOK, TEND ); |
|
239 } |
|
240 } |
|
241 |
|
242 // --------------------------------------------------------------------------- |
|
243 // CBCTestListEiklistCase::RunL |
|
244 // --------------------------------------------------------------------------- |
|
245 // |
|
246 void CBCTestListEiklistCase::RunL( TInt aCmd ) |
|
247 { |
|
248 if ( aCmd < EBCTestCmdOutline51 || aCmd > EBCTestCmdOutline55 ) |
|
249 { |
|
250 return; |
|
251 } |
|
252 iCurrentCmd = aCmd; |
|
253 ReleaseCase(); |
|
254 PrepareCaseL( aCmd ); |
|
255 switch( aCmd ) |
|
256 { |
|
257 case EBCTestCmdOutline51: |
|
258 TestListBoxDataL(); |
|
259 break; |
|
260 case EBCTestCmdOutline52: |
|
261 TestCEikListBoxEditorL(); |
|
262 break; |
|
263 case EBCTestCmdOutline53: |
|
264 TestCTextListItemDrawerL(); |
|
265 break; |
|
266 case EBCTestCmdOutline54: |
|
267 TestEikListBoxL(); |
|
268 TestListBoxViewL(); |
|
269 break; |
|
270 case EBCTestCmdOutline55: |
|
271 TestSnakingListBoxL(); |
|
272 TestSnakingListBoxViewL(); |
|
273 default: |
|
274 break; |
|
275 } |
|
276 } |
|
277 |
|
278 // --------------------------------------------------------------------------- |
|
279 // CBCTestListEiklistCase::PrepareCaseL |
|
280 // --------------------------------------------------------------------------- |
|
281 // |
|
282 void CBCTestListEiklistCase::PrepareCaseL( TInt aCmd ) |
|
283 { |
|
284 TInt flags = CEikListBox::EIncrementalMatching | |
|
285 EAknListBoxSelectionList | EAknListBoxViewerFlags; |
|
286 CDesCArray* textArray = NULL; |
|
287 |
|
288 if ( aCmd != EBCTestCmdOutline51 ) |
|
289 { |
|
290 textArray = iEikEnv->ReadDesCArrayResourceL( |
|
291 R_BCTESTLIST_ITEM_SINGLE1_ADD_RM ); |
|
292 CleanupStack::PushL( textArray ); |
|
293 } |
|
294 |
|
295 if ( aCmd == EBCTestCmdOutline52 || aCmd == EBCTestCmdOutline53 ) |
|
296 { |
|
297 iModel = new( ELeave ) CBCTestTextListModel(); |
|
298 iModel->ConstructL( textArray ); |
|
299 } |
|
300 |
|
301 switch ( aCmd ) |
|
302 { |
|
303 case EBCTestCmdOutline51: |
|
304 iData = new( ELeave ) CBCTestListBoxData(); |
|
305 AssertNotNullL( iData, KListBoxDataCreate ); |
|
306 iData->ConstructL( iEikEnv->NormalFont() ); |
|
307 break; |
|
308 case EBCTestCmdOutline53: |
|
309 iTextDrawer = new( ELeave ) CBCTestTextListItemDrawer( iModel, |
|
310 iEikEnv->NormalFont() ); |
|
311 AssertNotNullL( iTextDrawer, KTextItemDrawerCreate ); |
|
312 break; |
|
313 case EBCTestCmdOutline54: |
|
314 { |
|
315 iListBox = new( ELeave ) CBCTestTextListBox(); |
|
316 AssertNotNullL( iListBox, KTextListCreate ); |
|
317 iListBox->ConstructL( iContainer, flags ); |
|
318 iListBox->Model()->SetItemTextArray( textArray ); |
|
319 iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray ); |
|
320 |
|
321 CEikScrollBarFrame* scrollBarFrame = new( ELeave) CEikScrollBarFrame( |
|
322 iContainer, iListBox, ETrue ); |
|
323 CleanupStack::PushL( scrollBarFrame ); |
|
324 iListBox->SetScrollBarFrame( scrollBarFrame, |
|
325 CEikListBox::ENotOwnedExternally ); |
|
326 AssertTrueL( ETrue, KTextListTest1 ); |
|
327 CleanupStack::Pop( scrollBarFrame ); |
|
328 |
|
329 iContainer->SetControl( iListBox ); |
|
330 } |
|
331 break; |
|
332 case EBCTestCmdOutline55: |
|
333 iSnakingList = new( ELeave ) CBCTestTextSnakingListBox(); |
|
334 AssertNotNullL( iSnakingList, KSnakingListCreate ); |
|
335 flags |= CEikListBox::ELeftDownInViewRect; |
|
336 iSnakingList->ConstructL( iContainer, flags ); |
|
337 iSnakingList->Model()->SetItemTextArray( textArray ); |
|
338 iSnakingList->Model()->SetOwnershipType( ELbmOwnsItemArray ); |
|
339 |
|
340 iContainer->SetControl( iSnakingList ); |
|
341 default: |
|
342 break; |
|
343 } |
|
344 |
|
345 if ( aCmd != EBCTestCmdOutline51 ) |
|
346 { |
|
347 CleanupStack::Pop( textArray ); |
|
348 } |
|
349 } |
|
350 |
|
351 // --------------------------------------------------------------------------- |
|
352 // CBCTestListEiklistCase::ReleaseCase |
|
353 // --------------------------------------------------------------------------- |
|
354 // |
|
355 void CBCTestListEiklistCase::ReleaseCase() |
|
356 { |
|
357 iContainer->ResetControl(); |
|
358 iListBox = NULL; |
|
359 iSnakingList = NULL; |
|
360 |
|
361 delete iModel; |
|
362 delete iData; |
|
363 delete iTextDrawer; |
|
364 |
|
365 iModel = NULL; |
|
366 iData = NULL; |
|
367 iTextDrawer = NULL; |
|
368 } |
|
369 |
|
370 // --------------------------------------------------------------------------- |
|
371 // Test CListBoxData |
|
372 // --------------------------------------------------------------------------- |
|
373 // |
|
374 void CBCTestListEiklistCase::TestListBoxDataL() |
|
375 { |
|
376 MAknsControlContext* controlCtx = iData->SkinBackgroundControlContext(); |
|
377 AssertTrueL( ETrue, KListDataTest1 ); |
|
378 |
|
379 const TListFontBoundValues& boundValue = iData->FontBoundValues(); |
|
380 AssertTrueL( ETrue, KListDataTest2 ); |
|
381 |
|
382 TInt fontHeightInTwips = 10; |
|
383 TInt height = iData->SetFontHeight( fontHeightInTwips ); |
|
384 AssertTrueL( ETrue, KListDataTest3 ); |
|
385 |
|
386 // Test protected API |
|
387 iData->TestConstructFontL( iEikEnv->TitleFont() ); |
|
388 AssertTrueL( ETrue, KListDataTest4 ); |
|
389 TInt testRet = iData->TestRegenerateFonts(); |
|
390 AssertTrueL( ETrue, KListDataTest5 ); |
|
391 iData->TestUpdateFontBoundValues( iEikEnv->NormalFont() ); |
|
392 AssertTrueL( ETrue, KListDataTest6 ); |
|
393 TBool ret = iData->TestCFontWithStyle(); |
|
394 AssertTrueL( ret, KListDataTest7 ); |
|
395 AssertTrueL( ret, KListDataTest8 ); |
|
396 |
|
397 |
|
398 TPtrC ptr( KEikSearchString ); |
|
399 iData->SetSearchStringL( &ptr ); |
|
400 AssertTrueL( ETrue, KListDataTest9 ); |
|
401 TBool search = iData->IsSearchString(); |
|
402 AssertTrueL( ETrue, KListDataTest10 ); |
|
403 |
|
404 iContainer->ActivateGc(); |
|
405 CWindowGc& gc = iContainer->SystemGc(); |
|
406 const TInt KRectHeight = 30; |
|
407 TRect rect = iContainer->Rect(); |
|
408 rect.iBr.iY = rect.iTl.iY + KRectHeight; |
|
409 const CFont& font = *iEikEnv->NormalFont(); |
|
410 gc.UseFont( &font ); |
|
411 iData->DrawItem( gc, rect, KEikTestText, font, 0 ); |
|
412 AssertTrueL( ETrue, KListDataTest11 ); |
|
413 iContainer->DeactivateGc(); |
|
414 } |
|
415 |
|
416 // --------------------------------------------------------------------------- |
|
417 // Test CEikListBoxEditor |
|
418 // --------------------------------------------------------------------------- |
|
419 // |
|
420 void CBCTestListEiklistCase::TestCEikListBoxEditorL() |
|
421 { |
|
422 // test CTextListBoxModel |
|
423 const MDesCArray* array = iModel->MatchableTextArray(); |
|
424 TListBoxModelItemArrayOwnership type = |
|
425 iModel->TestItemArrayOwnershipType(); |
|
426 AssertIntL( ELbmOwnsItemArray, type, KTestListModelTest1 ); |
|
427 |
|
428 // test CBCTestListBoxEditor |
|
429 CBCTestListBoxEditor* editor = new( ELeave ) CBCTestListBoxEditor( |
|
430 iModel, iEikEnv ); |
|
431 CleanupStack::PushL( editor ); |
|
432 editor->SetFont( iEikEnv->NormalFont() ); |
|
433 AssertTrueL( ETrue, KListBoxEditorTest1 ); |
|
434 |
|
435 TRect rect = iContainer->Rect(); |
|
436 rect.iBr.iY = rect.iTl.iY + rect.Size().iHeight / 2; |
|
437 editor->StartEditingL( *iContainer, rect, 0, 30 ); |
|
438 AssertTrueL( ETrue, KListBoxEditorTest2 ); |
|
439 |
|
440 TBCTestListBoxEditorObserver observer; |
|
441 editor->SetListBoxEditorObserver( &observer ); |
|
442 AssertTrueL( ETrue, KListBoxEditorTest3 ); |
|
443 |
|
444 TKeyEvent eventEnter = { EKeyEnter, EKeyEnter, 0, 0 }; |
|
445 TKeyEvent eventShift = { '1', '1', EModifierCtrl | EModifierShift, 0 }; |
|
446 TKeyEvent eventT = { 'T', 'T', 0, 0 }; |
|
447 TKeyEvent evente = { 'e', 'e', 0, 0 }; |
|
448 TKeyEvent events = { 's', 's', 0, 0 }; |
|
449 TKeyEvent eventt = { 't', 't', 0, 0 }; |
|
450 |
|
451 editor->OfferKeyEventL( eventEnter, EEventKey ); |
|
452 editor->SetListBoxEditorObserver( NULL ); |
|
453 |
|
454 editor->OfferKeyEventL( eventT, EEventKey ); |
|
455 editor->OfferKeyEventL( evente, EEventKey ); |
|
456 editor->OfferKeyEventL( events, EEventKey ); |
|
457 editor->OfferKeyEventL( eventt, EEventKey ); |
|
458 editor->OfferKeyEventL( eventShift, EEventKey ); |
|
459 AssertTrueL( ETrue, KListBoxEditorTest4 ); |
|
460 |
|
461 TPtrC text = editor->ItemText(); |
|
462 AssertTrueL( ETrue, KListBoxEditorTest5 ); |
|
463 |
|
464 editor->TestWriteInternalStateL(); |
|
465 AssertTrueL( ETrue, KListBoxEditorTest6 ); |
|
466 |
|
467 editor->OfferKeyEventL( eventEnter, EEventKey ); |
|
468 AssertTrueL( ETrue, KListBoxEditorTest7 ); |
|
469 |
|
470 CleanupStack::PopAndDestroy( editor ); |
|
471 } |
|
472 |
|
473 // --------------------------------------------------------------------------- |
|
474 // Test CTextListItemDrawer |
|
475 // --------------------------------------------------------------------------- |
|
476 // |
|
477 void CBCTestListEiklistCase::TestCTextListItemDrawerL() |
|
478 { |
|
479 CTextListItemDrawer* textDrawer = new( ELeave ) CTextListItemDrawer(); |
|
480 CleanupStack::PushL( textDrawer ); |
|
481 _LIT( KTestItemDrawer1, |
|
482 "CTextListItemDrawer::CTextListItemDrawer without parameter" ); |
|
483 AssertNotNullL( textDrawer, KTestItemDrawer1 ); |
|
484 |
|
485 textDrawer->ConstructL( iEikEnv->NormalFont() ); |
|
486 _LIT( KTestItemDrawer2, "CTextListItemDrawer::ConstructL" ); |
|
487 AssertNotNullL( textDrawer, KTestItemDrawer2 ); |
|
488 CleanupStack::PopAndDestroy( textDrawer ); |
|
489 |
|
490 // test CListItemDrawer |
|
491 TRect cursorRect = iTextDrawer->CListItemDrawer::MatcherCursorRect( |
|
492 KTextItemDrawerMatchText, 0, 0, 0 ); |
|
493 AssertTrueL( ETrue, KListItemDrawerTest1 ); |
|
494 |
|
495 TInt cursorAscent = iTextDrawer->CListItemDrawer:: |
|
496 MatcherCursorAscent( 0 ); |
|
497 AssertTrueL( ETrue, KListItemDrawerTest2 ); |
|
498 |
|
499 iTextDrawer->SetSkinEnabledL( ETrue ); |
|
500 AssertTrueL( ETrue, KListItemDrawerTest3 ); |
|
501 |
|
502 MAknsControlContext* context = |
|
503 iTextDrawer->SkinBackgroundControlContext(); |
|
504 AssertTrueL( ETrue, KListItemDrawerTest4 ); |
|
505 |
|
506 iTextDrawer->SetSkinEnabledL( EFalse ); |
|
507 AssertTrueL( ETrue, KListItemDrawerTest5 ); |
|
508 |
|
509 iTextDrawer->SetFont( iEikEnv->TitleFont() ); |
|
510 AssertTrueL( ETrue, KListItemDrawerTest6 ); |
|
511 |
|
512 const CFont* font = iTextDrawer->CListItemDrawer::Font( 0 ); |
|
513 AssertTrueL( ETrue, KListItemDrawerTest7 ); |
|
514 |
|
515 const CFont* textFont = iTextDrawer->Font( 0 ); |
|
516 AssertTrueL( ETrue, KListItemDrawerTest8 ); |
|
517 |
|
518 iTextDrawer->SetMarkColumnWidth( 50 ); |
|
519 AssertTrueL( ETrue, KListItemDrawerTest9 ); |
|
520 |
|
521 iTextDrawer->SetMarkGutter( 20 ); |
|
522 AssertTrueL( ETrue, KListItemDrawerTest10 ); |
|
523 |
|
524 TInt markGutter = iTextDrawer->MarkGutter(); |
|
525 AssertTrueL( ETrue, KListItemDrawerTest11 ); |
|
526 |
|
527 TInt markColumn = iTextDrawer->MarkColumn(); |
|
528 AssertTrueL( ETrue, KListItemDrawerTest12 ); |
|
529 |
|
530 iTextDrawer->DrawItemMark( ETrue, EFalse, TPoint( 0, 0 ) ); |
|
531 AssertTrueL( ETrue, KListItemDrawerTest13 ); |
|
532 |
|
533 TRect rect = iContainer->Rect(); |
|
534 TSize size = iTextDrawer->CListItemDrawer::MinimumCellSize(); |
|
535 AssertTrueL( ETrue, KListItemDrawerTest14 ); |
|
536 |
|
537 size = iTextDrawer->ItemCellSize(); |
|
538 rect.iBr.iY = rect.iTl.iY + size.iHeight; |
|
539 rect.iBr.iX = rect.iTl.iX + size.iWidth; |
|
540 iTextDrawer->ClearRect( rect ); |
|
541 TInt itemWidthInPixel = iTextDrawer->ItemWidthInPixels( 0 ); |
|
542 AssertTrueL( ETrue, KListItemDrawerTest15 ); |
|
543 |
|
544 iTextDrawer->SetSymbolFont( iEikEnv->NormalFont() ); |
|
545 AssertTrueL( ETrue, KListItemDrawerTest16 ); |
|
546 |
|
547 // test CTextListItemDrawer |
|
548 cursorRect = iTextDrawer->MatcherCursorRect( KTextItemDrawerMatchText, 0, 0, 0 ); |
|
549 AssertTrueL( ETrue, KListItemDrawerTest17 ); |
|
550 |
|
551 cursorAscent = iTextDrawer->MatcherCursorAscent( 0 ); |
|
552 AssertTrueL( ETrue, KListItemDrawerTest18 ); |
|
553 |
|
554 TPtrC ptr( KTextItemDrawerMatchText ); |
|
555 iTextDrawer->SetSearchStringL( &ptr ); |
|
556 AssertTrueL( ETrue, KListItemDrawerTest19 ); |
|
557 |
|
558 iContainer->ActivateGc(); |
|
559 CWindowGc& gc = iContainer->SystemGc(); |
|
560 iTextDrawer->TestDrawItemText( gc ); |
|
561 AssertTrueL( ETrue, KListItemDrawerTest20 ); |
|
562 iContainer->DeactivateGc(); |
|
563 } |
|
564 |
|
565 // --------------------------------------------------------------------------- |
|
566 // Test CListBoxView |
|
567 // --------------------------------------------------------------------------- |
|
568 // |
|
569 void CBCTestListEiklistCase::TestListBoxViewL() |
|
570 { |
|
571 CListBoxView* view = iListBox->View(); |
|
572 view->ToggleItemL( 0 ); |
|
573 AssertTrueL( ETrue, KListViewTest1 ); |
|
574 |
|
575 view->SetAnchor( 8 ); |
|
576 AssertTrueL( ETrue, KListViewTest2 ); |
|
577 |
|
578 view->DeselectRangeL( 0, 4 ); |
|
579 AssertTrueL( ETrue, KListViewTest3 ); |
|
580 |
|
581 TBool visible = view->ScrollToMakeItemVisible( 8 ); |
|
582 AssertTrueL( ETrue, KListViewTest4 ); |
|
583 |
|
584 view->SetPaintedSelection( ETrue ); |
|
585 AssertTrueL( ETrue, KListViewTest5 ); |
|
586 |
|
587 view->SetTextColor( KRgbBlack ); |
|
588 AssertTrueL( ETrue, KListViewTest6 ); |
|
589 |
|
590 TRgb rgb = view->TextColor(); |
|
591 AssertTrueL( rgb == KRgbBlack, KListViewTest7 ); |
|
592 |
|
593 view->DrawEmptyList( iContainer->Rect() ); |
|
594 AssertTrueL( ETrue, KListViewTest8 ); |
|
595 |
|
596 TInt topIndex = view->CalcNewTopItemIndexSoItemIsVisible( 8 ); |
|
597 _LIT( KListViewTest11, |
|
598 "CListBoxView::CalcNewTopItemIndexSoItemIsVisible" ); |
|
599 AssertTrueL( ETrue, KListViewTest11 ); |
|
600 |
|
601 CArrayFixFlat<TInt>* selectionArray = new( ELeave ) |
|
602 CArrayFixFlat<TInt>( 5 ); |
|
603 CleanupStack::PushL( selectionArray ); |
|
604 selectionArray->AppendL( 0 ); |
|
605 selectionArray->AppendL( 1 ); |
|
606 selectionArray->AppendL( 2 ); |
|
607 view->SetSelectionIndexesL( selectionArray ); |
|
608 AssertTrueL( ETrue, KListViewTest9 ); |
|
609 |
|
610 selectionArray->Reset(); |
|
611 view->GetSelectionIndexesL( selectionArray ); |
|
612 AssertTrueL( ( selectionArray->Length() == 4 && |
|
613 selectionArray->At(0) == 0), |
|
614 KListViewTest10 ); |
|
615 |
|
616 CleanupStack::PopAndDestroy( selectionArray ); |
|
617 } |
|
618 |
|
619 // --------------------------------------------------------------------------- |
|
620 // Test CEikListBox |
|
621 // --------------------------------------------------------------------------- |
|
622 // |
|
623 void CBCTestListEiklistCase::TestEikListBoxL() |
|
624 { |
|
625 // test constructL of CEikListBox |
|
626 CDesCArray* textArray = iEikEnv->ReadDesCArrayResourceL( |
|
627 R_BCTESTLIST_ITEM_SINGLE1 ); |
|
628 CleanupStack::PushL( textArray ); |
|
629 |
|
630 CTextListBoxModel* model = new( ELeave ) CTextListBoxModel(); |
|
631 CleanupStack::PushL( model ); |
|
632 model->ConstructL( textArray ); |
|
633 |
|
634 CTextListItemDrawer* drawer = new( ELeave ) CTextListItemDrawer(); |
|
635 CleanupStack::PushL( drawer ); |
|
636 drawer->ConstructL( iEikEnv->NormalFont() ); |
|
637 |
|
638 CEikListBox* listBox = new( ELeave ) CEikListBox(); |
|
639 CleanupStack::PushL( listBox ); |
|
640 TGulBorder border( TGulBorder::ESingleGray ); |
|
641 listBox->ConstructL( model, drawer, |
|
642 iContainer, border, |
|
643 EAknListBoxSelectionList | EAknListBoxViewerFlags ); |
|
644 |
|
645 CleanupStack::PopAndDestroy( listBox ); |
|
646 CleanupStack::Pop( drawer ); |
|
647 CleanupStack::Pop( model ); |
|
648 CleanupStack::Pop( textArray ); |
|
649 AssertTrueL( ETrue, KTextListTest2 ); |
|
650 |
|
651 // test CEikListBox |
|
652 TRect rect = iContainer->Rect(); |
|
653 iListBox->Reset(); |
|
654 AssertTrueL( ETrue, KTextListTest3 ); |
|
655 iListBox->CreateMatchBufferL(); |
|
656 AssertTrueL( ETrue, KTextListTest4 ); |
|
657 RIncrMatcherBase* baMatch = iListBox->MatchBuffer(); |
|
658 AssertTrueL( ETrue, KTextListTest5 ); |
|
659 iListBox->ClearMatchBuffer(); |
|
660 AssertTrueL( ETrue, KTextListTest6 ); |
|
661 iListBox->CalcWidthBasedOnNumOfChars( 5 ); |
|
662 AssertTrueL( ETrue, KTextListTest7 ); |
|
663 iListBox->CalcWidthBasedOnRequiredItemWidth( 30 ); |
|
664 AssertTrueL( ETrue, KTextListTest8 ); |
|
665 iListBox->CalcHeightBasedOnNumOfItems( 2 ); |
|
666 AssertTrueL( ETrue, KTextListTest9 ); |
|
667 TSize size = iListBox->MinimumSize(); |
|
668 AssertTrueL( ETrue, KTextListTest10 ); |
|
669 iListBox->CalcSizeInPixels( 5, 2 ); |
|
670 AssertTrueL( ETrue, KTextListTest11 ); |
|
671 iListBox->SetViewRectFromClientRect( rect ); |
|
672 AssertTrueL( ETrue, KTextListTest12 ); |
|
673 iListBox->CalculatePopoutRect( 0, 0, rect ); |
|
674 AssertTrueL( ETrue, KTextListTest13 ); |
|
675 TInt bottomIndex = iListBox->BottomItemIndex(); |
|
676 AssertTrueL( ETrue, KTextListTest14 ); |
|
677 iListBox->SetTopItemIndex( 1 ); |
|
678 AssertTrueL( ETrue, KTextListTest15 ); |
|
679 iListBox->AdjustTopItemIndex(); |
|
680 AssertTrueL( ETrue, KTextListTest16 ); |
|
681 iListBox->SetCurrentItemIndexAndDraw( 0 ); |
|
682 AssertTrueL( ETrue, KTextListTest17 ); |
|
683 TBCTestListBoxObserver observer; |
|
684 iListBox->SetListBoxObserver( &observer ); |
|
685 AssertTrueL( ETrue, KTextListTest18 ); |
|
686 CListBoxView* view = iListBox->MakeViewClassInstanceL(); |
|
687 delete view; |
|
688 AssertTrueL( ETrue, KTextListTest19 ); |
|
689 iListBox->DrawMatcherCursor(); |
|
690 AssertTrueL( ETrue, KTextListTest20 ); |
|
691 TInt interItemGap = iListBox->InterItemGap(); |
|
692 AssertTrueL( ETrue, KTextListTest21 ); |
|
693 TEikScrollBarFrameLayout frameLayout; |
|
694 iListBox->CreateScrollBarFrameLayout( frameLayout ); |
|
695 AssertTrueL( ETrue, KTextListTest22 ); |
|
696 TInt scrollGraInPixels = iListBox->HorizScrollGranularityInPixels(); |
|
697 AssertTrueL( ETrue, KTextListTest23 ); |
|
698 iListBox->SetViewRectHeightAdjustment( 5 ); |
|
699 AssertTrueL( ETrue, KTextListTest24 ); |
|
700 TInt verticalInterItemGap = iListBox->VerticalInterItemGap(); |
|
701 AssertTrueL( ETrue, KTextListTest25 ); |
|
702 iListBox->ScrollToMakeItemVisible( 5 ); |
|
703 |
|
704 CArrayFixFlat<TInt>* selectionArray = new( ELeave ) |
|
705 CArrayFixFlat<TInt>( 4 ); |
|
706 CleanupStack::PushL( selectionArray ); |
|
707 selectionArray->AppendL( 0 ); |
|
708 selectionArray->AppendL( 1 ); |
|
709 selectionArray->AppendL( 3 ); |
|
710 iListBox->SetSelectionIndexesL( selectionArray ); |
|
711 AssertTrueL( ETrue, KTextListTest26 ); |
|
712 const CArrayFix<TInt>* getSelectionArray = iListBox->SelectionIndexes(); |
|
713 AssertTrueL( |
|
714 ( selectionArray->Length() == getSelectionArray->Length() ) |
|
715 && ( selectionArray->At( 0 ) == getSelectionArray->At( 0 ) ), |
|
716 KTextListTest27 ); |
|
717 TBool multiselection = iListBox->IsMultiselection(); |
|
718 AssertTrueL( !multiselection, KTextListTest28 ); |
|
719 CleanupStack::PopAndDestroy( selectionArray ); |
|
720 iListBox->ClearSelection(); |
|
721 AssertTrueL( ETrue, KTextListTest29 ); |
|
722 iListBox->HandleLeftArrowKeyL( CListBoxView::ESingleSelection ); |
|
723 AssertTrueL( ETrue, KTextListTest30 ); |
|
724 iListBox->HandleRightArrowKeyL( CListBoxView::ENoSelection ); |
|
725 AssertTrueL( ETrue, KTextListTest31 ); |
|
726 TKeyEvent eventT = { 'T', 'T', 0, 0 }; |
|
727 iListBox->OfferKeyEventL( eventT, EEventKey ); |
|
728 AssertTrueL( ETrue, KTextListTest32 ); |
|
729 TInt horizontalNudge = iListBox->HorizontalNudgeValue(); |
|
730 AssertTrueL( ETrue, KTextListTest33 ); |
|
731 CEikScrollBar* scrollBar = new( ELeave ) CEikScrollBar(); |
|
732 CleanupStack::PushL( scrollBar ); |
|
733 scrollBar->ConstructL( iListBox, iContainer, CEikScrollBar::EVertical, |
|
734 iContainer->Rect().Size().iHeight ); |
|
735 iListBox->HandleScrollEventL( scrollBar, EEikScrollDown ); |
|
736 AssertTrueL( ETrue, KTextListTest34 ); |
|
737 CleanupStack::PopAndDestroy( scrollBar ); |
|
738 iListBox->HandleDragEventL( TPoint( 0, 0 ) ); |
|
739 AssertTrueL( ETrue, KTextListTest35 ); |
|
740 iListBox->SimulateArrowKeyEventL( EKeyDownArrow ); |
|
741 AssertTrueL( ETrue, KTextListTest36 ); |
|
742 iListBox->SetDimmed( ETrue ); |
|
743 iListBox->SetDimmed( EFalse ); |
|
744 AssertTrueL( ETrue, KTextListTest37 ); |
|
745 iListBox->UndoLastChar(); |
|
746 AssertTrueL( ETrue, KTextListTest38 ); |
|
747 |
|
748 iListBox->SetShortcutValueFromPrevList( 1 ); |
|
749 AssertTrueL( ETrue, KTextListTest39 ); |
|
750 TInt shortcutValue = iListBox->ShortcutValueForNextList(); |
|
751 AssertTrueL( ETrue, KTextListTest40 ); |
|
752 TRect hightlightRect = iListBox->HighlightRect(); |
|
753 AssertTrueL( ETrue, KTextListTest41 ); |
|
754 iListBox->MatchTypedCharL( 'm' ); |
|
755 AssertTrueL( ETrue, KTextListTest42 ); |
|
756 TBool lastCharMatched = iListBox->LastCharMatched(); |
|
757 AssertTrueL( ETrue, KTextListTest43 ); |
|
758 iListBox->SetLaunchingButton( NULL ); |
|
759 AssertTrueL( ETrue, KTextListTest44 ); |
|
760 |
|
761 TInt eventModified = iListBox->EventModifiers(); |
|
762 AssertTrueL( ETrue, KTextListTest45 ); |
|
763 CEikListBox::TReasonForFocusLost reason = |
|
764 iListBox->ReasonForFocusLostL(); |
|
765 AssertTrueL( ETrue, KTextListTest46 ); |
|
766 iListBox->EditItemL( 40 ); |
|
767 AssertTrueL( ETrue, KTextListTest47 ); |
|
768 iListBox->StopEditingL( EFalse ); |
|
769 AssertTrueL( ETrue, KTextListTest48 ); |
|
770 |
|
771 CArrayFixFlat<TInt>* indexArray = new( ELeave ) CArrayFixFlat<TInt>( 4 ); |
|
772 CleanupStack::PushL( indexArray ); |
|
773 indexArray->AppendL( 9 ); |
|
774 indexArray->AppendL( 10 ); |
|
775 CDesCArray* array = static_cast<CDesCArray*>( |
|
776 iListBox->Model()->ItemTextArray() ); |
|
777 array->AppendL( KEikAddItem ); |
|
778 array->AppendL( KEikAddItem ); |
|
779 iListBox->HandleItemAdditionL( *indexArray ); |
|
780 AssertTrueL( ETrue, KTextListTest49 ); |
|
781 iListBox->HandleItemRemovalL( *indexArray ); |
|
782 AssertTrueL( ETrue, KTextListTest50 ); |
|
783 iListBox->HandleItemRemovalL(); |
|
784 AssertTrueL( ETrue, KTextListTest51 ); |
|
785 CleanupStack::PopAndDestroy( indexArray ); |
|
786 |
|
787 // test CEikTextListBox |
|
788 CTextListBoxModel* textModel = iListBox->Model(); |
|
789 AssertTrueL( ETrue, KTextListTest52 ); |
|
790 |
|
791 RFs& tempServer = iEikEnv->FsSession(); |
|
792 tempServer.Delete( KStreamName ); |
|
793 RFileWriteStream fWrite; |
|
794 User::LeaveIfError( fWrite.Create( tempServer, |
|
795 KStreamName, EFileWrite ) ); |
|
796 CleanupClosePushL( fWrite ); |
|
797 iListBox->WriteInternalStateL( fWrite ); |
|
798 AssertTrueL( ETrue, KTextListTest53 ); |
|
799 CleanupStack::PopAndDestroy( &fWrite ); |
|
800 |
|
801 CEikTextListBox* textList = new( ELeave ) CEikTextListBox(); |
|
802 CleanupStack::PushL( textList ); |
|
803 textList->SetContainerWindowL( *iContainer ); |
|
804 TResourceReader textReader; |
|
805 iEikEnv->CreateResourceReaderLC( textReader, |
|
806 R_BCTESTLIST_SINGLE_1_ADD_RM ); |
|
807 textList->ConstructFromResourceL( textReader ); |
|
808 CleanupStack::PopAndDestroy(); // textReader |
|
809 CleanupStack::PopAndDestroy( textList ); |
|
810 AssertTrueL( ETrue, KTextListTest54 ); |
|
811 } |
|
812 |
|
813 // --------------------------------------------------------------------------- |
|
814 // Test CSnakingListBoxView |
|
815 // --------------------------------------------------------------------------- |
|
816 // |
|
817 void CBCTestListEiklistCase::TestSnakingListBoxViewL() |
|
818 { |
|
819 CSnakingListBoxView* view = |
|
820 static_cast<CSnakingListBoxView*>( iSnakingList->View() ); |
|
821 TInt num = view->VisibleWidth( view->ViewRect() ); |
|
822 AssertTrueL( ETrue, KSnakingViewTest1 ); |
|
823 view->HScroll( num - 1 ); |
|
824 AssertTrueL( ETrue, KSnakingViewTest2 ); |
|
825 view->SetItemHeight( 30 ); |
|
826 AssertTrueL( ETrue, KSnakingViewTest3 ); |
|
827 TInt visible = view->CalculateHScrollOffsetSoItemIsVisible( 0 ); |
|
828 AssertTrueL( ETrue, KSnakingViewTest4 ); |
|
829 } |
|
830 |
|
831 // --------------------------------------------------------------------------- |
|
832 // Test CEikSnakingListBox |
|
833 // --------------------------------------------------------------------------- |
|
834 // |
|
835 void CBCTestListEiklistCase::TestSnakingListBoxL() |
|
836 { |
|
837 TRect rect = iContainer->Rect(); |
|
838 CListBoxView* view = iSnakingList->MakeViewClassInstanceL(); |
|
839 delete view; |
|
840 AssertTrueL( ETrue, KSnakingTest1 ); |
|
841 iSnakingList->SetColumnWidth( 100 ); |
|
842 AssertTrueL( ETrue, KSnakingTest2 ); |
|
843 TInt columnWidth = iSnakingList->ColumnWidth(); |
|
844 AssertIntL( 100, columnWidth, KSnakingTest3 ); |
|
845 iSnakingList->HandleLeftArrowKeyL( CListBoxView::ESingleSelection ); |
|
846 AssertTrueL( ETrue, KSnakingTest4 ); |
|
847 iSnakingList->HandleRightArrowKeyL( CListBoxView::EContiguousSelection ); |
|
848 AssertTrueL( ETrue, KSnakingTest5 ); |
|
849 TInt horizontalNudge = iSnakingList->HorizontalNudgeValue(); |
|
850 AssertTrueL( ETrue, KSnakingTest6 ); |
|
851 TInt horizGranuInPixel = iSnakingList->HorizScrollGranularityInPixels(); |
|
852 AssertTrueL( ETrue, KSnakingTest7 ); |
|
853 iSnakingList->SetTopItemIndex( 1 ); |
|
854 AssertTrueL( ETrue, KSnakingTest8 ); |
|
855 iSnakingList->AdjustTopItemIndex(); |
|
856 AssertTrueL( ETrue, KSnakingTest9 ); |
|
857 iSnakingList->SizeChanged(); |
|
858 AssertTrueL( ETrue, KSnakingTest10 ); |
|
859 iSnakingList->HandleDragEventL( TPoint( 0, 0 ) ); |
|
860 AssertTrueL( ETrue, KSnakingTest11 ); |
|
861 iSnakingList->HandleViewRectSizeChangeL(); |
|
862 AssertTrueL( ETrue, KSnakingTest12 ); |
|
863 iSnakingList->MoveToNextOrPreviousItemL( TPoint( 10, 50 ) ); |
|
864 AssertTrueL( ETrue, KSnakingTest13 ); |
|
865 iSnakingList->RestoreClientRectFromViewRect( rect ); |
|
866 AssertTrueL( ETrue, KSnakingTest14 ); |
|
867 TInt height = iSnakingList->AdjustRectHeightToWholeNumberOfItems( |
|
868 rect ); |
|
869 AssertTrueL( ETrue, KSnakingTest15 ); |
|
870 |
|
871 CArrayFixFlat<TCoeColorUse>* colorUseList = new( ELeave ) |
|
872 CArrayFixFlat<TCoeColorUse>( 4 ); |
|
873 CleanupStack::PushL( colorUseList ); |
|
874 iSnakingList->CEikSnakingListBox::GetColorUseListL( *colorUseList ); |
|
875 AssertTrueL( ETrue, KSnakingTest16 ); |
|
876 colorUseList->Reset(); |
|
877 iSnakingList->GetColorUseListL( *colorUseList ); |
|
878 AssertTrueL( ETrue, KSnakingTest17 ); |
|
879 CleanupStack::PopAndDestroy( colorUseList ); |
|
880 TPointerEvent event; |
|
881 event.iType = TPointerEvent::EButton1Down; |
|
882 event.iModifiers = 0; |
|
883 TPoint eventPos(0, 30); |
|
884 event.iPosition = eventPos; |
|
885 event.iParentPosition = eventPos; |
|
886 iSnakingList->CEikSnakingListBox::HandlePointerEventL( event ); |
|
887 AssertTrueL( ETrue, KSnakingTest18 ); |
|
888 iSnakingList->HandlePointerEventL( event ); |
|
889 AssertTrueL( ETrue, KSnakingTest19 ); |
|
890 iSnakingList->CEikSnakingListBox::HandleResourceChange( |
|
891 KAknsMessageSkinChange ); |
|
892 AssertTrueL( ETrue, KSnakingTest20 ); |
|
893 iSnakingList->HandleResourceChange( KAknsMessageSkinChange ); |
|
894 AssertTrueL( ETrue, KSnakingTest21 ); |
|
895 CTextListBoxModel* model = iSnakingList->Model(); |
|
896 AssertTrueL( ETrue, KSnakingTest22 ); |
|
897 } |
|
898 |
|
899 // ======== MEMBER FUNCTIONS ======== |
|
900 |
|
901 // --------------------------------------------------------------------------- |
|
902 // CBCTestListBoxData::TestConstructFont |
|
903 // --------------------------------------------------------------------------- |
|
904 // |
|
905 void CBCTestListBoxData::TestConstructFontL( const CFont* aBaseFont ) |
|
906 { |
|
907 TFontStyle style( EPostureItalic, EStrokeWeightBold, |
|
908 EPrintPosSuperscript ); |
|
909 ConstructFontL( aBaseFont, style, iItalicFont ); |
|
910 } |
|
911 |
|
912 // --------------------------------------------------------------------------- |
|
913 // CBCTestListBoxData::TestRegenerateFonts |
|
914 // --------------------------------------------------------------------------- |
|
915 // |
|
916 TInt CBCTestListBoxData::TestRegenerateFonts() |
|
917 { |
|
918 TInt fontHeightInTwips = 20; |
|
919 TInt ret = RegenerateFonts( iNormalFont, fontHeightInTwips ); |
|
920 return ret; |
|
921 } |
|
922 |
|
923 // --------------------------------------------------------------------------- |
|
924 // CBCTestListBoxData::TestUpdateFontBoundValues |
|
925 // --------------------------------------------------------------------------- |
|
926 // |
|
927 void CBCTestListBoxData::TestUpdateFontBoundValues( const CFont* aBaseFont ) |
|
928 { |
|
929 UpdateFontBoundValues( *aBaseFont ); |
|
930 } |
|
931 |
|
932 // --------------------------------------------------------------------------- |
|
933 // CBCTestListBoxData::TestCFontWithStyle |
|
934 // --------------------------------------------------------------------------- |
|
935 // |
|
936 TBool CBCTestListBoxData::TestCFontWithStyle() |
|
937 { |
|
938 TFontStyle style( EPostureItalic, EStrokeWeightBold, |
|
939 EPrintPosSuperscript ); |
|
940 iNormalFont.SetFontStyle( style ); |
|
941 TFontStyle fontStyle = iNormalFont.FontStyle(); |
|
942 iNormalFont.ReleaseFonts(); |
|
943 return ( fontStyle == style ); |
|
944 } |
|
945 |
|
946 // ======== MEMBER FUNCTIONS ======== |
|
947 |
|
948 // --------------------------------------------------------------------------- |
|
949 // TBCTestListBoxEditorObserver::HandleListBoxEditorEventL |
|
950 // Empty functions for test CEikListBoxTextEditor |
|
951 // --------------------------------------------------------------------------- |
|
952 // |
|
953 TKeyResponse TBCTestListBoxEditorObserver::HandleListBoxEditorEventL( |
|
954 MEikListBoxEditor* , const TKeyEvent& ) |
|
955 { |
|
956 return EKeyWasConsumed; |
|
957 } |
|
958 |
|
959 // ======== MEMBER FUNCTIONS ======== |
|
960 |
|
961 // --------------------------------------------------------------------------- |
|
962 // C++ constructor |
|
963 // --------------------------------------------------------------------------- |
|
964 // |
|
965 CBCTestListBoxEditor::CBCTestListBoxEditor( MListBoxModel* aModel, |
|
966 CEikonEnv* aEikEnv ): CEikListBoxTextEditor( aModel ), iEikEnv( aEikEnv ) |
|
967 { |
|
968 } |
|
969 |
|
970 // --------------------------------------------------------------------------- |
|
971 // Test protected API WriteInternalStateL |
|
972 // --------------------------------------------------------------------------- |
|
973 // |
|
974 void CBCTestListBoxEditor::TestWriteInternalStateL() |
|
975 { |
|
976 RFs& tempServer = iEikEnv->FsSession(); |
|
977 tempServer.Delete( KStreamName ); |
|
978 |
|
979 RFileWriteStream fWrite; |
|
980 User::LeaveIfError( fWrite.Create( tempServer, |
|
981 KStreamName, EFileWrite ) ); |
|
982 CleanupClosePushL( fWrite ); |
|
983 WriteInternalStateL( fWrite ); |
|
984 CleanupStack::PopAndDestroy( &fWrite ); |
|
985 } |
|
986 |
|
987 // ======== MEMBER FUNCTIONS ======== |
|
988 |
|
989 // --------------------------------------------------------------------------- |
|
990 // Constructor |
|
991 // --------------------------------------------------------------------------- |
|
992 // |
|
993 CBCTestTextListItemDrawer::CBCTestTextListItemDrawer( |
|
994 MTextListBoxModel* aTextListBoxModel, const CFont* aFont ): |
|
995 CTextListItemDrawer( aTextListBoxModel, aFont ) |
|
996 { |
|
997 } |
|
998 |
|
999 // --------------------------------------------------------------------------- |
|
1000 // Test protected API of CTextListItemDrawer and CListItemDrawer |
|
1001 // --------------------------------------------------------------------------- |
|
1002 // |
|
1003 void CBCTestTextListItemDrawer::TestDrawItemText( CWindowGc& aGc ) |
|
1004 { |
|
1005 CListItemDrawer::SetGc( &aGc ); |
|
1006 SetGc( &aGc ); |
|
1007 TSize size = ItemCellSize(); |
|
1008 TRect rect( TPoint( 0, 0 ), size ); |
|
1009 DrawItemText( 0, rect, ETrue, EFalse, EFalse ); |
|
1010 } |
|
1011 |
|
1012 // ======== MEMBER FUNCTIONS ======== |
|
1013 |
|
1014 // --------------------------------------------------------------------------- |
|
1015 // Fake list box observer |
|
1016 // --------------------------------------------------------------------------- |
|
1017 // |
|
1018 void TBCTestListBoxObserver::HandleListBoxEventL( CEikListBox*, |
|
1019 TListBoxEvent ) |
|
1020 { |
|
1021 } |
|
1022 |
|
1023 // ======== MEMBER FUNCTIONS ======== |
|
1024 |
|
1025 // --------------------------------------------------------------------------- |
|
1026 // Test protected API: ItemArrayOwnershipType |
|
1027 // --------------------------------------------------------------------------- |
|
1028 // |
|
1029 TListBoxModelItemArrayOwnership CBCTestTextListModel:: |
|
1030 TestItemArrayOwnershipType() |
|
1031 { |
|
1032 return ItemArrayOwnershipType(); |
|
1033 } |