sl@0: // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: using namespace NFeature; sl@0: sl@0: const TInt KInvalidFeatureId1 = 90901671; sl@0: const TUid KInvalidFeatureUid1 = {KInvalidFeatureId1}; sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////////////// sl@0: ////// Note: This test has no platsec capabilities. It should not be possible to ///// sl@0: ////// call platsec protected FeatMgr methods. ///// sl@0: /////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: static RTest TheTest(_L("t_fmgrsecurity1")); sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: //Deletes all created test files. sl@0: void DestroyTestEnv() sl@0: { sl@0: } sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////////////// sl@0: /////////////////////////////////////////////////////////////////////////////////////// sl@0: //Test macros and functions sl@0: void Check1(TInt aValue, TInt aLine) sl@0: { sl@0: if(!aValue) sl@0: { sl@0: DestroyTestEnv(); sl@0: RDebug::Print(_L("*** Expression evaluated to false. Line %d\r\n"), aLine); sl@0: TheTest(EFalse, aLine); sl@0: } sl@0: } sl@0: void Check2(TInt aValue, TInt aExpected, TInt aLine) sl@0: { sl@0: if(aValue != aExpected) sl@0: { sl@0: DestroyTestEnv(); sl@0: RDebug::Print(_L("*** Expected: %d, got: %d. Line %d\r\n"), aExpected, aValue, aLine); sl@0: TheTest(EFalse, aLine); sl@0: } sl@0: } sl@0: #define TEST(arg) ::Check1((arg), __LINE__) sl@0: #define TEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__) sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: /** sl@0: @SYMTestCaseID PDS-FEATMGR-CT-???? sl@0: @SYMTestCaseDesc sl@0: @SYMTestPriority High sl@0: @SYMTestActions sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMDEF ???? sl@0: */ sl@0: void FeatureControlPlatSecTest() sl@0: { sl@0: RFeatureControl ctrl; sl@0: TInt err = ctrl.Open(); sl@0: TEST2(err, KErrNone); sl@0: sl@0: err = ctrl.EnableFeature(KConnectivity); sl@0: TEST2(err, KErrPermissionDenied); sl@0: err = ctrl.EnableFeature(KInvalidFeatureUid1); sl@0: TEST2(err, KErrPermissionDenied); sl@0: sl@0: err = ctrl.DisableFeature(KConnectivity); sl@0: TEST2(err, KErrPermissionDenied); sl@0: err = ctrl.DisableFeature(KInvalidFeatureUid1); sl@0: TEST2(err, KErrPermissionDenied); sl@0: sl@0: err = ctrl.SetFeature(KConnectivity, ETrue, 0); sl@0: TEST2(err, KErrPermissionDenied); sl@0: err = ctrl.SetFeature(KInvalidFeatureUid1, ETrue, 0); sl@0: TEST2(err, KErrPermissionDenied); sl@0: err = ctrl.SetFeature(KConnectivity, 0); sl@0: TEST2(err, KErrPermissionDenied); sl@0: err = ctrl.SetFeature(KInvalidFeatureUid1, 0); sl@0: TEST2(err, KErrPermissionDenied); sl@0: sl@0: TFeatureEntry fentry; sl@0: err = ctrl.AddFeature(fentry); sl@0: TEST2(err, KErrPermissionDenied); sl@0: err = ctrl.DeleteFeature(KConnectivity); sl@0: TEST2(err, KErrPermissionDenied); sl@0: err = ctrl.DeleteFeature(KInvalidFeatureUid1); sl@0: TEST2(err, KErrPermissionDenied); sl@0: sl@0: err = ctrl.SWIStart(); sl@0: TEST2(err, KErrPermissionDenied); sl@0: err = ctrl.SWIEnd(); sl@0: TEST2(err, KErrPermissionDenied); sl@0: sl@0: ctrl.Close(); sl@0: } sl@0: sl@0: void DoTestsL() sl@0: { sl@0: TheTest.Start(_L("@SYMTestCaseID:PDS-EFM-CT-4108 RFeatureControl platsec test")); sl@0: FeatureControlPlatSecTest(); sl@0: } sl@0: sl@0: TInt E32Main() sl@0: { sl@0: TheTest.Title(); sl@0: sl@0: CTrapCleanup* tc = CTrapCleanup::New(); sl@0: TheTest(tc != NULL); sl@0: sl@0: __UHEAP_MARK; sl@0: sl@0: TRAPD(err, DoTestsL()); sl@0: DestroyTestEnv(); sl@0: TEST2(err, KErrNone); sl@0: sl@0: __UHEAP_MARKEND; sl@0: sl@0: TheTest.End(); sl@0: TheTest.Close(); sl@0: sl@0: delete tc; sl@0: sl@0: User::Heap().Check(); sl@0: return KErrNone; sl@0: }