photosgallery/slideshow/engine/tsrc/stubs/stub_mshweffect.h
changeset 0 4e91876724a2
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     1 /*
       
     2 * Copyright (c) 2007-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:    Test stub for MShwEffect
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include "shweffect.h"
       
    22 
       
    23 // -----------------------------------------------------------------------------
       
    24 // Stub for MShwEffect -->
       
    25 // -----------------------------------------------------------------------------
       
    26 class T_MShwTestEffect : public MShwEffect
       
    27     {
       
    28     public:
       
    29         T_MShwTestEffect( TInt aIndex );
       
    30         ~T_MShwTestEffect();
       
    31 
       
    32     public: // from MShwEffect
       
    33 
       
    34         MShwEffect* CloneLC();
       
    35         void InitializeL( 
       
    36             CAlfEnv* aAlfEnv, MGlxVisualList* aVisualList,
       
    37             MGlxMediaList* aMediaList, TSize aScreenSize );
       
    38         TSize PrepareViewL( CAlfVisual* aVisual, TSize aSize );
       
    39         MGlxLayout* EnterViewL( CAlfVisual* aVisual, TInt aDuration, TInt aDuration2 );
       
    40         void ExitView( CAlfVisual* aVisual );
       
    41         MGlxLayout* EnterTransitionL( CAlfVisual* aVisual, TInt aDuration );
       
    42         void ExitTransition( CAlfVisual* aVisual );
       
    43         void PauseL();
       
    44         void Resume();
       
    45         TShwEffectInfo EffectInfo();
       
    46 
       
    47     public:
       
    48         TInt iIndex;
       
    49         enum TState 
       
    50             {
       
    51             EConstruct, 
       
    52             EPrepareView,
       
    53             EEnterView,
       
    54             EExitView,
       
    55             EEnterTransition,
       
    56             EExitTransition
       
    57             } iState;	// state flag to assert prptocol
       
    58         CAlfVisual* iVisual;	// to track the visual
       
    59     };
       
    60 
       
    61 T_MShwTestEffect::T_MShwTestEffect( TInt aIndex )
       
    62     : iIndex( aIndex ), iState( EConstruct ), iVisual( NULL )
       
    63     {
       
    64     }
       
    65 T_MShwTestEffect::~T_MShwTestEffect()
       
    66     {
       
    67     }
       
    68 MShwEffect* T_MShwTestEffect::CloneLC()
       
    69     {
       
    70     T_MShwTestEffect* effect = new( ELeave ) T_MShwTestEffect( iIndex );
       
    71     CleanupStack::PushL( effect );
       
    72     return effect;
       
    73     }
       
    74 
       
    75 void T_MShwTestEffect::InitializeL( 
       
    76     CAlfEnv* /*aAlfEnv*/, MGlxVisualList* /*aVisualList*/,
       
    77     MGlxMediaList* /*aMediaList*/, TSize /*aScreenSize*/ )
       
    78     {
       
    79     }
       
    80 // this flag defines if the test expects the effects to be called completely
       
    81 // like Prepare -> Enter view -> Enter trans -> Prepare
       
    82 // if set to EFalse, then also Prepare -> Enter view -> Exit View -> Prepare
       
    83 // is allowed
       
    84 TBool gStrictEffectOrder = ETrue;
       
    85 TSize T_MShwTestEffect::PrepareViewL( CAlfVisual* aVisual, TSize aSize )
       
    86     {
       
    87     if( gStrictEffectOrder )
       
    88         {
       
    89         EUNIT_ASSERT_DESC( 
       
    90             EConstruct == iState || EExitTransition == iState,
       
    91             "state needs to be construct or exit transition" );
       
    92         }
       
    93     iState = EPrepareView;	// set state
       
    94     EUNIT_PRINT( _L("effect %d; PrepareViewL visual=%d"), iIndex, (TInt)aVisual );
       
    95     // remember the visual
       
    96     iVisual = aVisual;
       
    97     // return the given size
       
    98     return aSize;
       
    99     }
       
   100 
       
   101 MGlxLayout* T_MShwTestEffect::EnterViewL( 
       
   102     CAlfVisual* aVisual, TInt /*aDuration*/, TInt /*aDuration2*/ )
       
   103     {
       
   104     if( gStrictEffectOrder )
       
   105         {
       
   106         EUNIT_ASSERT_DESC( EPrepareView == iState, "state needs to be prepareview" );
       
   107         }
       
   108     else
       
   109         {
       
   110         EUNIT_ASSERT_DESC( 
       
   111             EPrepareView == iState ||
       
   112             EEnterView == iState, "state needs to be prepare or enterview" );
       
   113         }
       
   114     iState = EEnterView;	// set state
       
   115     EUNIT_PRINT( _L("effect %d; EnterViewL visual=%d"), iIndex, (TInt)aVisual );
       
   116     EUNIT_ASSERT_DESC( aVisual == iVisual, "Visual should be same as for PrepareViewL" );
       
   117     return NULL;
       
   118     }
       
   119 
       
   120 void T_MShwTestEffect::ExitView( CAlfVisual* aVisual )
       
   121     {
       
   122     EUNIT_ASSERT_DESC( EEnterView == iState, "state needs to be enterview" );
       
   123     iState = EExitView;	// set state
       
   124     EUNIT_PRINT( _L("effect %d; ExitView visual=%d"), iIndex, (TInt)aVisual );
       
   125     EUNIT_ASSERT_DESC( aVisual == iVisual, "Visual should be same as for PrepareViewL" );
       
   126     }
       
   127 
       
   128 MGlxLayout* T_MShwTestEffect::EnterTransitionL( CAlfVisual* aVisual, TInt /*aDuration*/ )
       
   129     {
       
   130     EUNIT_ASSERT_DESC( EExitView == iState, "state needs to be exitview" );
       
   131     iState = EEnterTransition;	// set state
       
   132     EUNIT_PRINT( _L("effect %d; EnterTransitionL visual=%d"), iIndex, (TInt)aVisual );
       
   133     EUNIT_ASSERT_DESC( aVisual == iVisual, "Visual should be same as for PrepareViewL" );
       
   134     return NULL;
       
   135     }
       
   136 
       
   137 void T_MShwTestEffect::ExitTransition( CAlfVisual* aVisual )
       
   138     {
       
   139     EUNIT_ASSERT_DESC( EEnterTransition == iState, "state needs to be entertransition" );
       
   140     iState = EExitTransition;	// set state
       
   141     EUNIT_PRINT( _L("effect %d; ExitTransition visual=%d"), iIndex, (TInt)aVisual );
       
   142     EUNIT_ASSERT_DESC( aVisual == iVisual, "Visual should be same as for PrepareViewL" );
       
   143     }
       
   144 
       
   145 void T_MShwTestEffect::PauseL()
       
   146     {
       
   147     }
       
   148 
       
   149 void T_MShwTestEffect::Resume()
       
   150     {
       
   151     }
       
   152 
       
   153 _LIT( KTestEffectName, "EffectName" );
       
   154 TShwEffectInfo T_MShwTestEffect::EffectInfo()
       
   155     {
       
   156     TShwEffectInfo info;
       
   157     info.iName = KTestEffectName;
       
   158     info.iId.iIndex = iIndex;
       
   159     return info;
       
   160     }