|
1 /* |
|
2 * Copyright (c) 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: Test case class of bctestsingleclick. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <w32std.h> |
|
19 #include <coecntrl.h> |
|
20 #include <aknitemactionmenu.h> |
|
21 #ifdef RD_TOUCH2 |
|
22 #include <aknViewAppUi.h> |
|
23 #include <aknview.h> |
|
24 #else |
|
25 #include <aknappui.h> |
|
26 #endif // RD_TOUCH2 |
|
27 #include <eikmenup.h> |
|
28 #include <eikmenub.h> |
|
29 #include <avkon.hrh> |
|
30 #include <eikfrlb.h> |
|
31 #include <bctestsingleclick.rsg> |
|
32 #ifdef RD_TOUCH2 |
|
33 #include <aknitemactionmenuregister.h> |
|
34 #endif // RD_TOUCH2 |
|
35 |
|
36 #include "bctestsingleclickcase.h" |
|
37 #include "bctestsingleclickcontainer.h" |
|
38 #include "bctestsingleclick.hrh" |
|
39 |
|
40 |
|
41 // ======== MEMBER FUNCTIONS ======== |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // Symbian 2nd static Constructor |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 CBCTESTSingleClickCase* CBCTESTSingleClickCase::NewL( |
|
48 CBCTESTSingleClickContainer* aContainer ) |
|
49 { |
|
50 CBCTESTSingleClickCase* self = |
|
51 new( ELeave ) CBCTESTSingleClickCase( aContainer ); |
|
52 CleanupStack::PushL( self ); |
|
53 self->ConstructL(); |
|
54 CleanupStack::Pop( self ); |
|
55 return self; |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // C++ default constructor |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 CBCTESTSingleClickCase::CBCTESTSingleClickCase( CBCTESTSingleClickContainer* |
|
63 aContainer ) |
|
64 : iContainer( aContainer ) |
|
65 { |
|
66 } |
|
67 |
|
68 // --------------------------------------------------------------------------- |
|
69 // Destructor |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 CBCTESTSingleClickCase::~CBCTESTSingleClickCase() |
|
73 { |
|
74 } |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // Symbian 2nd Constructor |
|
78 // --------------------------------------------------------------------------- |
|
79 // |
|
80 void CBCTESTSingleClickCase::ConstructL() |
|
81 { |
|
82 BuildScriptL(); |
|
83 } |
|
84 |
|
85 // --------------------------------------------------------------------------- |
|
86 // CBCTESTSingleClickCase::BuildScriptL |
|
87 // --------------------------------------------------------------------------- |
|
88 // |
|
89 void CBCTESTSingleClickCase::BuildScriptL() |
|
90 { |
|
91 // Add script as your need. |
|
92 // Use 30 to wait all discreet popups showing |
|
93 AddTestL( DELAY(1), LeftCBA, KeyOK, DELAY(1), TEND ); |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------------------------- |
|
97 // CBCTESTSingleClickCase::RunL |
|
98 // --------------------------------------------------------------------------- |
|
99 // |
|
100 void CBCTESTSingleClickCase::RunL( TInt aCmd ) |
|
101 { |
|
102 // Call release before prepare to let container has time to draw the |
|
103 // control created in PrepareCaseL. |
|
104 ReleaseCaseL(); |
|
105 PrepareCaseL( aCmd ); |
|
106 switch ( aCmd ) |
|
107 { |
|
108 case EBCTestCmdOutline1: |
|
109 TestSingleClickL(); |
|
110 TestListBoxL(); |
|
111 break; |
|
112 default: |
|
113 break; |
|
114 } |
|
115 } |
|
116 |
|
117 // --------------------------------------------------------------------------- |
|
118 // CBCTESTSingleClickCase::PrepareCaseL |
|
119 // --------------------------------------------------------------------------- |
|
120 // |
|
121 void CBCTESTSingleClickCase::PrepareCaseL( TInt aCmd ) |
|
122 { |
|
123 switch ( aCmd ) |
|
124 { |
|
125 case EBCTestCmdOutline1: |
|
126 // Here is a simple demo. You should create your control |
|
127 // instead of this. |
|
128 iControl = new( ELeave ) CCoeControl(); |
|
129 iControl->SetContainerWindowL( *iContainer ); |
|
130 iControl->MakeVisible( ETrue ); |
|
131 break; |
|
132 default: |
|
133 break; |
|
134 } |
|
135 // Pass the owner of iControl to iContainer. |
|
136 iContainer->SetControlL( iControl ); |
|
137 } |
|
138 |
|
139 // --------------------------------------------------------------------------- |
|
140 // CBCTESTSingleClickCase::ReleaseCaseL |
|
141 // --------------------------------------------------------------------------- |
|
142 // |
|
143 void CBCTESTSingleClickCase::ReleaseCaseL() |
|
144 { |
|
145 // let container delete the component control. |
|
146 iContainer->ResetControl(); |
|
147 iControl = NULL; |
|
148 } |
|
149 |
|
150 TUint CBCTESTSingleClickCase::CollectionState() const |
|
151 { |
|
152 return 1; |
|
153 } |
|
154 |
|
155 void CBCTESTSingleClickCase::ItemActionMenuClosed() |
|
156 { |
|
157 |
|
158 } |
|
159 |
|
160 TInt CBCTESTSingleClickCase::CollectionExtension( |
|
161 TUint /*aExtensionId*/, TAny*& /*a0*/, TAny* /*a1*/ ) |
|
162 { |
|
163 return 1; |
|
164 } |
|
165 |
|
166 // --------------------------------------------------------------------------- |
|
167 // CBCTESTSingleClickCase::TestSingleClickL |
|
168 // --------------------------------------------------------------------------- |
|
169 // |
|
170 void CBCTESTSingleClickCase::TestSingleClickL() |
|
171 { |
|
172 _LIT( KSetConstructingMenuBarOwnerL, |
|
173 "AknItemActionMenuRegister::SetConstructingMenuBarOwnerL" ); |
|
174 _LIT( KIsSingleClickCompatible, |
|
175 "CAknAppUiBase::IsSingleClickCompatible()" ); |
|
176 _LIT( KRegisterCollectionL, "CAknItemActionMenu::RegisterCollectionL" ); |
|
177 _LIT( KInitMenuL, "CAknItemActionMenu::InitMenuL" ); |
|
178 _LIT( KShowMenuL, "CAknItemActionMenu::ShowMenuL" ); |
|
179 _LIT( KRemoveCollection, "CAknItemActionMenu::RemoveCollection" ); |
|
180 _LIT( KItemSpecificCommandsEnabled, |
|
181 "CEikMenuBar::ItemSpecificCommandsEnabled()" ); |
|
182 _LIT( KSetItemSpecific, "CEikMenuPane::SetItemSpecific()" ); |
|
183 #ifdef RD_TOUCH2 |
|
184 _LIT( KSetOverridingMenuBarOwnerL, |
|
185 "AknItemActionMenuRegister::SetOverridingMenuBarOwnerL" ); |
|
186 _LIT( KCollectionChanged, "CAknItemActionMenu::CollectionChanged" ); |
|
187 #endif // RD_TOUCH2 |
|
188 |
|
189 //AknItemActionMenuRegister::SetConstructingMenuBarOwnerL is invoked in |
|
190 //CAknView::BaseConstructL(). |
|
191 AssertTrueL( ETrue, KSetConstructingMenuBarOwnerL ); |
|
192 |
|
193 #ifdef RD_TOUCH2 |
|
194 CCoeControl* dummy = new ( ELeave ) CCoeControl; |
|
195 CleanupStack::PushL( dummy ); |
|
196 AknItemActionMenuRegister::SetOverridingMenuBarOwnerL( dummy ); |
|
197 AknItemActionMenuRegister::SetOverridingMenuBarOwnerL( NULL ); |
|
198 AssertTrueL( ETrue, KSetOverridingMenuBarOwnerL ); |
|
199 CleanupStack::PopAndDestroy(); |
|
200 #endif // RD_TOUCH2 |
|
201 |
|
202 TBool isSingleClick = iAvkonAppUiBase->IsSingleClickCompatible(); |
|
203 AssertTrueL( isSingleClick, KIsSingleClickCompatible ); |
|
204 |
|
205 CAknItemActionMenu* aknItemActionMenu = |
|
206 CAknItemActionMenu::RegisterCollectionL( *this ); |
|
207 AssertTrueL( ETrue, KRegisterCollectionL ); |
|
208 if ( aknItemActionMenu ) |
|
209 { |
|
210 aknItemActionMenu->InitMenuL(); |
|
211 AssertTrueL( ETrue, KInitMenuL ); |
|
212 |
|
213 TPoint p( 10, 10 ); |
|
214 aknItemActionMenu->ShowMenuL( p ); |
|
215 AssertTrueL( ETrue, KShowMenuL ); |
|
216 |
|
217 #ifdef RD_TOUCH2 |
|
218 aknItemActionMenu->CollectionChanged( *this ); |
|
219 AssertTrueL( ETrue, KCollectionChanged ); |
|
220 #endif // RD_TOUCH2 |
|
221 |
|
222 aknItemActionMenu->RemoveCollection( *this ); |
|
223 AssertTrueL( ETrue, KRemoveCollection ); |
|
224 } |
|
225 |
|
226 #ifdef RD_TOUCH2 |
|
227 TVwsViewId uid; |
|
228 |
|
229 iAvkonViewAppUi->GetActiveViewId( uid ); |
|
230 CEikMenuBar* menuBar = iAvkonViewAppUi->View( uid.iViewUid )->MenuBar(); |
|
231 #else |
|
232 CEikMenuBar* menuBar = CEikonEnv::Static()->AppUiFactory()->MenuBar(); |
|
233 #endif // RD_TOUCH2 |
|
234 CEikMenuPane* menuPane = NULL; |
|
235 if ( menuBar ) |
|
236 { |
|
237 menuBar->ItemSpecificCommandsEnabled(); |
|
238 AssertTrueL( ETrue, KItemSpecificCommandsEnabled ); |
|
239 menuPane = menuBar->MenuPane(); |
|
240 } |
|
241 |
|
242 if ( menuPane ) |
|
243 { |
|
244 menuPane->AddMenuItemsL( R_BCTESTSINGLECLICK_ADD_MENU ); |
|
245 menuPane->SetItemSpecific( EBCTestCmdOutline2, ETrue ); |
|
246 AssertTrueL( ETrue, KSetItemSpecific ); |
|
247 } |
|
248 } |
|
249 |
|
250 // --------------------------------------------------------------------------- |
|
251 // CBCTESTSingleClickCase::TestSingleClickL |
|
252 // --------------------------------------------------------------------------- |
|
253 // |
|
254 void CBCTESTSingleClickCase::TestListBoxL() |
|
255 { |
|
256 _LIT( KDisableSingleClick, "CEikListBox::DisableSingleClick() invoked" ); |
|
257 |
|
258 CEikFormattedCellListBox* listbox = new CEikFormattedCellListBox(); |
|
259 CleanupStack::PushL( listbox ); |
|
260 |
|
261 listbox->ConstructL( iContainer, EAknListBoxSelectionList ); |
|
262 CDesCArrayFlat* text = new (ELeave) CDesCArrayFlat(1); |
|
263 CleanupStack::PushL( text ); |
|
264 |
|
265 text->AppendL( _L( "\tTextItem1\t" ) ); |
|
266 text->AppendL( _L( "\tTextItem2\t" ) ); |
|
267 text->AppendL( _L( "\tTextItem3\t" ) ); |
|
268 |
|
269 listbox->Model()->SetItemTextArray( text ); |
|
270 listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
271 |
|
272 listbox->DisableSingleClick( ETrue ); |
|
273 AssertTrueL( ETrue, KDisableSingleClick ); |
|
274 |
|
275 CleanupStack::PopAndDestroy( text ); |
|
276 CleanupStack::PopAndDestroy( listbox ); |
|
277 } |
|
278 |