os/persistentdata/featuremgmt/featuremgr/test/shared/src/efm_featurenotifierstepbase.cpp
Update contrib.
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Implementation of the base class for capability aware test steps.
24 #include "efm_featurenotifierstepbase.h"
26 static TInt WaitCallBack( TAny* aSelf )
30 TWaitInfo* info = static_cast<TWaitInfo*>( aSelf );
33 info->iPeriodic->Cancel();
37 if( info->iWait->IsStarted() )
39 info->iWait->AsyncStop();
48 void CFeatureNotifierStepBase::WaitL( TInt aIntervalInMicorseconds )
53 CPeriodic* periodic = CPeriodic::NewL( CActive::EPriorityStandard );
54 CleanupStack::PushL( periodic );
55 info.iPeriodic = periodic;
57 // Construct active scheduler wait
58 CActiveSchedulerWait* wait = new( ELeave ) CActiveSchedulerWait;
59 CleanupStack::PushL( wait );
63 // Start timer and wait
64 TCallBack cb( WaitCallBack, &info );
65 periodic->Start( aIntervalInMicorseconds, aIntervalInMicorseconds, cb );
69 CleanupStack::PopAndDestroy( wait );
70 CleanupStack::PopAndDestroy( periodic );
74 TVerdict CFeatureNotifierStepBase::doTestStepPreambleL(void)
76 CEFMConfigurableTestStepBase::doTestStepPreambleL();
77 iSched= new(ELeave) CActiveScheduler;
78 CActiveScheduler::Install(iSched);
79 TInt err = icontrol.Open();
80 TESTDIAGNOSTICERROR(err==KErrNone,
81 _L("RFeatureControl::Open failed: error = %d"), err);
82 return TestStepResult();
85 TVerdict CFeatureNotifierStepBase::doTestStepPostambleL(void)
87 CEFMConfigurableTestStepBase::doTestStepPostambleL();
88 CActiveScheduler::Install(NULL);
91 return TestStepResult();
95 void CFeatureNotifierStepBase :: HandleNotifyChange( TFeatureChangeType /* aType */ , TFeatureEntry /* aFeature */ )
98 iNotifyCompleted = ETrue;
101 void CFeatureNotifierStepBase:: HandleNotifyError( TInt aError )
103 INFO_PRINTF2(_L("CFeatureNotifier::HandleNotifyError %d"),aError);
104 SetTestStepResult(EFail);
108 void CFeatureNotifierStepBase::CheckNotifyRequestResultL(TUid aUid)
110 TInt err = icontrol.SetFeature( aUid, KChangeData );
114 //if we are running in the low capabilities environment we don't expect the feature
115 //to be modified and notification to be issued
116 TESTDIAGNOSTICERROR(err == KErrPermissionDenied,
117 _L("RFeatureControl::SetFeature - KErrPermissionDenied expected; error = %d"),err);
118 TESTDIAGNOSTIC(!iNotifyCompleted,
119 _L("Feature notification should not be issued due to insufficient capabilities"));
123 //if test environment has WDD capability then SetFeature should succeed and feature
124 //change notification should be issued
125 TESTDIAGNOSTICERROR(err == KErrNone,
126 _L("RFeatureControl::SetFeature - KErrNone expected; error = %d"),err);
127 TESTDIAGNOSTIC(iNotifyCompleted,
128 _L("Feature notification is expected to be issued"));
132 void CFeatureNotifierStepBase::CheckNotifyCancelResultL(TUid aUid)
134 TInt err = icontrol.SetFeature( aUid, KChangeData );
138 //if we are running in the low capabilities environment we don't expect the feature
139 //to be modified and notification to be issued
140 TESTDIAGNOSTICERROR(err == KErrPermissionDenied,
141 _L("RFeatureControl::SetFeature - KErrPermissionDenied expected; error = %d"),err);
142 TESTDIAGNOSTIC(!iNotifyCompleted,
143 _L("Feature notification should not be issued due to insufficient capabilities"));
147 //if test environment has WDD capability then SetFeature should succeed and feature
148 //change notification should be issued
149 TESTDIAGNOSTICERROR(err == KErrNone,
150 _L("RFeatureControl::SetFeature - KErrNone expected; error = %d"),err);
151 TESTDIAGNOSTIC(!iNotifyCompleted,
152 _L("Feature notification should not be issued as the natification has been cancelled"));
156 void CFeatureNotifierStepBase::CheckDeleteNotificationResultL(TUid aUid)
158 TInt err = icontrol.DeleteFeature(aUid);
162 //if we are running in the low capabilities environment we don't expect the feature
163 //to be modified and notification to be issued
164 TESTDIAGNOSTICERROR(err == KErrPermissionDenied,
165 _L("RFeatureControl::DeleteFeature - KErrPermissionDenied expected; error = %d"),err);
169 TESTDIAGNOSTICERROR(err == KErrNone,
170 _L("RFeatureControl::DeleteFeature - KErrNone or KErrAlreadyExists expected; error = %d"),err);
178 TESTDIAGNOSTIC(!iNotifyCompleted,
179 _L("Feature notification should not be issued due to insufficient capabilities"));
184 TESTDIAGNOSTIC(iNotifyCompleted,
185 _L("Feature notification is expected to be issued"));