|
1 // Copyright (c) 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 // |
|
15 |
|
16 #include <e32test.h> |
|
17 #include <featmgr.h> |
|
18 #include <featureuids.h> |
|
19 #include <featurecontrol.h> |
|
20 #include <featdiscovery.h> |
|
21 |
|
22 using namespace NFeature; |
|
23 |
|
24 const TInt KInvalidFeatureId1 = 90901671; |
|
25 const TUid KInvalidFeatureUid1 = {KInvalidFeatureId1}; |
|
26 |
|
27 /////////////////////////////////////////////////////////////////////////////////////// |
|
28 ////// Note: This test has no platsec capabilities. It should not be possible to ///// |
|
29 ////// call platsec protected FeatMgr methods. ///// |
|
30 /////////////////////////////////////////////////////////////////////////////////////// |
|
31 |
|
32 static RTest TheTest(_L("t_fmgrsecurity1")); |
|
33 |
|
34 /////////////////////////////////////////////////////////////////////////////////////// |
|
35 |
|
36 //Deletes all created test files. |
|
37 void DestroyTestEnv() |
|
38 { |
|
39 } |
|
40 |
|
41 /////////////////////////////////////////////////////////////////////////////////////// |
|
42 /////////////////////////////////////////////////////////////////////////////////////// |
|
43 //Test macros and functions |
|
44 void Check1(TInt aValue, TInt aLine) |
|
45 { |
|
46 if(!aValue) |
|
47 { |
|
48 DestroyTestEnv(); |
|
49 RDebug::Print(_L("*** Expression evaluated to false. Line %d\r\n"), aLine); |
|
50 TheTest(EFalse, aLine); |
|
51 } |
|
52 } |
|
53 void Check2(TInt aValue, TInt aExpected, TInt aLine) |
|
54 { |
|
55 if(aValue != aExpected) |
|
56 { |
|
57 DestroyTestEnv(); |
|
58 RDebug::Print(_L("*** Expected: %d, got: %d. Line %d\r\n"), aExpected, aValue, aLine); |
|
59 TheTest(EFalse, aLine); |
|
60 } |
|
61 } |
|
62 #define TEST(arg) ::Check1((arg), __LINE__) |
|
63 #define TEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__) |
|
64 |
|
65 /////////////////////////////////////////////////////////////////////////////////////// |
|
66 |
|
67 /** |
|
68 @SYMTestCaseID PDS-FEATMGR-CT-???? |
|
69 @SYMTestCaseDesc |
|
70 @SYMTestPriority High |
|
71 @SYMTestActions |
|
72 @SYMTestExpectedResults Test must not fail |
|
73 @SYMDEF ???? |
|
74 */ |
|
75 void FeatureControlPlatSecTest() |
|
76 { |
|
77 RFeatureControl ctrl; |
|
78 TInt err = ctrl.Open(); |
|
79 TEST2(err, KErrNone); |
|
80 |
|
81 err = ctrl.EnableFeature(KConnectivity); |
|
82 TEST2(err, KErrPermissionDenied); |
|
83 err = ctrl.EnableFeature(KInvalidFeatureUid1); |
|
84 TEST2(err, KErrPermissionDenied); |
|
85 |
|
86 err = ctrl.DisableFeature(KConnectivity); |
|
87 TEST2(err, KErrPermissionDenied); |
|
88 err = ctrl.DisableFeature(KInvalidFeatureUid1); |
|
89 TEST2(err, KErrPermissionDenied); |
|
90 |
|
91 err = ctrl.SetFeature(KConnectivity, ETrue, 0); |
|
92 TEST2(err, KErrPermissionDenied); |
|
93 err = ctrl.SetFeature(KInvalidFeatureUid1, ETrue, 0); |
|
94 TEST2(err, KErrPermissionDenied); |
|
95 err = ctrl.SetFeature(KConnectivity, 0); |
|
96 TEST2(err, KErrPermissionDenied); |
|
97 err = ctrl.SetFeature(KInvalidFeatureUid1, 0); |
|
98 TEST2(err, KErrPermissionDenied); |
|
99 |
|
100 TFeatureEntry fentry; |
|
101 err = ctrl.AddFeature(fentry); |
|
102 TEST2(err, KErrPermissionDenied); |
|
103 err = ctrl.DeleteFeature(KConnectivity); |
|
104 TEST2(err, KErrPermissionDenied); |
|
105 err = ctrl.DeleteFeature(KInvalidFeatureUid1); |
|
106 TEST2(err, KErrPermissionDenied); |
|
107 |
|
108 err = ctrl.SWIStart(); |
|
109 TEST2(err, KErrPermissionDenied); |
|
110 err = ctrl.SWIEnd(); |
|
111 TEST2(err, KErrPermissionDenied); |
|
112 |
|
113 ctrl.Close(); |
|
114 } |
|
115 |
|
116 void DoTestsL() |
|
117 { |
|
118 TheTest.Start(_L("@SYMTestCaseID:PDS-EFM-CT-4108 RFeatureControl platsec test")); |
|
119 FeatureControlPlatSecTest(); |
|
120 } |
|
121 |
|
122 TInt E32Main() |
|
123 { |
|
124 TheTest.Title(); |
|
125 |
|
126 CTrapCleanup* tc = CTrapCleanup::New(); |
|
127 TheTest(tc != NULL); |
|
128 |
|
129 __UHEAP_MARK; |
|
130 |
|
131 TRAPD(err, DoTestsL()); |
|
132 DestroyTestEnv(); |
|
133 TEST2(err, KErrNone); |
|
134 |
|
135 __UHEAP_MARKEND; |
|
136 |
|
137 TheTest.End(); |
|
138 TheTest.Close(); |
|
139 |
|
140 delete tc; |
|
141 |
|
142 User::Heap().Check(); |
|
143 return KErrNone; |
|
144 } |