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 CTestSetStartedCasesView class |
|
15 * definition. |
|
16 * |
|
17 */ |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <eikmenub.h> |
|
21 #include <aknViewAppUi.h> |
|
22 #include <barsread.h> //TResourceReader |
|
23 #include <Stifui.rsg> |
|
24 |
|
25 //#include "UIEngineContainer.h" |
|
26 #include <stifinternal/UIEngineContainer.h> |
|
27 |
|
28 #include "Stifui.hrh" |
|
29 |
|
30 #include "TestSetStartedCasesView.h" |
|
31 #include "TestSetStartedCasesContainer.h" |
|
32 #include "AppUIAppUi.h" |
|
33 |
|
34 // ================= MEMBER FUNCTIONS ======================= |
|
35 // ---------------------------------------------------------------------------- |
|
36 // CTestSetStartedCasesView::ConstructL |
|
37 // |
|
38 // Symbian OS two-phased constructor. |
|
39 // ---------------------------------------------------------------------------- |
|
40 // |
|
41 void CTestSetStartedCasesView::ConstructL() |
|
42 { |
|
43 CView::ConstructL(); |
|
44 BaseConstructL( R_TESTSET_STARTEDCASESVIEW ); |
|
45 iFilterModule.Zero(); |
|
46 iFilterTestCaseFile.Zero(); |
|
47 iSelectedTestCase=0; |
|
48 iNaviDecorator = NULL; |
|
49 } |
|
50 |
|
51 // ---------------------------------------------------------------------------- |
|
52 // CTestSetStartedCasesView::~CTestSetStartedCasesView |
|
53 // |
|
54 // Destructor. |
|
55 // ---------------------------------------------------------------------------- |
|
56 // |
|
57 CTestSetStartedCasesView::~CTestSetStartedCasesView() |
|
58 { |
|
59 if ( iContainer ) |
|
60 { |
|
61 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
62 delete iContainer; |
|
63 } |
|
64 delete iNaviDecorator; |
|
65 iNaviDecorator = NULL; |
|
66 } |
|
67 |
|
68 // ---------------------------------------------------------------------------- |
|
69 // CTestSetStartedCasesView::Id |
|
70 // |
|
71 // Returns view´s id. |
|
72 // ---------------------------------------------------------------------------- |
|
73 // |
|
74 TUid CTestSetStartedCasesView::Id() const |
|
75 { |
|
76 return TUid::Uid(ETestSetStartedCasesViewId); |
|
77 } |
|
78 |
|
79 // ---------------------------------------------------------------------------- |
|
80 // CTestSetStartedCasesView::HandleCommandL |
|
81 // |
|
82 // Handles a command. |
|
83 // ---------------------------------------------------------------------------- |
|
84 // |
|
85 void CTestSetStartedCasesView::HandleCommandL(TInt aCommand) |
|
86 { |
|
87 TBool refreshListBox = EFalse; |
|
88 // Handle rest possible commands |
|
89 switch ( aCommand ) |
|
90 { |
|
91 case ECmdShowAllStartedCases: |
|
92 { |
|
93 ((CAppUIAppUi*)iCoeEnv->AppUi())->iShowStartedCasesMode = EShowAllStartedCases; |
|
94 refreshListBox = ETrue; |
|
95 break; |
|
96 } |
|
97 case ECmdShowOngoingCases: |
|
98 { |
|
99 ((CAppUIAppUi*)iCoeEnv->AppUi())->iShowStartedCasesMode = EShowOngoingCases; |
|
100 refreshListBox = ETrue; |
|
101 break; |
|
102 } |
|
103 case ECmdShowPausedCases: |
|
104 { |
|
105 ((CAppUIAppUi*)iCoeEnv->AppUi())->iShowStartedCasesMode = EShowPausedCases; |
|
106 refreshListBox = ETrue; |
|
107 break; |
|
108 } |
|
109 case ECmdShowPassedCases: |
|
110 { |
|
111 ((CAppUIAppUi*)iCoeEnv->AppUi())->iShowStartedCasesMode = EShowPassedCases; |
|
112 refreshListBox = ETrue; |
|
113 break; |
|
114 } |
|
115 case ECmdShowFailedCases: |
|
116 { |
|
117 ((CAppUIAppUi*)iCoeEnv->AppUi())->iShowStartedCasesMode = EShowFailedCases; |
|
118 refreshListBox = ETrue; |
|
119 break; |
|
120 } |
|
121 case ECmdShowCrashedAbortedCases: |
|
122 { |
|
123 ((CAppUIAppUi*)iCoeEnv->AppUi())->iShowStartedCasesMode = EShowCrashedAbortedCases; |
|
124 refreshListBox = ETrue; |
|
125 break; |
|
126 } |
|
127 case ECmdShowStatistics: |
|
128 { |
|
129 //EShowStatistics |
|
130 TMessageBoxUtil::ShowNotImplementedYetL(); |
|
131 break; |
|
132 } |
|
133 case ECmdViewOutput: |
|
134 { |
|
135 ViewTestCaseOutputL(); |
|
136 break; |
|
137 } |
|
138 case ECmdPauseTestCase: |
|
139 { |
|
140 CStartedTestCase* startedTestCase = iContainer->SelectedTestCase(); |
|
141 if ( NULL != startedTestCase ) |
|
142 { |
|
143 startedTestCase->UIEngineContainer().PauseTest(); |
|
144 } |
|
145 break; |
|
146 } |
|
147 case ECmdResumeTestCase: |
|
148 { |
|
149 CStartedTestCase* startedTestCase = iContainer->SelectedTestCase(); |
|
150 if ( NULL != startedTestCase ) |
|
151 { |
|
152 startedTestCase->UIEngineContainer().ResumeTest(); |
|
153 } |
|
154 break; |
|
155 } |
|
156 case ECmdAbortTestCase: |
|
157 { |
|
158 CStartedTestCase* startedTestCase = iContainer->SelectedTestCase(); |
|
159 if ( NULL != startedTestCase ) |
|
160 { |
|
161 startedTestCase->UIEngineContainer().CancelTest(); |
|
162 } |
|
163 break; |
|
164 } |
|
165 case EAknSoftkeyOk: |
|
166 { |
|
167 iEikonEnv->InfoMsg( _L("TestCase Menu ok") ); |
|
168 break; |
|
169 } |
|
170 case EAknSoftkeyBack: |
|
171 { |
|
172 // Remove possible filterings so that they does not affect when coming again to this view |
|
173 iFilterModule.Zero(); |
|
174 iFilterTestCaseFile.Zero(); |
|
175 iSelectedTestCase=0; //Reset selected test case information |
|
176 AppUi()->HandleCommandL(EAppUIGoBack); |
|
177 break; |
|
178 } |
|
179 default: |
|
180 { |
|
181 AppUi()->HandleCommandL( aCommand ); |
|
182 break; |
|
183 } |
|
184 } |
|
185 |
|
186 if ( refreshListBox ) |
|
187 { |
|
188 RefreshNaviTitleL(); |
|
189 iContainer->ConstructListBoxModelL(); |
|
190 iContainer->DrawListBox(); |
|
191 } |
|
192 |
|
193 } |
|
194 |
|
195 |
|
196 // ---------------------------------------------------------------------------- |
|
197 // CTestSetStartedCasesView::RefreshNaviTitleL |
|
198 // |
|
199 // Refreshes view name shown in the navi pane. |
|
200 // ---------------------------------------------------------------------------- |
|
201 // |
|
202 void CTestSetStartedCasesView::RefreshNaviTitleL() |
|
203 { |
|
204 CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane(); |
|
205 CAknNavigationControlContainer* np= (CAknNavigationControlContainer *)sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi)); |
|
206 TResourceReader reader; |
|
207 |
|
208 switch ( ((CAppUIAppUi*)iCoeEnv->AppUi())->iShowStartedCasesMode ) |
|
209 { |
|
210 case EShowAllStartedCases: |
|
211 iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_STARTED); |
|
212 break; |
|
213 case EShowOngoingCases: |
|
214 iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_STARTED_ONGOING); |
|
215 break; |
|
216 case EShowPausedCases: |
|
217 iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_STARTED_PAUSED); |
|
218 break; |
|
219 case EShowPassedCases: |
|
220 iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_STARTED_PASSED); |
|
221 break; |
|
222 case EShowFailedCases: |
|
223 iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_STARTED_FAILED); |
|
224 break; |
|
225 case EShowCrashedAbortedCases: |
|
226 iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_STARTED_CRASHED_ABORTED); |
|
227 break; |
|
228 default: |
|
229 iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_TESTSET); |
|
230 break; |
|
231 } |
|
232 delete iNaviDecorator; |
|
233 iNaviDecorator = NULL; |
|
234 iNaviDecorator = np->CreateNavigationLabelL( reader ); |
|
235 CleanupStack::PopAndDestroy(); // resource reader |
|
236 np->PushL(*iNaviDecorator); |
|
237 } |
|
238 |
|
239 // ---------------------------------------------------------------------------- |
|
240 // CTestSetStartedCasesView::HandleListBoxEventL |
|
241 // |
|
242 // Handles listbox events. |
|
243 // ---------------------------------------------------------------------------- |
|
244 // |
|
245 void CTestSetStartedCasesView::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType) |
|
246 { |
|
247 if ( ( aEventType == EEventEnterKeyPressed ) || ( aEventType == EEventItemDoubleClicked ) ) |
|
248 { |
|
249 ViewTestCaseOutputL(); |
|
250 } |
|
251 |
|
252 } |
|
253 |
|
254 // ---------------------------------------------------------------------------- |
|
255 // CTestSetStartedCasesView::ViewTestCaseOutput |
|
256 // |
|
257 // Shows outputs of test case which is selected in Container. |
|
258 // ---------------------------------------------------------------------------- |
|
259 // |
|
260 void CTestSetStartedCasesView::ViewTestCaseOutputL() |
|
261 { |
|
262 iSelectedTestCase = iContainer->CurrentItemIndex(); |
|
263 |
|
264 // Sets index of selected test case to AppUi |
|
265 ( ( CAppUIAppUi* )AppUi() )->SetStartedTestCase( iContainer->CurrentTestCase() ); |
|
266 |
|
267 AppUi()->HandleCommandL(ECmdViewOutput); |
|
268 } |
|
269 |
|
270 // ---------------------------------------------------------------------------- |
|
271 // CTestSetStartedCasesView::HandleClientRectChange |
|
272 // |
|
273 // Handles client rect changes. |
|
274 // ---------------------------------------------------------------------------- |
|
275 // |
|
276 void CTestSetStartedCasesView::HandleClientRectChange() |
|
277 { |
|
278 if ( iContainer ) |
|
279 { |
|
280 iContainer->SetRect( ClientRect() ); |
|
281 } |
|
282 } |
|
283 |
|
284 // ---------------------------------------------------------------------------- |
|
285 // CTestSetStartedCasesView::DoActivateL |
|
286 // |
|
287 // Initializes view when activated. |
|
288 // ---------------------------------------------------------------------------- |
|
289 // |
|
290 void CTestSetStartedCasesView::DoActivateL( |
|
291 const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/, |
|
292 const TDesC8& /*aCustomMessage*/) |
|
293 { |
|
294 if (!iContainer) |
|
295 { |
|
296 iContainer = new (ELeave) CTestSetStartedCasesContainer; |
|
297 iContainer->SetMopParent(this); |
|
298 iContainer->ConstructL( ClientRect(), this ); |
|
299 AppUi()->AddToStackL( *this, iContainer ); |
|
300 } |
|
301 |
|
302 if ( iSelectedTestCase ) |
|
303 iContainer->SetCurrentItemIndex(iSelectedTestCase); |
|
304 |
|
305 iContainer->DrawListBox(); |
|
306 |
|
307 RefreshNaviTitleL(); |
|
308 } |
|
309 |
|
310 // ---------------------------------------------------------------------------- |
|
311 // CTestSetStartedCasesView::DoDeactivate |
|
312 // |
|
313 // Deactivates view. |
|
314 // ---------------------------------------------------------------------------- |
|
315 // |
|
316 void CTestSetStartedCasesView::DoDeactivate() |
|
317 { |
|
318 if ( iContainer ) |
|
319 { |
|
320 iContainer->SaveActiveLine(); |
|
321 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
322 delete iContainer; |
|
323 iContainer = NULL; |
|
324 } |
|
325 delete iNaviDecorator; |
|
326 iNaviDecorator = NULL; |
|
327 } |
|
328 |
|
329 // ---------------------------------------------------------------------------- |
|
330 // CTestSetStartedCasesView::DynInitMenuPaneL |
|
331 // |
|
332 // Initializes menu pane. |
|
333 // ---------------------------------------------------------------------------- |
|
334 // |
|
335 void CTestSetStartedCasesView::DynInitMenuPaneL( |
|
336 TInt aResourceId, CEikMenuPane* aMenuPane) |
|
337 { |
|
338 |
|
339 // options menu |
|
340 if ( R_TESTSET_STARTEDCASESVIEW_MENU == aResourceId ) |
|
341 { |
|
342 CStartedTestCase* startedTestCase = iContainer->SelectedTestCase(); |
|
343 if ( NULL != startedTestCase ) |
|
344 { |
|
345 switch ( startedTestCase->Status() ) |
|
346 { |
|
347 // test case running |
|
348 case CUIStoreIf::EStatusRunning: |
|
349 { |
|
350 switch ( startedTestCase->UIEngineContainer().State() ) |
|
351 { |
|
352 case CUIEngineContainer::ERunning: |
|
353 case CUIEngineContainer::EPaused: |
|
354 { |
|
355 aMenuPane->SetItemDimmed( ECmdShowSetMenu, EFalse ); |
|
356 break; |
|
357 } |
|
358 //case CUIEngineContainer::ENotStarted: |
|
359 //case CUIEngineContainer::EExecuted: |
|
360 //case CUIEngineContainer::EFinished: |
|
361 default: |
|
362 { |
|
363 aMenuPane->SetItemDimmed( ECmdShowSetMenu, ETrue ); |
|
364 } |
|
365 } |
|
366 break; |
|
367 } |
|
368 |
|
369 // test case not running |
|
370 //case CUIStoreIf::EStatusPassed: |
|
371 //case CUIStoreIf::EStatusFailed: |
|
372 //case CUIStoreIf::EStatusAborted: |
|
373 //case CUIStoreIf::EStatusExecuted |
|
374 default: |
|
375 { |
|
376 aMenuPane->SetItemDimmed( ECmdShowSetMenu, ETrue ); |
|
377 } |
|
378 } |
|
379 } |
|
380 else |
|
381 { |
|
382 aMenuPane->SetItemDimmed( ECmdViewOutput, ETrue ); |
|
383 aMenuPane->SetItemDimmed( ECmdShowSetMenu, ETrue ); |
|
384 } |
|
385 } |
|
386 |
|
387 // test case control menu |
|
388 if ( R_TESTCASE_CONTROL_SUBMENU == aResourceId ) |
|
389 { |
|
390 CStartedTestCase* startedTestCase = iContainer->SelectedTestCase(); |
|
391 |
|
392 if ( NULL != startedTestCase ) |
|
393 { |
|
394 if ( startedTestCase->Status() == CUIStoreIf::EStatusRunning ) |
|
395 { |
|
396 switch ( startedTestCase->UIEngineContainer().State() ) |
|
397 { |
|
398 case CUIEngineContainer::ERunning: |
|
399 { |
|
400 aMenuPane->SetItemDimmed( ECmdResumeTestCase, ETrue ); |
|
401 aMenuPane->SetItemDimmed( ECmdPauseTestCase, EFalse ); |
|
402 aMenuPane->SetItemDimmed( ECmdAbortTestCase, EFalse ); |
|
403 break; |
|
404 } |
|
405 case CUIEngineContainer::EPaused: |
|
406 { |
|
407 aMenuPane->SetItemDimmed( ECmdResumeTestCase, EFalse ); |
|
408 aMenuPane->SetItemDimmed( ECmdPauseTestCase, ETrue ); |
|
409 aMenuPane->SetItemDimmed( ECmdAbortTestCase, EFalse ); |
|
410 break; |
|
411 } |
|
412 //case CUIEngineContainer::ENotStarted: |
|
413 //case CUIEngineContainer::EExecuted: |
|
414 //case CUIEngineContainer::EFinished: |
|
415 default: |
|
416 { |
|
417 aMenuPane->SetItemDimmed( ECmdResumeTestCase, ETrue ); |
|
418 aMenuPane->SetItemDimmed( ECmdPauseTestCase, ETrue ); |
|
419 aMenuPane->SetItemDimmed( ECmdAbortTestCase, ETrue ); |
|
420 break; |
|
421 } |
|
422 } |
|
423 } |
|
424 else |
|
425 { |
|
426 aMenuPane->SetItemDimmed( ECmdResumeTestCase, ETrue ); |
|
427 aMenuPane->SetItemDimmed( ECmdPauseTestCase, ETrue ); |
|
428 aMenuPane->SetItemDimmed( ECmdAbortTestCase, ETrue ); |
|
429 } |
|
430 } |
|
431 else |
|
432 { |
|
433 aMenuPane->SetItemDimmed( ECmdResumeTestCase, ETrue ); |
|
434 aMenuPane->SetItemDimmed( ECmdPauseTestCase, ETrue ); |
|
435 aMenuPane->SetItemDimmed( ECmdAbortTestCase, ETrue ); |
|
436 } |
|
437 } |
|
438 |
|
439 } |
|
440 |
|
441 // ---------------------------------------------------------------------------- |
|
442 // CTestSetStartedCasesView::TestCaseStateChangedL |
|
443 // |
|
444 // Handles status changes of test cases in view. |
|
445 // ---------------------------------------------------------------------------- |
|
446 // |
|
447 void CTestSetStartedCasesView::TestCaseStateChangedL() |
|
448 { |
|
449 if ( iContainer ) |
|
450 { |
|
451 |
|
452 //CStartedTestCase* currentlySelectedTest = iContainer->SelectedTestCase(); |
|
453 |
|
454 TInt numOfTestsInViewBeforeStateChange = iContainer->TestsInViewCount(); |
|
455 |
|
456 //((CStartedTestsListBoxModel*)iContainer->iListBox->Model())->MdcaCount(); |
|
457 |
|
458 iContainer->ConstructListBoxModelL(); |
|
459 |
|
460 // Check if filtering by module or by test case file is selected |
|
461 /* |
|
462 if ( iFilterModule.Length() ) |
|
463 { |
|
464 iContainer->FilterCasesByModuleL(iFilterModule); |
|
465 } |
|
466 else if ( iFilterTestCaseFile.Length() ) |
|
467 { |
|
468 iContainer->FilterCasesByTCFileNameL(iFilterTestCaseFile); |
|
469 } |
|
470 */ |
|
471 |
|
472 TInt numOfTestsInViewAfterStateChange = iContainer->TestsInViewCount(); |
|
473 //((CStartedTestsListBoxModel*)iContainer->iListBox->Model())->MdcaCount(); |
|
474 |
|
475 if ( numOfTestsInViewAfterStateChange >= numOfTestsInViewBeforeStateChange ) |
|
476 iContainer->HandleItemAdditionL(); |
|
477 else |
|
478 iContainer->HandleItemRemovalL(); |
|
479 |
|
480 iContainer->DrawListBox(); |
|
481 |
|
482 } |
|
483 } |
|
484 |
|
485 // End of File |
|