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: This file contains CStartCasesView class definition. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <eikmenub.h> |
|
20 #include <aknViewAppUi.h> |
|
21 #include <aknlistquerydialog.h> |
|
22 #include <barsread.h> //TResourceReader |
|
23 #include <Stifui.rsg> |
|
24 #include "StartCasesView.h" |
|
25 #include "StartCasesContainer.h" |
|
26 #include "AppUIAppUi.h" |
|
27 #include "Stifui.hrh" |
|
28 |
|
29 |
|
30 // ================= MEMBER FUNCTIONS ======================= |
|
31 // ---------------------------------------------------------------------------- |
|
32 // CStartCasesView::ConstructL |
|
33 // |
|
34 // Symbian OS two-phased constructor. |
|
35 // ---------------------------------------------------------------------------- |
|
36 // |
|
37 void CStartCasesView::ConstructL() |
|
38 { |
|
39 CView::ConstructL(); |
|
40 BaseConstructL( R_APPUI_STARTCASESVIEW ); |
|
41 iCurrentTestCase = 0; |
|
42 |
|
43 } |
|
44 |
|
45 // ---------------------------------------------------------------------------- |
|
46 // CStartCasesView::~CStartCasesView |
|
47 // |
|
48 // Destructor |
|
49 // ---------------------------------------------------------------------------- |
|
50 // |
|
51 CStartCasesView::~CStartCasesView() |
|
52 { |
|
53 if ( iContainer ) |
|
54 { |
|
55 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
56 delete iContainer; |
|
57 } |
|
58 delete iNaviDecorator; |
|
59 iNaviDecorator = NULL; |
|
60 } |
|
61 |
|
62 // ---------------------------------------------------------------------------- |
|
63 // CStartCasesView::Id |
|
64 // |
|
65 // Returns view´s id. |
|
66 // ---------------------------------------------------------------------------- |
|
67 // |
|
68 TUid CStartCasesView::Id() const |
|
69 { |
|
70 return TUid::Uid(EStartCaseMenuViewId); |
|
71 |
|
72 } |
|
73 |
|
74 // ---------------------------------------------------------------------------- |
|
75 // CStartCasesView::HandleCommandL |
|
76 // |
|
77 // Handles a command. |
|
78 // ---------------------------------------------------------------------------- |
|
79 // |
|
80 void CStartCasesView::HandleCommandL(TInt aCommand) |
|
81 { |
|
82 if ( aCommand >= ECmdFilterByModule && aCommand < ECmdFilterByTestCaseFile ) // 0x1000 - 0x1FFF |
|
83 { |
|
84 TInt moduleNumber = aCommand - ECmdFilterByModule; |
|
85 RRefArray<TDesC> allModules; |
|
86 TInt ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->Modules( allModules ); |
|
87 if( KErrNone != ret ) |
|
88 { |
|
89 allModules.Reset(); |
|
90 allModules.Close(); |
|
91 User::Leave( ret ); |
|
92 } |
|
93 TName moduleName = allModules[ moduleNumber ]; |
|
94 |
|
95 iContainer->FilterCasesByModuleL( moduleName ); |
|
96 |
|
97 allModules.Reset(); |
|
98 allModules.Close(); |
|
99 } |
|
100 else if ( aCommand >= ECmdFilterByTestCaseFile && aCommand < ECmdNOFiltering ) |
|
101 { |
|
102 TInt testCaseFileNumber = aCommand - ECmdFilterByTestCaseFile; |
|
103 RRefArray<TDesC> allTestCases; |
|
104 TInt ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->TestCaseFiles( allTestCases ); |
|
105 if( KErrNone != ret ) |
|
106 { |
|
107 allTestCases.Reset(); |
|
108 allTestCases.Close(); |
|
109 User::Leave( ret ); |
|
110 } |
|
111 TFileName testCaseFileName = allTestCases[ testCaseFileNumber ]; |
|
112 |
|
113 iContainer->FilterCasesByTCFileNameL( testCaseFileName ); |
|
114 |
|
115 allTestCases.Reset(); |
|
116 allTestCases.Close(); |
|
117 } |
|
118 else if ( aCommand == ECmdNOFiltering ) |
|
119 { |
|
120 iContainer->NoFilteringL(); |
|
121 } |
|
122 else if ( aCommand == EAknCmdMark || aCommand == EAknCmdUnmark |
|
123 || aCommand == EAknMarkAll || aCommand == EAknUnmarkAll ) |
|
124 { |
|
125 iContainer->HandleMarkCommandL( aCommand ); |
|
126 } |
|
127 else |
|
128 { |
|
129 switch ( aCommand ) |
|
130 { |
|
131 case ECmdStartCases: |
|
132 { |
|
133 CheckListBoxSelectionsL( iContainer->ListBox() ); |
|
134 break; |
|
135 } |
|
136 case EAknSoftkeyBack: |
|
137 { |
|
138 iCurrentTestCase = 0; |
|
139 AppUi()->HandleCommandL(EAppUIGoBack); |
|
140 break; |
|
141 } |
|
142 default: |
|
143 { |
|
144 AppUi()->HandleCommandL( aCommand ); |
|
145 break; |
|
146 } |
|
147 } |
|
148 } |
|
149 |
|
150 } |
|
151 |
|
152 // ---------------------------------------------------------------------------- |
|
153 // CStartCasesView::HandleClientRectChange |
|
154 // |
|
155 // Handles client rect changes. |
|
156 // ---------------------------------------------------------------------------- |
|
157 // |
|
158 void CStartCasesView::HandleClientRectChange() |
|
159 { |
|
160 if ( iContainer ) |
|
161 { |
|
162 iContainer->SetRect( ClientRect() ); |
|
163 } |
|
164 |
|
165 } |
|
166 |
|
167 // ---------------------------------------------------------------------------- |
|
168 // CStartCasesView::DoActivateL |
|
169 // |
|
170 // Initializes view when activated. |
|
171 // ---------------------------------------------------------------------------- |
|
172 // |
|
173 void CStartCasesView::DoActivateL( |
|
174 const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/, |
|
175 const TDesC8& /*aCustomMessage*/) |
|
176 { |
|
177 if (!iContainer) |
|
178 { |
|
179 ((CAppUIAppUi*)AppUi())->iLogger->Log(_L("StartCasesView: DoActivateL")); |
|
180 iContainer = new (ELeave) CStartCasesContainer; |
|
181 iContainer->SetMopParent(this); |
|
182 iContainer->ConstructL( ClientRect(), this ); |
|
183 ((CAppUIAppUi*)AppUi())->iLogger->Log(_L("StartCasesView: container constructed")); |
|
184 AppUi()->AddToStackL( *this, iContainer ); |
|
185 } |
|
186 |
|
187 iContainer->SetCurrentItemIndex(iCurrentTestCase); |
|
188 |
|
189 CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane(); |
|
190 CAknNavigationControlContainer* np= (CAknNavigationControlContainer *)sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi)); |
|
191 |
|
192 TResourceReader reader; |
|
193 iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_STARTCASES); |
|
194 iNaviDecorator = np->CreateNavigationLabelL( reader ); |
|
195 CleanupStack::PopAndDestroy(); // resource reader |
|
196 np->PushL(*iNaviDecorator); |
|
197 |
|
198 } |
|
199 |
|
200 // ---------------------------------------------------------------------------- |
|
201 // CStartCasesView::DoDeactivate |
|
202 // |
|
203 // Deactivates view. |
|
204 // ---------------------------------------------------------------------------- |
|
205 // |
|
206 void CStartCasesView::DoDeactivate() |
|
207 { |
|
208 if ( iContainer ) |
|
209 { |
|
210 iContainer->SaveActiveLine(); |
|
211 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
212 delete iContainer; |
|
213 iContainer = NULL; |
|
214 } |
|
215 delete iNaviDecorator; |
|
216 iNaviDecorator = NULL; |
|
217 } |
|
218 |
|
219 |
|
220 // ---------------------------------------------------------------------------- |
|
221 // CStartCasesView::DynInitMenuPaneL |
|
222 // |
|
223 // Initializes menu pane. |
|
224 // ---------------------------------------------------------------------------- |
|
225 // |
|
226 void CStartCasesView::DynInitMenuPaneL( |
|
227 TInt aResourceId, CEikMenuPane* aMenuPane) |
|
228 { |
|
229 |
|
230 // Test modules are added to filter by test module submenu if the submenu is opened |
|
231 if (R_APPUI_FILTERBYMODULES_MENU == aResourceId) |
|
232 { |
|
233 RRefArray<TDesC> modules; |
|
234 TInt ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->Modules( modules ); |
|
235 if( KErrNone != ret ) |
|
236 { |
|
237 modules.Reset(); |
|
238 modules.Close(); |
|
239 User::Leave( ret ); |
|
240 } |
|
241 |
|
242 TInt moduleCount = modules.Count(); |
|
243 |
|
244 TInt i; |
|
245 CEikMenuPaneItem::SData item; |
|
246 |
|
247 item.iCommandId = ECmdFilterByModule; |
|
248 item.iFlags = 0; |
|
249 item.iCascadeId = 0; |
|
250 |
|
251 for (i = 0; i < moduleCount; i++) |
|
252 { |
|
253 //item.iText = modules[i].iModuleName; |
|
254 item.iText.Copy( modules[i].Left( item.iText.MaxLength() ) ) ; |
|
255 aMenuPane->AddMenuItemL(item); |
|
256 item.iCommandId++; // command IDs 0x1000 - 0x1FFF are reserved for modules in hrh file |
|
257 } |
|
258 |
|
259 modules.Reset(); |
|
260 modules.Close(); |
|
261 |
|
262 } |
|
263 |
|
264 // Test case files are added to filter by test case file submenu if the submenu is opened |
|
265 if (R_APPUI_FILTER_BY_TESTCASEFILE_MENU == aResourceId) |
|
266 { |
|
267 RRefArray<TDesC> testCaseFiles; |
|
268 TInt ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->TestCaseFiles( testCaseFiles ); |
|
269 if( KErrNone != ret ) |
|
270 { |
|
271 testCaseFiles.Reset(); |
|
272 testCaseFiles.Close(); |
|
273 User::Leave( ret ); |
|
274 } |
|
275 |
|
276 TInt testCaseFileCount = testCaseFiles.Count(); |
|
277 |
|
278 TInt i; |
|
279 CEikMenuPaneItem::SData item; |
|
280 |
|
281 item.iCommandId = ECmdFilterByTestCaseFile; |
|
282 item.iFlags = 0; |
|
283 item.iCascadeId = 0; |
|
284 |
|
285 for (i = 0; i < testCaseFileCount; i++) |
|
286 { |
|
287 item.iText.Copy( testCaseFiles[i].Left( item.iText.MaxLength() ) ); |
|
288 // If there´s no test case file, don´t add item to menu. |
|
289 if ( testCaseFiles[i].Length() > 0 ) |
|
290 { |
|
291 aMenuPane->AddMenuItemL(item); |
|
292 } |
|
293 item.iCommandId++; // command IDs 0x2000 - 0x2FFF are reserved for test case files in hrh file |
|
294 } |
|
295 |
|
296 testCaseFiles.Reset(); |
|
297 testCaseFiles.Close(); |
|
298 } |
|
299 |
|
300 } |
|
301 |
|
302 // ---------------------------------------------------------------------------- |
|
303 // CStartCasesView::HandleListBoxEventL |
|
304 // |
|
305 // Handles listbox events. |
|
306 // ---------------------------------------------------------------------------- |
|
307 // |
|
308 void CStartCasesView::HandleListBoxEventL( CEikListBox* aListBox, |
|
309 TListBoxEvent aEventType ) |
|
310 { |
|
311 if ( ( aEventType == EEventEnterKeyPressed ) || ( aEventType == EEventItemDoubleClicked ) ) |
|
312 { |
|
313 CheckListBoxSelectionsL( aListBox ); |
|
314 } |
|
315 |
|
316 } |
|
317 |
|
318 // ---------------------------------------------------------------------------- |
|
319 // CStartCasesView::CheckListBoxSelectionsL |
|
320 // |
|
321 // Checks listbox selections and launches query dialog to start test cases. |
|
322 // ---------------------------------------------------------------------------- |
|
323 // |
|
324 void CStartCasesView::CheckListBoxSelectionsL( CEikListBox* aListBox ) |
|
325 { |
|
326 TInt i(0); |
|
327 TInt count = aListBox->SelectionIndexes()->Count(); |
|
328 |
|
329 RArray<TInt> selectedIndices; |
|
330 CleanupClosePushL( selectedIndices ); |
|
331 |
|
332 if ( count > 0 ) |
|
333 { |
|
334 for( i = 0; i < count; i++ ) |
|
335 { |
|
336 selectedIndices.InsertInOrder( |
|
337 (*aListBox->SelectionIndexes())[i] ); |
|
338 } |
|
339 } |
|
340 |
|
341 // Check count of selected items. |
|
342 if ( count == 1 ) |
|
343 { |
|
344 iCurrentTestCase = selectedIndices[0]; |
|
345 StartTestCaseL(); |
|
346 } |
|
347 else if (count > 1) |
|
348 { |
|
349 StartTestCasesL( selectedIndices ); |
|
350 } |
|
351 else |
|
352 { |
|
353 iCurrentTestCase = iContainer->CurrentItemIndex(); |
|
354 StartTestCaseL(); |
|
355 } |
|
356 |
|
357 CleanupStack::PopAndDestroy(); |
|
358 |
|
359 } |
|
360 |
|
361 // ---------------------------------------------------------------------------- |
|
362 // CStartCasesView::StartTestCaseL |
|
363 // |
|
364 // Starts test case which is selected in containers list box. |
|
365 // First shows a list query if user wants just start test case or |
|
366 // if he wants to start test case and view test case output. |
|
367 // ---------------------------------------------------------------------------- |
|
368 // |
|
369 void CStartCasesView::StartTestCaseL() |
|
370 { |
|
371 TInt selectedItem(0); |
|
372 CAknListQueryDialog* startDialog = new (ELeave) CAknListQueryDialog(&selectedItem); |
|
373 if ( startDialog->ExecuteLD(R_START_TESTCASE_LIST_QUERY) ) |
|
374 { |
|
375 CTestInfo* testCaseInfo = iContainer->SelectedTestCaseInfo(); |
|
376 |
|
377 User::LeaveIfNull( testCaseInfo ); |
|
378 |
|
379 TInt testCaseIndex( 0 ); |
|
380 |
|
381 TInt ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->StartTestCase( *testCaseInfo, testCaseIndex ); |
|
382 |
|
383 if( KErrNone != ret ) |
|
384 { |
|
385 User::Leave( ret ); |
|
386 } |
|
387 |
|
388 // Increment the counter value |
|
389 ((CAppUIAppUi*)AppUi())->iUIStoreHandler->iExecutedTestCaseCount++; |
|
390 |
|
391 if ( selectedItem == 1 ) // if view output was selected |
|
392 { |
|
393 CStartedTestCase* startedCase = |
|
394 &((CAppUIAppUi*)AppUi())->UIStoreHandler()->StartedTestCaseL( |
|
395 testCaseIndex ); |
|
396 ((CAppUIAppUi*)AppUi())->SetStartedTestCase( startedCase ); |
|
397 |
|
398 AppUi()->HandleCommandL( ECmdViewOutput ); |
|
399 |
|
400 } |
|
401 } |
|
402 } |
|
403 |
|
404 // ---------------------------------------------------------------------------- |
|
405 // CStartCasesView::StartTestCasesL |
|
406 // |
|
407 // Starts multiple test cases which are selected in containers list box. |
|
408 // Shows a list query if user wants to start cases parallel or sequential. |
|
409 // ---------------------------------------------------------------------------- |
|
410 // |
|
411 void CStartCasesView::StartTestCasesL( RArray<TInt> aSelectedIndexes ) |
|
412 { |
|
413 _LIT( KTempSet, "TempSet"); |
|
414 TInt selectedItem(0); |
|
415 TInt i(0); |
|
416 TInt ret(0); |
|
417 |
|
418 CAknListQueryDialog* startDialog = new (ELeave) CAknListQueryDialog(&selectedItem); |
|
419 if ( startDialog->ExecuteLD(R_START_MULTIPLE_TESTCASES_LIST_QUERY) ) |
|
420 { |
|
421 ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->CreateTestSet( KTempSet ); |
|
422 |
|
423 User::LeaveIfError( ret ); |
|
424 |
|
425 for( i = 0; i < aSelectedIndexes.Count(); i++ ) |
|
426 { |
|
427 CTestInfo* testCaseInfo = iContainer->TestCaseInfo( aSelectedIndexes[i] ); |
|
428 User::LeaveIfNull( testCaseInfo ); |
|
429 |
|
430 ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->AddToTestSet( KTempSet, *testCaseInfo ); |
|
431 if( KErrNone != ret ) |
|
432 { |
|
433 User::Leave( ret ); |
|
434 } |
|
435 // Increment the counter value |
|
436 ((CAppUIAppUi*)AppUi())->iUIStoreHandler->iExecutedTestCaseCount++; |
|
437 } |
|
438 |
|
439 //start cases |
|
440 if ( selectedItem == 0 ) |
|
441 { |
|
442 ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->StartTestSet( |
|
443 ((CAppUIAppUi*)AppUi())->UIStoreHandler()->TestSetL( KTempSet ), |
|
444 i, CStartedTestSet::ESetParallel); |
|
445 } |
|
446 else if (selectedItem == 1) |
|
447 { |
|
448 ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->StartTestSet( |
|
449 ((CAppUIAppUi*)AppUi())->UIStoreHandler()->TestSetL( KTempSet ), |
|
450 i, CStartedTestSet::ESetSequential); |
|
451 } |
|
452 |
|
453 ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->RemoveTestSet( KTempSet ); |
|
454 } |
|
455 } |
|
456 |
|
457 // End of File |
|