Update contrib.
1 // Copyright (c) 2007-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 // Base class for capability aware test steps and a auxilarry test step to publish
15 // features needed by other test steps
25 #include "efm_teststepbase.h"
26 #include <featmgr/featurecontrol.h>
27 #include <featdiscovery.h>
29 CEFMTestStepPublishFeatures::CEFMTestStepPublishFeatures()
31 SetTestStepName(KEFMTestStepPublishFeatures);
34 TVerdict CEFMTestStepPublishFeatures::doTestStepL()
36 RFeatureControl control;
37 TInt err = control.Open();
38 TESTDIAGNOSTICERROR(err==KErrNone,
39 _L("Failed to open RFeatureControl connection during initial feature publishing: error = %d"),err);
40 CleanupClosePushL( control );
42 // Make sure feature which is not supported exists
43 TInt supported = control.FeatureSupported( KDefaultUnsupportedUid );
44 if( supported != KFeatureUnsupported && supported != KFeatureSupported )
46 TBitFlags32 flags( 0 );
47 flags.Set( EFeatureModifiable );
48 flags.Set( EFeaturePersisted );
49 TFeatureEntry entry( KDefaultUnsupportedUid, flags, KDefaultData1 );
50 err = control.AddFeature( entry );
51 TESTDIAGNOSTICERROR(err==KErrNone,
52 _L("Failed to add feature during initial feature publishing: error = %d"),err);
56 err = control.SetFeature( KDefaultUnsupportedUid, EFalse, KDefaultData1 );
57 TESTDIAGNOSTICERROR(err==KErrNone,
58 _L("Failed to set feature data during initial feature publishing: error = %d"),err);
61 // Make sure feature which is supported exists
62 supported = control.FeatureSupported( KDefaultSupportedUid );
63 if( supported != KFeatureUnsupported && supported != KFeatureSupported )
65 TBitFlags32 flags( 0 );
66 flags.Set( EFeatureSupported );
67 flags.Set( EFeatureModifiable );
68 flags.Set( EFeaturePersisted );
69 TFeatureEntry entry( KDefaultSupportedUid, flags, KDefaultData1 );
70 err = control.AddFeature( entry );
71 TESTDIAGNOSTICERROR(err==KErrNone,
72 _L("Failed to add feature during initial feature publishing: error = %d"),err);
76 err = control.SetFeature( KDefaultSupportedUid, ETrue, KDefaultData1 );
77 TESTDIAGNOSTICERROR(err==KErrNone,
78 _L("Failed to set feature data during initial feature publishing: error = %d"),err);
81 // Make sure feature which is modifiable exists
82 supported = control.FeatureSupported( KModifiableUid );
83 if( supported != KFeatureUnsupported && supported != KFeatureSupported )
85 TBitFlags32 flags( 0 );
86 flags.Set( EFeatureSupported );
87 flags.Set( EFeatureModifiable );
88 flags.Set( EFeaturePersisted );
89 TFeatureEntry entry( KModifiableUid, flags, KDefaultData1 );
90 err = control.AddFeature( entry );
91 TESTDIAGNOSTICERROR(err==KErrNone,
92 _L("Failed to add feature during initial feature publishing: error = %d"),err);
96 err = control.SetFeature( KModifiableUid, ETrue, KDefaultData1 );
97 TESTDIAGNOSTICERROR(err==KErrNone,
98 _L("Failed to set feature data during initial feature publishing: error = %d"),err);
101 // Make sure feature which is unmodifiable exists
102 supported = control.FeatureSupported( KUnmodifiableUid );
103 if( supported != KFeatureUnsupported && supported != KFeatureSupported )
105 TBitFlags32 flags( 0 );
106 flags.Set( EFeatureSupported );
107 TFeatureEntry entry( KUnmodifiableUid, flags, KDefaultData1 );
108 err = control.AddFeature( entry );
109 TESTE(err==KErrNone,err);
112 // Make sure uninitialized feature exists
113 supported = control.FeatureSupported( KUninitializedUid );
114 if( supported != KFeatureUnsupported && supported != KFeatureSupported
115 && supported != KErrNotReady )
117 TBitFlags32 flags( 0 );
118 flags.Set( EFeatureUninitialized );
119 flags.Set( EFeatureModifiable);
120 TFeatureEntry entry( KUninitializedUid, flags, KDefaultData1 );
121 err = control.AddFeature( entry );
122 TESTDIAGNOSTICERROR(err==KErrNone,
123 _L("Failed to add feature during initial feature publishing: error = %d"),err);
126 //Make sure that persisted feature exists
128 supported = control.FeatureSupported(KPersistedUid);
129 if(supported != KFeatureUnsupported && supported != KFeatureSupported)
131 TBitFlags32 flags( 0 );
132 //flags.Set( EFeatureSupported );
133 flags.Set( EFeaturePersisted );
134 TFeatureEntry entry( KPersistedUid, flags, KDefaultData1 );
135 err = control.AddFeature( entry );
136 TESTDIAGNOSTICERROR(err==KErrNone,
137 _L("Failed to add feature during initial feature publishing: error = %d"),err);
141 CleanupStack::PopAndDestroy( &control );
143 return TestStepResult();
146 TVerdict CEFMConfigurableTestStepBase::doTestStepPreambleL()
148 //read wether this test step is a OOM test
149 GetBoolFromConfig(ConfigSection(), KTestOOM, iOOM);
151 //read wether this test step is a Low-capability test
152 GetBoolFromConfig(ConfigSection(), KTestLowCap, iLowCap);
154 return TestStepResult();
157 void CEFMConfigurableTestStepBase::CheckCondition(TBool aMainCondition, TBool aOOMCondition, TPtrC aLoggingMessage, TInt aErrorCode)
159 TBool cond = iOOM?aMainCondition||aOOMCondition:aMainCondition;
162 ERR_PRINTF2( aLoggingMessage, aErrorCode );
163 SetTestStepResult(EFail);