os/persistentdata/featuremgmt/featuremgr/test/rtest/src/t_fmgrsecurity1.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include <e32test.h>
sl@0
    17
#include <featmgr.h>
sl@0
    18
#include <featureuids.h>
sl@0
    19
#include <featurecontrol.h>
sl@0
    20
#include <featdiscovery.h>
sl@0
    21
sl@0
    22
using namespace NFeature;
sl@0
    23
sl@0
    24
const TInt KInvalidFeatureId1    = 90901671;
sl@0
    25
const TUid KInvalidFeatureUid1  = {KInvalidFeatureId1};
sl@0
    26
sl@0
    27
///////////////////////////////////////////////////////////////////////////////////////
sl@0
    28
//////  Note: This test has no platsec capabilities. It should not be possible to /////
sl@0
    29
//////        call platsec protected FeatMgr methods.                             /////
sl@0
    30
///////////////////////////////////////////////////////////////////////////////////////
sl@0
    31
sl@0
    32
static RTest TheTest(_L("t_fmgrsecurity1"));
sl@0
    33
sl@0
    34
///////////////////////////////////////////////////////////////////////////////////////
sl@0
    35
sl@0
    36
//Deletes all created test files.
sl@0
    37
void DestroyTestEnv()
sl@0
    38
    {
sl@0
    39
    }
sl@0
    40
sl@0
    41
///////////////////////////////////////////////////////////////////////////////////////
sl@0
    42
///////////////////////////////////////////////////////////////////////////////////////
sl@0
    43
//Test macros and functions
sl@0
    44
void Check1(TInt aValue, TInt aLine)
sl@0
    45
    {
sl@0
    46
    if(!aValue)
sl@0
    47
        {
sl@0
    48
        DestroyTestEnv();
sl@0
    49
        RDebug::Print(_L("*** Expression evaluated to false. Line %d\r\n"), aLine);
sl@0
    50
        TheTest(EFalse, aLine);
sl@0
    51
        }
sl@0
    52
    }
sl@0
    53
void Check2(TInt aValue, TInt aExpected, TInt aLine)
sl@0
    54
    {
sl@0
    55
    if(aValue != aExpected)
sl@0
    56
        {
sl@0
    57
        DestroyTestEnv();
sl@0
    58
        RDebug::Print(_L("*** Expected: %d, got: %d. Line %d\r\n"), aExpected, aValue, aLine);
sl@0
    59
        TheTest(EFalse, aLine);
sl@0
    60
        }
sl@0
    61
    }
sl@0
    62
#define TEST(arg) ::Check1((arg), __LINE__)
sl@0
    63
#define TEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__)
sl@0
    64
sl@0
    65
///////////////////////////////////////////////////////////////////////////////////////
sl@0
    66
sl@0
    67
/**
sl@0
    68
@SYMTestCaseID          PDS-FEATMGR-CT-????
sl@0
    69
@SYMTestCaseDesc        
sl@0
    70
@SYMTestPriority        High
sl@0
    71
@SYMTestActions         
sl@0
    72
@SYMTestExpectedResults Test must not fail
sl@0
    73
@SYMDEF                 ????
sl@0
    74
*/
sl@0
    75
void FeatureControlPlatSecTest()
sl@0
    76
    {
sl@0
    77
    RFeatureControl ctrl;
sl@0
    78
    TInt err = ctrl.Open();
sl@0
    79
    TEST2(err, KErrNone);
sl@0
    80
sl@0
    81
    err = ctrl.EnableFeature(KConnectivity);
sl@0
    82
    TEST2(err, KErrPermissionDenied);
sl@0
    83
    err = ctrl.EnableFeature(KInvalidFeatureUid1);
sl@0
    84
    TEST2(err, KErrPermissionDenied);
sl@0
    85
    
sl@0
    86
    err = ctrl.DisableFeature(KConnectivity);
sl@0
    87
    TEST2(err, KErrPermissionDenied);
sl@0
    88
    err = ctrl.DisableFeature(KInvalidFeatureUid1);
sl@0
    89
    TEST2(err, KErrPermissionDenied);
sl@0
    90
sl@0
    91
    err = ctrl.SetFeature(KConnectivity, ETrue, 0);
sl@0
    92
    TEST2(err, KErrPermissionDenied);
sl@0
    93
    err = ctrl.SetFeature(KInvalidFeatureUid1, ETrue, 0);
sl@0
    94
    TEST2(err, KErrPermissionDenied);
sl@0
    95
    err = ctrl.SetFeature(KConnectivity, 0);
sl@0
    96
    TEST2(err, KErrPermissionDenied);
sl@0
    97
    err = ctrl.SetFeature(KInvalidFeatureUid1, 0);
sl@0
    98
    TEST2(err, KErrPermissionDenied);
sl@0
    99
sl@0
   100
    TFeatureEntry fentry;
sl@0
   101
    err = ctrl.AddFeature(fentry);
sl@0
   102
    TEST2(err, KErrPermissionDenied);
sl@0
   103
    err = ctrl.DeleteFeature(KConnectivity);
sl@0
   104
    TEST2(err, KErrPermissionDenied);
sl@0
   105
    err = ctrl.DeleteFeature(KInvalidFeatureUid1);
sl@0
   106
    TEST2(err, KErrPermissionDenied);
sl@0
   107
    
sl@0
   108
    err = ctrl.SWIStart();
sl@0
   109
    TEST2(err, KErrPermissionDenied);
sl@0
   110
    err = ctrl.SWIEnd();
sl@0
   111
    TEST2(err, KErrPermissionDenied);
sl@0
   112
    
sl@0
   113
    ctrl.Close();
sl@0
   114
    }
sl@0
   115
sl@0
   116
void DoTestsL()
sl@0
   117
    {
sl@0
   118
    TheTest.Start(_L("@SYMTestCaseID:PDS-EFM-CT-4108 RFeatureControl platsec test"));
sl@0
   119
    FeatureControlPlatSecTest();
sl@0
   120
    }
sl@0
   121
sl@0
   122
TInt E32Main()
sl@0
   123
    {
sl@0
   124
    TheTest.Title();
sl@0
   125
    
sl@0
   126
    CTrapCleanup* tc = CTrapCleanup::New();
sl@0
   127
    TheTest(tc != NULL);
sl@0
   128
    
sl@0
   129
    __UHEAP_MARK;
sl@0
   130
    
sl@0
   131
    TRAPD(err, DoTestsL());
sl@0
   132
    DestroyTestEnv();
sl@0
   133
    TEST2(err, KErrNone);
sl@0
   134
sl@0
   135
    __UHEAP_MARKEND;
sl@0
   136
    
sl@0
   137
    TheTest.End();
sl@0
   138
    TheTest.Close();
sl@0
   139
    
sl@0
   140
    delete tc;
sl@0
   141
sl@0
   142
    User::Heap().Check();
sl@0
   143
    return KErrNone;
sl@0
   144
    }