1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/featuremgmt/featuremgr/test/shared/src/efm_teststepbase.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,165 @@
1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Base class for capability aware test steps and a auxilarry test step to publish
1.18 +// features needed by other test steps
1.19 +//
1.20 +//
1.21 +
1.22 +/**
1.23 + @file
1.24 + @internalComponent
1.25 + @test
1.26 +*/
1.27 +
1.28 +#include "efm_teststepbase.h"
1.29 +#include <featmgr/featurecontrol.h>
1.30 +#include <featdiscovery.h>
1.31 +
1.32 +CEFMTestStepPublishFeatures::CEFMTestStepPublishFeatures()
1.33 + {
1.34 + SetTestStepName(KEFMTestStepPublishFeatures);
1.35 + }
1.36 +
1.37 +TVerdict CEFMTestStepPublishFeatures::doTestStepL()
1.38 +{
1.39 + RFeatureControl control;
1.40 + TInt err = control.Open();
1.41 + TESTDIAGNOSTICERROR(err==KErrNone,
1.42 + _L("Failed to open RFeatureControl connection during initial feature publishing: error = %d"),err);
1.43 + CleanupClosePushL( control );
1.44 +
1.45 + // Make sure feature which is not supported exists
1.46 + TInt supported = control.FeatureSupported( KDefaultUnsupportedUid );
1.47 + if( supported != KFeatureUnsupported && supported != KFeatureSupported )
1.48 + {
1.49 + TBitFlags32 flags( 0 );
1.50 + flags.Set( EFeatureModifiable );
1.51 + flags.Set( EFeaturePersisted );
1.52 + TFeatureEntry entry( KDefaultUnsupportedUid, flags, KDefaultData1 );
1.53 + err = control.AddFeature( entry );
1.54 + TESTDIAGNOSTICERROR(err==KErrNone,
1.55 + _L("Failed to add feature during initial feature publishing: error = %d"),err);
1.56 + }
1.57 + else
1.58 + {
1.59 + err = control.SetFeature( KDefaultUnsupportedUid, EFalse, KDefaultData1 );
1.60 + TESTDIAGNOSTICERROR(err==KErrNone,
1.61 + _L("Failed to set feature data during initial feature publishing: error = %d"),err);
1.62 + }
1.63 +
1.64 + // Make sure feature which is supported exists
1.65 + supported = control.FeatureSupported( KDefaultSupportedUid );
1.66 + if( supported != KFeatureUnsupported && supported != KFeatureSupported )
1.67 + {
1.68 + TBitFlags32 flags( 0 );
1.69 + flags.Set( EFeatureSupported );
1.70 + flags.Set( EFeatureModifiable );
1.71 + flags.Set( EFeaturePersisted );
1.72 + TFeatureEntry entry( KDefaultSupportedUid, flags, KDefaultData1 );
1.73 + err = control.AddFeature( entry );
1.74 + TESTDIAGNOSTICERROR(err==KErrNone,
1.75 + _L("Failed to add feature during initial feature publishing: error = %d"),err);
1.76 + }
1.77 + else
1.78 + {
1.79 + err = control.SetFeature( KDefaultSupportedUid, ETrue, KDefaultData1 );
1.80 + TESTDIAGNOSTICERROR(err==KErrNone,
1.81 + _L("Failed to set feature data during initial feature publishing: error = %d"),err);
1.82 + }
1.83 +
1.84 + // Make sure feature which is modifiable exists
1.85 + supported = control.FeatureSupported( KModifiableUid );
1.86 + if( supported != KFeatureUnsupported && supported != KFeatureSupported )
1.87 + {
1.88 + TBitFlags32 flags( 0 );
1.89 + flags.Set( EFeatureSupported );
1.90 + flags.Set( EFeatureModifiable );
1.91 + flags.Set( EFeaturePersisted );
1.92 + TFeatureEntry entry( KModifiableUid, flags, KDefaultData1 );
1.93 + err = control.AddFeature( entry );
1.94 + TESTDIAGNOSTICERROR(err==KErrNone,
1.95 + _L("Failed to add feature during initial feature publishing: error = %d"),err);
1.96 + }
1.97 + else
1.98 + {
1.99 + err = control.SetFeature( KModifiableUid, ETrue, KDefaultData1 );
1.100 + TESTDIAGNOSTICERROR(err==KErrNone,
1.101 + _L("Failed to set feature data during initial feature publishing: error = %d"),err);
1.102 + }
1.103 +
1.104 + // Make sure feature which is unmodifiable exists
1.105 + supported = control.FeatureSupported( KUnmodifiableUid );
1.106 + if( supported != KFeatureUnsupported && supported != KFeatureSupported )
1.107 + {
1.108 + TBitFlags32 flags( 0 );
1.109 + flags.Set( EFeatureSupported );
1.110 + TFeatureEntry entry( KUnmodifiableUid, flags, KDefaultData1 );
1.111 + err = control.AddFeature( entry );
1.112 + TESTE(err==KErrNone,err);
1.113 + }
1.114 +
1.115 + // Make sure uninitialized feature exists
1.116 + supported = control.FeatureSupported( KUninitializedUid );
1.117 + if( supported != KFeatureUnsupported && supported != KFeatureSupported
1.118 + && supported != KErrNotReady )
1.119 + {
1.120 + TBitFlags32 flags( 0 );
1.121 + flags.Set( EFeatureUninitialized );
1.122 + flags.Set( EFeatureModifiable);
1.123 + TFeatureEntry entry( KUninitializedUid, flags, KDefaultData1 );
1.124 + err = control.AddFeature( entry );
1.125 + TESTDIAGNOSTICERROR(err==KErrNone,
1.126 + _L("Failed to add feature during initial feature publishing: error = %d"),err);
1.127 + }
1.128 +
1.129 + //Make sure that persisted feature exists
1.130 +
1.131 + supported = control.FeatureSupported(KPersistedUid);
1.132 + if(supported != KFeatureUnsupported && supported != KFeatureSupported)
1.133 + {
1.134 + TBitFlags32 flags( 0 );
1.135 + //flags.Set( EFeatureSupported );
1.136 + flags.Set( EFeaturePersisted );
1.137 + TFeatureEntry entry( KPersistedUid, flags, KDefaultData1 );
1.138 + err = control.AddFeature( entry );
1.139 + TESTDIAGNOSTICERROR(err==KErrNone,
1.140 + _L("Failed to add feature during initial feature publishing: error = %d"),err);
1.141 + }
1.142 +
1.143 +
1.144 + CleanupStack::PopAndDestroy( &control );
1.145 +
1.146 + return TestStepResult();
1.147 +}
1.148 +
1.149 +TVerdict CEFMConfigurableTestStepBase::doTestStepPreambleL()
1.150 +{
1.151 + //read wether this test step is a OOM test
1.152 + GetBoolFromConfig(ConfigSection(), KTestOOM, iOOM);
1.153 +
1.154 + //read wether this test step is a Low-capability test
1.155 + GetBoolFromConfig(ConfigSection(), KTestLowCap, iLowCap);
1.156 +
1.157 + return TestStepResult();
1.158 +}
1.159 +
1.160 +void CEFMConfigurableTestStepBase::CheckCondition(TBool aMainCondition, TBool aOOMCondition, TPtrC aLoggingMessage, TInt aErrorCode)
1.161 +{
1.162 + TBool cond = iOOM?aMainCondition||aOOMCondition:aMainCondition;
1.163 + if (!cond)
1.164 + {
1.165 + ERR_PRINTF2( aLoggingMessage, aErrorCode );
1.166 + SetTestStepResult(EFail);
1.167 + }
1.168 +}