featuremgmt/featuremgr/test/shared/src/efm_teststepbase.cpp
changeset 0 08ec8eefde2f
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Base class for capability aware test steps and a auxilarry test step to publish 
       
    15 // features needed by other test steps
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file
       
    21  @internalComponent
       
    22  @test
       
    23 */
       
    24 
       
    25 #include "efm_teststepbase.h"
       
    26 #include <featmgr/featurecontrol.h>
       
    27 #include <featdiscovery.h>
       
    28 
       
    29 CEFMTestStepPublishFeatures::CEFMTestStepPublishFeatures()
       
    30    {
       
    31    SetTestStepName(KEFMTestStepPublishFeatures);
       
    32    } 
       
    33 
       
    34 TVerdict CEFMTestStepPublishFeatures::doTestStepL()
       
    35 {
       
    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 );
       
    41     
       
    42     // Make sure feature which is not supported exists
       
    43     TInt supported = control.FeatureSupported( KDefaultUnsupportedUid );
       
    44     if( supported != KFeatureUnsupported && supported != KFeatureSupported )
       
    45         {
       
    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);
       
    53         }
       
    54     else
       
    55         {
       
    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);
       
    59         }
       
    60     
       
    61     // Make sure feature which is supported exists
       
    62     supported = control.FeatureSupported( KDefaultSupportedUid );
       
    63     if( supported != KFeatureUnsupported && supported != KFeatureSupported )
       
    64         {
       
    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);
       
    73         }
       
    74     else
       
    75         {
       
    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);
       
    79         }
       
    80 
       
    81     // Make sure feature which is modifiable exists
       
    82     supported = control.FeatureSupported( KModifiableUid );
       
    83     if( supported != KFeatureUnsupported && supported != KFeatureSupported )
       
    84         {
       
    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);
       
    93         }
       
    94     else
       
    95         {
       
    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);
       
    99         }
       
   100 
       
   101     // Make sure feature which is unmodifiable exists
       
   102     supported = control.FeatureSupported( KUnmodifiableUid );
       
   103     if( supported != KFeatureUnsupported && supported != KFeatureSupported )
       
   104         {
       
   105         TBitFlags32 flags( 0 );
       
   106         flags.Set( EFeatureSupported );
       
   107         TFeatureEntry entry( KUnmodifiableUid, flags, KDefaultData1 );
       
   108         err = control.AddFeature( entry );
       
   109         TESTE(err==KErrNone,err);
       
   110         }
       
   111 
       
   112     // Make sure uninitialized feature exists
       
   113     supported = control.FeatureSupported( KUninitializedUid );
       
   114     if( supported != KFeatureUnsupported && supported != KFeatureSupported
       
   115         && supported != KErrNotReady )
       
   116         {
       
   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);
       
   124         }
       
   125         
       
   126    //Make sure that persisted feature exists
       
   127    
       
   128   supported = control.FeatureSupported(KPersistedUid);
       
   129    if(supported != KFeatureUnsupported && supported != KFeatureSupported)
       
   130    {
       
   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);
       
   138    }
       
   139 
       
   140 
       
   141     CleanupStack::PopAndDestroy( &control );        
       
   142     
       
   143     return TestStepResult();	
       
   144 }
       
   145 
       
   146 TVerdict CEFMConfigurableTestStepBase::doTestStepPreambleL()
       
   147 {
       
   148 	//read wether this test step is a OOM test
       
   149 	GetBoolFromConfig(ConfigSection(), KTestOOM, iOOM);
       
   150 	
       
   151 	//read wether this test step is a Low-capability test
       
   152 	GetBoolFromConfig(ConfigSection(), KTestLowCap, iLowCap);
       
   153 	
       
   154 	return TestStepResult();
       
   155 }
       
   156 
       
   157 void CEFMConfigurableTestStepBase::CheckCondition(TBool aMainCondition, TBool aOOMCondition, TPtrC aLoggingMessage, TInt aErrorCode)
       
   158 {
       
   159 	TBool cond = iOOM?aMainCondition||aOOMCondition:aMainCondition;  
       
   160 	if (!cond)
       
   161 		{
       
   162 		ERR_PRINTF2( aLoggingMessage, aErrorCode );
       
   163 		SetTestStepResult(EFail);
       
   164 		}		
       
   165 }