sl@0
|
1 |
// Copyright (c) 2009-2010 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 <hal.h>
|
sl@0
|
18 |
#include <featmgr.h>
|
sl@0
|
19 |
#include <featureuids.h>
|
sl@0
|
20 |
#include <featurecontrol.h>
|
sl@0
|
21 |
#include <featdiscovery.h>
|
sl@0
|
22 |
|
sl@0
|
23 |
using namespace NFeature;
|
sl@0
|
24 |
|
sl@0
|
25 |
TInt TheFastCounterFreq = 0;
|
sl@0
|
26 |
|
sl@0
|
27 |
const TInt KInvalidFeatureId1 = 90901671;
|
sl@0
|
28 |
const TUid KInvalidFeatureUid1 = {KInvalidFeatureId1};
|
sl@0
|
29 |
const TUid KNewFeatureUid = {0x7888ABC1};
|
sl@0
|
30 |
|
sl@0
|
31 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
32 |
|
sl@0
|
33 |
static RTest TheTest(_L("t_fmgrperformance"));
|
sl@0
|
34 |
|
sl@0
|
35 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
36 |
|
sl@0
|
37 |
//Deletes all created test files.
|
sl@0
|
38 |
void DestroyTestEnv()
|
sl@0
|
39 |
{
|
sl@0
|
40 |
}
|
sl@0
|
41 |
|
sl@0
|
42 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
43 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
44 |
//Test macros and functions
|
sl@0
|
45 |
void Check1(TInt aValue, TInt aLine)
|
sl@0
|
46 |
{
|
sl@0
|
47 |
if(!aValue)
|
sl@0
|
48 |
{
|
sl@0
|
49 |
DestroyTestEnv();
|
sl@0
|
50 |
RDebug::Print(_L("*** Expression evaluated to false. Line %d\r\n"), aLine);
|
sl@0
|
51 |
TheTest(EFalse, aLine);
|
sl@0
|
52 |
}
|
sl@0
|
53 |
}
|
sl@0
|
54 |
void Check2(TInt aValue, TInt aExpected, TInt aLine)
|
sl@0
|
55 |
{
|
sl@0
|
56 |
if(aValue != aExpected)
|
sl@0
|
57 |
{
|
sl@0
|
58 |
DestroyTestEnv();
|
sl@0
|
59 |
RDebug::Print(_L("*** Expected: %d, got: %d. Line %d\r\n"), aExpected, aValue, aLine);
|
sl@0
|
60 |
TheTest(EFalse, aLine);
|
sl@0
|
61 |
}
|
sl@0
|
62 |
}
|
sl@0
|
63 |
#define TEST(arg) ::Check1((arg), __LINE__)
|
sl@0
|
64 |
#define TEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__)
|
sl@0
|
65 |
|
sl@0
|
66 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
67 |
|
sl@0
|
68 |
TInt TimeDiffUs(TUint32 aStartTicks, TUint32 aEndTicks)
|
sl@0
|
69 |
{
|
sl@0
|
70 |
if(TheFastCounterFreq == 0)
|
sl@0
|
71 |
{
|
sl@0
|
72 |
TEST2(HAL::Get(HAL::EFastCounterFrequency, TheFastCounterFreq), KErrNone);
|
sl@0
|
73 |
TheTest.Printf(_L("===Fast counter frequency = %d Hz\r\n"), TheFastCounterFreq);
|
sl@0
|
74 |
}
|
sl@0
|
75 |
TInt64 diffTicks = (TInt64)aEndTicks - (TInt64)aStartTicks;
|
sl@0
|
76 |
if(diffTicks < 0)
|
sl@0
|
77 |
{
|
sl@0
|
78 |
diffTicks = KMaxTUint32 + diffTicks + 1;
|
sl@0
|
79 |
}
|
sl@0
|
80 |
const TInt KMicroSecIn1Sec = 1000000;
|
sl@0
|
81 |
TInt us = (diffTicks * KMicroSecIn1Sec) / TheFastCounterFreq;
|
sl@0
|
82 |
return us;
|
sl@0
|
83 |
}
|
sl@0
|
84 |
|
sl@0
|
85 |
void PrintTime(const TDesC& aFmt, TUint32 aStartTicks, TUint32 aEndTicks)
|
sl@0
|
86 |
{
|
sl@0
|
87 |
TInt us = TimeDiffUs(aStartTicks, aEndTicks);
|
sl@0
|
88 |
TheTest.Printf(aFmt, us);
|
sl@0
|
89 |
}
|
sl@0
|
90 |
|
sl@0
|
91 |
/**
|
sl@0
|
92 |
@SYMTestCaseID PDS-EFM-CT-4106
|
sl@0
|
93 |
@SYMTestCaseDesc
|
sl@0
|
94 |
@SYMTestPriority High
|
sl@0
|
95 |
@SYMTestActions
|
sl@0
|
96 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
97 |
@SYMDEF DEF144262
|
sl@0
|
98 |
*/
|
sl@0
|
99 |
void FeatureControlTest()
|
sl@0
|
100 |
{
|
sl@0
|
101 |
TFeatureEntry fentry;
|
sl@0
|
102 |
|
sl@0
|
103 |
TUint32 start = User::FastCounter();
|
sl@0
|
104 |
RFeatureControl ctrl;
|
sl@0
|
105 |
|
sl@0
|
106 |
TInt err = ctrl.Open();
|
sl@0
|
107 |
TEST2(err, KErrNone);
|
sl@0
|
108 |
TUint32 end = User::FastCounter();
|
sl@0
|
109 |
PrintTime(_L("===1 RFeatureControl::Open(), time=%d us\r\n"), start, end);
|
sl@0
|
110 |
|
sl@0
|
111 |
//The second RFeatureControl::Open() call is "free", because only one connection per thread is kept in TLS
|
sl@0
|
112 |
RFeatureControl ctrl2;
|
sl@0
|
113 |
start = User::FastCounter();
|
sl@0
|
114 |
err = ctrl2.Open();
|
sl@0
|
115 |
TEST2(err, KErrNone);
|
sl@0
|
116 |
end = User::FastCounter();
|
sl@0
|
117 |
PrintTime(_L("===2 RFeatureControl::Open(), time=%d us\r\n"), start, end);
|
sl@0
|
118 |
|
sl@0
|
119 |
//
|
sl@0
|
120 |
start = User::FastCounter();
|
sl@0
|
121 |
ctrl2.Close();
|
sl@0
|
122 |
end = User::FastCounter();
|
sl@0
|
123 |
PrintTime(_L("===2 RFeatureControl::Close(), time=%d us\r\n"), start, end);
|
sl@0
|
124 |
|
sl@0
|
125 |
//
|
sl@0
|
126 |
TBitFlags32 flags;
|
sl@0
|
127 |
flags.ClearAll();
|
sl@0
|
128 |
flags.Set(EFeatureSupported);
|
sl@0
|
129 |
flags.Set(EFeatureModifiable);
|
sl@0
|
130 |
|
sl@0
|
131 |
fentry = TFeatureEntry(KNewFeatureUid, flags, 0x0);
|
sl@0
|
132 |
start = User::FastCounter();
|
sl@0
|
133 |
err = ctrl.AddFeature(fentry);
|
sl@0
|
134 |
TEST2(err, KErrNone);
|
sl@0
|
135 |
end = User::FastCounter();
|
sl@0
|
136 |
PrintTime(_L("===RFeatureControl::AddFeature(), time=%d us\r\n"), start, end);
|
sl@0
|
137 |
//
|
sl@0
|
138 |
start = User::FastCounter();
|
sl@0
|
139 |
err = ctrl.FeatureSupported(KNewFeatureUid);
|
sl@0
|
140 |
TEST2(err, 1);
|
sl@0
|
141 |
end = User::FastCounter();
|
sl@0
|
142 |
PrintTime(_L("===RFeatureControl::FeatureSupported(TUid), time=%d us\r\n"), start, end);
|
sl@0
|
143 |
//
|
sl@0
|
144 |
start = User::FastCounter();
|
sl@0
|
145 |
err = ctrl.FeatureSupported(KInvalidFeatureUid1);
|
sl@0
|
146 |
TEST2(err, KErrNotFound);
|
sl@0
|
147 |
end = User::FastCounter();
|
sl@0
|
148 |
PrintTime(_L("===RFeatureControl::FeatureSupported(invalid TUid), time=%d us\r\n"), start, end);
|
sl@0
|
149 |
//
|
sl@0
|
150 |
fentry = TFeatureEntry(KNewFeatureUid);
|
sl@0
|
151 |
start = User::FastCounter();
|
sl@0
|
152 |
err = ctrl.FeatureSupported(fentry);
|
sl@0
|
153 |
TEST2(err, 1);
|
sl@0
|
154 |
end = User::FastCounter();
|
sl@0
|
155 |
PrintTime(_L("===RFeatureControl::FeatureSupported(TFeatureEntry), time=%d us\r\n"), start, end);
|
sl@0
|
156 |
//
|
sl@0
|
157 |
RFeatureArray farray;
|
sl@0
|
158 |
err = farray.Append(TFeatureEntry(KNewFeatureUid));
|
sl@0
|
159 |
TEST2(err, KErrNone);
|
sl@0
|
160 |
err = farray.Append(TFeatureEntry(KInvalidFeatureUid1));
|
sl@0
|
161 |
TEST2(err, KErrNone);
|
sl@0
|
162 |
err = farray.Append(TFeatureEntry(KConnectivity));
|
sl@0
|
163 |
TEST2(err, KErrNone);
|
sl@0
|
164 |
err = farray.Append(TFeatureEntry(KUsb));
|
sl@0
|
165 |
TEST2(err, KErrNone);
|
sl@0
|
166 |
start = User::FastCounter();
|
sl@0
|
167 |
err = ctrl.FeaturesSupported(farray);
|
sl@0
|
168 |
end = User::FastCounter();
|
sl@0
|
169 |
PrintTime(_L("===RFeatureControl::FeaturesSupported(), time=%d us\r\n"), start, end);
|
sl@0
|
170 |
TEST2(farray.Count(), 3);//KInvalidFeatureUid1 should have been removed from the array
|
sl@0
|
171 |
farray.Close();
|
sl@0
|
172 |
//
|
sl@0
|
173 |
start = User::FastCounter();
|
sl@0
|
174 |
err = ctrl.DisableFeature(KNewFeatureUid);
|
sl@0
|
175 |
TEST2(err, KErrNone);
|
sl@0
|
176 |
end = User::FastCounter();
|
sl@0
|
177 |
PrintTime(_L("===1 RFeatureControl::DisableFeature(), time=%d us\r\n"), start, end);
|
sl@0
|
178 |
//Disable the same feature again
|
sl@0
|
179 |
start = User::FastCounter();
|
sl@0
|
180 |
err = ctrl.DisableFeature(KNewFeatureUid);
|
sl@0
|
181 |
TEST2(err, KErrNone);
|
sl@0
|
182 |
end = User::FastCounter();
|
sl@0
|
183 |
PrintTime(_L("===2 RFeatureControl::DisableFeature(already disabled), time=%d us\r\n"), start, end);
|
sl@0
|
184 |
//
|
sl@0
|
185 |
start = User::FastCounter();
|
sl@0
|
186 |
err = ctrl.DisableFeature(KFax);
|
sl@0
|
187 |
TEST2(err, KErrAccessDenied);
|
sl@0
|
188 |
end = User::FastCounter();
|
sl@0
|
189 |
PrintTime(_L("===3 RFeatureControl::DisableFeature(access denied), time=%d us\r\n"), start, end);
|
sl@0
|
190 |
//
|
sl@0
|
191 |
start = User::FastCounter();
|
sl@0
|
192 |
err = ctrl.EnableFeature(KNewFeatureUid);
|
sl@0
|
193 |
TEST2(err, KErrNone);
|
sl@0
|
194 |
end = User::FastCounter();
|
sl@0
|
195 |
PrintTime(_L("===1 RFeatureControl::EnableFeature(), time=%d us\r\n"), start, end);
|
sl@0
|
196 |
//Enable the same feature again
|
sl@0
|
197 |
start = User::FastCounter();
|
sl@0
|
198 |
err = ctrl.EnableFeature(KNewFeatureUid);
|
sl@0
|
199 |
TEST2(err, KErrNone);
|
sl@0
|
200 |
end = User::FastCounter();
|
sl@0
|
201 |
PrintTime(_L("===2 RFeatureControl::EnableFeature(already enabled), time=%d us\r\n"), start, end);
|
sl@0
|
202 |
//
|
sl@0
|
203 |
start = User::FastCounter();
|
sl@0
|
204 |
err = ctrl.EnableFeature(KFax);
|
sl@0
|
205 |
TEST2(err, KErrAccessDenied);
|
sl@0
|
206 |
end = User::FastCounter();
|
sl@0
|
207 |
PrintTime(_L("===3 RFeatureControl::EnableFeature(access denied), time=%d us\r\n"), start, end);
|
sl@0
|
208 |
//
|
sl@0
|
209 |
start = User::FastCounter();
|
sl@0
|
210 |
err = ctrl.SetFeature(KNewFeatureUid, EFalse, 100);
|
sl@0
|
211 |
TEST2(err, KErrNone);
|
sl@0
|
212 |
end = User::FastCounter();
|
sl@0
|
213 |
PrintTime(_L("===1 RFeatureControl::SetFeature(), time=%d us\r\n"), start, end);
|
sl@0
|
214 |
//
|
sl@0
|
215 |
start = User::FastCounter();
|
sl@0
|
216 |
err = ctrl.SetFeature(KNewFeatureUid, 200);
|
sl@0
|
217 |
TEST2(err, KErrNone);
|
sl@0
|
218 |
end = User::FastCounter();
|
sl@0
|
219 |
PrintTime(_L("===2 RFeatureControl::SetFeature(), time=%d us\r\n"), start, end);
|
sl@0
|
220 |
//
|
sl@0
|
221 |
RFeatureUidArray farray2;
|
sl@0
|
222 |
start = User::FastCounter();
|
sl@0
|
223 |
err = ctrl.ListSupportedFeatures(farray2);
|
sl@0
|
224 |
TEST2(err, KErrNone);
|
sl@0
|
225 |
end = User::FastCounter();
|
sl@0
|
226 |
PrintTime(_L("===RFeatureControl::ListSupportedFeatures(), time=%d us\r\n"), start, end);
|
sl@0
|
227 |
TEST(farray2.Count() > 0);
|
sl@0
|
228 |
farray2.Close();
|
sl@0
|
229 |
//
|
sl@0
|
230 |
start = User::FastCounter();
|
sl@0
|
231 |
ctrl.DeleteFeature(KNewFeatureUid);
|
sl@0
|
232 |
end = User::FastCounter();
|
sl@0
|
233 |
PrintTime(_L("===RFeatureControl::DeleteFeature(), time=%d us\r\n"), start, end);
|
sl@0
|
234 |
//
|
sl@0
|
235 |
start = User::FastCounter();
|
sl@0
|
236 |
ctrl.Close();
|
sl@0
|
237 |
end = User::FastCounter();
|
sl@0
|
238 |
PrintTime(_L("===1 RFeatureControl::Close(), time=%d us\r\n"), start, end);
|
sl@0
|
239 |
}
|
sl@0
|
240 |
|
sl@0
|
241 |
/**
|
sl@0
|
242 |
@SYMTestCaseID PDS-EFM-CT-4107
|
sl@0
|
243 |
@SYMTestCaseDesc
|
sl@0
|
244 |
@SYMTestPriority High
|
sl@0
|
245 |
@SYMTestActions
|
sl@0
|
246 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
247 |
@SYMDEF DEF144262
|
sl@0
|
248 |
*/
|
sl@0
|
249 |
void FeatureManagerTestL()
|
sl@0
|
250 |
{
|
sl@0
|
251 |
TUint32 start = User::FastCounter();
|
sl@0
|
252 |
FeatureManager::InitializeLibL();
|
sl@0
|
253 |
TUint32 end = User::FastCounter();
|
sl@0
|
254 |
PrintTime(_L("===FeatureManager::InitializeLibL(server already loaded by the previous test), time=%d us\r\n"), start, end);
|
sl@0
|
255 |
//
|
sl@0
|
256 |
start = User::FastCounter();
|
sl@0
|
257 |
TBool rc = FeatureManager::FeatureSupported(KConnectivity.iUid);
|
sl@0
|
258 |
TEST(rc);
|
sl@0
|
259 |
end = User::FastCounter();
|
sl@0
|
260 |
PrintTime(_L("===FeatureManager::FeatureSupported(), time=%d us\r\n"), start, end);
|
sl@0
|
261 |
//
|
sl@0
|
262 |
start = User::FastCounter();
|
sl@0
|
263 |
FeatureManager::UnInitializeLib();
|
sl@0
|
264 |
end = User::FastCounter();
|
sl@0
|
265 |
PrintTime(_L("===FeatureManager::UnInitializeLib(), time=%d us\r\n"), start, end);
|
sl@0
|
266 |
}
|
sl@0
|
267 |
|
sl@0
|
268 |
void DoTestsL()
|
sl@0
|
269 |
{
|
sl@0
|
270 |
TheTest.Start(_L("@SYMTestCaseID:PDS-EFM-CT-4106 RFeatureControl performance test"));
|
sl@0
|
271 |
FeatureControlTest();
|
sl@0
|
272 |
|
sl@0
|
273 |
TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4107 FeatureManager performance test"));
|
sl@0
|
274 |
FeatureManagerTestL();
|
sl@0
|
275 |
}
|
sl@0
|
276 |
|
sl@0
|
277 |
TInt E32Main()
|
sl@0
|
278 |
{
|
sl@0
|
279 |
TheTest.Title();
|
sl@0
|
280 |
|
sl@0
|
281 |
CTrapCleanup* tc = CTrapCleanup::New();
|
sl@0
|
282 |
TheTest(tc != NULL);
|
sl@0
|
283 |
|
sl@0
|
284 |
__UHEAP_MARK;
|
sl@0
|
285 |
|
sl@0
|
286 |
TRAPD(err, DoTestsL());
|
sl@0
|
287 |
DestroyTestEnv();
|
sl@0
|
288 |
TEST2(err, KErrNone);
|
sl@0
|
289 |
|
sl@0
|
290 |
__UHEAP_MARKEND;
|
sl@0
|
291 |
|
sl@0
|
292 |
TheTest.End();
|
sl@0
|
293 |
TheTest.Close();
|
sl@0
|
294 |
|
sl@0
|
295 |
delete tc;
|
sl@0
|
296 |
|
sl@0
|
297 |
User::Heap().Check();
|
sl@0
|
298 |
return KErrNone;
|
sl@0
|
299 |
}
|