featuremgmt/featuremgr/test/rtest/src/t_fmgroom.cpp
branchRCL_3
changeset 8 fa9941cf3867
child 9 667e88a979d7
equal deleted inserted replaced
6:5ffdb8f2067f 8:fa9941cf3867
       
     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 <bautils.h>
       
    18 #include <featmgr.h>
       
    19 #include <featureuids.h>
       
    20 #include <featurecontrol.h>
       
    21 #include <featdiscovery.h>
       
    22 #include <featurenotifier.h>
       
    23 #include "../../../src/clientdll/featmgrresourcetester.h"
       
    24 
       
    25 using namespace NFeature;
       
    26 
       
    27 _LIT( KZOrgFeaturesFile, "Z:\\Private\\10205054\\features.dat" );
       
    28 #ifdef EXTENDED_FEATURE_MANAGER_TEST
       
    29 _LIT( KZFeaturesFile, "C:\\Private\\102836E5\\features.dat" );
       
    30 _LIT( KZFeaturesDir, "C:\\Private\\102836E5\\" );
       
    31 #else
       
    32 _LIT( KZFeaturesFile, "Z:\\Private\\10205054\\features.dat" );
       
    33 _LIT( KZFeaturesDir, "Z:\\Private\\10205054\\" );
       
    34 #endif // EXTENDED_FEATURE_MANAGER_TEST
       
    35 
       
    36 const TInt KInvalidFeatureId    = 90901671;
       
    37 const TUid KInvalidFeatureUid   = {KInvalidFeatureId};
       
    38 
       
    39 static TInt TheProcessHandleCount = 0;
       
    40 static TInt TheThreadHandleCount = 0;
       
    41 static TInt TheAllocatedCellsCount = 0;
       
    42 
       
    43 #ifdef EXTENDED_FEATURE_MANAGER_TEST
       
    44 static const TInt KBurstRate = 20;
       
    45 #endif
       
    46 
       
    47 enum TFeatMgrOomTestMode
       
    48     {
       
    49     EFeatMgrOomServerTestMode,
       
    50     EFeatMgrOomClientTestMode,
       
    51     };
       
    52 
       
    53 ///////////////////////////////////////////////////////////////////////////////////////
       
    54 
       
    55 static RTest TheTest(_L("t_fmgroom"));
       
    56 
       
    57 ///////////////////////////////////////////////////////////////////////////////////////
       
    58 
       
    59 //Deletes all created test files.
       
    60 void DestroyTestEnv()
       
    61     {
       
    62     }
       
    63 
       
    64 ///////////////////////////////////////////////////////////////////////////////////////
       
    65 ///////////////////////////////////////////////////////////////////////////////////////
       
    66 //Test macros and functions
       
    67 void Check1(TInt aValue, TInt aLine)
       
    68     {
       
    69     if(!aValue)
       
    70         {
       
    71         DestroyTestEnv();
       
    72         RDebug::Print(_L("*** Expression evaluated to false. Line %d\r\n"), aLine);
       
    73         TheTest(EFalse, aLine);
       
    74         }
       
    75     }
       
    76 void Check2(TInt aValue, TInt aExpected, TInt aLine)
       
    77     {
       
    78     if(aValue != aExpected)
       
    79         {
       
    80         DestroyTestEnv();
       
    81         RDebug::Print(_L("*** Expected: %d, got: %d. Line %d\r\n"), aExpected, aValue, aLine);
       
    82         TheTest(EFalse, aLine);
       
    83         }
       
    84     }
       
    85 #define TEST(arg) ::Check1((arg), __LINE__)
       
    86 #define TEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__)
       
    87 
       
    88 ///////////////////////////////////////////////////////////////////////////////////////
       
    89 
       
    90 static void MarkHandles()
       
    91     {
       
    92     RThread().HandleCount(TheProcessHandleCount, TheThreadHandleCount);
       
    93     }
       
    94 
       
    95 static void MarkAllocatedCells()
       
    96     {
       
    97     TheAllocatedCellsCount = User::CountAllocCells();
       
    98     }
       
    99 
       
   100 static void CheckAllocatedCells()
       
   101     {
       
   102     TInt allocatedCellsCount = User::CountAllocCells();
       
   103     TEST2(allocatedCellsCount, TheAllocatedCellsCount);
       
   104     }
       
   105 
       
   106 static void CheckHandles()
       
   107     {
       
   108     TInt endProcessHandleCount;
       
   109     TInt endThreadHandleCount;
       
   110     
       
   111     RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
       
   112 
       
   113     TEST2(TheProcessHandleCount, endProcessHandleCount);
       
   114     TEST2(TheThreadHandleCount, endThreadHandleCount);
       
   115     }
       
   116 
       
   117 static void OomPreStep(TInt aFailingAllocationNo, TFeatMgrOomTestMode aMode = EFeatMgrOomClientTestMode)
       
   118     {
       
   119     if(aMode == EFeatMgrOomClientTestMode)
       
   120         {
       
   121         MarkHandles();
       
   122         MarkAllocatedCells();
       
   123         __UHEAP_MARK;
       
   124         __UHEAP_SETBURSTFAIL(RAllocator::EBurstFailNext, aFailingAllocationNo, KBurstRate);
       
   125         }
       
   126     else
       
   127         {
       
   128         TFeatMgrResourceTester::Mark();
       
   129         TFeatMgrResourceTester::SetHeapFailure(RHeap::EBurstFailNext, aFailingAllocationNo);
       
   130         }
       
   131     }
       
   132 
       
   133 static void OomPostStep(TFeatMgrOomTestMode aMode = EFeatMgrOomClientTestMode)
       
   134     {
       
   135     if(aMode == EFeatMgrOomClientTestMode)
       
   136         {
       
   137         __UHEAP_RESET;
       
   138         __UHEAP_MARKEND;
       
   139         CheckAllocatedCells();
       
   140         CheckHandles();
       
   141         }
       
   142     else
       
   143         {
       
   144         TFeatMgrResourceTester::SetHeapFailure(RHeap::ENone, 0);
       
   145         TFeatMgrResourceTester::Check();
       
   146         }
       
   147     }
       
   148 
       
   149 ///////////////////////////////////////////////////////////////////////////////////////
       
   150 
       
   151 /**
       
   152 @SYMTestCaseID          PDS-EFM-CT-4068
       
   153 @SYMTestCaseDesc        Include test case 4069 too
       
   154 @SYMTestPriority        High
       
   155 @SYMTestActions         
       
   156 @SYMTestExpectedResults Test must not fail
       
   157 @SYMDEF                 DEF144262
       
   158 */
       
   159 void ControlOpenOomTest(TBool aUseConnect)
       
   160     {
       
   161     TInt err = KErrNoMemory;
       
   162     TInt failingAllocationNo = 0;
       
   163     RFeatureControl ctrl;
       
   164     TheTest.Printf(_L("Iteration:\r\n"));
       
   165     while(err == KErrNoMemory)
       
   166         {
       
   167         TheTest.Printf(_L(" %d"), ++failingAllocationNo);
       
   168         OomPreStep(failingAllocationNo);
       
   169         err = aUseConnect ? ctrl.Connect() : ctrl.Open();
       
   170         ctrl.Close();
       
   171         OomPostStep();
       
   172         }
       
   173     if(err != KErrNoMemory)
       
   174         {
       
   175         TEST2(err, KErrNone);   
       
   176         }
       
   177     TheTest.Printf(_L("\r\n===OOM test succeeded at heap failure rate of %d ===\r\n"), failingAllocationNo);
       
   178     }
       
   179 
       
   180 /**
       
   181 @SYMTestCaseID          PDS-EFM-CT-4070
       
   182 @SYMTestCaseDesc        Include test case 4071-4077 too
       
   183 @SYMTestPriority        High
       
   184 @SYMTestActions         
       
   185 @SYMTestExpectedResults Test must not fail
       
   186 @SYMDEF                 DEF144262
       
   187 */
       
   188 void ControlFeatureSupportedOomTest(TBool aUseUid, TBool aInvalidFeature, TFeatMgrOomTestMode aMode)
       
   189     {
       
   190     RFeatureControl ctrl;
       
   191     TInt err = ctrl.Open();
       
   192     TEST2(err, KErrNone);
       
   193     
       
   194     const TUid KFeatureUid(aInvalidFeature ? KInvalidFeatureUid : KConnectivity);
       
   195     TFeatureEntry fentry(KFeatureUid);
       
   196     
       
   197     err = KErrNoMemory;
       
   198     TInt failingAllocationNo = 0;
       
   199     TheTest.Printf(_L("Iteration:\r\n"));
       
   200     while(err == KErrNoMemory)
       
   201         {
       
   202         TheTest.Printf(_L(" %d"), ++failingAllocationNo);
       
   203         OomPreStep(failingAllocationNo, aMode);
       
   204         err = aUseUid ? ctrl.FeatureSupported(KFeatureUid) : ctrl.FeatureSupported(fentry);
       
   205         OomPostStep(aMode);
       
   206         }
       
   207     ctrl.Close();
       
   208     if(err != KErrNoMemory)
       
   209         {
       
   210         TEST2(err, aInvalidFeature ? KErrNotFound : KFeatureSupported);   
       
   211         }
       
   212     TheTest.Printf(_L("\r\n===OOM test succeeded at heap failure rate of %d ===\r\n"), failingAllocationNo);
       
   213     }
       
   214 
       
   215 /**
       
   216 @SYMTestCaseID          PDS-EFM-CT-4078
       
   217 @SYMTestCaseDesc        Include test case 4079 too
       
   218 @SYMTestPriority        High
       
   219 @SYMTestActions         
       
   220 @SYMTestExpectedResults Test must not fail
       
   221 @SYMDEF                 DEF144262
       
   222 */
       
   223 void ControlListSupportedFeaturesOomTest(TFeatMgrOomTestMode aMode)
       
   224     {
       
   225     RFeatureControl ctrl;
       
   226     TInt err = ctrl.Open();
       
   227     TEST2(err, KErrNone);
       
   228     
       
   229     err = KErrNoMemory;
       
   230     TInt failingAllocationNo = 0;
       
   231     TheTest.Printf(_L("Iteration:\r\n"));
       
   232     while(err == KErrNoMemory)
       
   233         {
       
   234         TheTest.Printf(_L(" %d"), ++failingAllocationNo);
       
   235         OomPreStep(failingAllocationNo, aMode);
       
   236         const TInt KGranularity = 1;
       
   237         RFeatureUidArray farray(KGranularity);
       
   238         err = ctrl.ListSupportedFeatures(farray);
       
   239         if(err != KErrNoMemory)
       
   240             {
       
   241             TEST2(err, KErrNone);
       
   242             TInt count = farray.Count();
       
   243             TheTest.Printf(_L("===Features count: %d\r\n"), count);
       
   244             TEST(count > 0);
       
   245             }
       
   246         farray.Close();
       
   247         OomPostStep(aMode);
       
   248         }
       
   249     ctrl.Close();
       
   250     TheTest.Printf(_L("\r\n===OOM test succeeded at heap failure rate of %d ===\r\n"), failingAllocationNo);
       
   251     }
       
   252 
       
   253 /**
       
   254 @SYMTestCaseID          PDS-EFM-CT-4080
       
   255 @SYMTestCaseDesc        Include test case 4081 too
       
   256 @SYMTestPriority        High
       
   257 @SYMTestActions         
       
   258 @SYMTestExpectedResults Test must not fail
       
   259 @SYMDEF                 DEF144262
       
   260 */
       
   261 void ControlFeaturesSupportedOomTest(TFeatMgrOomTestMode aMode)
       
   262     {
       
   263     RFeatureControl ctrl;
       
   264     TInt err = ctrl.Open();
       
   265     TEST2(err, KErrNone);
       
   266     RFeatureUidArray farray;
       
   267     err = ctrl.ListSupportedFeatures(farray);
       
   268     TEST2(err, KErrNone);
       
   269     
       
   270     err = KErrNoMemory;
       
   271     TInt failingAllocationNo = 0;
       
   272     TheTest.Printf(_L("Iteration:\r\n"));
       
   273     while(err == KErrNoMemory)
       
   274         {
       
   275         TheTest.Printf(_L(" %d"), ++failingAllocationNo);
       
   276         OomPreStep(failingAllocationNo, aMode);
       
   277         RFeatureArray farray2;
       
   278         err = KErrNone;
       
   279         for(TInt i=0;i<farray.Count() && err==KErrNone;++i)
       
   280             {
       
   281             err = farray2.Append(farray[i]); 
       
   282             }
       
   283         if(err == KErrNone)
       
   284             {
       
   285             err = ctrl.FeaturesSupported(farray2);
       
   286             }
       
   287         if(err != KErrNoMemory)
       
   288             {
       
   289             TEST2(err, KErrNone);
       
   290             TInt count = farray2.Count();
       
   291             TheTest.Printf(_L("===Features count: %d\r\n"), count);
       
   292             TEST(count > 0);
       
   293             }
       
   294         farray2.Close();
       
   295         OomPostStep(aMode);
       
   296         }
       
   297     farray.Close();
       
   298     ctrl.Close();
       
   299     TheTest.Printf(_L("\r\n===OOM test succeeded at heap failure rate of %d ===\r\n"), failingAllocationNo);
       
   300     }
       
   301 
       
   302 /**
       
   303 @SYMTestCaseID          PDS-EFM-CT-4082
       
   304 @SYMTestCaseDesc        Include test case 4083 too
       
   305 @SYMTestPriority        High
       
   306 @SYMTestActions         
       
   307 @SYMTestExpectedResults Test must not fail
       
   308 @SYMDEF                 DEF144262
       
   309 */
       
   310 void ControlAddFeatureOomTest(TFeatMgrOomTestMode aMode)
       
   311     {
       
   312     RFeatureControl ctrl;
       
   313     TInt err = ctrl.Open();
       
   314     TEST2(err, KErrNone);
       
   315 
       
   316     const TUid KNewFeatureUid = {0x7888ABCE}; 
       
   317     TBitFlags32 flags;
       
   318     flags.Set(EFeatureSupported);
       
   319     flags.Set(EFeatureModifiable);
       
   320     TFeatureEntry fentry(KNewFeatureUid, flags, 0x0);
       
   321     
       
   322     err = KErrNoMemory;
       
   323     TInt failingAllocationNo = 0;
       
   324     TheTest.Printf(_L("Iteration:\r\n"));
       
   325     while(err == KErrNoMemory)
       
   326         {
       
   327         TheTest.Printf(_L(" %d"), ++failingAllocationNo);
       
   328         OomPreStep(failingAllocationNo, aMode);
       
   329         err = ctrl.AddFeature(fentry);
       
   330         OomPostStep(aMode);
       
   331         if(err == KErrNoMemory)
       
   332             {
       
   333             err = ctrl.EnableFeature(fentry.FeatureUid());
       
   334             TEST2(err, KErrNotFound);
       
   335             }
       
   336         }
       
   337     TEST2(err, KErrNone);
       
   338     err = ctrl.DeleteFeature(fentry.FeatureUid());
       
   339     TEST2(err, KErrNone);
       
   340     
       
   341     ctrl.Close();
       
   342     TheTest.Printf(_L("\r\n===OOM test succeeded at heap failure rate of %d ===\r\n"), failingAllocationNo);
       
   343     }
       
   344 
       
   345 /**
       
   346 @SYMTestCaseID          PDS-EFM-CT-4084
       
   347 @SYMTestCaseDesc        Include test case 4085 too
       
   348 @SYMTestPriority        High
       
   349 @SYMTestActions         
       
   350 @SYMTestExpectedResults Test must not fail
       
   351 @SYMDEF                 DEF144262
       
   352 */
       
   353 void ControlDeleteFeatureOomTest(TFeatMgrOomTestMode aMode)
       
   354     {
       
   355     RFeatureControl ctrl;
       
   356     TInt err = ctrl.Open();
       
   357     TEST2(err, KErrNone);
       
   358 
       
   359     const TUid KNewFeatureUid = {0x7888ABCE}; 
       
   360     TBitFlags32 flags;
       
   361     flags.Set(EFeatureSupported);
       
   362     flags.Set(EFeatureModifiable);
       
   363     TFeatureEntry fentry(KNewFeatureUid, flags, 0x0);
       
   364     err = ctrl.AddFeature(fentry);
       
   365     TEST2(err, KErrNone);
       
   366     
       
   367     err = KErrNoMemory;
       
   368     TInt failingAllocationNo = 0;
       
   369     TheTest.Printf(_L("Iteration:\r\n"));
       
   370     while(err == KErrNoMemory)
       
   371         {
       
   372         TheTest.Printf(_L(" %d"), ++failingAllocationNo);
       
   373         OomPreStep(failingAllocationNo, aMode);
       
   374         err = ctrl.DeleteFeature(fentry.FeatureUid());
       
   375         OomPostStep(aMode);
       
   376         if(err == KErrNoMemory)
       
   377             {
       
   378             err = ctrl.EnableFeature(fentry.FeatureUid());
       
   379             TEST2(err, KErrNone);
       
   380             }
       
   381         }
       
   382     TEST2(err, KErrNone);
       
   383     
       
   384     ctrl.Close();
       
   385     TheTest.Printf(_L("\r\n===OOM test succeeded at heap failure rate of %d ===\r\n"), failingAllocationNo);
       
   386     }
       
   387 
       
   388 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
       
   389 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
       
   390 
       
   391 class TTestFeatureObserver : public MFeatureObserver
       
   392     {
       
   393     public: 
       
   394         virtual void HandleNotifyChange(TFeatureChangeType /*aType*/, TFeatureEntry /*aFeature*/)
       
   395             {
       
   396             }
       
   397         virtual void HandleNotifyError(TInt /*aError*/)
       
   398             {
       
   399             }
       
   400     };
       
   401 
       
   402 /**
       
   403 @SYMTestCaseID          PDS-EFM-CT-4086
       
   404 @SYMTestCaseDesc        Include test case 4087 too
       
   405 @SYMTestPriority        High
       
   406 @SYMTestActions         
       
   407 @SYMTestExpectedResults Test must not fail
       
   408 @SYMDEF                 DEF144262
       
   409 */
       
   410 void NotifierNewLOomTest(TFeatMgrOomTestMode aMode)
       
   411     {
       
   412     CActiveScheduler* scheduler = new CActiveScheduler;
       
   413     TEST(scheduler != NULL);
       
   414     CActiveScheduler::Install(scheduler);
       
   415     
       
   416     RFeatureControl ctrl;
       
   417     TInt err = ctrl.Open();
       
   418     TEST2(err, KErrNone);
       
   419     
       
   420     TTestFeatureObserver observer;
       
   421     err = KErrNoMemory;
       
   422     TInt failingAllocationNo = 0;
       
   423     TheTest.Printf(_L("Iteration:\r\n"));
       
   424     while(err == KErrNoMemory)
       
   425         {
       
   426         TheTest.Printf(_L(" %d"), ++failingAllocationNo);
       
   427         OomPreStep(failingAllocationNo, aMode);
       
   428         CFeatureNotifier* notifier = NULL;
       
   429         TRAP(err, notifier = CFeatureNotifier::NewL(observer));
       
   430         delete notifier;
       
   431         OomPostStep(aMode);
       
   432         }
       
   433     TEST2(err, KErrNone);
       
   434     ctrl.Close();
       
   435     delete scheduler;
       
   436     TheTest.Printf(_L("\r\n===OOM test succeeded at heap failure rate of %d ===\r\n"), failingAllocationNo);
       
   437     }
       
   438 
       
   439 /**
       
   440 @SYMTestCaseID          PDS-EFM-CT-4088
       
   441 @SYMTestCaseDesc        Include test case 4089-4091 too
       
   442 @SYMTestPriority        High
       
   443 @SYMTestActions         
       
   444 @SYMTestExpectedResults Test must not fail
       
   445 @SYMDEF                 DEF144262
       
   446 */
       
   447 void NotifierNotifyRequestOomTest(TBool aInvalidFeature, TFeatMgrOomTestMode aMode)
       
   448     {
       
   449     CActiveScheduler* scheduler = new CActiveScheduler;
       
   450     TEST(scheduler != NULL);
       
   451     CActiveScheduler::Install(scheduler);
       
   452     
       
   453     RFeatureControl ctrl;
       
   454     TInt err = ctrl.Open();
       
   455     TEST2(err, KErrNone);
       
   456     
       
   457     TTestFeatureObserver observer;
       
   458     CFeatureNotifier* notifier = NULL;
       
   459     TRAP(err, notifier = CFeatureNotifier::NewL(observer));
       
   460     TEST2(err, KErrNone);
       
   461 
       
   462     const TUid KFeatureUid(aInvalidFeature ? KInvalidFeatureUid : KConnectivity);
       
   463     
       
   464     err = KErrNoMemory;
       
   465     TInt failingAllocationNo = 0;
       
   466     TheTest.Printf(_L("Iteration:\r\n"));
       
   467     while(err == KErrNoMemory)
       
   468         {
       
   469         TheTest.Printf(_L(" %d"), ++failingAllocationNo);
       
   470         OomPreStep(failingAllocationNo, aMode);
       
   471         err = notifier->NotifyRequest(KFeatureUid);
       
   472         (void)notifier->NotifyCancelAll();
       
   473         OomPostStep(aMode);
       
   474         }
       
   475     TEST2(err, KErrNone);
       
   476     delete notifier;
       
   477     ctrl.Close();
       
   478     delete scheduler;
       
   479     TheTest.Printf(_L("\r\n===OOM test succeeded at heap failure rate of %d ===\r\n"), failingAllocationNo);
       
   480     }
       
   481 
       
   482 /**
       
   483 @SYMTestCaseID          PDS-EFM-CT-4092
       
   484 @SYMTestCaseDesc        Include test case 4093 too
       
   485 @SYMTestPriority        High
       
   486 @SYMTestActions         
       
   487 @SYMTestExpectedResults Test must not fail
       
   488 @SYMDEF                 DEF144262
       
   489 */
       
   490 void NotifierNotifyRequestsOomTest(TFeatMgrOomTestMode aMode)
       
   491     {
       
   492     CActiveScheduler* scheduler = new CActiveScheduler;
       
   493     TEST(scheduler != NULL);
       
   494     CActiveScheduler::Install(scheduler);
       
   495     
       
   496     RFeatureControl ctrl;
       
   497     TInt err = ctrl.Open();
       
   498     TEST2(err, KErrNone);
       
   499     
       
   500     TTestFeatureObserver observer;
       
   501     CFeatureNotifier* notifier = NULL;
       
   502     TRAP(err, notifier = CFeatureNotifier::NewL(observer));
       
   503     TEST2(err, KErrNone);
       
   504 
       
   505     RFeatureUidArray features;
       
   506     err = features.Append(KConnectivity);
       
   507     TEST2(err, KErrNone);
       
   508     err = features.Append(KFax);
       
   509     TEST2(err, KErrNone);
       
   510     err = features.Append(KConnectivity);
       
   511     TEST2(err, KErrNone);
       
   512     err = features.Append(KLocationManagement);
       
   513     TEST2(err, KErrNone);
       
   514     
       
   515     err = KErrNoMemory;
       
   516     TInt failingAllocationNo = 0;
       
   517     TheTest.Printf(_L("Iteration:\r\n"));
       
   518     while(err == KErrNoMemory)
       
   519         {
       
   520         TheTest.Printf(_L(" %d"), ++failingAllocationNo);
       
   521         OomPreStep(failingAllocationNo, aMode);
       
   522         err = notifier->NotifyRequest(features);
       
   523         (void)notifier->NotifyCancelAll();
       
   524         OomPostStep(aMode);
       
   525         }
       
   526     TEST2(err, KErrNone);
       
   527     features.Close();
       
   528     delete notifier;
       
   529     ctrl.Close();
       
   530     delete scheduler;
       
   531     TheTest.Printf(_L("\r\n===OOM test succeeded at heap failure rate of %d ===\r\n"), failingAllocationNo);
       
   532     }
       
   533 
       
   534 void PreTest()
       
   535     {
       
   536     // Connect session
       
   537     RFs fsSession;
       
   538     User::LeaveIfError(fsSession.Connect()); 
       
   539     
       
   540     TEntry entry;
       
   541     TInt err = fsSession.Entry(KZFeaturesDir, entry);
       
   542     if (err == KErrNotFound)
       
   543         {
       
   544         err = fsSession.MkDir(KZFeaturesDir);
       
   545         }
       
   546     TEST2 (err, KErrNone);
       
   547     err = BaflUtils::CopyFile(fsSession, KZOrgFeaturesFile, KZFeaturesDir);
       
   548     TEST2 (err, KErrNone);
       
   549     
       
   550     // close file server session
       
   551     fsSession.Close();
       
   552 
       
   553     }
       
   554 
       
   555 void PostTest()
       
   556     {
       
   557     // Connect session
       
   558     RFs fsSession;
       
   559     User::LeaveIfError(fsSession.Connect()); 
       
   560     
       
   561     TEntry entry;
       
   562     TInt err = fsSession.Entry(KZFeaturesDir, entry);
       
   563     if (err == KErrNone)
       
   564         {
       
   565         err = BaflUtils::DeleteFile(fsSession,KZFeaturesFile);
       
   566         TEST2 (err, KErrNone);
       
   567         
       
   568         }
       
   569     TEST2 (err, KErrNone);
       
   570     
       
   571     // close file server session
       
   572     fsSession.Close();
       
   573     }
       
   574 
       
   575 void DoTestsL()
       
   576     {
       
   577     
       
   578     TheTest.Start(_L("@SYMTestCaseID:PDS-EFM-CT-4068 RFeatureControl::Connect() OOM test"));
       
   579     PreTest();
       
   580     ControlOpenOomTest(ETrue);
       
   581     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4069 RFeatureControl::Open() OOM test"));
       
   582     ControlOpenOomTest(EFalse);
       
   583     
       
   584     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4070 RFeatureControl::FeatureSupported(UID) + valid feature, client side OOM test"));
       
   585     ControlFeatureSupportedOomTest(ETrue, EFalse, EFeatMgrOomClientTestMode);
       
   586     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4071 RFeatureControl::FeatureSupported(UID) + valid feature, server side OOM test"));
       
   587     ControlFeatureSupportedOomTest(ETrue, EFalse, EFeatMgrOomServerTestMode);
       
   588     
       
   589     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4072 RFeatureControl::FeatureSupported() + valid feature, client side OOM test"));
       
   590     ControlFeatureSupportedOomTest(EFalse, EFalse, EFeatMgrOomClientTestMode);
       
   591     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4073 RFeatureControl::FeatureSupported() + valid feature, server side OOM test"));
       
   592     ControlFeatureSupportedOomTest(EFalse, EFalse, EFeatMgrOomServerTestMode);
       
   593     
       
   594     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4074 RFeatureControl::FeatureSupported(UID) + invalid feature, client side OOM test"));
       
   595     ControlFeatureSupportedOomTest(ETrue, ETrue, EFeatMgrOomClientTestMode);
       
   596     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4075 RFeatureControl::FeatureSupported(UID) + invalid feature, server side OOM test"));
       
   597     ControlFeatureSupportedOomTest(ETrue, ETrue, EFeatMgrOomServerTestMode);
       
   598     
       
   599     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4076 RFeatureControl::FeatureSupported() + invalid feature, client side OOM OOM test"));
       
   600     ControlFeatureSupportedOomTest(EFalse, ETrue, EFeatMgrOomClientTestMode);
       
   601     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4077 RFeatureControl::FeatureSupported() + invalid feature, server side OOM OOM test"));
       
   602     ControlFeatureSupportedOomTest(EFalse, ETrue, EFeatMgrOomServerTestMode);
       
   603     
       
   604     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4078 RFeatureControl::ListSupportedFeatures(), client side OOM test"));
       
   605     ControlListSupportedFeaturesOomTest(EFeatMgrOomClientTestMode);
       
   606     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4079 RFeatureControl::ListSupportedFeatures(), server side OOM test"));
       
   607     ControlListSupportedFeaturesOomTest(EFeatMgrOomServerTestMode);
       
   608     
       
   609     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4080 RFeatureControl::FeaturesSupported(), client side OOM test"));
       
   610     ControlFeaturesSupportedOomTest(EFeatMgrOomClientTestMode);
       
   611     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4081 RFeatureControl::FeaturesSupported(),server side OOM test"));
       
   612     ControlFeaturesSupportedOomTest(EFeatMgrOomServerTestMode);
       
   613     
       
   614     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4082 RFeatureControl::AddFeature(), client side OOM test"));
       
   615     ControlAddFeatureOomTest(EFeatMgrOomClientTestMode);
       
   616     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4083 RFeatureControl::AddFeature(), server side OOM test"));
       
   617     ControlAddFeatureOomTest(EFeatMgrOomServerTestMode);
       
   618     
       
   619     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4084 RFeatureControl::DeleteFeature(), client side OOM test"));
       
   620     ControlDeleteFeatureOomTest(EFeatMgrOomClientTestMode);
       
   621     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4085 RFeatureControl::DeleteFeature(), server side OOM test"));
       
   622     ControlDeleteFeatureOomTest(EFeatMgrOomServerTestMode);
       
   623 
       
   624     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4086 CFeatureNotifier::NewL(), client side OOM test"));
       
   625     NotifierNewLOomTest(EFeatMgrOomClientTestMode);
       
   626     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4087 CFeatureNotifier::NewL(), server side OOM test"));
       
   627     NotifierNewLOomTest(EFeatMgrOomServerTestMode);
       
   628     
       
   629     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4088 CFeatureNotifier::NotifyRequest(), valid feature, client side OOM test"));
       
   630     NotifierNotifyRequestOomTest(ETrue, EFeatMgrOomClientTestMode);
       
   631     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4089 CFeatureNotifier::NotifyRequest(), valid feature, server side OOM test"));
       
   632     NotifierNotifyRequestOomTest(ETrue, EFeatMgrOomServerTestMode);
       
   633     
       
   634     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4090 CFeatureNotifier::NotifyRequest(), invalid feature, client side OOM test"));
       
   635     NotifierNotifyRequestOomTest(EFalse, EFeatMgrOomClientTestMode);
       
   636     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4091 CFeatureNotifier::NotifyRequest(), invalid feature, server side OOM test"));
       
   637     NotifierNotifyRequestOomTest(EFalse, EFeatMgrOomServerTestMode);
       
   638 
       
   639     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4092 CFeatureNotifier::NotifyRequest(<array>), valid feature, client side OOM test"));
       
   640     NotifierNotifyRequestsOomTest(EFeatMgrOomClientTestMode);
       
   641     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4093 CFeatureNotifier::NotifyRequest(<array>), valid feature, server side OOM test"));
       
   642     NotifierNotifyRequestsOomTest(EFeatMgrOomServerTestMode);
       
   643     
       
   644     PostTest();
       
   645     }
       
   646 
       
   647 TInt E32Main()
       
   648     {
       
   649     TheTest.Title();
       
   650     
       
   651     CTrapCleanup* tc = CTrapCleanup::New();
       
   652     TheTest(tc != NULL);
       
   653     
       
   654     __UHEAP_MARK;
       
   655     
       
   656     TRAPD(err, DoTestsL());
       
   657     DestroyTestEnv();
       
   658     TEST2(err, KErrNone);
       
   659 
       
   660     __UHEAP_MARKEND;
       
   661     
       
   662     TheTest.End();
       
   663     TheTest.Close();
       
   664     
       
   665     delete tc;
       
   666 
       
   667     User::Heap().Check();
       
   668     return KErrNone;
       
   669     }