|
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 selection list dialog classes |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <w32std.h> |
|
20 #include <eikenv.h> |
|
21 |
|
22 #include "bctestlistselectioncase.h" |
|
23 #include "bctestlistcontainer.h" |
|
24 #include "bctestlist.hrh" |
|
25 #include <bctestlist.rsg> |
|
26 #include <bctestlist.mbg> |
|
27 |
|
28 _LIT( KSelectNewL, "CAknSelectionListDialog::NewL" ); |
|
29 _LIT( KSelSetFind, "CAknMarkableListDialog::SetupFind" ); |
|
30 _LIT( KSelSetIconArray, "CAknSelectionListDialog::SetIconArrayL" ); |
|
31 _LIT( KSelHandleListEvent, "CAknSelectionListDialog::HandleListBoxEventL" ); |
|
32 _LIT( KSelSelListProcCmd, "CAknSelectionListDialog::SelectionListProcessCommandL" ); |
|
33 _LIT( KSelProcCmd, "CAknSelectionListDialog::ProcessCommandL" ); |
|
34 _LIT( KSelCustomCtrl, "CAknSelectionListDialog::CreateCustomControlL" ); |
|
35 _LIT( KSelDraw, "CAknSelectionListDialog::Draw" ); |
|
36 |
|
37 _LIT( KMarkedNewL, "CAknMarkableListDialog::NewL" ); |
|
38 _LIT( KSelHandlePointer, "CAknMarkableListDialog::HandlePointerEventL" ); |
|
39 _LIT( KSelPreLayout, "CAknMarkableListDialog::PreLayoutDynInitL" ); |
|
40 _LIT( KMarSelListProcCmd, "CAknMarkableListDialog::SelectionListProcessCommandL" ); |
|
41 _LIT( KMarPreProcCmd, "CAknMarkableListDialog::ProcessCommandL" ); |
|
42 _LIT( KSelDynMenPane, "CAknMarkableListDialog::DynInitMenuPaneL" ); |
|
43 _LIT( KMarHandleListEvent, "CAknMarkableListDialog::HandleListBoxEventL" ); |
|
44 _LIT( KMarOfferKey, "CAknMarkableListDialog::OfferKeyEventL" ); |
|
45 _LIT( KMarPostLayout, "CAknMarkableListDialog::PostLayoutDynInitL" ); |
|
46 _LIT( KMarOK, "CAknMarkableListDialog::OkToExitL" ); |
|
47 |
|
48 |
|
49 // ======== MEMBER FUNCTIONS ======== |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // Symbian 2nd static Constructor |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 CBCTestListSelectionCase* CBCTestListSelectionCase::NewL( |
|
56 CBCTestListContainer* aContainer, CEikonEnv* aEikEnv ) |
|
57 { |
|
58 CBCTestListSelectionCase* self = new( ELeave ) CBCTestListSelectionCase( |
|
59 aContainer, aEikEnv ); |
|
60 CleanupStack::PushL( self ); |
|
61 self->ConstructL(); |
|
62 CleanupStack::Pop( self ); |
|
63 return self; |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // C++ default constructor |
|
68 // --------------------------------------------------------------------------- |
|
69 // |
|
70 CBCTestListSelectionCase::CBCTestListSelectionCase( CBCTestListContainer* aContainer, |
|
71 CEikonEnv* aEikEnv ) |
|
72 : CBCTestListBaseCase( aContainer, aEikEnv ) |
|
73 { |
|
74 } |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // Destructor |
|
78 // --------------------------------------------------------------------------- |
|
79 // |
|
80 CBCTestListSelectionCase::~CBCTestListSelectionCase() |
|
81 { |
|
82 } |
|
83 |
|
84 // --------------------------------------------------------------------------- |
|
85 // Symbian 2nd Constructor |
|
86 // --------------------------------------------------------------------------- |
|
87 // |
|
88 void CBCTestListSelectionCase::ConstructL() |
|
89 { |
|
90 BuildScriptL(); |
|
91 } |
|
92 |
|
93 // --------------------------------------------------------------------------- |
|
94 // CBCTestListSelectionCase::BuildScriptL |
|
95 // --------------------------------------------------------------------------- |
|
96 // |
|
97 void CBCTestListSelectionCase::BuildScriptL() |
|
98 { |
|
99 for ( TInt i=0; i <= EBCTestCmdOutline57 - EBCTestCmdOutline56; i++ ) |
|
100 { |
|
101 AddTestL( LeftCBA, REP( Down, 9 ), KeyOK, TEND ); |
|
102 AddTestL( REP( Down, i ), KeyOK, TEND ); |
|
103 } |
|
104 } |
|
105 |
|
106 // --------------------------------------------------------------------------- |
|
107 // CBCTestListSelectionCase::RunL |
|
108 // --------------------------------------------------------------------------- |
|
109 // |
|
110 void CBCTestListSelectionCase::RunL( TInt aCmd ) |
|
111 { |
|
112 if ( aCmd < EBCTestCmdOutline56 || aCmd > EBCTestCmdOutline57 ) |
|
113 { |
|
114 return; |
|
115 } |
|
116 ReleaseCase(); |
|
117 switch ( aCmd ) |
|
118 { |
|
119 case EBCTestCmdOutline56: |
|
120 TestMarkableListDialogL(); |
|
121 break; |
|
122 case EBCTestCmdOutline57: |
|
123 TestSelectionListDialogL(); |
|
124 break; |
|
125 default: |
|
126 break; |
|
127 } |
|
128 } |
|
129 |
|
130 // --------------------------------------------------------------------------- |
|
131 // CBCTestListSelectionCase::ReleaseCaseL |
|
132 // --------------------------------------------------------------------------- |
|
133 // |
|
134 void CBCTestListSelectionCase::ReleaseCase() |
|
135 { |
|
136 iContainer->ResetControl(); |
|
137 } |
|
138 |
|
139 // --------------------------------------------------------------------------- |
|
140 // Test CAknSelectionListDialog |
|
141 // --------------------------------------------------------------------------- |
|
142 // |
|
143 |
|
144 void CBCTestListSelectionCase::TestSelectionListDialogL() |
|
145 { |
|
146 TInt value( -1 ); |
|
147 CArrayFix<TInt>* markedItems = new( ELeave ) CArrayFixFlat<TInt>( 2 ); |
|
148 CleanupStack::PushL( markedItems ); |
|
149 CDesCArray* textArray = NULL; |
|
150 textArray = iEikEnv->ReadDesCArrayResourceL( R_BCTESTLIST_ITEM_SINGLE1 ); |
|
151 CleanupStack::PushL( textArray ); |
|
152 |
|
153 // test CAknSelectionListDialog::NewL |
|
154 CAknSelectionListDialog* selDlg = CAknSelectionListDialog::NewL( |
|
155 value, textArray, R_AVKON_DIALOG_EMPTY_MENUBAR, NULL ); |
|
156 CleanupStack::PushL( selDlg ); |
|
157 AssertNotNullL( selDlg, KSelectNewL ); |
|
158 CleanupStack::PopAndDestroy( selDlg ); |
|
159 |
|
160 // test API of CAknSelectionListDialog |
|
161 CBCSelectionListDialog* dlg = CBCSelectionListDialog::NewL( value, |
|
162 textArray ); |
|
163 dlg->PrepareLC( R_BCTESTLIST_SINGLE_SELECTION_LIST_DIALOG ); |
|
164 |
|
165 dlg->SetupFind( CAknSelectionListDialog::EFixedFind ); |
|
166 AssertTrueL( ETrue, KSelSetFind ); |
|
167 |
|
168 CArrayPtr<CGulIcon>* icons = new( ELeave ) CArrayPtrFlat<CGulIcon>( |
|
169 KBCTestListGraphicGulIconIndex ); |
|
170 CleanupStack::PushL( icons ); |
|
171 GraphicIconL( icons ); |
|
172 dlg->SetIconArrayL( icons ); |
|
173 CArrayPtr<CGulIcon>* getIcons = dlg->IconArray(); |
|
174 AssertTrueL( ( getIcons == icons ), KSelSetIconArray ); |
|
175 CleanupStack::Pop( icons ); |
|
176 |
|
177 dlg->SetSizeAndPosition( iContainer->Rect().Size() ); |
|
178 |
|
179 dlg->HandleListBoxEventL( |
|
180 dlg->ListBox(), |
|
181 MEikListBoxObserver::EEventEnterKeyPressed ); |
|
182 AssertTrueL( ETrue, KSelHandleListEvent ); |
|
183 |
|
184 dlg->SelectionListProcessCommandL( EAknMarkAll ); |
|
185 AssertTrueL( ETrue, KSelSelListProcCmd ); |
|
186 |
|
187 dlg->ProcessCommandL( EAknUnmarkAll ); |
|
188 AssertTrueL( ETrue, KSelProcCmd ); |
|
189 |
|
190 SEikControlInfo info = dlg->CreateCustomControlL( |
|
191 EAknCtSingleNumberListBox ); |
|
192 AssertTrueL( ETrue, KSelCustomCtrl ); |
|
193 delete info.iControl; |
|
194 |
|
195 TRect rect = iContainer->Rect(); |
|
196 dlg->Draw( rect ); |
|
197 AssertTrueL( ETrue, KSelDraw ); |
|
198 |
|
199 CleanupStack::PopAndDestroy(); // for PrepareLC |
|
200 CleanupStack::PopAndDestroy( textArray ); |
|
201 CleanupStack::PopAndDestroy( markedItems ); |
|
202 } |
|
203 |
|
204 // --------------------------------------------------------------------------- |
|
205 // Test CAknMarkableListDialog |
|
206 // --------------------------------------------------------------------------- |
|
207 // |
|
208 void CBCTestListSelectionCase::TestMarkableListDialogL() |
|
209 { |
|
210 TInt value( -1 ); |
|
211 CArrayFix<TInt>* markedItems = new( ELeave ) CArrayFixFlat<TInt>( 2 ); |
|
212 CleanupStack::PushL( markedItems ); |
|
213 CDesCArray* textArray = NULL; |
|
214 |
|
215 textArray = iEikEnv->ReadDesCArrayResourceL( R_BCTESTLIST_ITEM_SINGLE1 ); |
|
216 CleanupStack::PushL( textArray ); |
|
217 |
|
218 // test CAknMarkableListDialog::NewL |
|
219 CAknMarkableListDialog* markedDlg = CAknMarkableListDialog::NewL( |
|
220 value, markedItems, textArray, |
|
221 R_AVKON_DIALOG_EMPTY_MENUBAR, R_AVKON_DIALOG_EMPTY_MENUBAR, NULL ); |
|
222 CleanupStack::PushL( markedDlg ); |
|
223 AssertNotNullL( markedDlg, KMarkedNewL ); |
|
224 CleanupStack::PopAndDestroy( markedDlg ); |
|
225 |
|
226 // test API of CAknMarkableListDialog |
|
227 CBCMarkableListDialog* dlg = CBCMarkableListDialog::NewL( |
|
228 value, markedItems, textArray ); |
|
229 CleanupStack::PushL( dlg ); |
|
230 dlg->PrepareLC( R_BCTESTLIST_MARKABLE_DIALOG ); |
|
231 |
|
232 dlg->PreLayoutDynInitL(); |
|
233 AssertTrueL( ETrue, KSelPreLayout ); |
|
234 |
|
235 dlg->PostLayoutDynInitL(); |
|
236 AssertTrueL( ETrue, KMarPostLayout ); |
|
237 |
|
238 TPointerEvent event; |
|
239 event.iType = TPointerEvent::EButton1Down; |
|
240 event.iModifiers = 0; |
|
241 TPoint eventPos(0, 30); |
|
242 event.iPosition = eventPos; |
|
243 event.iParentPosition = eventPos; |
|
244 dlg->HandlePointerEventL( event ); |
|
245 AssertTrueL( ETrue, KSelHandlePointer ); |
|
246 |
|
247 dlg->SelectionListProcessCommandL( EAknMarkAll ); |
|
248 AssertTrueL( ETrue, KMarSelListProcCmd ); |
|
249 |
|
250 dlg->ProcessCommandL( EAknUnmarkAll ); |
|
251 AssertTrueL( ETrue, KMarPreProcCmd ); |
|
252 |
|
253 CEikMenuPane* menuPane = new( ELeave ) CEikMenuPane( dlg ); |
|
254 CleanupStack::PushL( menuPane ); |
|
255 dlg->DynInitMenuPaneL( R_BCTESTLIST_COLUMN_MENU, menuPane ); |
|
256 AssertTrueL( ETrue, KSelDynMenPane ); |
|
257 CleanupStack::PopAndDestroy( menuPane ); |
|
258 |
|
259 dlg->HandleListBoxEventL( dlg->ListBox(), |
|
260 MEikListBoxObserver::EEventItemClicked ); |
|
261 AssertTrueL( ETrue, KMarHandleListEvent ); |
|
262 |
|
263 TKeyEvent keyEvent; |
|
264 keyEvent.iCode = EKeyLeftArrow; |
|
265 dlg->OfferKeyEventL( keyEvent, EEventKey ); |
|
266 keyEvent.iCode = 'M'; |
|
267 dlg->OfferKeyEventL( keyEvent, EEventKey ); |
|
268 AssertTrueL( ETrue, KMarOfferKey ); |
|
269 |
|
270 dlg->OkToExitL( EAknSoftkeyOk ); |
|
271 AssertTrueL( ETrue, KMarOK ); |
|
272 |
|
273 CleanupStack::PopAndDestroy(); //prepareLC |
|
274 CleanupStack::Pop( dlg ); |
|
275 CleanupStack::PopAndDestroy( textArray ); |
|
276 CleanupStack::PopAndDestroy( markedItems ); |
|
277 } |
|
278 |
|
279 // --------------------------------------------------------------------------- |
|
280 // GraphicIconL |
|
281 // --------------------------------------------------------------------------- |
|
282 // |
|
283 void CBCTestListSelectionCase::GraphicIconL( CArrayPtr<CGulIcon>* aIcons ) |
|
284 { |
|
285 if ( aIcons ) |
|
286 { |
|
287 CreateIconAndAddToArrayL( |
|
288 aIcons, KBCTestListMifFileName, |
|
289 EMbmBctestlistQgn_indi_marked_add, |
|
290 EMbmBctestlistQgn_indi_marked_add_mask ); |
|
291 CreateIconAndAddToArrayL( |
|
292 aIcons, KBCTestListMbmFileName, |
|
293 EMbmBctestlistGolgo2, |
|
294 EMbmBctestlistGolgo2_mask ); |
|
295 } |
|
296 } |
|
297 |
|
298 // ======== MEMBER FUNCTIONS ======== |
|
299 // CBCMarkableListDialog |
|
300 |
|
301 // --------------------------------------------------------------------------- |
|
302 // Symbian 2nd constructor |
|
303 // --------------------------------------------------------------------------- |
|
304 // |
|
305 CBCMarkableListDialog* CBCMarkableListDialog::NewL( TInt &aValue, |
|
306 CArrayFix<TInt> *aSelectedItems, MDesCArray *aArray ) |
|
307 { |
|
308 CBCMarkableListDialog* self = new( ELeave ) CBCMarkableListDialog( |
|
309 aValue, aSelectedItems, aArray, |
|
310 R_AVKON_DIALOG_EMPTY_MENUBAR, R_AVKON_DIALOG_EMPTY_MENUBAR, NULL ); |
|
311 CleanupStack::PushL( self ); |
|
312 self->ConstructL( R_AVKON_DIALOG_EMPTY_MENUBAR ); |
|
313 CleanupStack::Pop( self ); |
|
314 return self; |
|
315 } |
|
316 |
|
317 // --------------------------------------------------------------------------- |
|
318 // C++ constructor |
|
319 // --------------------------------------------------------------------------- |
|
320 // |
|
321 CBCMarkableListDialog::CBCMarkableListDialog( |
|
322 TInt &aValue, CArrayFix<TInt> *aSelectedItems, |
|
323 MDesCArray *aArray, TInt aMenuBarResourceId, |
|
324 TInt aOkMenuBarResourceId, MEikCommandObserver *aObserver ): |
|
325 CAknMarkableListDialog( aValue, aSelectedItems, aArray, aMenuBarResourceId, |
|
326 aOkMenuBarResourceId, aObserver ) |
|
327 { |
|
328 } |
|
329 |
|
330 // ======== MEMBER FUNCTIONS ======== |
|
331 // CBCSelectionListDialog |
|
332 |
|
333 // --------------------------------------------------------------------------- |
|
334 // Symbian 2nd constructor |
|
335 // --------------------------------------------------------------------------- |
|
336 // |
|
337 CBCSelectionListDialog* CBCSelectionListDialog::NewL( TInt &aValue, |
|
338 MDesCArray *aArray ) |
|
339 { |
|
340 CBCSelectionListDialog* self = new( ELeave ) CBCSelectionListDialog( |
|
341 aValue, aArray, NULL ); |
|
342 CleanupStack::PushL( self ); |
|
343 self->ConstructL( R_AVKON_DIALOG_EMPTY_MENUBAR ); |
|
344 CleanupStack::Pop( self ); |
|
345 return self; |
|
346 } |
|
347 |
|
348 // --------------------------------------------------------------------------- |
|
349 // C++ constructor |
|
350 // --------------------------------------------------------------------------- |
|
351 // |
|
352 CBCSelectionListDialog::CBCSelectionListDialog( |
|
353 TInt &aValue, MDesCArray *aArray, |
|
354 MEikCommandObserver *aObserver ): |
|
355 CAknSelectionListDialog( aValue, aArray, aObserver ) |
|
356 { |
|
357 } |