|
1 /* |
|
2 * Copyright (c) 2007-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: Contains the test cases. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <avkon.hrh> |
|
19 #include <eikfrlb.h> |
|
20 #include <aknappui.h> |
|
21 #include <aknpointereventmodifier.h> |
|
22 #include <akntashook.h> |
|
23 #include <aknpreviewpopupcontroller.h> |
|
24 #include <eikmenub.h> |
|
25 #include <eikenv.h> |
|
26 #include <aknutils.h> |
|
27 #include <akntoolbar.h> |
|
28 |
|
29 #include <bctestmixmcl.rsg> |
|
30 #include <eikedwin.h> |
|
31 #include <aknphysics.h> |
|
32 |
|
33 #include "bctestmixmclgeneralcase.h" |
|
34 #include "bctestmixmclcontainer.h" |
|
35 #include "bctestmixmcl.hrh" |
|
36 |
|
37 // CONSTATNS |
|
38 |
|
39 |
|
40 // ======== MEMBER FUNCTIONS ======== |
|
41 |
|
42 // --------------------------------------------------------------------------- |
|
43 // Symbian 2nd static Constructor |
|
44 // --------------------------------------------------------------------------- |
|
45 // |
|
46 CBCTestMixMCLGeneralCase* CBCTestMixMCLGeneralCase::NewL( CBCTestMixMCLContainer* |
|
47 aContainer, CBCTestMixMCLView* aView ) |
|
48 { |
|
49 CBCTestMixMCLGeneralCase* self = new( ELeave ) CBCTestMixMCLGeneralCase( |
|
50 aContainer, aView ); |
|
51 CleanupStack::PushL( self ); |
|
52 self->ConstructL(); |
|
53 CleanupStack::Pop( self ); |
|
54 return self; |
|
55 } |
|
56 |
|
57 // --------------------------------------------------------------------------- |
|
58 // C++ default constructor |
|
59 // --------------------------------------------------------------------------- |
|
60 // |
|
61 CBCTestMixMCLGeneralCase::CBCTestMixMCLGeneralCase( CBCTestMixMCLContainer* |
|
62 aContainer, CBCTestMixMCLView* aView ) |
|
63 : iView( aView ), iContainer( aContainer ) |
|
64 { |
|
65 } |
|
66 |
|
67 // --------------------------------------------------------------------------- |
|
68 // Destructor |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 CBCTestMixMCLGeneralCase::~CBCTestMixMCLGeneralCase() |
|
72 { |
|
73 } |
|
74 |
|
75 // --------------------------------------------------------------------------- |
|
76 // Symbian 2nd Constructor |
|
77 // --------------------------------------------------------------------------- |
|
78 // |
|
79 void CBCTestMixMCLGeneralCase::ConstructL() |
|
80 { |
|
81 BuildScriptL(); |
|
82 } |
|
83 |
|
84 // --------------------------------------------------------------------------- |
|
85 // CBCTestMixMCLGeneralCase::BuildScriptL |
|
86 // --------------------------------------------------------------------------- |
|
87 // |
|
88 void CBCTestMixMCLGeneralCase::BuildScriptL() |
|
89 { |
|
90 // Add script as your need. |
|
91 AddTestL( DELAY(1), LeftCBA, Down, KeyOK, TEND ); // outline02 |
|
92 } |
|
93 |
|
94 // --------------------------------------------------------------------------- |
|
95 // CBCTestMixMCLGeneralCase::RunL |
|
96 // --------------------------------------------------------------------------- |
|
97 // |
|
98 void CBCTestMixMCLGeneralCase::RunL( TInt aCmd ) |
|
99 { |
|
100 if ( aCmd != EBCTestCmdOutline2 ) |
|
101 { |
|
102 return; |
|
103 } |
|
104 // Call release before prepare to let container has time to draw the |
|
105 // control created in PrepareCaseL. |
|
106 ReleaseCaseL(); |
|
107 PrepareCaseL( aCmd ); |
|
108 |
|
109 TestListBoxL(); |
|
110 TestOptionsMenuL(); |
|
111 TestTasObjectInfoAndTasHookL(); |
|
112 TestMiscApisFuncOneL(); |
|
113 TestAknToolbar(); |
|
114 TestAknPopupUtils(); |
|
115 TestEditorKineticScrollingL(); |
|
116 TestAknPhysicsSuspendPhysicsL(); |
|
117 TestAknPhysicsResumePhysicsL(); |
|
118 TestCba(); |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------------------------- |
|
122 // CBCTestMixMCLGeneralCase::PrepareCaseL |
|
123 // --------------------------------------------------------------------------- |
|
124 // |
|
125 void CBCTestMixMCLGeneralCase::PrepareCaseL( TInt aCmd ) |
|
126 { |
|
127 switch ( aCmd ) |
|
128 { |
|
129 case EBCTestCmdOutline2: |
|
130 // Here is a simple demo. You should create your control |
|
131 // instead of this. |
|
132 iControl = new( ELeave ) CCoeControl(); |
|
133 iControl->SetContainerWindowL( *iContainer ); |
|
134 iControl->MakeVisible( ETrue ); |
|
135 break; |
|
136 default: |
|
137 break; |
|
138 } |
|
139 // Pass the owner of iControl to iContainer. |
|
140 iContainer->SetControlL( iControl ); |
|
141 } |
|
142 |
|
143 // --------------------------------------------------------------------------- |
|
144 // CBCTestMixMCLGeneralCase::ReleaseCaseL |
|
145 // --------------------------------------------------------------------------- |
|
146 // |
|
147 void CBCTestMixMCLGeneralCase::ReleaseCaseL() |
|
148 { |
|
149 // let container delete the component control. |
|
150 iContainer->ResetControl(); |
|
151 iControl = NULL; |
|
152 } |
|
153 |
|
154 // --------------------------------------------------------------------------- |
|
155 // CBCTestMixMCLGeneralCase::HandleLongTapEventL |
|
156 // --------------------------------------------------------------------------- |
|
157 // |
|
158 void CBCTestMixMCLGeneralCase::HandleLongTapEventL( |
|
159 const TPoint& /*aPenEventLocation*/, |
|
160 const TPoint& /*aPenEventScreenLocation*/ ) |
|
161 { |
|
162 |
|
163 } |
|
164 |
|
165 // --------------------------------------------------------------------------- |
|
166 // CBCTestMixMCLGeneralCase::TestListBoxL |
|
167 // --------------------------------------------------------------------------- |
|
168 // |
|
169 void CBCTestMixMCLGeneralCase::TestListBoxL() |
|
170 { |
|
171 _LIT( KDisableScrolling, "CEikListBox::DisableScrolling() invoked" ); |
|
172 _LIT( KSetItemsInSingleLine, |
|
173 "CEikListBox::SetItemsInSingleLine() invoked" ); |
|
174 _LIT( KBackgroundDrawingSuppressed, |
|
175 "CEikListBox::BackgroundDrawingSuppressed() invoked" ); |
|
176 _LIT( KHandlePhysicsScrollEventL, |
|
177 "CEikListBox::HandlePhysicsScrollEventL() invoked" ); |
|
178 _LIT( KSuspendEffectsL, "CEikListBox::SuspendEffects() invoked" ); |
|
179 _LIT( KScrollingDisabledL, "CEikListBox::ScrollingDisabled() invoked" ); |
|
180 _LIT( KItemIsPartiallyVisibleL, |
|
181 "CListBoxView::ItemIsPartiallyVisible() invoked" ); |
|
182 _LIT( KItemOffsetInPixels, |
|
183 "CListBoxView::ItemOffsetInPixels() invoked" ); |
|
184 _LIT( KDisableItemSpecificMenu, |
|
185 "CListBoxView::DisableItemSpecificMenu() invoked" ); |
|
186 |
|
187 CEikFormattedCellListBox * listbox = new CEikFormattedCellListBox(); |
|
188 CleanupStack::PushL( listbox ); |
|
189 |
|
190 listbox->ConstructL( iContainer, EAknListBoxSelectionList ); |
|
191 CDesCArrayFlat* text = new (ELeave) CDesCArrayFlat(1); |
|
192 CleanupStack::PushL( text ); |
|
193 |
|
194 text->AppendL( _L( "\tTextItem1\t" ) ); |
|
195 text->AppendL( _L( "\tTextItem2\t" ) ); |
|
196 text->AppendL( _L( "\tTextItem3\t" ) ); |
|
197 |
|
198 listbox->Model()->SetItemTextArray( text ); |
|
199 listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
200 |
|
201 listbox->DisableScrolling( ETrue ); |
|
202 AssertTrueL( ETrue, KDisableScrolling ); |
|
203 |
|
204 listbox->SetItemsInSingleLine( 1 ); |
|
205 AssertTrueL( ETrue, KSetItemsInSingleLine ); |
|
206 |
|
207 listbox->BackgroundDrawingSuppressed(); |
|
208 AssertTrueL( ETrue, KBackgroundDrawingSuppressed ); |
|
209 |
|
210 listbox->HandlePhysicsScrollEventL( listbox->ItemHeight() ); |
|
211 AssertTrueL( ETrue, KHandlePhysicsScrollEventL ); |
|
212 |
|
213 listbox->SuspendEffects( ETrue ); |
|
214 AssertTrueL( ETrue, KSuspendEffectsL ); |
|
215 |
|
216 listbox->ScrollingDisabled(); |
|
217 AssertTrueL( ETrue, KScrollingDisabledL ); |
|
218 |
|
219 listbox->View()->ItemIsPartiallyVisible( 1 ); |
|
220 AssertTrueL( ETrue, KItemIsPartiallyVisibleL ); |
|
221 |
|
222 listbox->View()->ItemOffsetInPixels(); |
|
223 AssertTrueL( ETrue, KItemOffsetInPixels ); |
|
224 |
|
225 listbox->DisableItemSpecificMenu(); |
|
226 AssertTrueL( ETrue, KDisableItemSpecificMenu ); |
|
227 |
|
228 CleanupStack::PopAndDestroy( text ); |
|
229 CleanupStack::PopAndDestroy( listbox ); |
|
230 } |
|
231 |
|
232 // --------------------------------------------------------------------------- |
|
233 // CBCTestMixMCLGeneralCase::TestOptionsMenuL |
|
234 // --------------------------------------------------------------------------- |
|
235 // |
|
236 void CBCTestMixMCLGeneralCase::TestOptionsMenuL() |
|
237 { |
|
238 _LIT( KGetMenuType, "CEikMenuBar::GetMenuType invoked" ); |
|
239 CEikMenuBar* menuBar = CEikonEnv::Static()->AppUiFactory()->MenuBar(); |
|
240 if( menuBar ) |
|
241 { |
|
242 menuBar->GetMenuType(); |
|
243 AssertTrueL( ETrue, KGetMenuType ); |
|
244 } |
|
245 } |
|
246 |
|
247 // --------------------------------------------------------------------------- |
|
248 // CBCTestMixMCLGeneralCase::TestTasObjectInfoAndTasHookL |
|
249 // --------------------------------------------------------------------------- |
|
250 // |
|
251 void CBCTestMixMCLGeneralCase::TestTasObjectInfoAndTasHookL() |
|
252 { |
|
253 _LIT( KClassName, "CBCTestMixMCLGeneralCase" ); |
|
254 _LIT( KAddL, "CAknTasHook::AddL() tested" ); |
|
255 _LIT( KGet, "CAknTasHook::Get() tested" ); |
|
256 _LIT( KRemove, "CAknTasHook::Remove() tested" ); |
|
257 _LIT( KIsA, "CAknTasObjectInfo::IsA() tested" ); |
|
258 _LIT( KType, "CAknTasObjectInfo::Type() tested" ); |
|
259 _LIT( KGetClassNames, "CAknTasObjectInfo::GetClassNames() tested" ); |
|
260 _LIT( KGetControl, "CAknTasObjectInfo::GetControl() tested" ); |
|
261 |
|
262 CAknTasHook::AddL( this, KClassName() ); |
|
263 AssertTrueL( ETrue, KAddL ); |
|
264 |
|
265 CAknTasObjectInfo* info = CAknTasHook::Get( this ); |
|
266 AssertTrueL( ETrue, KGet ); |
|
267 |
|
268 // info would be NULL if KTasHooking is not enabled. |
|
269 if ( info ) |
|
270 { |
|
271 info->IsA( KClassName() ); |
|
272 AssertTrueL( ETrue, KIsA ); |
|
273 |
|
274 info->Type(); |
|
275 AssertTrueL( ETrue, KType ); |
|
276 |
|
277 info->GetClassNames(); |
|
278 AssertTrueL( ETrue, KGetClassNames ); |
|
279 |
|
280 info->GetControl(); |
|
281 AssertTrueL( ETrue, KGetControl ); |
|
282 } |
|
283 |
|
284 CAknTasHook::Remove( this ); |
|
285 AssertTrueL( ETrue, KRemove ); |
|
286 } |
|
287 |
|
288 // --------------------------------------------------------------------------- |
|
289 // CBCTestMixMCLGeneralCase::TestMiscApisFuncOneL |
|
290 // --------------------------------------------------------------------------- |
|
291 // |
|
292 void CBCTestMixMCLGeneralCase::TestMiscApisFuncOneL() |
|
293 { |
|
294 _LIT( KCancelAnimationL, |
|
295 "CAknLongTapDetector::CancelAnimationL() invoked" ); |
|
296 _LIT( KHandlePointerEvent, |
|
297 "CAknPointerEventModifier::CAknPointerEventModifier() tested"); |
|
298 _LIT( KResetTimer, "CAknPreviewPopUpController::ResetTimer() teseted"); |
|
299 |
|
300 CAknLongTapDetector* detector = CAknLongTapDetector::NewL( this ); |
|
301 CleanupStack::PushL( detector ); |
|
302 |
|
303 detector->After( TTimeIntervalMicroSeconds32( 1000000 ) ); |
|
304 detector->CancelAnimationL(); |
|
305 AssertTrueL( ETrue, KCancelAnimationL ); |
|
306 |
|
307 CleanupStack::PopAndDestroy( detector ); |
|
308 |
|
309 CAknPreviewPopUpController* popupController = |
|
310 CAknPreviewPopUpController::NewL( *iControl ); |
|
311 CleanupStack::PushL( popupController ); |
|
312 |
|
313 popupController->ResetTimer(); |
|
314 AssertTrueL( ETrue, KResetTimer ); |
|
315 |
|
316 CleanupStack::PopAndDestroy( popupController ); |
|
317 |
|
318 // simulate a pointer event for forcing the CAknAppUi::HandleWsEventL |
|
319 // to call CAknPointerEventModifier::HandlePointerEventL(). |
|
320 TRawEvent eventDown; |
|
321 eventDown.Set( TRawEvent::EButton1Down, 0, 0 ); |
|
322 UserSvr::AddEvent( eventDown ); |
|
323 |
|
324 User::After( 1000000 ); |
|
325 |
|
326 TRawEvent eventUp; |
|
327 eventUp.Set( TRawEvent::EButton1Up, 0, 0 ); |
|
328 UserSvr::AddEvent( eventUp ); |
|
329 |
|
330 AssertTrueL( ETrue, KHandlePointerEvent ); |
|
331 } |
|
332 |
|
333 // --------------------------------------------------------------------------- |
|
334 // CBCTestMixMCLGeneralCase::TestAknPopupUtils |
|
335 // --------------------------------------------------------------------------- |
|
336 // |
|
337 void CBCTestMixMCLGeneralCase::TestAknPopupUtils() |
|
338 { |
|
339 TSize size( 10, 10 ); |
|
340 TPoint point( AknPopupUtils::Position( size, ETrue ) ); |
|
341 point = AknPopupUtils::Position( size, EFalse ); |
|
342 point = AknPopupUtils::Position( size, NULL ); |
|
343 _LIT( KAknPopupUtilsPosition, "AknPopupUtils::Position funcs are tested" ); |
|
344 AssertTrueL( ETrue, KAknPopupUtilsPosition ); |
|
345 } |
|
346 |
|
347 // --------------------------------------------------------------------------- |
|
348 // CBCTestMixMCLGeneralCase::TestAknToolbar |
|
349 // --------------------------------------------------------------------------- |
|
350 // |
|
351 void CBCTestMixMCLGeneralCase::TestAknToolbar() |
|
352 { |
|
353 _LIT( KAknToolbarNew, "CAknToolbar::New toolbar is constructed" ); |
|
354 _LIT( KAknToolbarSetBgId, "CAknToolbar::New background skin theme ID is set" ); |
|
355 |
|
356 CAknToolbar* toolbar = CAknToolbar::NewL( R_BCTESTMIXMCL_TOOLBAR_FIXED ); |
|
357 CleanupStack::PushL( toolbar ); |
|
358 AssertTrueL( ETrue, KAknToolbarNew ); |
|
359 |
|
360 toolbar->SetSkinBackgroundId( KAknsIIDQsnBgAreaControlMp ); |
|
361 AssertTrueL( ETrue, KAknToolbarSetBgId ); |
|
362 CleanupStack::PopAndDestroy( toolbar ); |
|
363 } |
|
364 |
|
365 // --------------------------------------------------------------------------- |
|
366 // CBCTestMixMCLGeneralCase::TestEditorKineticScrollingL |
|
367 // --------------------------------------------------------------------------- |
|
368 // |
|
369 void CBCTestMixMCLGeneralCase::TestEditorKineticScrollingL() |
|
370 { |
|
371 CEikEdwin* editor = new ( ELeave ) CEikEdwin; |
|
372 CleanupStack::PushL( editor ); |
|
373 editor->EnableKineticScrollingL( ETrue ); |
|
374 CleanupStack::PopAndDestroy( editor ); |
|
375 _LIT( KEdwinEnableScrolling, "CEikEdwin::EnableKineticScrollingL tested" ); |
|
376 AssertTrueL( ETrue, KEdwinEnableScrolling ); |
|
377 } |
|
378 |
|
379 // --------------------------------------------------------------------------- |
|
380 // CBCTestMixMCLGeneralCase::TestAknPhysicsSuspendPhysicsL |
|
381 // --------------------------------------------------------------------------- |
|
382 // |
|
383 void CBCTestMixMCLGeneralCase::TestAknPhysicsSuspendPhysicsL() |
|
384 { |
|
385 CCoeControl* testControl = new (ELeave) CCoeControl(); |
|
386 CleanupStack::PushL( testControl ); |
|
387 CAknPhysics* physics = CAknPhysics::NewL( *this, testControl ); |
|
388 CleanupStack::PushL( physics ); |
|
389 physics->SuspendPhysics(); |
|
390 CleanupStack::PopAndDestroy( physics ); |
|
391 CleanupStack::PopAndDestroy( testControl ); |
|
392 _LIT( KSuspendPhysics, "CAknPhysics::SuspendPhysics tested" ); |
|
393 AssertTrueL( ETrue, KSuspendPhysics ); |
|
394 } |
|
395 |
|
396 // --------------------------------------------------------------------------- |
|
397 // CBCTestMixMCLGeneralCase::TestAknPhysicsResumePhysicsL |
|
398 // --------------------------------------------------------------------------- |
|
399 // |
|
400 void CBCTestMixMCLGeneralCase::TestAknPhysicsResumePhysicsL() |
|
401 { |
|
402 CCoeControl* testControl = new (ELeave) CCoeControl(); |
|
403 CleanupStack::PushL( testControl ); |
|
404 CAknPhysics* physics = CAknPhysics::NewL( *this, testControl ); |
|
405 CleanupStack::PushL( physics ); |
|
406 physics->ResumePhysics(); |
|
407 CleanupStack::PopAndDestroy( physics ); |
|
408 CleanupStack::PopAndDestroy( testControl ); |
|
409 _LIT( KResumePhysics, "CAknPhysics::ResumePhysics tested" ); |
|
410 AssertTrueL( ETrue, KResumePhysics ); |
|
411 } |
|
412 |
|
413 // --------------------------------------------------------------------------- |
|
414 // CBCTestMixMCLGeneralCase::TestCba |
|
415 // --------------------------------------------------------------------------- |
|
416 // |
|
417 void CBCTestMixMCLGeneralCase::TestCba() |
|
418 { |
|
419 CEikCba* cba = static_cast<CEikCba*>( |
|
420 iAvkonAppUi->Cba()->ButtonGroup()->AsControl() ); |
|
421 cba->EnableItemSpecificSoftkey( EFalse ); |
|
422 cba->EnableItemSpecificSoftkey( ETrue ); |
|
423 _LIT( CEikCbaEnableItemSpecificSoftkey, |
|
424 "CEikCba::EnableItemSpecificSoftkey tested" ); |
|
425 AssertTrueL( ETrue, CEikCbaEnableItemSpecificSoftkey ); |
|
426 } |
|
427 |
|
428 // --------------------------------------------------------------------------- |
|
429 // CBCTestMixMCLGeneralCase::ViewPositionChanged |
|
430 // --------------------------------------------------------------------------- |
|
431 // |
|
432 void CBCTestMixMCLGeneralCase::ViewPositionChanged( |
|
433 const TPoint& /*aNewPosition*/, |
|
434 TBool /*aDrawNow*/, |
|
435 TUint /*aFlags*/ ) |
|
436 { |
|
437 } |
|
438 |
|
439 // --------------------------------------------------------------------------- |
|
440 // CBCTestMixMCLGeneralCase::PhysicEmulationEnded |
|
441 // --------------------------------------------------------------------------- |
|
442 // |
|
443 void CBCTestMixMCLGeneralCase::PhysicEmulationEnded() |
|
444 { |
|
445 } |
|
446 |
|
447 // --------------------------------------------------------------------------- |
|
448 // CBCTestMixMCLGeneralCase::ViewPosition |
|
449 // --------------------------------------------------------------------------- |
|
450 // |
|
451 TPoint CBCTestMixMCLGeneralCase::ViewPosition() const |
|
452 { |
|
453 return TPoint( 0, 0 ); |
|
454 } |
|
455 |
|
456 //end of file |
|
457 |