contextframework/cfw/tsrc/public/basic/UT_CFActivatorEngine/UT_CFActivatorEngine.cpp
changeset 0 2e3d3ce01487
child 28 b0b858956ed5
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 /*
       
     2 * Copyright (c) 2006 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 //  CLASS HEADER
       
    20 #include "UT_CFActivatorEngine.h"
       
    21 
       
    22 //  EXTERNAL INCLUDES
       
    23 #include <EUnitMacros.h>
       
    24 #include <e32property.h>
       
    25 
       
    26 
       
    27 //  INTERNAL INCLUDES
       
    28 #include "CFActionCacheElement.h"
       
    29 #include "CFActionPlugin.h"
       
    30 #include "CFActionPlugInImpl.h"
       
    31 #include "CFActivator.h"
       
    32 #include "CFActivatorEngineActionPluginManager.h"
       
    33 #include "CFActivatorTimedSchedulerWait.h"
       
    34 #include "TestActionPlugIn.h"
       
    35 #include "cfactionindicationimpl.h"
       
    36 #include "cfactionsubscriptionimpl.h"
       
    37 #include "cfscriptevent.h"
       
    38 #include "cfenvutils.h"
       
    39 #include "TestActionPluginConst.hrh"
       
    40 #include "cfactionpluginthread.h"
       
    41 
       
    42 // CONSTANTS
       
    43 
       
    44 const TInt KOneSecond = 1000000;
       
    45 const TInt KThreeSeconds = 3 * KOneSecond;
       
    46 const TInt KFiveSeconds = 5 * KOneSecond;
       
    47 const TInt KActionExecutionDelay = KFiveSeconds; // 5 second
       
    48 const TInt KTeardownDelay = KOneSecond; // 1 second
       
    49 const TInt KPluginLoadWaitDelay = KThreeSeconds; // 3 second
       
    50 
       
    51 _LIT( KFalseIdentifier, "false" );
       
    52 _LIT( KTestActionIdTestAc3, "AC3" );
       
    53 _LIT( KTestActionIdLeave, "AC_Leave" );
       
    54 // Security policy
       
    55 _LIT_SECURITY_POLICY_PASS( KSecurity );
       
    56 
       
    57 // LOCAL FUNCTIONS
       
    58 
       
    59 /**
       
    60 * Clenup operation for RImplInfoPtrArray
       
    61 */
       
    62 LOCAL_C void CleanUpImplInfoArray( TAny* aParams )
       
    63     {
       
    64     RImplInfoPtrArray* array = static_cast<RImplInfoPtrArray*>( aParams );
       
    65     array->ResetAndDestroy();
       
    66     }
       
    67 
       
    68 /**
       
    69 * Push operation for RImplInfoPtrArray
       
    70 */
       
    71 LOCAL_C void CleanupPushImplInfoArrayL( RImplInfoPtrArray& aArray )
       
    72     {
       
    73     TCleanupItem item( CleanUpImplInfoArray, &aArray );
       
    74     CleanupStack::PushL( item );
       
    75     }
       
    76 
       
    77 // CONSTRUCTION
       
    78 UT_CFActivatorEngine* UT_CFActivatorEngine::NewL()
       
    79     {
       
    80     UT_CFActivatorEngine* self = UT_CFActivatorEngine::NewLC();
       
    81     CleanupStack::Pop();
       
    82 
       
    83     return self;
       
    84     }
       
    85 
       
    86 UT_CFActivatorEngine* UT_CFActivatorEngine::NewLC()
       
    87     {
       
    88     UT_CFActivatorEngine* self = new( ELeave ) UT_CFActivatorEngine();
       
    89     CleanupStack::PushL( self );
       
    90 
       
    91     self->ConstructL();
       
    92 
       
    93     return self;
       
    94     }
       
    95 
       
    96 // Destructor (virtual by CBase)
       
    97 UT_CFActivatorEngine::~UT_CFActivatorEngine()
       
    98     {
       
    99     Teardown();
       
   100 
       
   101     // Enable screen saver again
       
   102     CFEnvUtils::EnableScreenSaver( ETrue );
       
   103     }
       
   104 
       
   105 // Default constructor
       
   106 UT_CFActivatorEngine::UT_CFActivatorEngine()
       
   107     {
       
   108     }
       
   109 
       
   110 // Second phase construct
       
   111 void UT_CFActivatorEngine::ConstructL()
       
   112     {
       
   113     // The ConstructL from the base class CEUnitTestSuiteClass must be called.
       
   114     // It generates the test case table.
       
   115     CEUnitTestSuiteClass::ConstructL();    
       
   116 
       
   117     // Disable screen saver since it is causing false memory leaks
       
   118     CFEnvUtils::EnableScreenSaver( EFalse );
       
   119     }
       
   120 
       
   121 // METHODS
       
   122 
       
   123 void UT_CFActivatorEngine::ActionIndicationL( CCFActionIndication* aIndication )
       
   124     {
       
   125     delete aIndication;
       
   126     }
       
   127 
       
   128 MCFActionOwner::TCFActionOwner UT_CFActivatorEngine::ActionOwner() const
       
   129     {
       
   130     return MCFActionOwner::ECFExternalAction;
       
   131     }
       
   132 
       
   133 TInt UT_CFActivatorEngine::CallBack( TAny* aSelf )
       
   134     {
       
   135     UT_CFActivatorEngine* self = static_cast<UT_CFActivatorEngine*>( aSelf );
       
   136     self->iPeriodic->Cancel();
       
   137     if( self->iWait->IsStarted() )
       
   138         {
       
   139         self->iWait->AsyncStop();
       
   140         }
       
   141     return KErrNone;
       
   142     }
       
   143 
       
   144 void UT_CFActivatorEngine::Wait( TTimeIntervalMicroSeconds32& aDelay )
       
   145     {
       
   146     if( iPeriodic )
       
   147         {
       
   148         if( !iPeriodic->IsActive() )
       
   149             {
       
   150             TCallBack cb( CallBack, this );
       
   151             iPeriodic->Start( aDelay, aDelay, cb );
       
   152             iWait->Start();
       
   153             }
       
   154         }
       
   155 
       
   156     if( iTimedWait )
       
   157         {
       
   158         iTimedWait->Stop();
       
   159         }
       
   160     }
       
   161 
       
   162 void UT_CFActivatorEngine::SetupEmptyL(  )
       
   163     {
       
   164     }
       
   165 
       
   166 void UT_CFActivatorEngine::SetupL(  )
       
   167     {
       
   168     TInt err = RProperty::Define( KActionPluginTestCategory,
       
   169         KLeaveInitializationFunction,
       
   170         RProperty::EInt,
       
   171         KSecurity,
       
   172         KSecurity );
       
   173     EUNIT_PRINT( _L("Define P&S key KActionPluginTestCategory, KLeaveInitializationFunction: err = %d" ), err );
       
   174     
       
   175     iActionPluginManager = CCFActivatorEngineActionPluginManager::NewL(
       
   176         iActionCache );
       
   177     iPeriodic = CPeriodic::NewL( CActive::EPriorityStandard );
       
   178     iWait = new( ELeave ) CActiveSchedulerWait;
       
   179     iOwnerUid = RThread().SecureId();
       
   180     }
       
   181 
       
   182 void UT_CFActivatorEngine::Teardown(  )
       
   183     {
       
   184     iActionCache.ResetAndDestroy();
       
   185 
       
   186     delete iActionPluginManager;
       
   187     iActionPluginManager = NULL;
       
   188 
       
   189     delete iTimedWait;
       
   190     iTimedWait = NULL;
       
   191 
       
   192     delete iPeriodic;
       
   193     iPeriodic = NULL;
       
   194 
       
   195     if( iWait )
       
   196         {
       
   197         if( iWait->IsStarted() )
       
   198             {
       
   199             iWait->AsyncStop();
       
   200             }
       
   201         delete iWait;
       
   202         iWait = NULL;
       
   203         }
       
   204     // If key exist, it has to be assigned to value false.
       
   205     // Doesn't matter if call fails because key doesn't exist.
       
   206     RProperty::Set( KActionPluginTestCategory, KLeaveInitializationFunction, EFalse );
       
   207     }
       
   208 
       
   209 void UT_CFActivatorEngine::TeardownDelayed(  )
       
   210     {
       
   211     iActionCache.ResetAndDestroy();
       
   212 
       
   213     delete iActionPluginManager;
       
   214     iActionPluginManager = NULL;
       
   215 
       
   216     delete iTimedWait;
       
   217     iTimedWait = NULL;
       
   218 
       
   219     // Wait here until the thread has fully been closed
       
   220     TTimeIntervalMicroSeconds32 interval( KTeardownDelay * 2 );
       
   221     Wait( interval );
       
   222 
       
   223     delete iPeriodic;
       
   224     iPeriodic = NULL;
       
   225 
       
   226     if( iWait )
       
   227         {
       
   228         if( iWait->IsStarted() )
       
   229             {
       
   230             iWait->AsyncStop();
       
   231             }
       
   232         delete iWait;
       
   233         iWait = NULL;
       
   234         }
       
   235     // If key exist, it has to be assigned to value false.
       
   236     // Doesn't matter if call fails because key doesn't exist.
       
   237     RProperty::Set( KActionPluginTestCategory, KLeaveInitializationFunction, EFalse );
       
   238     }
       
   239 
       
   240 //-----------------------------------------------------------------------------
       
   241 // UT_CFActivatorEngine::UT_CCFActionCacheElement_NewLL
       
   242 //-----------------------------------------------------------------------------
       
   243 //
       
   244 void UT_CFActivatorEngine::UT_CCFActionCacheElement_NewLL(  )
       
   245     {
       
   246     _LIT( KActionId, "ActionId" );
       
   247     _LIT_SECURITY_POLICY_PASS( KSecurity );
       
   248 
       
   249     CCFActionCacheElement* instance =
       
   250         CCFActionCacheElement::NewL( KActionId, KSecurity, iOwnerUid, this );
       
   251     CleanupStack::PushL( instance );
       
   252 
       
   253     EUNIT_ASSERT_DESC( instance, "CCFActionCacheElement instance not created!" );
       
   254 
       
   255     CleanupStack::PopAndDestroy( instance );
       
   256     }
       
   257 
       
   258 //-----------------------------------------------------------------------------
       
   259 // UT_CFActivatorEngine::UT_CCFActionCacheElement_NewLCL
       
   260 //-----------------------------------------------------------------------------
       
   261 //
       
   262 void UT_CFActivatorEngine::UT_CCFActionCacheElement_NewLCL(  )
       
   263     {
       
   264     _LIT( KActionId, "ActionId" );
       
   265     _LIT_SECURITY_POLICY_PASS( KSecurity );
       
   266 
       
   267     CCFActionCacheElement* instance =
       
   268         CCFActionCacheElement::NewLC( KActionId, KSecurity, iOwnerUid, this );
       
   269 
       
   270     EUNIT_ASSERT_DESC( instance, "CCFActionCacheElement instance not created!" );
       
   271 
       
   272     CleanupStack::PopAndDestroy( instance );
       
   273     }
       
   274 
       
   275 //-----------------------------------------------------------------------------
       
   276 // UT_CFActivatorEngine::UT_CCFActionCacheElement_CompareByIdentifierL
       
   277 //-----------------------------------------------------------------------------
       
   278 //
       
   279 void UT_CFActivatorEngine::UT_CCFActionCacheElement_CompareByIdentifierL(  )
       
   280     {
       
   281     _LIT( KCorrectId, "ActionId" );
       
   282     _LIT( KFalseId1, "False1" );
       
   283     _LIT( KFalseId2, "False2" );
       
   284     _LIT_SECURITY_POLICY_PASS( KSecurity );
       
   285     TBool pass = EFalse;
       
   286     CCFActionCacheElement* actionCache =
       
   287         CCFActionCacheElement::NewLC( KCorrectId, KSecurity, iOwnerUid, this );
       
   288 
       
   289     // These should not pass
       
   290     pass = actionCache->CompareByIdentifier( KFalseId1 );
       
   291     EUNIT_ASSERT_DESC( !pass, "Invalid return value!" );
       
   292     pass = actionCache->CompareByIdentifier( KFalseId2 );
       
   293     EUNIT_ASSERT_DESC( !pass, "Invalid return value!" );
       
   294 
       
   295     // This should pass
       
   296     pass = actionCache->CompareByIdentifier( KCorrectId );
       
   297     EUNIT_ASSERT_DESC( pass, "Invalid return value!" );
       
   298 
       
   299     // Cleanup
       
   300     CleanupStack::PopAndDestroy( actionCache );
       
   301     }
       
   302 
       
   303 //-----------------------------------------------------------------------------
       
   304 // UT_CFActivatorEngine::UT_CCFActionCacheElement_AddSubscriptionLL
       
   305 //-----------------------------------------------------------------------------
       
   306 //
       
   307 void UT_CFActivatorEngine::UT_CCFActionCacheElement_AddSubscriptionLL(  )
       
   308     {
       
   309     TInt count = 0;
       
   310     _LIT( KCorrectId, "ActionId" );
       
   311     _LIT_SECURITY_POLICY_PASS( KSecurity );
       
   312     CCFActionCacheElement* actionCache =
       
   313         CCFActionCacheElement::NewLC( KCorrectId, KSecurity, iOwnerUid, this );
       
   314 
       
   315     // Test empty
       
   316     count = actionCache->Subscriptions().Count();
       
   317     EUNIT_ASSERT_DESC( !count, "Invalid subscription count!" );
       
   318 
       
   319     // Add subscription
       
   320     CCFActionSubscriptionImpl* subscription =
       
   321         static_cast<CCFActionSubscriptionImpl*>( CCFActionSubscription::NewLC() );
       
   322     subscription->SetActionIdentifierL( KCorrectId );
       
   323     subscription->SetListener( this );
       
   324     actionCache->AddSubscriptionL( subscription );
       
   325     CleanupStack::Pop( subscription );
       
   326     count = actionCache->Subscriptions().Count();
       
   327     EUNIT_ASSERT_DESC( count == 1, "Invalid subscription count!" );
       
   328     EUNIT_ASSERT_DESC( subscription == actionCache->Subscriptions()[0], "Invalid subscriber!" )
       
   329 
       
   330     // Cleanup
       
   331     CleanupStack::PopAndDestroy( actionCache );
       
   332     }
       
   333 
       
   334 //-----------------------------------------------------------------------------
       
   335 // UT_CFActivatorEngine::UT_CCFActionCacheElement_SecurityPolicyL
       
   336 //-----------------------------------------------------------------------------
       
   337 //
       
   338 void UT_CFActivatorEngine::UT_CCFActionCacheElement_SecurityPolicyL(  )
       
   339     {
       
   340     _LIT( KCorrectId, "ActionId" );
       
   341     _LIT_SECURITY_POLICY_FAIL( KSecurity );
       
   342     CCFActionCacheElement* actionCache =
       
   343         CCFActionCacheElement::NewLC( KCorrectId, KSecurity, iOwnerUid, this );
       
   344 
       
   345     // Test security against EUnit thread, should fail
       
   346     RThread thread;
       
   347     TBool check = actionCache->SecurityPolicy().CheckPolicy( thread );
       
   348     EUNIT_ASSERT_DESC( !check, "Invalid security policy!" );
       
   349     thread.Close();
       
   350 
       
   351     // Cleanup
       
   352     CleanupStack::PopAndDestroy( actionCache );
       
   353     }
       
   354 
       
   355 //-----------------------------------------------------------------------------
       
   356 // UT_CFActivatorEngine::UT_CCFActionCacheElement_RemoveSubscriptionL
       
   357 //-----------------------------------------------------------------------------
       
   358 //
       
   359 void UT_CFActivatorEngine::UT_CCFActionCacheElement_RemoveSubscriptionL(  )
       
   360     {
       
   361     TInt count = 0;
       
   362     _LIT( KCorrectId, "ActionId" );
       
   363     _LIT_SECURITY_POLICY_PASS( KSecurity );
       
   364     CCFActionCacheElement* actionCache =
       
   365         CCFActionCacheElement::NewLC( KCorrectId, KSecurity, iOwnerUid, this );
       
   366     CCFActionSubscriptionImpl* subscription =
       
   367         static_cast<CCFActionSubscriptionImpl*>( CCFActionSubscription::NewLC() );
       
   368     subscription->SetActionIdentifierL( KCorrectId );
       
   369     subscription->SetListener( this );
       
   370     actionCache->AddSubscriptionL( subscription );
       
   371     CleanupStack::Pop( subscription );
       
   372 
       
   373     // Test
       
   374     subscription = static_cast<CCFActionSubscriptionImpl*>( CCFActionSubscription::NewLC() );
       
   375     subscription->SetActionIdentifierL( KCorrectId );
       
   376     subscription->SetListener( this );
       
   377     count = actionCache->Subscriptions().Count();
       
   378     actionCache->RemoveSubscription( *subscription );
       
   379     EUNIT_ASSERT_DESC( count == actionCache->Subscriptions().Count() + 1,
       
   380         "Invalid subscription count!" );
       
   381 
       
   382     // Cleanup
       
   383     CleanupStack::PopAndDestroy( subscription );
       
   384     CleanupStack::PopAndDestroy( actionCache );
       
   385     }
       
   386 
       
   387 //-----------------------------------------------------------------------------
       
   388 // UT_CFActivatorEngine::UT_CCFActionPlugInImpl_NewLL
       
   389 //-----------------------------------------------------------------------------
       
   390 //
       
   391 void UT_CFActivatorEngine::UT_CCFActionPlugInImpl_NewLL(  )
       
   392     {
       
   393     CCFActionPlugInImpl* obj = CCFActionPlugInImpl::NewL( NULL, NULL );
       
   394     CleanupStack::PushL( obj );
       
   395 
       
   396     EUNIT_ASSERT_DESC( obj, "CCFActionPlugInImpl instance not created!" );
       
   397 
       
   398     CleanupStack::PopAndDestroy( obj );
       
   399     }
       
   400 
       
   401 //-----------------------------------------------------------------------------
       
   402 // UT_CFActivatorEngine::UT_CCFActionPlugInImpl_NewLCL
       
   403 //-----------------------------------------------------------------------------
       
   404 //
       
   405 void UT_CFActivatorEngine::UT_CCFActionPlugInImpl_NewLCL(  )
       
   406     {
       
   407     CCFActionPlugInImpl* obj = CCFActionPlugInImpl::NewLC( NULL, NULL );
       
   408 
       
   409     EUNIT_ASSERT_DESC( obj, "CCFActionPlugInImpl instance not created!" );
       
   410 
       
   411     CleanupStack::PopAndDestroy( obj );
       
   412     }
       
   413 
       
   414 //-----------------------------------------------------------------------------
       
   415 // UT_CFActivatorEngine::UT_CCFActivator_NewLL
       
   416 //-----------------------------------------------------------------------------
       
   417 //
       
   418 void UT_CFActivatorEngine::UT_CCFActivator_NewLL(  )
       
   419     {
       
   420     CCFActivator* instance = CCFActivator::NewL();
       
   421     CleanupStack::PushL( instance );
       
   422 
       
   423     EUNIT_ASSERT_DESC( instance, "CCFActivator instance not created!" );
       
   424 
       
   425     CleanupStack::PopAndDestroy( instance );
       
   426     }
       
   427 
       
   428 //-----------------------------------------------------------------------------
       
   429 // UT_CFActivatorEngine::UT_CCFActivatorEngineActionPluginManager_NewLL
       
   430 //-----------------------------------------------------------------------------
       
   431 //
       
   432 void UT_CFActivatorEngine::UT_CCFActivatorEngineActionPluginManager_NewLL(  )
       
   433     {
       
   434     CCFActivatorEngineActionPluginManager* obj =
       
   435         CCFActivatorEngineActionPluginManager::NewL( iActionCache );
       
   436     CleanupStack::PushL( obj );
       
   437 
       
   438     EUNIT_ASSERT_DESC( obj, "CCFActivatorEngineActionPluginManager instance not created!" );
       
   439 
       
   440     CleanupStack::PopAndDestroy( obj );
       
   441     }
       
   442 
       
   443 //-----------------------------------------------------------------------------
       
   444 // UT_CFActivatorEngine::UT_CCFActivatorEngineActionPluginManager_NewLCL
       
   445 //-----------------------------------------------------------------------------
       
   446 //
       
   447 void UT_CFActivatorEngine::UT_CCFActivatorEngineActionPluginManager_NewLCL(  )
       
   448     {
       
   449     CCFActivatorEngineActionPluginManager* obj =
       
   450         CCFActivatorEngineActionPluginManager::NewLC( iActionCache );
       
   451 
       
   452     EUNIT_ASSERT_DESC( obj, "CCFActivatorEngineActionPluginManager instance not created!" );
       
   453 
       
   454     CleanupStack::PopAndDestroy( obj );
       
   455     }
       
   456 
       
   457 
       
   458 //-----------------------------------------------------------------------------
       
   459 // UT_CFActivatorEngine::PluginThreadCreationFailureL
       
   460 //-----------------------------------------------------------------------------
       
   461 //
       
   462 void UT_CFActivatorEngine::PluginThreadCreationFailureL()
       
   463     {
       
   464     RImplInfoPtrArray implInfoArray;
       
   465     CleanupPushImplInfoArrayL( implInfoArray );
       
   466     REComSession::ListImplementationsL( KActionPluginUid, implInfoArray );
       
   467 
       
   468     CImplementationInformation* impInfo( NULL );
       
   469     for( TInt ii = 0; ii < implInfoArray.Count(); ii++ )
       
   470         {
       
   471         impInfo = implInfoArray[ii];
       
   472         if( impInfo->ImplementationUid() == TUid::Uid( KTestActionPluginImplementationUid ) )
       
   473             {
       
   474             // Implementation info found
       
   475             break;
       
   476             }
       
   477         impInfo = NULL;
       
   478         }
       
   479     EUNIT_ASSERT_DESC( impInfo, "KTestActionPluginImplementationUid not found!" );
       
   480 
       
   481     TInt err = RProperty::Set( KActionPluginTestCategory, KLeaveInitializationFunction, ETrue );
       
   482     EUNIT_ASSERT_DESC( KErrNone == err, "Setting KActionPluginTestCategory, KLeaveInitializationFunction, ETrue failed!" );
       
   483 
       
   484     CCFActivatorEngineActionPluginManager* obj =
       
   485         CCFActivatorEngineActionPluginManager::NewLC( iActionCache );
       
   486     EUNIT_ASSERT_DESC( obj, "Creating CCFActivatorEngineActionPluginManager object failed!" );
       
   487 
       
   488     CCFActionPlugInThread* plugInThread = NULL;
       
   489     TRAP( err, plugInThread = CCFActionPlugInThread::NewL( *obj, *impInfo ) );
       
   490     EUNIT_ASSERT( err == KErrAbort );
       
   491     EUNIT_ASSERT( !plugInThread );
       
   492     
       
   493     CleanupStack::PopAndDestroy( obj );
       
   494     CleanupStack::PopAndDestroy( &implInfoArray );
       
   495     }
       
   496 
       
   497 //-----------------------------------------------------------------------------
       
   498 // UT_CFActivatorEngine::UT_CCFActivatorEngineActionPluginManager_TriggerLL
       
   499 //-----------------------------------------------------------------------------
       
   500 //
       
   501 void UT_CFActivatorEngine::UT_CCFActivatorEngineActionPluginManager_TriggerLL(  )
       
   502     {
       
   503     // Initialize
       
   504     iActionPluginManager->InitializePhaseL( CCFPhaseBase::ECFDeviceStarting );
       
   505     // Wait here to complete plug-in loading
       
   506     TTimeIntervalMicroSeconds32 interval( KPluginLoadWaitDelay );
       
   507     Wait( interval );
       
   508 
       
   509     iActionPluginManager->InitializePhaseL( CCFPhaseBase::ECFDeviceStarted );
       
   510     Wait( interval );
       
   511     iActionPluginManager->InitializePhaseL( CCFPhaseBase::ECFLoadingPlugins );
       
   512     Wait( interval );
       
   513 
       
   514     // Trigger some actions
       
   515     CCFActionIndicationImpl* action = NULL;
       
   516     CCFActionIndicationImpl* action2 = NULL;
       
   517     TBool executed = EFalse;
       
   518     TBool executed2 = EFalse;
       
   519 
       
   520     // False actions
       
   521     action = static_cast<CCFActionIndicationImpl*>( CCFActionIndication::NewLC() );
       
   522     action->SetIdentifierL( KFalseIdentifier );
       
   523     executed = iActionPluginManager->TriggerL( action );
       
   524     EUNIT_ASSERT_DESC( !executed, "Incorrect action executed!" );
       
   525     CleanupStack::PopAndDestroy( action );
       
   526 
       
   527     // True actions
       
   528     action = static_cast<CCFActionIndicationImpl*>( CCFActionIndication::NewLC() );
       
   529     action->SetIdentifierL( KTestActionIdTestAc3 );
       
   530     action2 = static_cast<CCFActionIndicationImpl*>( CCFActionIndication::NewLC() );
       
   531     action2->SetIdentifierL( KTestActionIdTestAc3 );
       
   532     executed = iActionPluginManager->TriggerL( action );
       
   533     executed2 = iActionPluginManager->TriggerL( action2 );
       
   534     EUNIT_ASSERT_DESC( executed, "Action not executed!" );
       
   535     EUNIT_ASSERT_DESC( executed2, "Action not executed!" );
       
   536     CleanupStack::Pop( action2 );
       
   537     CleanupStack::Pop( action );
       
   538 
       
   539     // Wait here to complete actions
       
   540     interval = KActionExecutionDelay;
       
   541     Wait( interval );
       
   542 
       
   543     // Leave action and try correct ones after the leave
       
   544     executed = EFalse;
       
   545     executed2 = EFalse;
       
   546 
       
   547     action = static_cast<CCFActionIndicationImpl*>( CCFActionIndication::NewLC() );
       
   548     action->SetIdentifierL( KTestActionIdLeave );
       
   549     executed = iActionPluginManager->TriggerL( action );
       
   550     EUNIT_ASSERT_DESC( executed, "Incorrect action executed!" );
       
   551     CleanupStack::Pop( action );
       
   552 
       
   553     action = static_cast<CCFActionIndicationImpl*>( CCFActionIndication::NewLC() );
       
   554     action->SetIdentifierL( KTestActionIdTestAc3 );
       
   555     action2 = static_cast<CCFActionIndicationImpl*>( CCFActionIndication::NewLC() );
       
   556     action2->SetIdentifierL( KTestActionIdTestAc3 );
       
   557     executed = iActionPluginManager->TriggerL( action );
       
   558     executed2 = iActionPluginManager->TriggerL( action2 );
       
   559     EUNIT_ASSERT_DESC( executed, "Action not executed!" );
       
   560     EUNIT_ASSERT_DESC( executed2, "Action not executed!" );
       
   561     CleanupStack::Pop( action2 );
       
   562     CleanupStack::Pop( action );
       
   563 
       
   564     // Wait here to complete actions
       
   565     interval = KActionExecutionDelay;
       
   566     Wait( interval );
       
   567     }
       
   568 
       
   569 //-----------------------------------------------------------------------------
       
   570 // UT_CFActivatorEngine::UT_CCFActivatorEngineActionPluginManager_InitializePhaseLL
       
   571 //-----------------------------------------------------------------------------
       
   572 //
       
   573 void UT_CFActivatorEngine::UT_CCFActivatorEngineActionPluginManager_InitializePhaseLL(  )
       
   574     {
       
   575     TTimeIntervalMicroSeconds32 interval( KPluginLoadWaitDelay );
       
   576 
       
   577     iActionPluginManager->InitializePhaseL( CCFPhaseBase::ECFDeviceStarting );
       
   578     Wait( interval );
       
   579 
       
   580     iActionPluginManager->InitializePhaseL( CCFPhaseBase::ECFDeviceStarted );
       
   581     Wait( interval );
       
   582 
       
   583     iActionPluginManager->InitializePhaseL( CCFPhaseBase::ECFLoadingPlugins );
       
   584     Wait( interval );
       
   585 
       
   586     delete iActionPluginManager;
       
   587     iActionPluginManager = NULL;
       
   588     iActionPluginManager = CCFActivatorEngineActionPluginManager::NewL( iActionCache );
       
   589 
       
   590     RProperty::Set( KActionPluginTestCategory, KLeaveInitializationFunction, ETrue );
       
   591 
       
   592     // One action plugin leaves
       
   593     iActionPluginManager->InitializePhaseL( CCFPhaseBase::ECFDeviceStarting );
       
   594     Wait( interval );
       
   595 
       
   596     iActionPluginManager->InitializePhaseL( CCFPhaseBase::ECFDeviceStarted );
       
   597     Wait( interval );
       
   598 
       
   599     iActionPluginManager->InitializePhaseL( CCFPhaseBase::ECFLoadingPlugins );
       
   600     Wait( interval );
       
   601     }
       
   602 
       
   603 //-----------------------------------------------------------------------------
       
   604 // UT_CFActivatorEngine::UT_CCFActivatorTimedSchedulerWait_NewLL
       
   605 //-----------------------------------------------------------------------------
       
   606 //
       
   607 void UT_CFActivatorEngine::UT_CCFActivatorTimedSchedulerWait_NewLL(  )
       
   608     {
       
   609     CCFActivatorTimedSchedulerWait* instance = CCFActivatorTimedSchedulerWait::NewL();
       
   610     CleanupStack::PushL( instance );
       
   611 
       
   612     EUNIT_ASSERT_DESC( instance, "CCFActivatorTimedSchedulerWait instance not created!" );
       
   613 
       
   614     CleanupStack::PopAndDestroy( instance );
       
   615     }
       
   616 
       
   617 //-----------------------------------------------------------------------------
       
   618 // UT_CFActivatorEngine::UT_CCFActivatorTimedSchedulerWait_NewLCL
       
   619 //-----------------------------------------------------------------------------
       
   620 //
       
   621 void UT_CFActivatorEngine::UT_CCFActivatorTimedSchedulerWait_NewLCL(  )
       
   622     {
       
   623     CCFActivatorTimedSchedulerWait* instance = CCFActivatorTimedSchedulerWait::NewLC();
       
   624 
       
   625     EUNIT_ASSERT_DESC( instance, "CCFActivatorTimedSchedulerWait instance not created!" );
       
   626 
       
   627     CleanupStack::PopAndDestroy( instance );
       
   628     }
       
   629 
       
   630 //-----------------------------------------------------------------------------
       
   631 // UT_CFActivatorEngine::UT_CCFActivatorTimedSchedulerWait_StartL
       
   632 //-----------------------------------------------------------------------------
       
   633 //
       
   634 void UT_CFActivatorEngine::UT_CCFActivatorTimedSchedulerWait_StartL(  )
       
   635     {
       
   636     iTimedWait = CCFActivatorTimedSchedulerWait::NewL();
       
   637 
       
   638     // Start wait. It should timeout and continue after 1sec
       
   639     iTimedWait->Start( 1000000 );
       
   640     }
       
   641 
       
   642 //-----------------------------------------------------------------------------
       
   643 // UT_CFActivatorEngine::
       
   644 //-----------------------------------------------------------------------------
       
   645 //
       
   646 void UT_CFActivatorEngine::UT_CCFActivatorTimedSchedulerWait_StopL(  )
       
   647     {
       
   648     iTimedWait = CCFActivatorTimedSchedulerWait::NewL();
       
   649 
       
   650     // Start wait for 5sec
       
   651     TTimeIntervalMicroSeconds32 interval( KFiveSeconds );
       
   652     iTimedWait->Start( interval );
       
   653     interval = KOneSecond;
       
   654     Wait( interval );
       
   655     }
       
   656 
       
   657 //  TEST TABLE
       
   658 
       
   659 EUNIT_BEGIN_TEST_TABLE(
       
   660     UT_CFActivatorEngine,
       
   661     "CFActivatorEngine unit test",
       
   662     "UNIT" )
       
   663 
       
   664 EUNIT_TEST(
       
   665     "NewL - test ",
       
   666     "CCFActionCacheElement",
       
   667     "NewL",
       
   668     "FUNCTIONALITY",
       
   669     SetupEmptyL, UT_CCFActionCacheElement_NewLL, Teardown)
       
   670 
       
   671 EUNIT_TEST(
       
   672     "NewLC - test ",
       
   673     "CCFActionCacheElement",
       
   674     "NewLC",
       
   675     "FUNCTIONALITY",
       
   676     SetupEmptyL, UT_CCFActionCacheElement_NewLCL, Teardown)
       
   677 
       
   678 EUNIT_TEST(
       
   679     "CompareByIdentifier - test ",
       
   680     "CCFActionCacheElement",
       
   681     "CompareByIdentifier",
       
   682     "FUNCTIONALITY",
       
   683     SetupL, UT_CCFActionCacheElement_CompareByIdentifierL, Teardown)
       
   684 
       
   685 EUNIT_TEST(
       
   686     "AddSubscriptionL - test ",
       
   687     "CCFActionCacheElement",
       
   688     "AddSubscriptionL",
       
   689     "FUNCTIONALITY",
       
   690     SetupL, UT_CCFActionCacheElement_AddSubscriptionLL, Teardown)
       
   691 
       
   692 EUNIT_TEST(
       
   693     "SecurityPolicy - test ",
       
   694     "CCFActionCacheElement",
       
   695     "SecurityPolicy",
       
   696     "FUNCTIONALITY",
       
   697     SetupL, UT_CCFActionCacheElement_SecurityPolicyL, Teardown)
       
   698 
       
   699 EUNIT_TEST(
       
   700     "RemoveSubscription - test ",
       
   701     "CCFActionCacheElement",
       
   702     "RemoveSubscription",
       
   703     "FUNCTIONALITY",
       
   704     SetupL, UT_CCFActionCacheElement_RemoveSubscriptionL, Teardown)
       
   705 
       
   706 EUNIT_TEST(
       
   707     "NewL - test ",
       
   708     "CCFActionPlugInImpl",
       
   709     "NewL",
       
   710     "FUNCTIONALITY",
       
   711     SetupEmptyL, UT_CCFActionPlugInImpl_NewLL, Teardown)
       
   712 
       
   713 EUNIT_TEST(
       
   714     "NewLC - test ",
       
   715     "CCFActionPlugInImpl",
       
   716     "NewLC",
       
   717     "FUNCTIONALITY",
       
   718     SetupEmptyL, UT_CCFActionPlugInImpl_NewLCL, Teardown)
       
   719 
       
   720 EUNIT_TEST(
       
   721     "NewL - test ",
       
   722     "CCFActivator",
       
   723     "NewL",
       
   724     "FUNCTIONALITY",
       
   725     SetupL, UT_CCFActivator_NewLL, TeardownDelayed)
       
   726 
       
   727 EUNIT_TEST(
       
   728     "NewL - test ",
       
   729     "CCFActivatorEngineActionPluginManager",
       
   730     "NewL",
       
   731     "FUNCTIONALITY",
       
   732     SetupEmptyL, UT_CCFActivatorEngineActionPluginManager_NewLL, Teardown)
       
   733 
       
   734 EUNIT_TEST(
       
   735     "NewLC - test ",
       
   736     "CCFActivatorEngineActionPluginManager",
       
   737     "NewLC",
       
   738     "FUNCTIONALITY",
       
   739     SetupEmptyL, UT_CCFActivatorEngineActionPluginManager_NewLCL, Teardown)
       
   740 
       
   741 EUNIT_TEST(
       
   742     "TriggerL - test ",
       
   743     "CCFActivatorEngineActionPluginManager",
       
   744     "TriggerL",
       
   745     "FUNCTIONALITY",
       
   746     SetupL, UT_CCFActivatorEngineActionPluginManager_TriggerLL, TeardownDelayed)
       
   747 
       
   748 EUNIT_TEST(
       
   749     "InitializePhaseL - test ",
       
   750     "CCFActivatorEngineActionPluginManager",
       
   751     "InitializePhaseL",
       
   752     "FUNCTIONALITY",
       
   753     SetupL, UT_CCFActivatorEngineActionPluginManager_InitializePhaseLL, TeardownDelayed)
       
   754 
       
   755 EUNIT_TEST(
       
   756     "NewL - test ",
       
   757     "CCFActivatorTimedSchedulerWait",
       
   758     "NewL",
       
   759     "FUNCTIONALITY",
       
   760     SetupEmptyL, UT_CCFActivatorTimedSchedulerWait_NewLL, Teardown)
       
   761 
       
   762 EUNIT_TEST(
       
   763     "NewLC - test ",
       
   764     "CCFActivatorTimedSchedulerWait",
       
   765     "NewLC",
       
   766     "FUNCTIONALITY",
       
   767     SetupEmptyL, UT_CCFActivatorTimedSchedulerWait_NewLCL, Teardown)
       
   768 
       
   769 EUNIT_TEST(
       
   770     "Start - test ",
       
   771     "CCFActivatorTimedSchedulerWait",
       
   772     "Start",
       
   773     "FUNCTIONALITY",
       
   774     SetupL, UT_CCFActivatorTimedSchedulerWait_StartL, Teardown)
       
   775 
       
   776 EUNIT_TEST(
       
   777     "Stop - test ",
       
   778     "CCFActivatorTimedSchedulerWait",
       
   779     "Stop",
       
   780     "FUNCTIONALITY",
       
   781     SetupL, UT_CCFActivatorTimedSchedulerWait_StopL, Teardown)
       
   782 
       
   783 EUNIT_TEST(
       
   784     "CCFActionPlugInThread::NewL - test ",
       
   785     "CCFActionPlugInThread::NewL",
       
   786     "NewL",
       
   787     "FUNCTIONALITY",
       
   788     SetupL, PluginThreadCreationFailureL, TeardownDelayed)
       
   789     
       
   790 EUNIT_END_TEST_TABLE
       
   791 
       
   792 //  END OF FILE