uifw/AvKon/tsrc/bc/bctestlauncher/src/bctestlauncherappui.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2006-2007 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:  Implementation of application UI class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <bctestlauncher.rsg>
       
    22 #include <avkon.hrh>
       
    23 #include <bacline.h>
       
    24 
       
    25 #include "bctestlauncherappui.h"
       
    26 #include "bctestlaunchercontainer.h" 
       
    27 #include "bctestlauncher.hrh"
       
    28 #include "bctestlauncherview.h"
       
    29 #include "bctestrunner.h"
       
    30 #include "streamlogger.h"
       
    31 
       
    32 #include "bctestapplication.h"
       
    33 
       
    34 const TInt CMDNum = 32;
       
    35 _LIT( KFULL, "full" );
       
    36 
       
    37 // ============================ MEMBER FUNCTIONS =============================
       
    38 
       
    39 // ---------------------------------------------------------------------------
       
    40 // C++ default constructor
       
    41 // ---------------------------------------------------------------------------
       
    42 //
       
    43 CBCTestLauncherAppUi::CBCTestLauncherAppUi()
       
    44                     : iNaviPane( NULL ), iAppContainer( NULL ),iRunner( 0 )
       
    45     {
       
    46     }
       
    47 
       
    48 // ---------------------------------------------------------------------------
       
    49 // Symbian 2nd phase constructor can leave.
       
    50 // ---------------------------------------------------------------------------
       
    51 //
       
    52 void CBCTestLauncherAppUi::ConstructL()
       
    53     {
       
    54     BaseConstructL();
       
    55 
       
    56     // Create status pane
       
    57     CEikStatusPane *sp = StatusPane();
       
    58     // Create navi pane
       
    59     iNaviPane = ( CAknNavigationControlContainer* )sp->ControlL(
       
    60         TUid::Uid( EEikStatusPaneUidNavi ) );
       
    61 
       
    62 	iRunner = CBCTestRunner::NewL();
       
    63 
       
    64     iAppView = new( ELeave )CBCTestLauncherView( iRunner->Apps() );
       
    65     iAppView->ConstructL();
       
    66 	AddViewL( iAppView );
       
    67 
       
    68     ActivateLocalViewL( iAppView->Id() );
       
    69 	SetDefaultViewL( *iAppView );
       
    70 
       
    71 	DoCommand();
       
    72 
       
    73     }
       
    74 
       
    75 // Destructor
       
    76 CBCTestLauncherAppUi::~CBCTestLauncherAppUi()
       
    77     {
       
    78     delete iAppContainer;
       
    79     delete iRunner;
       
    80     }
       
    81 
       
    82 // ---------------------------------------------------------------------------
       
    83 // CBCTestLauncherAppUi::HandleCommandL( TInt aCommand )
       
    84 // Handles command list
       
    85 // ---------------------------------------------------------------------------
       
    86 //
       
    87 void CBCTestLauncherAppUi::HandleCommandL( TInt aCommand )
       
    88     {
       
    89     switch ( aCommand )
       
    90         {
       
    91         case EAknCmdExit:
       
    92         case EEikCmdExit:
       
    93 		case EAknSoftkeyBack:
       
    94 			Exit();
       
    95             break;
       
    96         case ESdkVersion:
       
    97             iAppView->HandleCommandL( aCommand );
       
    98             break;
       
    99 		case EAutoTestSelection:
       
   100 			if( !iAppView->SelectL() )
       
   101 				{
       
   102 				return;
       
   103 				}
       
   104 
       
   105         default:
       
   106             iRunner->RunL( aCommand );
       
   107         }
       
   108     }
       
   109 
       
   110 // ---------------------------------------------------------------------------
       
   111 // CBCTestLauncherAppUi::HandleKeyEventL(
       
   112 //     const TKeyEvent& aKeyEvent, TEventCode /*aType*/ )
       
   113 // Handles key events.
       
   114 // ---------------------------------------------------------------------------
       
   115 //
       
   116 TKeyResponse CBCTestLauncherAppUi::HandleKeyEventL(
       
   117     const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/ )
       
   118     {
       
   119     return EKeyWasNotConsumed;
       
   120     }
       
   121  
       
   122 void CBCTestLauncherAppUi::DoCommand()
       
   123     {
       
   124     
       
   125 	CCommandLineArguments* args = CCommandLineArguments::NewLC();
       
   126 
       
   127     if ( args->Count() == 1)
       
   128         {
       
   129         CleanupStack::PopAndDestroy( args );
       
   130         return;
       
   131         } 
       
   132 
       
   133     CArrayFixFlat<TPtrC>* cmdData = new( ELeave )CArrayFixFlat<TPtrC>( CMDNum );
       
   134     CleanupStack::PushL( cmdData );
       
   135     
       
   136     HBufC* msg = HBufC::NewLC( 32 );
       
   137  	for (TInt i=0; i<args->Count(); i++)
       
   138 		{
       
   139         msg->Des().Copy( args->Arg(i) );
       
   140         msg->Des().LowerCase();
       
   141 		cmdData->AppendL( msg->Des() );
       
   142 		}
       
   143     
       
   144     if ( ( *cmdData )[1] == KFULL )
       
   145         {
       
   146         iAppView->HandleCommandL( EAutoTestAll );
       
   147         }
       
   148     else
       
   149         {
       
   150         iAppView->Reset();
       
   151         RArray<CBCTestApplication*>* aList = iRunner->Apps();
       
   152 
       
   153         for( TInt i=0; i<cmdData->Count(); i++)
       
   154             {
       
   155 
       
   156             for( TInt j=0; j<( *aList ).Count(); j++ )
       
   157                 {
       
   158                 if( ( *cmdData )[i] == ( *aList )[j]->Name()  )
       
   159                     {
       
   160                     ( *aList )[j]->Select();
       
   161                     }
       
   162                 }
       
   163             }
       
   164          iRunner->RunL( EAutoTestSelection );
       
   165          }
       
   166     CleanupStack::PopAndDestroy( msg );
       
   167     CleanupStack::PopAndDestroy( cmdData ); 
       
   168     CleanupStack::PopAndDestroy( args );
       
   169 
       
   170     iAppView->HandleCommandL( EAknCmdExit );//auto exit
       
   171 
       
   172     }