stifui/avkon/stifui/src/ShowStartedCasesView.cpp
branchRCL_3
changeset 20 48060abbbeaf
parent 19 d40e813b23c0
child 21 b3cee849fa46
equal deleted inserted replaced
19:d40e813b23c0 20:48060abbbeaf
     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 CShowStartedCasesView 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 #include  "ShowStartedCasesView.h"
       
    30 #include  "ShowStartedCasesContainer.h"
       
    31 #include  "AppUIAppUi.h"
       
    32 
       
    33 // ================= MEMBER FUNCTIONS =======================
       
    34 
       
    35 // ----------------------------------------------------------------------------
       
    36 // CShowStartedCasesView::ConstructL
       
    37 // 
       
    38 // Symbian OS two-phased constructor
       
    39 // ----------------------------------------------------------------------------
       
    40 //
       
    41 void CShowStartedCasesView::ConstructL()
       
    42     {
       
    43     CView::ConstructL();
       
    44     BaseConstructL( R_APPUI_SHOWSTARTEDCASESVIEW );
       
    45     iFilterModule.Zero();
       
    46     iFilterTestCaseFile.Zero();
       
    47     iSelectedTestCase=0;
       
    48     iNaviDecorator = NULL;
       
    49     }
       
    50 
       
    51 // ----------------------------------------------------------------------------
       
    52 // CShowStartedCasesView::~CShowStartedCasesView()
       
    53 // 
       
    54 // Destructor
       
    55 // ----------------------------------------------------------------------------
       
    56 //
       
    57 CShowStartedCasesView::~CShowStartedCasesView()
       
    58     {
       
    59     if ( iContainer )
       
    60         {
       
    61         AppUi()->RemoveFromViewStack( *this, iContainer );
       
    62         delete iContainer;
       
    63         }
       
    64     delete iNaviDecorator;
       
    65     iNaviDecorator = NULL;
       
    66     }
       
    67 
       
    68 // ----------------------------------------------------------------------------
       
    69 // TUid CShowStartedCasesView::Id()
       
    70 // 
       
    71 // Returns view´s id.
       
    72 // ----------------------------------------------------------------------------
       
    73 //
       
    74 TUid CShowStartedCasesView::Id() const
       
    75     {
       
    76     return TUid::Uid(EShowStartedCasesViewId);
       
    77     }
       
    78 
       
    79 // ----------------------------------------------------------------------------
       
    80 // CShowStartedCasesView::HandleCommandL(TInt aCommand)
       
    81 // 
       
    82 // Handles a command.
       
    83 // ----------------------------------------------------------------------------
       
    84 //
       
    85 void CShowStartedCasesView::HandleCommandL(TInt aCommand)
       
    86     {   
       
    87     if ( aCommand >= ECmdFilterByModule && aCommand < ECmdFilterByTestCaseFile )
       
    88         {
       
    89         TInt moduleNumber = aCommand - ECmdFilterByModule;
       
    90         RRefArray<TDesC> testModules;
       
    91         TInt ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->Modules( testModules );
       
    92         if( KErrNone != ret )
       
    93             {
       
    94             testModules.Reset();
       
    95             testModules.Close();
       
    96             User::Leave( ret );
       
    97             }
       
    98         iFilterModule = testModules[moduleNumber];
       
    99             
       
   100         iFilterTestCaseFile.Zero();
       
   101         
       
   102         iContainer->FilterCasesByModuleL(iFilterModule);
       
   103         //iContainer->ResetListBox();
       
   104         //iContainer->DrawListBox();
       
   105         
       
   106         testModules.Reset();
       
   107         testModules.Close();
       
   108 
       
   109         return;
       
   110         }
       
   111 
       
   112     else if ( aCommand >= ECmdFilterByTestCaseFile && aCommand < ECmdNOFiltering )
       
   113         {
       
   114         TInt testCaseFileNumber = aCommand - ECmdFilterByTestCaseFile;
       
   115         RRefArray<TDesC> testCaseFiles;
       
   116         TInt ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->TestCaseFiles( testCaseFiles );
       
   117         if( KErrNone != ret )
       
   118             {
       
   119             testCaseFiles.Reset();
       
   120             testCaseFiles.Close();
       
   121             User::Leave( ret );
       
   122             }
       
   123 
       
   124         iFilterTestCaseFile = testCaseFiles[ testCaseFileNumber ];
       
   125         iFilterModule.Zero();
       
   126         //iContainer->FilterCasesByTCFileNameL(testCaseFileName);
       
   127         iContainer->FilterCasesByTCFileNameL(iFilterTestCaseFile);
       
   128         iContainer->ResetListBox();
       
   129         iContainer->DrawListBox();
       
   130 
       
   131         testCaseFiles.Reset();
       
   132         testCaseFiles.Close();
       
   133 
       
   134         return;
       
   135         }
       
   136 
       
   137     else if ( aCommand == ECmdNOFiltering )
       
   138         {
       
   139         iFilterModule.Zero();
       
   140         iFilterTestCaseFile.Zero();
       
   141         iContainer->NoFilteringL();
       
   142         iContainer->ResetListBox();
       
   143         iContainer->DrawListBox();
       
   144         return;
       
   145         }
       
   146 
       
   147     // Handle rest possible commands
       
   148     switch ( aCommand )
       
   149         {
       
   150         case ECmdViewOutput:
       
   151             {
       
   152             ViewTestCaseOutputL();
       
   153             break;
       
   154             }
       
   155         case ECmdRemoveExecution:
       
   156             {
       
   157             iContainer->RemoveSelectedExecutionsL();
       
   158             break;
       
   159             }
       
   160         case ECmdRemoveAllExecutions:
       
   161             {
       
   162             iContainer->RemoveAllExecutionsInViewL();
       
   163             break;
       
   164             }
       
   165         case ECmdPauseTestCase:
       
   166             {
       
   167             TInt index = iContainer->CurrentItemIndex();
       
   168             RRefArray<CStartedTestCase> runningTestCases;
       
   169             TShowStartedCasesMode currentMode = (TShowStartedCasesMode)((CAppUIAppUi*)iCoeEnv->AppUi())->iShowStartedCasesMode;
       
   170 			TInt ret = KErrNone;
       
   171 			if(currentMode == EShowAllStartedCases)
       
   172 				ret = iUIStore->StartedTestCases(runningTestCases, CUIStoreIf::EStatusAll);
       
   173 			else if(currentMode == EShowOngoingCases)
       
   174 				ret = iUIStore->StartedTestCases(runningTestCases, CUIStoreIf::EStatusRunning);
       
   175  			if( KErrNone != ret )
       
   176  			    {
       
   177  			    User::Leave( ret );
       
   178  			    }
       
   179  			runningTestCases[index].UIEngineContainer().PauseTest();
       
   180  			runningTestCases.Close();
       
   181             break;
       
   182             }
       
   183         case ECmdResumeTestCase:
       
   184             {
       
   185             TInt index = iContainer->CurrentItemIndex();
       
   186             RRefArray<CStartedTestCase> runningTestCases;
       
   187             TShowStartedCasesMode currentMode = (TShowStartedCasesMode)((CAppUIAppUi*)iCoeEnv->AppUi())->iShowStartedCasesMode;
       
   188 			TInt ret = KErrNone;
       
   189 			if(currentMode == EShowAllStartedCases)
       
   190 				ret = iUIStore->StartedTestCases(runningTestCases, CUIStoreIf::EStatusAll);
       
   191 			else if(currentMode == EShowOngoingCases || currentMode == EShowPausedCases)
       
   192 				ret = iUIStore->StartedTestCases(runningTestCases, CUIStoreIf::EStatusRunning);
       
   193  			if( KErrNone != ret )
       
   194  			    {
       
   195  			    User::Leave( ret );
       
   196  			    }
       
   197  			TInt testCaseToControl = 0;
       
   198  			if(currentMode == EShowAllStartedCases || currentMode == EShowOngoingCases)
       
   199 				{
       
   200 				testCaseToControl = index;
       
   201 				}
       
   202 			else if(currentMode == EShowPausedCases)
       
   203 				{
       
   204 				TInt pausedTestCasesCounter = 0;
       
   205 				for(int i = 0; i < runningTestCases.Count(); i++)
       
   206 					{
       
   207 					if(runningTestCases[i].UIEngineContainer().State() == CUIEngineContainer::EPaused)
       
   208 						{
       
   209 						if(pausedTestCasesCounter == index)
       
   210 							{
       
   211 							testCaseToControl = i;
       
   212 							break;
       
   213 							}
       
   214 						pausedTestCasesCounter++;
       
   215 						}
       
   216 					}
       
   217 				}
       
   218  			
       
   219  			runningTestCases[testCaseToControl].UIEngineContainer().ResumeTest();
       
   220  			runningTestCases.Close();
       
   221             break;
       
   222             }
       
   223         case ECmdAbortTestCase:
       
   224             { 
       
   225 			TInt index = iContainer->CurrentItemIndex();
       
   226 			RRefArray<CStartedTestCase> runningTestCases;
       
   227 			TShowStartedCasesMode currentMode = (TShowStartedCasesMode)((CAppUIAppUi*)iCoeEnv->AppUi())->iShowStartedCasesMode;
       
   228 			TInt ret = KErrNone;
       
   229 			if(currentMode == EShowAllStartedCases)
       
   230 				ret = iUIStore->StartedTestCases(runningTestCases, CUIStoreIf::EStatusAll);
       
   231 			else if(currentMode == EShowOngoingCases || currentMode == EShowPausedCases)
       
   232 				ret = iUIStore->StartedTestCases(runningTestCases, CUIStoreIf::EStatusRunning);
       
   233 				
       
   234 			if( KErrNone != ret )
       
   235 			    {
       
   236 			    User::Leave( ret );
       
   237 			    }
       
   238 			TInt testCaseToControl = 0;
       
   239 			
       
   240 			if(currentMode == EShowAllStartedCases || currentMode == EShowOngoingCases)
       
   241 				{
       
   242 				testCaseToControl = index;
       
   243 				}
       
   244 			else if(currentMode == EShowPausedCases)
       
   245 				{
       
   246 				TInt pausedTestCasesCounter = 0;
       
   247 				for(int i = 0; i < runningTestCases.Count(); i++)
       
   248 					{
       
   249 					if(runningTestCases[i].UIEngineContainer().State() == CUIEngineContainer::EPaused)
       
   250 						{
       
   251 						if(pausedTestCasesCounter == index)
       
   252 							{
       
   253 							testCaseToControl = i;
       
   254 							break;
       
   255 							}
       
   256 						pausedTestCasesCounter++;
       
   257 						}
       
   258 					}
       
   259 				}
       
   260 			
       
   261 			runningTestCases[testCaseToControl].UIEngineContainer().CancelTest();
       
   262 			runningTestCases.Close();
       
   263             break;
       
   264             }
       
   265         case EAknSoftkeyOk:
       
   266             {
       
   267             iEikonEnv->InfoMsg( _L("TestCase Menu ok") );
       
   268             break;
       
   269             }
       
   270         case EAknSoftkeyBack:
       
   271             {
       
   272             // Remove possible filterings so that they does not affect when coming again to this view
       
   273             iFilterModule.Zero();
       
   274             iFilterTestCaseFile.Zero();
       
   275             iSelectedTestCase=0; //Reset selected test case information
       
   276             AppUi()->HandleCommandL(EAppUIGoBack);
       
   277             break;
       
   278             }
       
   279         default:
       
   280             {
       
   281             AppUi()->HandleCommandL( aCommand );
       
   282             break;
       
   283             }
       
   284         }
       
   285 
       
   286     }
       
   287 
       
   288 // ----------------------------------------------------------------------------
       
   289 // CShowStartedCasesView::HandleListBoxEventL
       
   290 // 
       
   291 // Handles listbox events.
       
   292 // ----------------------------------------------------------------------------
       
   293 //
       
   294 void CShowStartedCasesView::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType)
       
   295 	{
       
   296 	if ( ( aEventType == EEventEnterKeyPressed ) || ( aEventType == EEventItemDoubleClicked ) )
       
   297 		{
       
   298         ViewTestCaseOutputL();
       
   299         }
       
   300 
       
   301     }
       
   302 
       
   303 // ----------------------------------------------------------------------------
       
   304 // CShowStartedCasesView::ViewTestCaseOutputL
       
   305 // 
       
   306 // Shows outputs of test case which is selected in Container.
       
   307 // ----------------------------------------------------------------------------
       
   308 //
       
   309 void CShowStartedCasesView::ViewTestCaseOutputL()
       
   310 	{
       
   311     iSelectedTestCase = iContainer->CurrentItemIndex();
       
   312     
       
   313     // Sets index  of selected test case to AppUi
       
   314     //( ( CAppUIAppUi* )AppUi() )->SetTestCaseIndex( iSelectedTestCase );
       
   315     ( ( CAppUIAppUi* )AppUi() )->SetStartedTestCase( iContainer->CurrentTestCase() );
       
   316     
       
   317     AppUi()->HandleCommandL(ECmdViewOutput);
       
   318     }
       
   319 
       
   320 
       
   321 // ----------------------------------------------------------------------------
       
   322 // CShowStartedCasesView::HandleClientRectChange()
       
   323 // 
       
   324 // Handles client rect changes.
       
   325 // ----------------------------------------------------------------------------
       
   326 //
       
   327 void CShowStartedCasesView::HandleClientRectChange()
       
   328     {
       
   329     if ( iContainer )
       
   330         {
       
   331         iContainer->SetRect( ClientRect() );
       
   332         }
       
   333     }
       
   334 
       
   335 // ----------------------------------------------------------------------------
       
   336 // CShowStartedCasesView::DoActivateL
       
   337 // 
       
   338 // Initializes view when activated.
       
   339 // ----------------------------------------------------------------------------
       
   340 //
       
   341 void CShowStartedCasesView::DoActivateL(
       
   342    const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
       
   343    const TDesC8& /*aCustomMessage*/)
       
   344     {
       
   345     if (!iContainer)
       
   346         {
       
   347         iContainer = new (ELeave) CShowStartedCasesContainer;
       
   348         iContainer->SetMopParent(this);
       
   349         iContainer->ConstructL( ClientRect(), this );
       
   350         AppUi()->AddToStackL( *this, iContainer );
       
   351         } 
       
   352 
       
   353     // Check if filtering by module or by test case file is selected
       
   354     if ( iFilterModule.Length() )
       
   355         {
       
   356         iContainer->FilterCasesByModuleL(iFilterModule);
       
   357         }
       
   358     else if ( iFilterTestCaseFile.Length() )
       
   359         {
       
   360         iContainer->FilterCasesByTCFileNameL(iFilterTestCaseFile);
       
   361         }
       
   362     if ( iSelectedTestCase )
       
   363         iContainer->SetCurrentItemIndex(iSelectedTestCase);
       
   364     
       
   365     RefreshNaviTitleL();
       
   366     
       
   367     iContainer->DrawListBox();
       
   368    }
       
   369 
       
   370 
       
   371 // ----------------------------------------------------------------------------
       
   372 // CShowStartedCasesView::RefreshNaviTitle
       
   373 // 
       
   374 // Refreshes view name shown in the navi pane.
       
   375 // ----------------------------------------------------------------------------
       
   376 //
       
   377 void CShowStartedCasesView::RefreshNaviTitleL()
       
   378     {
       
   379     CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane();
       
   380 	CAknNavigationControlContainer* np= (CAknNavigationControlContainer *)sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi));
       
   381 	TResourceReader reader;
       
   382 
       
   383     switch ( ((CAppUIAppUi*)iCoeEnv->AppUi())->iShowStartedCasesMode )
       
   384         {
       
   385         case EShowAllStartedCases:
       
   386             iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_STARTED_ALL);
       
   387             break;
       
   388         case EShowOngoingCases:
       
   389             iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_STARTED_ONGOING);
       
   390             break;
       
   391         case EShowPausedCases:
       
   392             iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_STARTED_PAUSED);
       
   393             break;
       
   394         case EShowPassedCases:
       
   395             iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_STARTED_PASSED);
       
   396             break;
       
   397         case EShowFailedCases:
       
   398             iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_STARTED_FAILED);
       
   399             break;
       
   400         case EShowCrashedAbortedCases:
       
   401             iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_STARTED_CRASHED_ABORTED);
       
   402             break;
       
   403         default:
       
   404             iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_TESTSET);
       
   405             break;
       
   406         }
       
   407     delete iNaviDecorator;
       
   408     iNaviDecorator = NULL;        
       
   409     iNaviDecorator = np->CreateNavigationLabelL( reader );
       
   410 	CleanupStack::PopAndDestroy(); // resource reader
       
   411 	np->PushL(*iNaviDecorator);
       
   412     }
       
   413     
       
   414     
       
   415 // ----------------------------------------------------------------------------
       
   416 // CShowStartedCasesView::DoDeactivate
       
   417 // 
       
   418 // Deactivates view.
       
   419 // ----------------------------------------------------------------------------
       
   420 //
       
   421 void CShowStartedCasesView::DoDeactivate()
       
   422     {
       
   423     if ( iContainer )
       
   424         {
       
   425         TInt mode = ((CAppUIAppUi*)iCoeEnv->AppUi())->iShowStartedCasesMode;
       
   426         if(mode != EShowOngoingCases && mode != EShowPausedCases
       
   427 		    	&& mode != EShowCrashedAbortedCases  && mode != EShowAllStartedCases)
       
   428         	{
       
   429         	iContainer->SaveActiveLine();
       
   430         	}
       
   431         AppUi()->RemoveFromViewStack( *this, iContainer );
       
   432         delete iContainer;
       
   433         iContainer = NULL;        
       
   434         }
       
   435     delete iNaviDecorator;
       
   436     iNaviDecorator = NULL;
       
   437 
       
   438     }
       
   439 
       
   440 
       
   441 // ----------------------------------------------------------------------------
       
   442 // CShowStartedCasesView::DynInitMenuPaneL
       
   443 // 
       
   444 // Initializes menu pane.
       
   445 // ----------------------------------------------------------------------------
       
   446 //
       
   447 void CShowStartedCasesView::DynInitMenuPaneL(
       
   448     TInt aResourceId, CEikMenuPane* aMenuPane)
       
   449     {
       
   450     // options menu
       
   451     if ( R_APPUI_SHOWSTARTEDCASESVIEW_MENU == aResourceId )
       
   452         {
       
   453         CStartedTestCase* startedTestCase = iContainer->SelectedTestCase();
       
   454         if ( NULL != startedTestCase )
       
   455             {
       
   456             aMenuPane->SetItemDimmed( ECmdFilterMenu, EFalse );
       
   457             switch ( startedTestCase->Status() )
       
   458                 {
       
   459                 // test case running
       
   460                 case CUIStoreIf::EStatusRunning:
       
   461                     {
       
   462                     switch ( startedTestCase->UIEngineContainer().State() )
       
   463                         {
       
   464                         case CUIEngineContainer::ERunning:
       
   465                         case CUIEngineContainer::EPaused:
       
   466                             {
       
   467                             aMenuPane->SetItemDimmed( ECmdShowSetMenu, EFalse );
       
   468                             break;
       
   469                             }
       
   470                         //case CUIEngineContainer::ENotStarted:
       
   471                         //case CUIEngineContainer::EExecuted:
       
   472                         //case CUIEngineContainer::EFinished:
       
   473                         default:
       
   474                             {
       
   475                             aMenuPane->SetItemDimmed( ECmdShowSetMenu, ETrue );
       
   476                             }
       
   477                         }
       
   478                     break;
       
   479                     }
       
   480                         
       
   481                 // test case not running
       
   482                 //case CUIStoreIf::EStatusPassed:
       
   483                 //case CUIStoreIf::EStatusFailed:
       
   484                 //case CUIStoreIf::EStatusAborted:
       
   485                 //case CUIStoreIf::EStatusExecuted
       
   486                 default:
       
   487                     {
       
   488                     aMenuPane->SetItemDimmed( ECmdShowSetMenu, ETrue );
       
   489                     }
       
   490                 }
       
   491             }
       
   492         else
       
   493             {
       
   494             //aMenuPane->SetItemDimmed( ECmdFilterMenu, ETrue );
       
   495             aMenuPane->SetItemDimmed( ECmdViewOutput, ETrue );
       
   496             aMenuPane->SetItemDimmed( ECmdShowSetMenu, ETrue );
       
   497             }
       
   498         }
       
   499 
       
   500     // test case control menu
       
   501     if ( R_TESTCASE_CONTROL_SUBMENU == aResourceId )
       
   502         {
       
   503         CStartedTestCase* startedTestCase = iContainer->SelectedTestCase();
       
   504         
       
   505         if ( NULL != startedTestCase )
       
   506             {
       
   507             if ( startedTestCase->Status() == CUIStoreIf::EStatusRunning )
       
   508                 {
       
   509                 switch ( startedTestCase->UIEngineContainer().State() )
       
   510                     {
       
   511                     case CUIEngineContainer::ERunning:
       
   512                         {
       
   513                         aMenuPane->SetItemDimmed( ECmdResumeTestCase, ETrue );
       
   514                         aMenuPane->SetItemDimmed( ECmdPauseTestCase, EFalse );
       
   515                         aMenuPane->SetItemDimmed( ECmdAbortTestCase, EFalse );
       
   516                         break;
       
   517                         }
       
   518                     case CUIEngineContainer::EPaused:
       
   519                         {
       
   520                         aMenuPane->SetItemDimmed( ECmdResumeTestCase, EFalse );
       
   521                         aMenuPane->SetItemDimmed( ECmdPauseTestCase, ETrue );
       
   522                         aMenuPane->SetItemDimmed( ECmdAbortTestCase, EFalse );
       
   523                         break;
       
   524                         }
       
   525                     //case CUIEngineContainer::ENotStarted:
       
   526                     //case CUIEngineContainer::EExecuted:
       
   527                     //case CUIEngineContainer::EFinished:
       
   528                     default:
       
   529                         {
       
   530                         aMenuPane->SetItemDimmed( ECmdResumeTestCase, ETrue );
       
   531                         aMenuPane->SetItemDimmed( ECmdPauseTestCase, ETrue );
       
   532                         aMenuPane->SetItemDimmed( ECmdAbortTestCase, ETrue );
       
   533                         break;
       
   534                         }
       
   535                     }
       
   536                 }
       
   537             else
       
   538                 {
       
   539                 aMenuPane->SetItemDimmed( ECmdResumeTestCase, ETrue );
       
   540                 aMenuPane->SetItemDimmed( ECmdPauseTestCase, ETrue );
       
   541                 aMenuPane->SetItemDimmed( ECmdAbortTestCase, ETrue );
       
   542                 }
       
   543             }
       
   544         else
       
   545             {
       
   546             aMenuPane->SetItemDimmed( ECmdResumeTestCase, ETrue );
       
   547             aMenuPane->SetItemDimmed( ECmdPauseTestCase, ETrue );
       
   548             aMenuPane->SetItemDimmed( ECmdAbortTestCase, ETrue );
       
   549             }
       
   550         }
       
   551 
       
   552     // Test modules are added to filter by test module submenu if the submenu is opened
       
   553     if (R_APPUI_FILTERBYMODULES_MENU == aResourceId)
       
   554         {
       
   555         RRefArray<TDesC> testModules;
       
   556         TInt ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->Modules( testModules );
       
   557         if( KErrNone != ret )
       
   558             {
       
   559             testModules.Reset();
       
   560             testModules.Close();
       
   561             User::Leave( ret );
       
   562             }        
       
   563         TInt moduleCount = testModules.Count();
       
   564 
       
   565         TInt i;
       
   566         CEikMenuPaneItem::SData item;
       
   567 
       
   568         item.iCommandId = ECmdFilterByModule;
       
   569         item.iFlags = 0;
       
   570         item.iCascadeId = 0;
       
   571 
       
   572         for (i = 0; i < moduleCount; i++)
       
   573             {
       
   574             item.iText = testModules[i];
       
   575             aMenuPane->AddMenuItemL(item);
       
   576             item.iCommandId++; // command IDs 0x1000 - 0x1FFF are reserved for modules in hrh file
       
   577             }
       
   578         
       
   579         testModules.Reset();
       
   580         testModules.Close();
       
   581 
       
   582         }
       
   583 
       
   584     // Test case files are added to filter by test case file submenu if the submenu is opened
       
   585     if (R_APPUI_FILTER_BY_TESTCASEFILE_MENU == aResourceId)
       
   586         {
       
   587         RRefArray<TDesC> testCaseFiles;
       
   588         TInt ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->TestCaseFiles( testCaseFiles );
       
   589         if( KErrNone != ret )
       
   590             {
       
   591             testCaseFiles.Reset();
       
   592             testCaseFiles.Close();
       
   593             User::Leave( ret );
       
   594             }        
       
   595         TInt testCaseFileCount = testCaseFiles.Count();
       
   596 
       
   597         TInt i;
       
   598         CEikMenuPaneItem::SData item;
       
   599 
       
   600         item.iCommandId = ECmdFilterByTestCaseFile;
       
   601         item.iFlags = 0;
       
   602         item.iCascadeId = 0;
       
   603 
       
   604         for (i = 0; i < testCaseFileCount; i++)
       
   605             {
       
   606             item.iText = testCaseFiles[i];
       
   607             // If there´s no test case file, don´t add item to menu.
       
   608             if ( testCaseFiles[i].Length() > 0 )
       
   609                 {
       
   610                 aMenuPane->AddMenuItemL(item);
       
   611                 }
       
   612             item.iCommandId++; // command IDs 0x2000 - 0x2FFF are reserved for test case files in hrh file
       
   613             }
       
   614         
       
   615         testCaseFiles.Reset();
       
   616         testCaseFiles.Close();
       
   617 
       
   618         }
       
   619 
       
   620     }
       
   621 
       
   622 // ----------------------------------------------------------------------------
       
   623 // CShowStartedCasesView::TestCaseStateChangedL
       
   624 // 
       
   625 // Handles status changes of test cases in view.
       
   626 // ----------------------------------------------------------------------------
       
   627 //
       
   628 void CShowStartedCasesView::TestCaseStateChangedL()
       
   629     {
       
   630     if ( iContainer )
       
   631         {
       
   632 
       
   633         //CStartedTestCase* currentlySelectedTest = iContainer->SelectedTestCase();
       
   634 
       
   635         TInt numOfTestsInViewBeforeStateChange = iContainer->TestsInViewCount();
       
   636 
       
   637             //((CStartedTestsListBoxModel*)iContainer->iListBox->Model())->MdcaCount();
       
   638 
       
   639         iContainer->ConstructListBoxModelL();
       
   640 
       
   641         // Check if filtering by module or by test case file is selected
       
   642         if ( iFilterModule.Length() )
       
   643             {
       
   644             iContainer->FilterCasesByModuleL(iFilterModule);
       
   645             }
       
   646         else if ( iFilterTestCaseFile.Length() )
       
   647             {
       
   648             iContainer->FilterCasesByTCFileNameL(iFilterTestCaseFile);
       
   649             }
       
   650 
       
   651         TInt numOfTestsInViewAfterStateChange = iContainer->TestsInViewCount();
       
   652             //((CStartedTestsListBoxModel*)iContainer->iListBox->Model())->MdcaCount();
       
   653 
       
   654         if ( numOfTestsInViewAfterStateChange >= numOfTestsInViewBeforeStateChange )
       
   655             iContainer->HandleItemAdditionL();
       
   656         else
       
   657             iContainer->HandleItemRemovalL();
       
   658         
       
   659         if(iContainer->CurrentItemIndex() < 0)
       
   660         	{
       
   661         	iContainer->SetCurrentItemIndex(0);
       
   662         	}
       
   663         iContainer->DrawListBox();
       
   664 
       
   665         }
       
   666     }
       
   667 
       
   668 // End of File