idlefw/tsrc/wsplugin/ut_aiwspluginanim/inc/ut_aiwspluginanimtls.h
branchRCL_3
changeset 111 053c6c7c14f3
equal deleted inserted replaced
110:2c7f27287390 111:053c6c7c14f3
       
     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:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef _UT_AIWSPLUGINANIMTLS_H
       
    20 #define _UT_AIWSPLUGINANIMTLS_H
       
    21 
       
    22 // System includes 
       
    23 #include <e32base.h>
       
    24 #include <e32hashtab.h>
       
    25 
       
    26 // User incldues
       
    27 #include "testeventhandler_stub.h"
       
    28 
       
    29 // Forward declarations
       
    30 
       
    31 /**
       
    32  * TLS shared test data holder for CAiWsPluginAnim unit tests.
       
    33  */
       
    34 NONSHARABLE_CLASS( UT_AiWsPluginAnimTls )
       
    35 	: public CBase
       
    36     {
       
    37 public:
       
    38     static void CreateL();
       
    39     static UT_AiWsPluginAnimTls* Instance();
       
    40     static void Destroy();
       
    41 
       
    42 private:
       
    43     UT_AiWsPluginAnimTls();
       
    44     void ConstructL();
       
    45     ~UT_AiWsPluginAnimTls();
       
    46 
       
    47 public:    // New methods
       
    48     template<class EventHandler_t>
       
    49     EventHandler_t* FindEventHandler() const;
       
    50     
       
    51     void AddEventHandlerL( T_AiWsPlugin::CTestEventHandler& aHandler );
       
    52     TArray<T_AiWsPlugin::CTestEventHandler*> EventHandlers() const;
       
    53     
       
    54     void  IncFeatMgrCount();
       
    55     void  DecFeatMgrCount();
       
    56     TInt  FeatMgrCount() const;
       
    57     TBool FeatureSupported( TInt aFeatureId ) const;
       
    58     void  SetFeatureSupportedL( TInt aFeatureId, TBool aValue );
       
    59 
       
    60 private:    // Data
       
    61     RPointerArray<T_AiWsPlugin::CTestEventHandler> iEventHandlers;
       
    62     TInt iFeatMgrCount;
       
    63     RHashMap< TInt, TBool > iFeatures;
       
    64     };
       
    65 
       
    66 
       
    67 template<class EventHandler_t>
       
    68 EventHandler_t* UT_AiWsPluginAnimTls::FindEventHandler() const
       
    69     {
       
    70     EventHandler_t* result = NULL;
       
    71     const TInt count = iEventHandlers.Count();
       
    72     for( TInt i = 0; i < count && !result; ++i )
       
    73         {
       
    74         T_AiWsPlugin::CTestEventHandler* handler = iEventHandlers[i];
       
    75         result = dynamic_cast<EventHandler_t*>( handler );
       
    76         }
       
    77     return result;
       
    78     }
       
    79 
       
    80 #endif  //  _UT_AIWSPLUGINANIMTLS_H
       
    81