widgetmanager/tsrc/wmunittest/src/wmunittest_plugin.cpp
changeset 0 f72a12da539e
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     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: test blocks for CWmPlugin
       
    15 *
       
    16 */
       
    17 
       
    18 //INCLUDE FILES
       
    19 #include <e32svr.h>
       
    20 #include <stdlib.h>
       
    21 #include <stifparser.h>
       
    22 #include <stiftestinterface.h>
       
    23 #include <bautils.h>
       
    24 #include <aknsskininstance.h>
       
    25 #include "wmunittest.h"
       
    26 // components to test
       
    27 #include "wmplugin.h"
       
    28 #include <hscontentinfo.h>
       
    29 #include <hscontentinfoarray.h>
       
    30 
       
    31 // MACROS
       
    32 #define _LOG(a) iLog->Log(_L(a))
       
    33 #define _RETURN(a, b) iLog->Log(_L("\treturn: %d"),b); \
       
    34                      iLog->Log(_L(a)); \
       
    35                      return b; \
       
    36 
       
    37 #define _CLEANUPCHECK_BEGIN \
       
    38     CBase* __check = new (ELeave) CBase(); \
       
    39     CleanupStack::PushL( __check );
       
    40 
       
    41 #define _CLEANUPCHECK_END \
       
    42     CleanupStack::PopAndDestroy( __check );
       
    43 
       
    44 // ============================ MEMBER FUNCTIONS ===============================
       
    45 
       
    46 
       
    47 // -----------------------------------------------------------------------------
       
    48 // CWmUnitTest::PluginCreateL
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 TInt CWmUnitTest::PluginCreateL( CStifItemParser& /*aItem*/ )
       
    52     {
       
    53     if ( iWmPlugin != 0 ) User::Leave( KErrArgument );
       
    54     TInt ret = KErrNone;
       
    55     _CLEANUPCHECK_BEGIN
       
    56     iWmPlugin = CWmPlugin::NewL();
       
    57     iWmPlugin->SetContentController( this );
       
    58     _CLEANUPCHECK_END
       
    59     _RETURN("PluginCreateL End", ret);
       
    60     }
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 // CWmUnitTest::PluginDeleteL
       
    64 // -----------------------------------------------------------------------------
       
    65 //
       
    66 TInt CWmUnitTest::PluginDeleteL( CStifItemParser& /*aItem*/ )
       
    67     {
       
    68     if ( iWmPlugin == 0 ) User::Leave( KErrArgument );
       
    69     TInt ret = KErrNone;
       
    70     delete iWmPlugin;
       
    71     iWmPlugin = 0;
       
    72     _RETURN("PluginDeleteL End", ret);
       
    73     }
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // CWmUnitTest::PluginActivateL
       
    77 // -----------------------------------------------------------------------------
       
    78 //
       
    79 TInt CWmUnitTest::PluginActivateL( CStifItemParser& /*aItem*/ )
       
    80     {
       
    81     if ( iWmPlugin == 0 ) User::Leave( KErrArgument );
       
    82     iWmPlugin->Activate();
       
    83     _RETURN("PluginActivateL End", KErrNone);
       
    84     }
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // CWmUnitTest::PluginDeactivateL
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 TInt CWmUnitTest::PluginDeactivateL( CStifItemParser& /*aItem*/ )
       
    91     {
       
    92     if ( iWmPlugin == 0 ) User::Leave( KErrArgument );
       
    93     iWmPlugin->Deactivate();
       
    94     _RETURN("PluginActivateL End", KErrNone);
       
    95     }
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // CWmUnitTest::PluginWidgetsChangedL
       
    99 // -----------------------------------------------------------------------------
       
   100 //
       
   101 TInt CWmUnitTest::PluginWidgetsChangedL( CStifItemParser& /*aItem*/ )
       
   102     {
       
   103     if ( iWmPlugin == 0 ) User::Leave( KErrArgument );
       
   104     iWmPlugin->NotifyWidgetListChanged();
       
   105     _RETURN("PluginWidgetsChangedL End", KErrNone);
       
   106     }
       
   107 
       
   108 // =============================================================================
       
   109 // Methods from MHsContentController
       
   110 // =============================================================================
       
   111 
       
   112 TInt CWmUnitTest::WidgetListL( CHsContentInfoArray& aArray )
       
   113     {
       
   114     CreateContentInfoArrayL( aArray, iMass );
       
   115     return KErrNone;
       
   116     }
       
   117 
       
   118 TInt CWmUnitTest::ViewListL( CHsContentInfoArray& /*aArray*/ )
       
   119     {
       
   120     return KErrNone;
       
   121     }
       
   122 
       
   123 TInt CWmUnitTest::AppListL( CHsContentInfoArray& /*aArray*/ )
       
   124     {
       
   125     return KErrNone;
       
   126     }
       
   127 
       
   128 TInt CWmUnitTest::AddWidgetL( CHsContentInfo& /*aInfo*/ )
       
   129     {
       
   130     return KErrNone;
       
   131     }
       
   132 
       
   133 TInt CWmUnitTest::RemoveWidgetL( CHsContentInfo& /*aInfo*/ )
       
   134     {
       
   135     return KErrNone;
       
   136     }
       
   137 
       
   138 TInt CWmUnitTest::AddViewL( CHsContentInfo& /*aInfo*/ )
       
   139     {
       
   140     return KErrNone;
       
   141     }
       
   142 
       
   143 TInt CWmUnitTest::RemoveViewL( CHsContentInfo& /*aInfo*/ )
       
   144     {
       
   145     return KErrNone;
       
   146     }
       
   147 
       
   148 TInt CWmUnitTest::ActivateViewL( CHsContentInfo& /*aInfo*/ )
       
   149     {
       
   150     return KErrNone;
       
   151     }
       
   152 
       
   153 TInt CWmUnitTest::ActivateAppL( CHsContentInfo& /*aInfo*/ )
       
   154     {
       
   155     return KErrNone;
       
   156     }
       
   157 
       
   158 
       
   159 
       
   160 
       
   161 // -----------------------------------------------------------------------------
       
   162 // CWmUnitTest::CreateContentInfoArrayL
       
   163 // -----------------------------------------------------------------------------
       
   164 //
       
   165 void CWmUnitTest::CreateContentInfoArrayL( CHsContentInfoArray& aArray, TInt aCount )
       
   166     {
       
   167     for( TInt i=0; i<aCount; ++i )
       
   168         {
       
   169         CHsContentInfo* info = CHsContentInfo::NewLC();
       
   170         TBuf<64> name;
       
   171         name.Format( _L("Widget_%d"), i );
       
   172         info->SetNameL( name );
       
   173         TBuf8<20> id;
       
   174         id.Num( i );
       
   175         info->SetUidL( id );
       
   176         info->SetTypeL( _L8("template") );
       
   177         info->SetIconPathL( _L("uid(0x2000DAD2)") );
       
   178         info->SetCanBeAdded( ETrue );
       
   179         info->SetDescriptionL(_L("Default plaa plaa plaa plaa plaa plaa plaa"));
       
   180         
       
   181         aArray.Array().AppendL( info );
       
   182         CleanupStack::Pop( info );
       
   183         }
       
   184     }
       
   185 
       
   186 // End of File