featuremgmt/featuremgr/test/rtest/src/t_fmgroom.cpp
changeset 17 55f2396f6d25
parent 15 3eacc0623088
child 55 44f437012c90
equal deleted inserted replaced
15:3eacc0623088 17:55f2396f6d25
     1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    22 #include <featurenotifier.h>
    22 #include <featurenotifier.h>
    23 #include "../../../src/clientdll/featmgrresourcetester.h"
    23 #include "../../../src/clientdll/featmgrresourcetester.h"
    24 
    24 
    25 using namespace NFeature;
    25 using namespace NFeature;
    26 
    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 
    27 
    36 const TInt KInvalidFeatureId    = 90901671;
    28 const TInt KInvalidFeatureId    = 90901671;
    37 const TUid KInvalidFeatureUid   = {KInvalidFeatureId};
    29 const TUid KInvalidFeatureUid   = {KInvalidFeatureId};
    38 
    30 
    39 static TInt TheProcessHandleCount = 0;
    31 static TInt TheProcessHandleCount = 0;
    40 static TInt TheThreadHandleCount = 0;
    32 static TInt TheThreadHandleCount = 0;
    41 static TInt TheAllocatedCellsCount = 0;
    33 static TInt TheAllocatedCellsCount = 0;
       
    34 
    42 #ifdef _DEBUG
    35 #ifdef _DEBUG
    43 static const TInt KBurstRate = 20;
    36 static const TInt KBurstRate = 20;
    44 #endif
    37 #endif
    45 
    38 
    46 enum TFeatMgrOomTestMode
    39 enum TFeatMgrOomTestMode
    51 
    44 
    52 ///////////////////////////////////////////////////////////////////////////////////////
    45 ///////////////////////////////////////////////////////////////////////////////////////
    53 
    46 
    54 static RTest TheTest(_L("t_fmgroom"));
    47 static RTest TheTest(_L("t_fmgroom"));
    55 
    48 
    56 ///////////////////////////////////////////////////////////////////////////////////////
    49 
    57 
       
    58 //Deletes all created test files.
       
    59 void DestroyTestEnv()
       
    60     {
       
    61     }
       
    62 
    50 
    63 ///////////////////////////////////////////////////////////////////////////////////////
    51 ///////////////////////////////////////////////////////////////////////////////////////
    64 ///////////////////////////////////////////////////////////////////////////////////////
    52 ///////////////////////////////////////////////////////////////////////////////////////
    65 //Test macros and functions
    53 //Test macros and functions
    66 void Check1(TInt aValue, TInt aLine)
    54 void Check1(TInt aValue, TInt aLine)
    67     {
    55     {
    68     if(!aValue)
    56     if(!aValue)
    69         {
    57         {
    70         DestroyTestEnv();
       
    71         RDebug::Print(_L("*** Expression evaluated to false. Line %d\r\n"), aLine);
    58         RDebug::Print(_L("*** Expression evaluated to false. Line %d\r\n"), aLine);
    72         TheTest(EFalse, aLine);
    59         TheTest(EFalse, aLine);
    73         }
    60         }
    74     }
    61     }
    75 void Check2(TInt aValue, TInt aExpected, TInt aLine)
    62 void Check2(TInt aValue, TInt aExpected, TInt aLine)
    76     {
    63     {
    77     if(aValue != aExpected)
    64     if(aValue != aExpected)
    78         {
    65         {
    79         DestroyTestEnv();
       
    80         RDebug::Print(_L("*** Expected: %d, got: %d. Line %d\r\n"), aExpected, aValue, aLine);
    66         RDebug::Print(_L("*** Expected: %d, got: %d. Line %d\r\n"), aExpected, aValue, aLine);
    81         TheTest(EFalse, aLine);
    67         TheTest(EFalse, aLine);
    82         }
    68         }
    83     }
    69     }
    84 #define TEST(arg) ::Check1((arg), __LINE__)
    70 #define TEST(arg) ::Check1((arg), __LINE__)
   313     TEST2(err, KErrNone);
   299     TEST2(err, KErrNone);
   314 
   300 
   315     const TUid KNewFeatureUid = {0x7888ABCE}; 
   301     const TUid KNewFeatureUid = {0x7888ABCE}; 
   316     TBitFlags32 flags;
   302     TBitFlags32 flags;
   317     flags.Set(EFeatureSupported);
   303     flags.Set(EFeatureSupported);
   318     flags.Set(EFeatureModifiable);
   304     flags.Set(EFeatureModifiable);    
       
   305     flags.Set(EFeaturePersisted);
   319     TFeatureEntry fentry(KNewFeatureUid, flags, 0x0);
   306     TFeatureEntry fentry(KNewFeatureUid, flags, 0x0);
   320     
   307     
   321     err = KErrNoMemory;
   308     err = KErrNoMemory;
   322     TInt failingAllocationNo = 0;
   309     TInt failingAllocationNo = 0;
   323     TheTest.Printf(_L("Iteration:\r\n"));
   310     TheTest.Printf(_L("Iteration:\r\n"));
   528     ctrl.Close();
   515     ctrl.Close();
   529     delete scheduler;
   516     delete scheduler;
   530     TheTest.Printf(_L("\r\n===OOM test succeeded at heap failure rate of %d ===\r\n"), failingAllocationNo);
   517     TheTest.Printf(_L("\r\n===OOM test succeeded at heap failure rate of %d ===\r\n"), failingAllocationNo);
   531     }
   518     }
   532 
   519 
   533 void PreTest()
   520 
   534     {
       
   535     // Connect session
       
   536     RFs fsSession;
       
   537     User::LeaveIfError(fsSession.Connect()); 
       
   538     
       
   539     TEntry entry;
       
   540     TInt err = fsSession.Entry(KZFeaturesDir, entry);
       
   541     if (err == KErrNotFound)
       
   542         {
       
   543         err = fsSession.MkDir(KZFeaturesDir);
       
   544         }
       
   545     TEST2 (err, KErrNone);
       
   546     err = BaflUtils::CopyFile(fsSession, KZOrgFeaturesFile, KZFeaturesDir);
       
   547     TEST2 (err, KErrNone);
       
   548     
       
   549     // close file server session
       
   550     fsSession.Close();
       
   551 
       
   552     }
       
   553 
       
   554 void PostTest()
       
   555     {
       
   556     // Connect session
       
   557     RFs fsSession;
       
   558     User::LeaveIfError(fsSession.Connect()); 
       
   559     
       
   560     TEntry entry;
       
   561     TInt err = fsSession.Entry(KZFeaturesDir, entry);
       
   562     if (err == KErrNone)
       
   563         {
       
   564         err = BaflUtils::DeleteFile(fsSession,KZFeaturesFile);
       
   565         TEST2 (err, KErrNone);
       
   566         
       
   567         }
       
   568     TEST2 (err, KErrNone);
       
   569     
       
   570     // close file server session
       
   571     fsSession.Close();
       
   572     }
       
   573 
   521 
   574 void DoTestsL()
   522 void DoTestsL()
   575     {
   523     {
   576     
       
   577     TheTest.Start(_L("@SYMTestCaseID:PDS-EFM-CT-4068 RFeatureControl::Connect() OOM test"));
   524     TheTest.Start(_L("@SYMTestCaseID:PDS-EFM-CT-4068 RFeatureControl::Connect() OOM test"));
   578     PreTest();
       
   579     ControlOpenOomTest(ETrue);
   525     ControlOpenOomTest(ETrue);
   580     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4069 RFeatureControl::Open() OOM test"));
   526     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4069 RFeatureControl::Open() OOM test"));
   581     ControlOpenOomTest(EFalse);
   527     ControlOpenOomTest(EFalse);
   582     
   528     
   583     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4070 RFeatureControl::FeatureSupported(UID) + valid feature, client side OOM test"));
   529     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4070 RFeatureControl::FeatureSupported(UID) + valid feature, client side OOM test"));
   637 
   583 
   638     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4092 CFeatureNotifier::NotifyRequest(<array>), valid feature, client side OOM test"));
   584     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4092 CFeatureNotifier::NotifyRequest(<array>), valid feature, client side OOM test"));
   639     NotifierNotifyRequestsOomTest(EFeatMgrOomClientTestMode);
   585     NotifierNotifyRequestsOomTest(EFeatMgrOomClientTestMode);
   640     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4093 CFeatureNotifier::NotifyRequest(<array>), valid feature, server side OOM test"));
   586     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4093 CFeatureNotifier::NotifyRequest(<array>), valid feature, server side OOM test"));
   641     NotifierNotifyRequestsOomTest(EFeatMgrOomServerTestMode);
   587     NotifierNotifyRequestsOomTest(EFeatMgrOomServerTestMode);
   642     
       
   643     PostTest();
       
   644     }
   588     }
   645 
   589 
   646 TInt E32Main()
   590 TInt E32Main()
   647     {
   591     {
   648     TheTest.Title();
   592     TheTest.Title();
   651     TheTest(tc != NULL);
   595     TheTest(tc != NULL);
   652     
   596     
   653     __UHEAP_MARK;
   597     __UHEAP_MARK;
   654     
   598     
   655     TRAPD(err, DoTestsL());
   599     TRAPD(err, DoTestsL());
   656     DestroyTestEnv();
       
   657     TEST2(err, KErrNone);
   600     TEST2(err, KErrNone);
   658 
   601 
   659     __UHEAP_MARKEND;
   602     __UHEAP_MARKEND;
   660     
   603     
   661     TheTest.End();
   604     TheTest.End();