uiacceltk/hitchcock/tsrc/alfperfapp/src/alfperfappframeworktestcase.cpp
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2008 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:  CAlfPerfAppFrameworkTestCase implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "alfperfappframeworktestcase.h"
       
    20 #include "alfperfapp.hrh"
       
    21 
       
    22 // ============================ MEMBER FUNCTIONS ===============================
       
    23 
       
    24 // -----------------------------------------------------------------------------
       
    25 // Checks if specified case is supported by this class.
       
    26 // -----------------------------------------------------------------------------
       
    27 //
       
    28 TBool CAlfPerfAppFrameworkTestCase::IsSupported( TInt aCaseId )
       
    29     {
       
    30     return aCaseId > EAlfPerfAppFrameworkMin && 
       
    31            aCaseId < EAlfPerfAppFrameworkMax;
       
    32     }
       
    33 
       
    34 CAlfPerfAppFrameworkTestCase* CAlfPerfAppFrameworkTestCase::NewL( TInt aCaseId, TInt aSequenceIndex)
       
    35     {
       
    36     if ( !IsSupported( aCaseId ) )
       
    37         {
       
    38         User::Leave( KErrNotSupported );
       
    39         }
       
    40 
       
    41     CAlfPerfAppFrameworkTestCase* self = 
       
    42         new (ELeave) CAlfPerfAppFrameworkTestCase( aCaseId, aSequenceIndex );
       
    43     CleanupStack::PushL( self );
       
    44     self->ConstructL();
       
    45     CleanupStack::Pop( self );
       
    46     return self;
       
    47     }
       
    48 
       
    49 CAlfPerfAppFrameworkTestCase::~CAlfPerfAppFrameworkTestCase()
       
    50     {
       
    51     }
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // Starts setup phase.
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 void CAlfPerfAppFrameworkTestCase::SetupL( 
       
    58         CAlfEnv& aEnv, const TRect& /*aVisibleArea*/, TRequestStatus& aStatus )
       
    59     {
       
    60     __ASSERT_ALWAYS( !iEnv, User::Invariant() );
       
    61     iEnv = &aEnv;
       
    62     
       
    63     TInt errorCode = KErrNone;
       
    64     switch ( iCaseId )
       
    65         {   
       
    66         case EAlfPerfAppFrameworkSetupFailSynch:
       
    67             User::Leave( KErrGeneral );
       
    68             break;
       
    69             
       
    70         case EAlfPerfAppFrameworkSetupFailAsynch:
       
    71             errorCode = KErrGeneral;
       
    72             break;
       
    73         
       
    74         case EAlfPerfAppFrameworkEmpty:
       
    75         case EAlfPerfAppFrameworkExecuteFailSynch:    
       
    76         case EAlfPerfAppFrameworkExecuteFailAsynch:
       
    77             break;
       
    78 
       
    79         case EAlfPerfAppFrameworkCreateFail:
       
    80         default:
       
    81             User::Invariant();
       
    82             break;
       
    83         }
       
    84         
       
    85     CAlfPerfAppTestCase::CompleteNow( aStatus, errorCode );
       
    86     }
       
    87 
       
    88 // -----------------------------------------------------------------------------
       
    89 // Starts execution phase.
       
    90 // -----------------------------------------------------------------------------
       
    91 //
       
    92 void CAlfPerfAppFrameworkTestCase::ExecuteL( TRequestStatus& aStatus )
       
    93     {
       
    94     __ASSERT_ALWAYS( iEnv, User::Invariant() );
       
    95     
       
    96     TInt errorCode = KErrNone;
       
    97     switch ( iCaseId )
       
    98         {
       
    99         case EAlfPerfAppFrameworkEmpty:
       
   100             break;
       
   101             
       
   102         case EAlfPerfAppFrameworkExecuteFailSynch:
       
   103             User::Leave( KErrGeneral );
       
   104             break;
       
   105             
       
   106         case EAlfPerfAppFrameworkExecuteFailAsynch:
       
   107             errorCode = KErrGeneral;
       
   108             break;
       
   109         
       
   110         case EAlfPerfAppFrameworkCreateFail:
       
   111         case EAlfPerfAppFrameworkSetupFailSynch:
       
   112         case EAlfPerfAppFrameworkSetupFailAsynch:
       
   113             // If setup fails, then ExecuteL must not be called.
       
   114         default:
       
   115             User::Invariant();
       
   116             break;            
       
   117         }
       
   118         
       
   119     CAlfPerfAppTestCase::CompleteNow( aStatus, errorCode );
       
   120     }
       
   121 
       
   122 // -----------------------------------------------------------------------------
       
   123 // Tears down.
       
   124 // -----------------------------------------------------------------------------
       
   125 //
       
   126 void CAlfPerfAppFrameworkTestCase::TearDown()
       
   127     {
       
   128     iEnv = NULL;
       
   129     }
       
   130 
       
   131 void CAlfPerfAppFrameworkTestCase::HandleVisibleAreaChange( 
       
   132         const TRect& /*aRect*/ )
       
   133     {
       
   134     }
       
   135 
       
   136 TInt CAlfPerfAppFrameworkTestCase::CaseID()
       
   137     {
       
   138     return iCaseId;
       
   139     }
       
   140 
       
   141 CAlfPerfAppFrameworkTestCase::CAlfPerfAppFrameworkTestCase( TInt aCaseId, TInt aSequenceIndex )
       
   142     : CAlfPerfAppTestCase(aSequenceIndex), iCaseId ( aCaseId )
       
   143     {
       
   144     }
       
   145 
       
   146 void CAlfPerfAppFrameworkTestCase::ConstructL()
       
   147     {
       
   148     switch ( iCaseId )
       
   149         {
       
   150         case EAlfPerfAppFrameworkCreateFail:
       
   151             User::Leave( KErrGeneral );
       
   152             break;
       
   153             
       
   154         default:
       
   155             // Simply continue with other cases.
       
   156             break;
       
   157         }
       
   158     }