featuremgmt/featuremgr/test/rtest/src/t_fmgrstartup.cpp
branchRCL_3
changeset 24 cc28652e0254
parent 23 26645d81f48d
equal deleted inserted replaced
23:26645d81f48d 24:cc28652e0254
    24 
    24 
    25 #ifdef _DEBUG
    25 #ifdef _DEBUG
    26 static const TInt KBurstRate = 20;
    26 static const TInt KBurstRate = 20;
    27 #endif
    27 #endif
    28 
    28 
    29 void DestroyTestEnv();
       
    30 ///////////////////////////////////////////////////////////////////////////////////////
    29 ///////////////////////////////////////////////////////////////////////////////////////
    31 
    30 
    32 static RTest TheTest(_L("t_fmgrstartup"));
    31 static RTest TheTest(_L("t_fmgrstartup"));
    33 
    32 
    34 #ifdef EXTENDED_FEATURE_MANAGER_TEST
    33 #ifdef EXTENDED_FEATURE_MANAGER_TEST
    36 _LIT( KFeaturesFile, "C:\\Private\\102836E5\\features.dat" );
    35 _LIT( KFeaturesFile, "C:\\Private\\102836E5\\features.dat" );
    37 _LIT( KFeaturesDir, "C:\\Private\\102836E5\\" );
    36 _LIT( KFeaturesDir, "C:\\Private\\102836E5\\" );
    38 #endif
    37 #endif
    39 
    38 
    40 ///////////////////////////////////////////////////////////////////////////////////////
    39 ///////////////////////////////////////////////////////////////////////////////////////
    41 //Test macros and functions
       
    42 void Check1(TInt aValue, TInt aLine)
       
    43     {
       
    44     if(!aValue)
       
    45         {
       
    46         DestroyTestEnv();
       
    47         RDebug::Print(_L("*** Expression evaluated to false. Line %d\r\n"), aLine);
       
    48         TheTest(EFalse, aLine);
       
    49         }
       
    50     }
       
    51 void Check2(TInt aValue, TInt aExpected, TInt aLine)
       
    52     {
       
    53     if(aValue != aExpected)
       
    54         {
       
    55         DestroyTestEnv();
       
    56         RDebug::Print(_L("*** Expected: %d, got: %d. Line %d\r\n"), aExpected, aValue, aLine);
       
    57         TheTest(EFalse, aLine);
       
    58         }
       
    59     }
       
    60 #define TEST(arg) ::Check1((arg), __LINE__)
       
    61 #define TEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__)
       
    62 
       
    63 ///////////////////////////////////////////////////////////////////////////////////////
       
    64 void CreateTestEnv()
       
    65     {
       
    66     //KFeaturesDir is defined only if EXTENDED_FEATURE_MANAGER_TEST is defined     
       
    67 #ifdef EXTENDED_FEATURE_MANAGER_TEST    
       
    68     RFs fs;
       
    69     TInt err = fs.Connect();
       
    70     TEST2(err, KErrNone);
       
    71     
       
    72     err = fs.MkDir(KFeaturesDir);
       
    73     TEST (err == KErrNone || err == KErrAlreadyExists);
       
    74     
       
    75     (void)fs.Delete(KFeaturesFile);
       
    76     err = BaflUtils::CopyFile(fs, KZOrgFeaturesFile, KFeaturesDir);
       
    77     TEST2 (err, KErrNone);
       
    78     err = fs.SetAtt(KFeaturesFile, KEntryAttNormal, KEntryAttReadOnly);
       
    79     TEST2 (err, KErrNone);
       
    80     fs.Close();
       
    81 #endif
       
    82     }
       
    83 
    40 
    84 //Deletes all created test files.
    41 //Deletes all created test files.
    85 void DestroyTestEnv()
    42 void DestroyTestEnv()
    86     {
    43     {
    87     //KFeaturesDir is defined only if EXTENDED_FEATURE_MANAGER_TEST is defined     
    44     //KFeaturesDir is defined only if EXTENDED_FEATURE_MANAGER_TEST is defined     
    88 #ifdef EXTENDED_FEATURE_MANAGER_TEST
    45 #ifdef EXTENDED_FEATURE_MANAGER_TEST
    89     RFs fs;
    46     RFs fs;
    90     TInt err = fs.Connect();
    47     TInt err = fs.Connect();
    91     if(err == KErrNone)
    48     if(err == KErrNone)
    92         {
    49         {
    93         err = fs.Delete(KFeaturesFile);
    50         (void)fs.Delete(KFeaturesFile);
    94         if (err != KErrNone)
       
    95             {
       
    96             RDebug::Print(_L("Warning: Clean test enviroment failed with error %d"), err);
       
    97             }
       
    98         }
    51         }
    99     fs.Close();
    52     fs.Close();
   100 #endif        
    53 #endif        
   101     }
    54     }
       
    55 
       
    56 ///////////////////////////////////////////////////////////////////////////////////////
       
    57 ///////////////////////////////////////////////////////////////////////////////////////
       
    58 //Test macros and functions
       
    59 void Check1(TInt aValue, TInt aLine)
       
    60     {
       
    61     if(!aValue)
       
    62         {
       
    63         DestroyTestEnv();
       
    64         RDebug::Print(_L("*** Expression evaluated to false. Line %d\r\n"), aLine);
       
    65         TheTest(EFalse, aLine);
       
    66         }
       
    67     }
       
    68 void Check2(TInt aValue, TInt aExpected, TInt aLine)
       
    69     {
       
    70     if(aValue != aExpected)
       
    71         {
       
    72         DestroyTestEnv();
       
    73         RDebug::Print(_L("*** Expected: %d, got: %d. Line %d\r\n"), aExpected, aValue, aLine);
       
    74         TheTest(EFalse, aLine);
       
    75         }
       
    76     }
       
    77 #define TEST(arg) ::Check1((arg), __LINE__)
       
    78 #define TEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__)
       
    79 
   102 ///////////////////////////////////////////////////////////////////////////////////////
    80 ///////////////////////////////////////////////////////////////////////////////////////
   103 
    81 
   104 static void MarkHandles()
    82 static void MarkHandles()
   105     {
    83     {
   106     RThread().HandleCount(TheProcessHandleCount, TheThreadHandleCount);
    84     RThread().HandleCount(TheProcessHandleCount, TheThreadHandleCount);
   213         }
   191         }
   214     fs.Close();
   192     fs.Close();
   215     TheTest.Printf(_L("\r\n===File I/O error simulation test succeeded on iteration %d===\r\n"), cnt);
   193     TheTest.Printf(_L("\r\n===File I/O error simulation test succeeded on iteration %d===\r\n"), cnt);
   216     }
   194     }
   217 
   195 
       
   196 void CreateTestEnv()
       
   197     {
       
   198     //KFeaturesDir is defined only if EXTENDED_FEATURE_MANAGER_TEST is defined     
       
   199 #ifdef EXTENDED_FEATURE_MANAGER_TEST    
       
   200     RFs fs;
       
   201     TInt err = fs.Connect();
       
   202     TEST2(err, KErrNone);
       
   203     
       
   204     err = fs.MkDir(KFeaturesDir);
       
   205     TEST (err == KErrNone || err == KErrAlreadyExists);
       
   206     
       
   207     (void)fs.Delete(KFeaturesFile);
       
   208     err = BaflUtils::CopyFile(fs, KZOrgFeaturesFile, KFeaturesDir);
       
   209     TEST2 (err, KErrNone);
       
   210     
       
   211     fs.Close();
       
   212 #endif
       
   213     }
   218 
   214 
   219 void DoTestsL()
   215 void DoTestsL()
   220     {
   216     {
   221     CActiveScheduler* scheduler = new CActiveScheduler;
   217     CActiveScheduler* scheduler = new CActiveScheduler;
   222     TEST(scheduler != NULL);
   218     TEST(scheduler != NULL);