sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Implementation of the base class for capability aware test steps. sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent sl@0: @test sl@0: */ sl@0: sl@0: #include "efm_featurenotifierstepbase.h" sl@0: sl@0: static TInt WaitCallBack( TAny* aSelf ) sl@0: { sl@0: if( aSelf ) sl@0: { sl@0: TWaitInfo* info = static_cast( aSelf ); sl@0: if( info->iPeriodic ) sl@0: { sl@0: info->iPeriodic->Cancel(); sl@0: } sl@0: if( info->iWait ) sl@0: { sl@0: if( info->iWait->IsStarted() ) sl@0: { sl@0: info->iWait->AsyncStop(); sl@0: } sl@0: } sl@0: } sl@0: sl@0: return KErrNone; sl@0: } sl@0: sl@0: sl@0: void CFeatureNotifierStepBase::WaitL( TInt aIntervalInMicorseconds ) sl@0: { sl@0: TWaitInfo info; sl@0: sl@0: // Construct periodic sl@0: CPeriodic* periodic = CPeriodic::NewL( CActive::EPriorityStandard ); sl@0: CleanupStack::PushL( periodic ); sl@0: info.iPeriodic = periodic; sl@0: sl@0: // Construct active scheduler wait sl@0: CActiveSchedulerWait* wait = new( ELeave ) CActiveSchedulerWait; sl@0: CleanupStack::PushL( wait ); sl@0: info.iWait = wait; sl@0: iWait = wait; sl@0: sl@0: // Start timer and wait sl@0: TCallBack cb( WaitCallBack, &info ); sl@0: periodic->Start( aIntervalInMicorseconds, aIntervalInMicorseconds, cb ); sl@0: wait->Start(); sl@0: sl@0: // Cleanup sl@0: CleanupStack::PopAndDestroy( wait ); sl@0: CleanupStack::PopAndDestroy( periodic ); sl@0: } sl@0: sl@0: sl@0: TVerdict CFeatureNotifierStepBase::doTestStepPreambleL(void) sl@0: { sl@0: CEFMConfigurableTestStepBase::doTestStepPreambleL(); sl@0: iSched= new(ELeave) CActiveScheduler; sl@0: CActiveScheduler::Install(iSched); sl@0: TInt err = icontrol.Open(); sl@0: TESTDIAGNOSTICERROR(err==KErrNone, sl@0: _L("RFeatureControl::Open failed: error = %d"), err); sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TVerdict CFeatureNotifierStepBase::doTestStepPostambleL(void) sl@0: { sl@0: CEFMConfigurableTestStepBase::doTestStepPostambleL(); sl@0: CActiveScheduler::Install(NULL); sl@0: delete iSched; sl@0: icontrol.Close(); sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: void CFeatureNotifierStepBase :: HandleNotifyChange( TFeatureChangeType /* aType */ , TFeatureEntry /* aFeature */ ) sl@0: { sl@0: iWait->AsyncStop(); sl@0: iNotifyCompleted = ETrue; sl@0: } sl@0: sl@0: void CFeatureNotifierStepBase:: HandleNotifyError( TInt aError ) sl@0: { sl@0: INFO_PRINTF2(_L("CFeatureNotifier::HandleNotifyError %d"),aError); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: sl@0: void CFeatureNotifierStepBase::CheckNotifyRequestResultL(TUid aUid) sl@0: { sl@0: TInt err = icontrol.SetFeature( aUid, KChangeData ); sl@0: WaitL(KWaitDelay); sl@0: if (iLowCap) sl@0: { sl@0: //if we are running in the low capabilities environment we don't expect the feature sl@0: //to be modified and notification to be issued sl@0: TESTDIAGNOSTICERROR(err == KErrPermissionDenied, sl@0: _L("RFeatureControl::SetFeature - KErrPermissionDenied expected; error = %d"),err); sl@0: TESTDIAGNOSTIC(!iNotifyCompleted, sl@0: _L("Feature notification should not be issued due to insufficient capabilities")); sl@0: } sl@0: else sl@0: { sl@0: //if test environment has WDD capability then SetFeature should succeed and feature sl@0: //change notification should be issued sl@0: TESTDIAGNOSTICERROR(err == KErrNone, sl@0: _L("RFeatureControl::SetFeature - KErrNone expected; error = %d"),err); sl@0: TESTDIAGNOSTIC(iNotifyCompleted, sl@0: _L("Feature notification is expected to be issued")); sl@0: } sl@0: } sl@0: sl@0: void CFeatureNotifierStepBase::CheckNotifyCancelResultL(TUid aUid) sl@0: { sl@0: TInt err = icontrol.SetFeature( aUid, KChangeData ); sl@0: WaitL(KWaitDelay); sl@0: if (iLowCap) sl@0: { sl@0: //if we are running in the low capabilities environment we don't expect the feature sl@0: //to be modified and notification to be issued sl@0: TESTDIAGNOSTICERROR(err == KErrPermissionDenied, sl@0: _L("RFeatureControl::SetFeature - KErrPermissionDenied expected; error = %d"),err); sl@0: TESTDIAGNOSTIC(!iNotifyCompleted, sl@0: _L("Feature notification should not be issued due to insufficient capabilities")); sl@0: } sl@0: else sl@0: { sl@0: //if test environment has WDD capability then SetFeature should succeed and feature sl@0: //change notification should be issued sl@0: TESTDIAGNOSTICERROR(err == KErrNone, sl@0: _L("RFeatureControl::SetFeature - KErrNone expected; error = %d"),err); sl@0: TESTDIAGNOSTIC(!iNotifyCompleted, sl@0: _L("Feature notification should not be issued as the natification has been cancelled")); sl@0: } sl@0: } sl@0: sl@0: void CFeatureNotifierStepBase::CheckDeleteNotificationResultL(TUid aUid) sl@0: { sl@0: TInt err = icontrol.DeleteFeature(aUid); sl@0: sl@0: if (iLowCap) sl@0: { sl@0: //if we are running in the low capabilities environment we don't expect the feature sl@0: //to be modified and notification to be issued sl@0: TESTDIAGNOSTICERROR(err == KErrPermissionDenied, sl@0: _L("RFeatureControl::DeleteFeature - KErrPermissionDenied expected; error = %d"),err); sl@0: } sl@0: else sl@0: { sl@0: TESTDIAGNOSTICERROR(err == KErrNone, sl@0: _L("RFeatureControl::DeleteFeature - KErrNone or KErrAlreadyExists expected; error = %d"),err); sl@0: } sl@0: sl@0: WaitL(KWaitDelay); sl@0: sl@0: if (iLowCap) sl@0: { sl@0: sl@0: TESTDIAGNOSTIC(!iNotifyCompleted, sl@0: _L("Feature notification should not be issued due to insufficient capabilities")); sl@0: } sl@0: sl@0: else sl@0: { sl@0: TESTDIAGNOSTIC(iNotifyCompleted, sl@0: _L("Feature notification is expected to be issued")); sl@0: sl@0: } sl@0: } sl@0: sl@0: sl@0: