|
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 // UnitTestSteps.cpp |
|
15 // Feature Discovery unit test steps |
|
16 // |
|
17 // |
|
18 |
|
19 /** |
|
20 @file |
|
21 @internalComponent |
|
22 @test |
|
23 */ |
|
24 |
|
25 #include "efm_unit_teststeps.h" |
|
26 #include "efm_teststepbase.h" |
|
27 #include "featmgrfeatureregistry.h" |
|
28 #include "efm_test_consts.h" |
|
29 #include <apgcli.h> |
|
30 #include <apacmdln.h> |
|
31 |
|
32 CServerDataTestStep::CServerDataTestStep() |
|
33 { |
|
34 SetTestStepName(KServerDataTest); |
|
35 } |
|
36 |
|
37 TVerdict CServerDataTestStep::doTestStepL() |
|
38 { |
|
39 TFeatureServerEntry defaultEntry; |
|
40 TESTDIAGNOSTICERROR(defaultEntry.FeatureFlags().Value()==0, |
|
41 _L("TFeatureServerEntry has wrong feature flags: value = %d"),defaultEntry.FeatureFlags().Value()); |
|
42 TESTDIAGNOSTICERROR(defaultEntry.FeatureData()==0, |
|
43 _L("TFeatureServerEntry has wrong feature data: value = %d"),defaultEntry.FeatureData()); |
|
44 TESTDIAGNOSTICERROR(defaultEntry.FeatureUid().iUid==0, |
|
45 _L("TFeatureServerEntry has wrong feature flags: value = %d"),defaultEntry.FeatureUid()); |
|
46 |
|
47 TFeatureServerEntry uidEntry(KDefaultSupportedUid); |
|
48 TESTDIAGNOSTICERROR(uidEntry.FeatureUid()==KDefaultSupportedUid, |
|
49 _L("TFeatureServerEntry has wrong feature flags: value = %d"),defaultEntry.FeatureUid()); |
|
50 TESTDIAGNOSTICERROR(uidEntry.FeatureFlags().Value()==0, |
|
51 _L("TFeatureServerEntry has wrong feature flags: value = %d"),defaultEntry.FeatureFlags().Value()); |
|
52 TESTDIAGNOSTICERROR(uidEntry.FeatureData()==0, |
|
53 _L("TFeatureServerEntry has wrong feature data: value = %d"),defaultEntry.FeatureData()); |
|
54 |
|
55 TFeatureServerEntry argumentListEntry(KDefaultSupportedUid, TBitFlags(1), 1); |
|
56 TESTDIAGNOSTICERROR(argumentListEntry.FeatureUid()==KDefaultSupportedUid, |
|
57 _L("TFeatureServerEntry has wrong feature flags: value = %d"),defaultEntry.FeatureUid()); |
|
58 TESTDIAGNOSTICERROR(argumentListEntry.FeatureFlags().Value()==1, |
|
59 _L("TFeatureServerEntry has wrong feature flags: value = %d"),defaultEntry.FeatureFlags().Value()); |
|
60 TESTDIAGNOSTICERROR(argumentListEntry.FeatureData()==1, |
|
61 _L("TFeatureServerEntry has wrong feature data: value = %d"),defaultEntry.FeatureData()); |
|
62 |
|
63 return TestStepResult(); |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 |
|
68 // Create some resources necessary to the tests. Do this in the preamble |
|
69 // so that it isn't affected if we're running with the TEF '!OOM' option. |
|
70 // That only operates on the 'doTestStepL' method. |
|
71 TVerdict CServerBaseTestStep::doTestStepPreambleL() |
|
72 { |
|
73 CEFMConfigurableTestStepBase::doTestStepPreambleL(); |
|
74 TInt err = ifs.Connect(); |
|
75 TESTDIAGNOSTICERROR(err==KErrNone, |
|
76 _L("CServerBaseTestStep::doTestStepPreambleL RFS::Connect expected to return KErrNone: returned value is %d"),err); |
|
77 if(err) return TestStepResult(); |
|
78 CleanupClosePushL(ifs); |
|
79 |
|
80 ifeatureSet = CFeatMgrFeatureRegistry::NewL(ifs, *this); |
|
81 |
|
82 CleanupStack::PushL(ifeatureSet); |
|
83 return TestStepResult(); |
|
84 } |
|
85 |
|
86 // Clean up the resources previously allocated. |
|
87 TVerdict CServerBaseTestStep::doTestStepPostambleL() |
|
88 { |
|
89 CEFMConfigurableTestStepBase::doTestStepPostambleL(); |
|
90 CleanupStack::PopAndDestroy(ifeatureSet); |
|
91 CleanupStack::PopAndDestroy(&ifs); |
|
92 return TestStepResult(); |
|
93 } |
|
94 |
|
95 // --------------------------------------------------------------------------- |
|
96 |
|
97 CServerFeatureLookupTestStep::CServerFeatureLookupTestStep() |
|
98 { |
|
99 SetTestStepName(KServerFeatureLookupTest); |
|
100 } |
|
101 |
|
102 TVerdict CServerFeatureLookupTestStep::doTestStepL() |
|
103 { |
|
104 //check that an emty registry returns expected values |
|
105 TFeatureServerEntry feaureEntry1(KDefaultSupportedUid,TBitFlags32(1),0); |
|
106 TInt supported = ifeatureSet->IsFeatureSupported( feaureEntry1 ); |
|
107 TESTDIAGNOSTICERROR(supported==KErrNotFound, |
|
108 _L("Feature is not expected to be supported in the empty feature registry: value = %d"),supported); |
|
109 |
|
110 //add one feature and check that it is reported as found |
|
111 TInt error = ifeatureSet->AddFeature( feaureEntry1 ); |
|
112 CheckCondition(error==KErrNone, error==KErrNoMemory, |
|
113 _L("CFeatMgrFeatureRegistry::AddFeature failed: error = %d"),error); |
|
114 if (error==KErrNoMemory) |
|
115 { |
|
116 return TestStepResult(); |
|
117 } |
|
118 supported = ifeatureSet->IsFeatureSupported( feaureEntry1 ); |
|
119 TESTDIAGNOSTICERROR(supported==KFeatureSupported, |
|
120 _L("Feature is expected to be supported after being added: value = %d"),supported); |
|
121 |
|
122 //check that non-existing features are reported as not found |
|
123 TUid supportedUid(KDefaultSupportedUid); |
|
124 TFeatureServerEntry feaureEntry2(TUid::Uid(supportedUid.iUid-1)); |
|
125 supported = ifeatureSet->IsFeatureSupported( feaureEntry2 ); |
|
126 TESTDIAGNOSTICERROR(supported==KErrNotFound, |
|
127 _L("Feature is not expected to be supported: value = %d"),supported); |
|
128 TFeatureServerEntry feaureEntry3(TUid::Uid(supportedUid.iUid+1)); |
|
129 supported = ifeatureSet->IsFeatureSupported( feaureEntry3 ); |
|
130 TESTDIAGNOSTICERROR(supported==KErrNotFound, |
|
131 _L("Feature is not expected to be supported: value = %d"),supported); |
|
132 |
|
133 //add one more feature |
|
134 TFeatureServerEntry feaureEntry4(TUid::Uid(supportedUid.iUid+2),TBitFlags32(1),0); |
|
135 error = ifeatureSet->AddFeature( feaureEntry4 ); |
|
136 CheckCondition(error==KErrNone, error==KErrNoMemory, |
|
137 _L("CFeatMgrFeatureRegistry::AddFeature failed: error = %d"),error); |
|
138 if (error==KErrNoMemory) |
|
139 { |
|
140 return TestStepResult(); |
|
141 } |
|
142 //check that the original feature is still supported |
|
143 supported = ifeatureSet->IsFeatureSupported( feaureEntry1 ); |
|
144 TESTDIAGNOSTICERROR(supported==KFeatureSupported, |
|
145 _L("Feature is expected to be supported after being added: value = %d"),supported); |
|
146 |
|
147 //check that the newly added feature is supported |
|
148 supported = ifeatureSet->IsFeatureSupported( feaureEntry4 ); |
|
149 TESTDIAGNOSTICERROR(supported==KFeatureSupported, |
|
150 _L("Feature is expected to be supported after being added: value = %d"),supported); |
|
151 |
|
152 //check that non-existing features are still reported as not found |
|
153 supported = ifeatureSet->IsFeatureSupported( feaureEntry2 ); |
|
154 TESTDIAGNOSTICERROR(supported==KErrNotFound, |
|
155 _L("Feature is expected to be not found: value = %d"),supported); |
|
156 TFeatureServerEntry feaureEntry5(TUid::Uid(supportedUid.iUid+3)); |
|
157 supported = ifeatureSet->IsFeatureSupported( feaureEntry5 ); |
|
158 TESTDIAGNOSTICERROR(supported==KErrNotFound, |
|
159 _L("Feature is expected to be not found: value = %d"),supported); |
|
160 |
|
161 return TestStepResult(); |
|
162 } |
|
163 |
|
164 CServerUpdateCodeTestStep::CServerUpdateCodeTestStep() |
|
165 { |
|
166 SetTestStepName(KServerUpdateCodeTest); |
|
167 } |
|
168 |
|
169 // Run the test.. |
|
170 TVerdict CServerUpdateCodeTestStep::doTestStepL() |
|
171 { |
|
172 //read the feature data files |
|
173 TRAPD(err, ifeatureSet->ReadFeatureFilesL()); |
|
174 CheckCondition(err==KErrNone,err==KErrNoMemory, |
|
175 _L("CFeatMgrFeatureRegistry::ReadFeatureFilesL failed: error = %d"), err); |
|
176 if (err==KErrNoMemory) |
|
177 { |
|
178 return TestStepResult(); |
|
179 } |
|
180 |
|
181 TInt nfeat = ifeatureSet->NumberOfSupportedFeatures(); |
|
182 TESTDIAGNOSTICERROR(nfeat==1, |
|
183 _L("CFeatMgrFeatureRegistry::NumberOfSupportedFeatures expected to return 1: returned value is %d"), nfeat); |
|
184 |
|
185 TUint32 featureData = KChangeData; |
|
186 err = ifeatureSet->SetFeature( KDefaultSupportedUid, 0, &featureData); |
|
187 CheckCondition(err==KErrNone,err==KErrNoMemory, |
|
188 _L("CFeatMgrFeatureRegistry::SetFeature failed: error = %d"),err); |
|
189 if (err==KErrNoMemory) |
|
190 { |
|
191 return TestStepResult(); |
|
192 } |
|
193 |
|
194 err = ifeatureSet->SetFeature(KUnknownUid, 0, &featureData); |
|
195 TESTDIAGNOSTICERROR(err==KErrNotFound, |
|
196 _L("CFeatMgrFeatureRegistry::SetFeature for an undefined feature failed: returned value is %d"),err); |
|
197 if (err==KErrNoMemory) |
|
198 { |
|
199 return TestStepResult(); |
|
200 } |
|
201 |
|
202 err = ifeatureSet->SetFeature(KDSR1Uid, 0, &featureData); |
|
203 TESTDIAGNOSTICERROR(err==KErrNotFound, |
|
204 _L("CFeatMgrFeatureRegistry::SetFeature for a feature from DSR failed: returned value is %d"),err); |
|
205 |
|
206 return TestStepResult(); |
|
207 } |
|
208 |
|
209 CServerReadRuntimeFeaturesTestStep::CServerReadRuntimeFeaturesTestStep() |
|
210 { |
|
211 SetTestStepName(KServerReadRuntimeFeaturesTest); |
|
212 } |
|
213 |
|
214 TVerdict CServerReadRuntimeFeaturesTestStep::doTestStepL() |
|
215 { |
|
216 TBool mybool; |
|
217 TRAPD(err, ifeatureSet->ReadRuntimeFeaturesL(mybool)); |
|
218 TESTDIAGNOSTICERROR(err==KErrNone, |
|
219 _L("CFeatMgrFeatureRegistry::ReadRuntimeFeaturesL is expected to return KErrNone: returned value is %d"), err); |
|
220 TESTDIAGNOSTICERROR(mybool, |
|
221 _L("CFeatMgrFeatureRegistry::ReadRuntimeFeaturesL, boolean should be true. Returned value is %d"), mybool); |
|
222 |
|
223 return TestStepResult(); |
|
224 } |
|
225 |
|
226 CServerMergePluginFeaturesTestStep::CServerMergePluginFeaturesTestStep() |
|
227 { |
|
228 SetTestStepName(KServerMergePluginFeaturesTest); |
|
229 } |
|
230 |
|
231 TVerdict CServerMergePluginFeaturesTestStep::doTestStepPreambleL() |
|
232 { |
|
233 // Get the required RFs handle and CFeatMgrFeatureRegistry object set up. |
|
234 CServerBaseTestStep::doTestStepPreambleL(); |
|
235 |
|
236 // Set up an RFeatureArray with 5 features. These uids are arbitrary. |
|
237 // We do this in the preamble because this test is expected to operate |
|
238 // under low memory conditions with the TEF '!OOM' option. We don't |
|
239 // want that interfering with the creation of the RFeatureArray object |
|
240 // necessary to the test. |
|
241 TBitFlags32 flags1(0); |
|
242 flags1.Set( EFeatureSupported ); |
|
243 flags1.Set( EFeatureModifiable ); |
|
244 TFeatureEntry newentry1(KMergeUid1, flags1, KDefaultData1 ); |
|
245 |
|
246 TBitFlags32 flags2(0); |
|
247 flags2.Set( EFeatureSupported ); |
|
248 flags2.Set( EFeatureBlackListed ); |
|
249 TFeatureEntry newentry2(KMergeUid2, flags2, KDefaultData1 ); |
|
250 |
|
251 TBitFlags32 flags3(0); |
|
252 flags3.Set( EFeatureSupported ); |
|
253 flags3.Set( EFeatureUpgradeable ); |
|
254 flags3.Set( EFeatureModifiable ); |
|
255 TFeatureEntry newentry3(KMergeUid3, flags3, KDefaultData1 ); |
|
256 |
|
257 TBitFlags32 flags4(0); |
|
258 flags4.Set( EFeatureSupported ); |
|
259 flags4.Set( EFeatureUpgradeable ); |
|
260 TFeatureEntry newentry4(KMergeUid4, flags4, KDefaultData1 ); |
|
261 |
|
262 TBitFlags32 flags5(0); |
|
263 flags5.Set( EFeatureSupported ); |
|
264 flags5.Set( EFeatureModifiable ); |
|
265 flags5.Set( EFeaturePersisted ); |
|
266 TFeatureEntry newentry5(KMergeUid5, flags5, KDefaultData1 ); |
|
267 |
|
268 CleanupClosePushL(irfa); |
|
269 irfa.AppendL(newentry1); |
|
270 irfa.AppendL(newentry2); |
|
271 irfa.AppendL(newentry3); |
|
272 irfa.AppendL(newentry4); |
|
273 irfa.AppendL(newentry5); |
|
274 |
|
275 return TestStepResult(); |
|
276 } |
|
277 |
|
278 TVerdict CServerMergePluginFeaturesTestStep::doTestStepPostambleL() |
|
279 { |
|
280 CleanupStack::PopAndDestroy(&irfa); |
|
281 CServerBaseTestStep::doTestStepPostambleL(); |
|
282 return TestStepResult(); |
|
283 } |
|
284 |
|
285 TVerdict CServerMergePluginFeaturesTestStep::doTestStepL() |
|
286 { |
|
287 // This is a void method, so we can't actually check directly if this worked |
|
288 ifeatureSet->MergePluginFeatures(irfa); |
|
289 |
|
290 // .. so get the supported features in this array and check |
|
291 RFeatureUidArray rf; |
|
292 CleanupClosePushL(rf); |
|
293 ifeatureSet->SupportedFeaturesL(rf); |
|
294 TInt nfeat = rf.Count(); |
|
295 CheckCondition(nfeat==5,nfeat==4, |
|
296 _L("CFeatMgrFeatureRegistry::SupportedFeaturesL expected to return an array of 5: returned value is %d"), nfeat); |
|
297 CleanupStack::PopAndDestroy(&rf); |
|
298 return TestStepResult(); |
|
299 } |
|
300 |
|
301 |
|
302 CServerMergePluginFeaturesTestStep2::CServerMergePluginFeaturesTestStep2() |
|
303 { |
|
304 SetTestStepName(KServerMergePluginFeaturesTest2); |
|
305 } |
|
306 |
|
307 TVerdict CServerMergePluginFeaturesTestStep2::doTestStepPreambleL() |
|
308 { |
|
309 // Get the required RFs handle and CFeatMgrFeatureRegistry object set up. |
|
310 CServerBaseTestStep::doTestStepPreambleL(); |
|
311 CleanupClosePushL(ifc); |
|
312 |
|
313 // Get values that are easy to bitwise OR into flags. |
|
314 TInt supported = (1 << EFeatureSupported); |
|
315 TInt upgradeable = (1 << EFeatureUpgradeable); |
|
316 TInt modifiable = (1 << EFeatureModifiable); |
|
317 TInt blacklisted = (1 << EFeatureBlackListed); |
|
318 // TInt uninitialized = (1 << EFeatureUninitialized); // not used. |
|
319 TInt persisted = (1 << EFeaturePersisted); |
|
320 |
|
321 // Set up an RFeatureArray with 5 features. These uids are arbitrary. |
|
322 // We do this in the preamble because this test is expected to operate |
|
323 // under low memory conditions with the TEF '!OOM' option. We don't |
|
324 // want that interfering with the creation of the RFeatureArray object |
|
325 // necessary to the test. |
|
326 FeatureInfoCommand::TFeature feature1; |
|
327 |
|
328 feature1.iFeatureID = KMergeUid1.iUid; |
|
329 feature1.iValue = supported | modifiable; |
|
330 |
|
331 FeatureInfoCommand::TFeature feature2; |
|
332 feature2.iFeatureID = KMergeUid2.iUid; |
|
333 feature2.iValue = supported | blacklisted; |
|
334 |
|
335 FeatureInfoCommand::TFeature feature3; |
|
336 feature3.iFeatureID = KMergeUid3.iUid; |
|
337 feature3.iValue = supported | upgradeable | modifiable; |
|
338 |
|
339 FeatureInfoCommand::TFeature feature4; |
|
340 feature4.iFeatureID = KMergeUid4.iUid; |
|
341 feature4.iValue = supported | upgradeable; |
|
342 |
|
343 FeatureInfoCommand::TFeature feature5; |
|
344 feature5.iFeatureID = KMergeUid5.iUid; |
|
345 feature5.iValue = supported | modifiable | persisted; |
|
346 |
|
347 ifc.AppendL(feature1); |
|
348 ifc.AppendL(feature2); |
|
349 ifc.AppendL(feature3); |
|
350 ifc.AppendL(feature4); |
|
351 ifc.AppendL(feature5); |
|
352 |
|
353 return TestStepResult(); |
|
354 } |
|
355 |
|
356 TVerdict CServerMergePluginFeaturesTestStep2::doTestStepPostambleL() |
|
357 { |
|
358 CleanupStack::PopAndDestroy(&ifc); |
|
359 CServerBaseTestStep::doTestStepPostambleL(); |
|
360 return TestStepResult(); |
|
361 } |
|
362 |
|
363 TVerdict CServerMergePluginFeaturesTestStep2::doTestStepL() |
|
364 { |
|
365 // This is a void method, so we can't actually check directly if this worked |
|
366 ifeatureSet->MergePluginFeatures(ifc); |
|
367 |
|
368 // .. so get the supported features in this array and check |
|
369 RFeatureUidArray rf; |
|
370 CleanupClosePushL(rf); |
|
371 ifeatureSet->SupportedFeaturesL(rf); |
|
372 TInt nfeat = rf.Count(); |
|
373 CheckCondition(nfeat==5, nfeat==4, |
|
374 _L("CFeatMgrFeatureRegistry::SupportedFeaturesL expected to return an array of 5: returned value is %d"), nfeat); |
|
375 CleanupStack::PopAndDestroy(&rf); |
|
376 return TestStepResult(); |
|
377 } |
|
378 |
|
379 |
|
380 CControlASTimer* CControlASTimer::NewL() |
|
381 { |
|
382 CControlASTimer* self = new(ELeave) CControlASTimer(); |
|
383 CleanupStack::PushL(self); |
|
384 self->ConstructL(); |
|
385 CleanupStack::Pop(self); |
|
386 return self; |
|
387 } |
|
388 |
|
389 CControlASTimer::CControlASTimer() : CTimer(EPriorityStandard) |
|
390 { |
|
391 } |
|
392 |
|
393 CControlASTimer::~CControlASTimer() |
|
394 { |
|
395 Cancel(); |
|
396 } |
|
397 |
|
398 void CControlASTimer::ConstructL() |
|
399 { |
|
400 CTimer::ConstructL(); |
|
401 CActiveScheduler::Add(this); |
|
402 } |
|
403 |
|
404 void CControlASTimer::Start() |
|
405 { |
|
406 After(1500000); |
|
407 CActiveScheduler::Start(); |
|
408 } |
|
409 |
|
410 void CControlASTimer::RunL() |
|
411 { |
|
412 CActiveScheduler::Stop(); |
|
413 } |
|
414 |
|
415 void CControlASTimer::DoCancel() |
|
416 { |
|
417 CTimer::DoCancel(); |
|
418 } |
|
419 |
|
420 CFeatmgrOomSWI::CFeatmgrOomSWI() : iIterations(1) |
|
421 { |
|
422 SetTestStepName(KFeatmgrOomSWI); |
|
423 } |
|
424 |
|
425 TVerdict CFeatmgrOomSWI::doTestStepPreambleL() |
|
426 { |
|
427 INFO_PRINTF2(_L("Iteration: %d START"), iIterations); |
|
428 |
|
429 CServerBaseTestStep::doTestStepPreambleL(); |
|
430 |
|
431 // Launching dummyswi.exe |
|
432 _LIT(KDummySWIPath, "dummyswi.exe"); |
|
433 TInt err = iSWIProcess.Create(KDummySWIPath, _L("1")); // 1 = install success |
|
434 TESTDIAGNOSTICERROR(err==KErrNone, |
|
435 _L("RProcess::Create expects KErrNone, returned value is = %d"),err); |
|
436 if( err==KErrNone ) |
|
437 { |
|
438 RApaLsSession ls; |
|
439 CApaCommandLine* cmdLine; |
|
440 User::LeaveIfError(ls.Connect()); |
|
441 CleanupClosePushL(ls); |
|
442 cmdLine = CApaCommandLine::NewLC(); |
|
443 cmdLine->SetExecutableNameL(KDummySWIPath); |
|
444 cmdLine->SetProcessEnvironmentL(iSWIProcess); |
|
445 iSWIProcess.Resume(); |
|
446 CleanupStack::PopAndDestroy(2); |
|
447 cmdLine = NULL; |
|
448 } |
|
449 |
|
450 // Install the Active Scheduler. We need this for the SWIListener Active Object on the server to |
|
451 // be able to subscribe to the P&S install property. |
|
452 iActivescheduler = new(ELeave) CActiveScheduler(); |
|
453 CActiveScheduler::Install(iActivescheduler); |
|
454 // Starts the Active Scheduler (after it is installed) and stops it after 1.5 seconds (the time |
|
455 // needed for DummySWI to reset the P&S install property to ESASwisStatusSuccess which indicates |
|
456 // a successful installation). |
|
457 iAsTimer = CControlASTimer::NewL(); |
|
458 |
|
459 // Delay to prepare the listener for SWI install P&S property |
|
460 User::After(1000000); |
|
461 |
|
462 // Get this process' ID |
|
463 RThread thread; |
|
464 RProcess thisprocess = RProcess(); |
|
465 TInt processId = TUint(thisprocess.Id()); |
|
466 |
|
467 err = ifeatureSet->SWIStart(processId); |
|
468 TESTDIAGNOSTICERROR(err==KErrNone, |
|
469 _L("CFeatMgrFeatureRegistry::SWIStart failed: error = %d"),err); |
|
470 |
|
471 return TestStepResult(); |
|
472 } |
|
473 |
|
474 TVerdict CFeatmgrOomSWI::doTestStepPostambleL() |
|
475 { |
|
476 INFO_PRINTF2(_L("Iteration: %d END"), iIterations); |
|
477 |
|
478 iSWIProcess.Close(); |
|
479 delete iAsTimer; |
|
480 iAsTimer = NULL; |
|
481 delete iActivescheduler; |
|
482 iActivescheduler = NULL; |
|
483 CServerBaseTestStep::doTestStepPostambleL(); |
|
484 ++iIterations; |
|
485 |
|
486 return TestStepResult(); |
|
487 } |
|
488 |
|
489 TVerdict CFeatmgrOomSWI::doTestStepL() |
|
490 { |
|
491 TInt err(KErrGeneral); |
|
492 |
|
493 // Get this process' ID |
|
494 RThread thread; |
|
495 RProcess thisprocess = RProcess(); |
|
496 TInt processId = TUint(thisprocess.Id()); |
|
497 |
|
498 TBitFlags32 flags( 0 ); |
|
499 flags.Set( EFeatureSupported); |
|
500 flags.Set( EFeatureModifiable ); |
|
501 |
|
502 // |
|
503 // Caching starts here |
|
504 // |
|
505 |
|
506 // Adding feature KNewUid1 |
|
507 // In the second iteration in OOM this fails with KErrNoMemory, meaning that KNewUid1 |
|
508 // could not be cached. |
|
509 TFeatureServerEntry entry1(KNewUid1,flags,KDefaultData1); |
|
510 err = ifeatureSet->AddFeature( entry1, processId ); |
|
511 TESTDIAGNOSTICERROR(err==KErrNone || err==KErrNoMemory, |
|
512 _L("CFeatMgrFeatureRegistry::AddFeature for KNewUid1 failed: error = %d"),err); |
|
513 |
|
514 // Adding feature KNewUid2 |
|
515 TFeatureServerEntry entry2(KNewUid2,flags,KDefaultData1); |
|
516 err = ifeatureSet->AddFeature( entry2, processId ); |
|
517 TESTDIAGNOSTICERROR(err==KErrNone || err==KErrNoMemory, |
|
518 _L("CFeatMgrFeatureRegistry::AddFeature for KNewUid2 failed: error = %d"),err); |
|
519 |
|
520 // Setting feature KNewUid1 |
|
521 TUint32 value = 2; |
|
522 TInt seterr = ifeatureSet->SetFeature( (TUid)KNewUid1, 1, &value, processId ); |
|
523 TESTDIAGNOSTICERROR(err==KErrNone || err==KErrNoMemory, |
|
524 _L("CFeatMgrFeatureRegistry::SetFeature - KErrNone or KErrNoMemory expected; error = %d"), seterr); |
|
525 |
|
526 // In the second iteration this returns KErrGeneral which means that an OOM error |
|
527 // occurred during caching. |
|
528 // In the third iteration it fails with KErrNoMemory because it failed to allocate |
|
529 // memory in the features list on the server for KNewUid1 and KNewUid2. |
|
530 err = ifeatureSet->SWIEnd(processId); |
|
531 TESTDIAGNOSTICERROR(err==KErrNone || err==KErrNoMemory, |
|
532 _L("CFeatMgrFeatureRegistry::SWIEnd failed: error = %d"),err); |
|
533 |
|
534 // |
|
535 // Committing is issued on the server after this point |
|
536 // |
|
537 |
|
538 // Starts the Active Scheduler which was installed in doTestStepPreambleL. |
|
539 // The Active Scheduler will be closed when the timer of iAsTimer expires and that |
|
540 // will prevent the thread from hanging. |
|
541 iAsTimer->Start(); |
|
542 |
|
543 // Deleting feature KNewUid1 |
|
544 // On both the second and third iterations this fails with KErrNotFound because |
|
545 // KNewUid1 was not successfully added to the features list on the server. |
|
546 TInt delerr = ifeatureSet->DeleteFeature( KNewUid1, processId ); |
|
547 TESTDIAGNOSTICERROR(delerr == KErrNone || delerr == KErrNotFound , |
|
548 _L("CFeatMgrFeatureRegistry::DeleteFeature for KNewUid1 - KErrNone or KErrNotFound expected; error = %d"), delerr); |
|
549 |
|
550 return TestStepResult(); |
|
551 } |
|
552 |
|
553 |
|
554 |