|
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 grid pane list box classes |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <eikenv.h> |
|
20 #include <aknlists.h> |
|
21 #include <barsread.h> |
|
22 #include <akniconarray.h> |
|
23 |
|
24 #include "bctestlistgridcase.h" |
|
25 #include "bctestlistcontainer.h" |
|
26 #include "bctestlist.hrh" |
|
27 #include <bctestlist.rsg> |
|
28 #include <bctestlist.mbg> |
|
29 |
|
30 _LIT( KGridCreate1, "Create CAknPinbStyleGrid" ); |
|
31 _LIT( KGridCreate2, "Create CAknQdialStyleGrid" ); |
|
32 _LIT( KGridCreate3, "Create CAknCaleMonthStyleGrid" ); |
|
33 |
|
34 _LIT( KPinbTest1, "CAknPinbStyleGrid::SizeChanged" ); |
|
35 _LIT( KPinbTest2, "CAknPinbStyleGrid::MinimumSize" ); |
|
36 _LIT( KPinbTest3, "CAknPinbStyleGrid::HandlePointerEventL" ); |
|
37 _LIT( KLayoutSetupGridFormGfxCell, "AknListBoxLayouts::SetupGridFormGfxCell" ); |
|
38 |
|
39 _LIT( KQdialTest1, "CAknQdialStyleGrid::SizeChanged" ); |
|
40 _LIT( KQdialTest2, "CAknQdialStyleGrid::MinimumSize" ); |
|
41 _LIT( KQdialTest3, "CAknQdialStyleGrid::HandlePointerEventL" ); |
|
42 |
|
43 _LIT( KCaleMonthTest1, "CAknCaleMonthStyleGrid::SizeChanged" ); |
|
44 _LIT( KCaleMonthTest2, "CAknCaleMonthStyleGrid::MinimumSize" ); |
|
45 _LIT( KCaleMonthTest3, "CAknCaleMonthStyleGrid::HandlePointerEventL" ); |
|
46 |
|
47 // ======== MEMBER FUNCTIONS ======== |
|
48 |
|
49 // --------------------------------------------------------------------------- |
|
50 // Symbian 2nd static Constructor |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 CBCTestListGridCase* CBCTestListGridCase::NewL( |
|
54 CBCTestListContainer* aContainer, CEikonEnv* aEikEnv ) |
|
55 { |
|
56 CBCTestListGridCase* self = new( ELeave ) CBCTestListGridCase( |
|
57 aContainer, aEikEnv ); |
|
58 CleanupStack::PushL( self ); |
|
59 self->ConstructL(); |
|
60 CleanupStack::Pop( self ); |
|
61 return self; |
|
62 } |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // C++ default constructor |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 CBCTestListGridCase::CBCTestListGridCase( CBCTestListContainer* aContainer, |
|
69 CEikonEnv* aEikEnv ) |
|
70 : CBCTestListBaseCase( aContainer, aEikEnv ) |
|
71 { |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------------------------- |
|
75 // Destructor |
|
76 // --------------------------------------------------------------------------- |
|
77 // |
|
78 CBCTestListGridCase::~CBCTestListGridCase() |
|
79 { |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // Symbian 2nd Constructor |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 void CBCTestListGridCase::ConstructL() |
|
87 { |
|
88 BuildScriptL(); |
|
89 } |
|
90 |
|
91 // --------------------------------------------------------------------------- |
|
92 // CBCTestListGridCase::BuildScriptL |
|
93 // --------------------------------------------------------------------------- |
|
94 // |
|
95 void CBCTestListGridCase::BuildScriptL() |
|
96 { |
|
97 for ( TInt i=0; i <= EBCTestCmdOutline42 - EBCTestCmdOutline40; i++ ) |
|
98 { |
|
99 AddTestL( LeftCBA, REP( Down, 4 ), KeyOK, TEND ); |
|
100 AddTestL( REP( Down, i ), KeyOK, TEND ); |
|
101 } |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------------------------- |
|
105 // CBCTestListGridCase::RunL |
|
106 // --------------------------------------------------------------------------- |
|
107 // |
|
108 void CBCTestListGridCase::RunL( TInt aCmd ) |
|
109 { |
|
110 if ( aCmd < EBCTestCmdOutline40 || |
|
111 aCmd > EBCTestCmdOutline42 ) |
|
112 { |
|
113 return; |
|
114 } |
|
115 iOutlineId = aCmd; |
|
116 ReleaseCase(); |
|
117 PrepareCaseL( aCmd ); |
|
118 TestGridListL( aCmd ); |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------------------------- |
|
122 // CBCTestListGridCase::PrepareCaseL |
|
123 // --------------------------------------------------------------------------- |
|
124 // |
|
125 void CBCTestListGridCase::PrepareCaseL( TInt aCmd ) |
|
126 { |
|
127 TInt resourceId( R_BCTESTLIST_SELECTION_GRID ); |
|
128 |
|
129 switch ( aCmd ) |
|
130 { |
|
131 case EBCTestCmdOutline40: |
|
132 iListBox = new( ELeave ) CAknPinbStyleGrid(); |
|
133 AssertNotNullL( iListBox, KGridCreate1 ); |
|
134 break; |
|
135 case EBCTestCmdOutline41: |
|
136 iListBox = new( ELeave ) CAknQdialStyleGrid(); |
|
137 AssertNotNullL( iListBox, KGridCreate2 ); |
|
138 break; |
|
139 case EBCTestCmdOutline42: |
|
140 iListBox = new( ELeave ) CAknCaleMonthStyleGrid(); |
|
141 AssertNotNullL( iListBox, KGridCreate3 ); |
|
142 break; |
|
143 |
|
144 default: |
|
145 break; |
|
146 } |
|
147 |
|
148 if ( iListBox ) |
|
149 { |
|
150 // construct from resource |
|
151 iListBox->SetContainerWindowL( *iContainer ); |
|
152 |
|
153 TResourceReader reader; |
|
154 iEikEnv->CreateResourceReaderLC( reader, resourceId ); |
|
155 iListBox->ConstructFromResourceL( reader ); |
|
156 CleanupStack::PopAndDestroy(); // resource stuffs. |
|
157 |
|
158 // create icon array |
|
159 CArrayPtr<CGulIcon>* icons = new( ELeave ) CAknIconArray( |
|
160 KBCTestListGraphicGulIconIndex ); |
|
161 CleanupStack::PushL( icons ); |
|
162 GraphicIconL( icons ); // Appends graphic data. |
|
163 // Sets graphics as ListBox icon. |
|
164 iListBox->ItemDrawer()->ColumnData()->SetIconArray( icons ); |
|
165 CleanupStack::Pop(); |
|
166 |
|
167 iContainer->SetControl( iListBox ); |
|
168 } |
|
169 } |
|
170 |
|
171 // --------------------------------------------------------------------------- |
|
172 // CBCTestListGridCase::ReleaseCaseL |
|
173 // --------------------------------------------------------------------------- |
|
174 // |
|
175 void CBCTestListGridCase::ReleaseCase() |
|
176 { |
|
177 iContainer->ResetControl(); |
|
178 iListBox = NULL; |
|
179 } |
|
180 |
|
181 // --------------------------------------------------------------------------- |
|
182 // CBCTestListGridCase::TestGridListL |
|
183 // --------------------------------------------------------------------------- |
|
184 // |
|
185 void CBCTestListGridCase::TestGridListL( TInt aCmd ) |
|
186 { |
|
187 if ( !iListBox ) |
|
188 { |
|
189 return; |
|
190 } |
|
191 TPointerEvent event; |
|
192 event.iType = TPointerEvent::EButton1Down; |
|
193 event.iModifiers = 0; |
|
194 TPoint eventPos(0, 30); |
|
195 event.iPosition = eventPos; |
|
196 event.iParentPosition = eventPos; |
|
197 |
|
198 TSize size; |
|
199 switch ( aCmd ) |
|
200 { |
|
201 case EBCTestCmdOutline40: |
|
202 { |
|
203 CAknPinbStyleGrid* listbox = |
|
204 static_cast<CAknPinbStyleGrid*>( iListBox ); |
|
205 listbox->SizeChanged(); |
|
206 AssertTrueL( ETrue, KPinbTest1 ); |
|
207 size = listbox->MinimumSize(); |
|
208 AssertTrueL( ETrue, KPinbTest2 ); |
|
209 listbox->HandlePointerEventL( event ); |
|
210 AssertTrueL( ETrue, KPinbTest3 ); |
|
211 |
|
212 TRect rect = iContainer->Rect(); |
|
213 TSize size = listbox->ItemDrawer()->MinimumCellSize(); |
|
214 TPoint pt1( rect.iTl ); |
|
215 TPoint pt2( rect.iTl.iX + size.iWidth, |
|
216 rect.iTl.iY + size.iHeight ); |
|
217 AknListBoxLayouts::SetupGridFormGfxCell( |
|
218 *listbox, listbox->ItemDrawer(), |
|
219 0, rect.iTl.iX, rect.iTl.iY, rect.iBr.iX, rect.iBr.iY, |
|
220 size.iWidth, size.iHeight, pt1, pt2 ); |
|
221 AssertTrueL( ETrue, KLayoutSetupGridFormGfxCell ); |
|
222 } |
|
223 break; |
|
224 case EBCTestCmdOutline41: |
|
225 { |
|
226 CAknQdialStyleGrid* listbox = |
|
227 static_cast<CAknQdialStyleGrid*>( iListBox ); |
|
228 listbox->SizeChanged(); |
|
229 AssertTrueL( ETrue, KQdialTest1 ); |
|
230 size = listbox->MinimumSize(); |
|
231 AssertTrueL( ETrue, KQdialTest2 ); |
|
232 listbox->HandlePointerEventL( event ); |
|
233 AssertTrueL( ETrue, KQdialTest3 ); |
|
234 } |
|
235 break; |
|
236 case EBCTestCmdOutline42: |
|
237 { |
|
238 CAknCaleMonthStyleGrid* listbox = |
|
239 static_cast<CAknCaleMonthStyleGrid*>( iListBox ); |
|
240 listbox->SizeChanged(); |
|
241 AssertTrueL( ETrue, KCaleMonthTest1 ); |
|
242 size = listbox->MinimumSize(); |
|
243 AssertTrueL( ETrue, KCaleMonthTest2 ); |
|
244 listbox->HandlePointerEventL( event ); |
|
245 AssertTrueL( ETrue, KCaleMonthTest3 ); |
|
246 } |
|
247 break; |
|
248 |
|
249 default: |
|
250 break; |
|
251 } |
|
252 } |
|
253 |
|
254 // --------------------------------------------------------------------------- |
|
255 // CBCTestListGridCase::GraphicIconL |
|
256 // --------------------------------------------------------------------------- |
|
257 // |
|
258 void CBCTestListGridCase::GraphicIconL( CArrayPtr<CGulIcon>* aIcons ) |
|
259 { |
|
260 if ( aIcons ) |
|
261 { |
|
262 // Appends icon according to iOutlineId. |
|
263 switch ( iOutlineId ) |
|
264 { |
|
265 case EBCTestCmdOutline40: |
|
266 case EBCTestCmdOutline41: |
|
267 case EBCTestCmdOutline42: |
|
268 CreateIconAndAddToArrayL( |
|
269 aIcons, KBCTestListMifFileName, |
|
270 EMbmBctestlistQgn_indi_marked_add, |
|
271 EMbmBctestlistQgn_indi_marked_add_mask ); |
|
272 CreateIconAndAddToArrayL( |
|
273 aIcons, KBCTestListMbmFileName, |
|
274 EMbmBctestlistGolgo2, |
|
275 EMbmBctestlistGolgo2_mask ); |
|
276 CreateIconAndAddToArrayL( |
|
277 aIcons, KBCTestListMbmFileName, |
|
278 EMbmBctestlistGolgo3, |
|
279 EMbmBctestlistGolgo3_mask ); |
|
280 CreateIconAndAddToArrayL( |
|
281 aIcons, KBCTestListMbmFileName, |
|
282 EMbmBctestlistGolgo4, |
|
283 EMbmBctestlistGolgo4_mask ); |
|
284 |
|
285 break; |
|
286 |
|
287 default: |
|
288 break; |
|
289 } |
|
290 } |
|
291 } |