keepalive/flextimer/test/testflextimer/src/testflextimer.cpp
branchRCL_3
changeset 58 83ca720e2b9a
parent 57 05bc53fe583b
child 62 bb1f80fb7db2
equal deleted inserted replaced
57:05bc53fe583b 58:83ca720e2b9a
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 * 
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include <StifTestInterface.h>
       
    20 #include "TestFlexTimer.h"
       
    21 #include "SettingServerClient.h"
       
    22 #include "testflexperiodic.h"
       
    23 #include "testcflextimer.h"
       
    24 #include "testrflextimer.h"
       
    25 #include "rflextimerservermonitor.h"
       
    26 
       
    27 // EXTERNAL DATA STRUCTURES
       
    28 //extern  ?external_data;
       
    29 
       
    30 // EXTERNAL FUNCTION PROTOTYPES  
       
    31 //extern ?external_function( ?arg_type,?arg_type );
       
    32 
       
    33 // CONSTANTS
       
    34 //const ?type ?constant_var = ?constant;
       
    35 
       
    36 // MACROS
       
    37 //#define ?macro ?macro_def
       
    38 
       
    39 // LOCAL CONSTANTS AND MACROS
       
    40 //const ?type ?constant_var = ?constant;
       
    41 //#define ?macro_name ?macro_def
       
    42 
       
    43 // MODULE DATA STRUCTURES
       
    44 //enum ?declaration
       
    45 //typedef ?declaration
       
    46 
       
    47 // LOCAL FUNCTION PROTOTYPES
       
    48 //?type ?function_name( ?arg_type, ?arg_type );
       
    49 
       
    50 // FORWARD DECLARATIONS
       
    51 //class ?FORWARD_CLASSNAME;
       
    52 
       
    53 // ============================= LOCAL FUNCTIONS ===============================
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // ?function_name ?description.
       
    57 // ?description
       
    58 // Returns: ?value_1: ?description
       
    59 //          ?value_n: ?description_line1
       
    60 //                    ?description_line2
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 /*
       
    64 ?type ?function_name(
       
    65     ?arg_type arg,  // ?description
       
    66     ?arg_type arg)  // ?description
       
    67     {
       
    68 
       
    69     ?code  // ?comment
       
    70 
       
    71     // ?comment
       
    72     ?code
       
    73     }
       
    74 */
       
    75 
       
    76 // ============================ MEMBER FUNCTIONS ===============================
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // CTestFlexTimer::CTestFlexTimer
       
    80 // C++ default constructor can NOT contain any code, that
       
    81 // might leave.
       
    82 // -----------------------------------------------------------------------------
       
    83 //
       
    84 CTestFlexTimer::CTestFlexTimer()
       
    85     {
       
    86 
       
    87     }
       
    88 
       
    89 // -----------------------------------------------------------------------------
       
    90 // CTestFlexTimer::ConstructL
       
    91 // Symbian 2nd phase constructor can leave.
       
    92 // Note: If OOM test case uses STIF Logger, then STIF Logger must be created
       
    93 // with static buffer size parameter (aStaticBufferSize). Otherwise Logger 
       
    94 // allocates memory from heap and therefore causes error situations with OOM 
       
    95 // testing. For more information about STIF Logger construction, see STIF Users 
       
    96 // Guide.
       
    97 // -----------------------------------------------------------------------------
       
    98 //
       
    99 void CTestFlexTimer::ConstructL()
       
   100     {
       
   101     //Read logger settings to check whether test case name is to be
       
   102     //appended to log file name.
       
   103     RSettingServer settingServer;
       
   104     TInt ret = settingServer.Connect();
       
   105     if(ret != KErrNone)
       
   106         {
       
   107         User::Leave(ret);
       
   108         }
       
   109     // Struct to StifLogger settigs.
       
   110     TLoggerSettings loggerSettings; 
       
   111     // Parse StifLogger defaults from STIF initialization file.
       
   112     ret = settingServer.GetLoggerSettings(loggerSettings);
       
   113     if(ret != KErrNone)
       
   114         {
       
   115         User::Leave(ret);
       
   116         } 
       
   117     // Close Setting server session
       
   118     settingServer.Close();
       
   119     iAddTestCaseTitleToLogName = loggerSettings.iAddTestCaseTitle;
       
   120 
       
   121     iStdLog = CStifLogger::NewL( KTestFlexTimerLogPath, 
       
   122                                  KTestFlexTimerLogFile);
       
   123     iLog = iStdLog;
       
   124     
       
   125     iVersionLogged = EFalse;
       
   126     }
       
   127 
       
   128 // -----------------------------------------------------------------------------
       
   129 // CTestFlexTimer::NewL
       
   130 // Two-phased constructor.
       
   131 // -----------------------------------------------------------------------------
       
   132 //
       
   133 CTestFlexTimer* CTestFlexTimer::NewL()
       
   134     {
       
   135     CTestFlexTimer* self = new (ELeave) CTestFlexTimer;
       
   136 
       
   137     CleanupStack::PushL( self );
       
   138     self->ConstructL();
       
   139     CleanupStack::Pop();
       
   140 
       
   141     return self;
       
   142 
       
   143     }
       
   144 
       
   145 // Destructor
       
   146 CTestFlexTimer::~CTestFlexTimer()
       
   147     { 
       
   148     iLog = NULL;
       
   149     delete iStdLog;
       
   150     iStdLog = NULL;
       
   151     delete iTCLog;
       
   152     iTCLog = NULL;
       
   153     }
       
   154 
       
   155 // -----------------------------------------------------------------------------
       
   156 // CTestFlexTimer::InitL
       
   157 // InitL is used to initialize the Test Module.
       
   158 // -----------------------------------------------------------------------------
       
   159 //
       
   160 TInt CTestFlexTimer::InitL( 
       
   161     TFileName& /*aIniFile*/, 
       
   162     TBool /*aFirstTime*/ )
       
   163     {
       
   164     return KErrNone;
       
   165 
       
   166     }
       
   167 
       
   168 // -----------------------------------------------------------------------------
       
   169 // CTestFlexTimer::CreateTitleLoggerL
       
   170 // Check for settings and create logger with test case title in file name.
       
   171 // -----------------------------------------------------------------------------
       
   172 //
       
   173 void CTestFlexTimer::CreateTitleLoggerL(void)
       
   174     {
       
   175     //Open new log file with test case title in file name
       
   176     if(iAddTestCaseTitleToLogName)
       
   177         {
       
   178         // Check if there is no test case logger already created.
       
   179         if(iTCLog) 
       
   180             { 
       
   181             delete iTCLog; 
       
   182             iTCLog = NULL; 
       
   183             } 
       
   184             
       
   185         TFileName logFileName;
       
   186         TName title;
       
   187         TestModuleIf().GetTestCaseTitleL(title);
       
   188         
       
   189         logFileName.Format(KTestFlexTimerLogFileWithTitle, &title);
       
   190 
       
   191         iTCLog = CStifLogger::NewL(KTestFlexTimerLogPath, 
       
   192                                  logFileName);
       
   193         iLog = iTCLog; 
       
   194         }
       
   195     }
       
   196 
       
   197 // -----------------------------------------------------------------------------
       
   198 // CTestFlexTimer::CreateStdLoggerL
       
   199 // Check for logger settings and create standard logger.
       
   200 // -----------------------------------------------------------------------------
       
   201 //
       
   202 void CTestFlexTimer::DeleteTitleLogger(void)
       
   203     {
       
   204     //Delete title logger
       
   205     if(iAddTestCaseTitleToLogName)
       
   206         {
       
   207         iLog = iStdLog;
       
   208         delete iTCLog;
       
   209         iTCLog = NULL;
       
   210         }
       
   211     }
       
   212 
       
   213 // -----------------------------------------------------------------------------
       
   214 // CTestFlexTimer::GetTestCasesL
       
   215 // GetTestCases is used to inquire test cases from the Test Module. Test
       
   216 // cases are stored to array of test cases. The Test Framework will be 
       
   217 // the owner of the data in the RPointerArray after GetTestCases return
       
   218 // and it does the memory deallocation. 
       
   219 // -----------------------------------------------------------------------------
       
   220 //
       
   221 TInt CTestFlexTimer::GetTestCasesL( 
       
   222     const TFileName& /*aConfig*/, 
       
   223     RPointerArray<TTestCaseInfo>& aTestCases )
       
   224     {
       
   225     // Loop through all test cases and create new
       
   226     // TTestCaseInfo items and append items to aTestCase array    
       
   227     for( TInt i = 0; Case(i).iMethod != NULL; i++ )
       
   228         {
       
   229         // Allocate new TTestCaseInfo from heap for a testcase definition.
       
   230         TTestCaseInfo* newCase = new( ELeave ) TTestCaseInfo();
       
   231     
       
   232         // PushL TTestCaseInfo to CleanupStack.    
       
   233         CleanupStack::PushL( newCase );
       
   234 
       
   235         // Set number for the testcase.
       
   236         // When the testcase is run, this comes as a parameter to RunTestCaseL.
       
   237         newCase->iCaseNumber = i;
       
   238 
       
   239         // Set title for the test case. This is shown in UI to user.
       
   240         newCase->iTitle.Copy( Case(i).iCaseName );
       
   241 
       
   242         // Append TTestCaseInfo to the testcase array. After appended 
       
   243         // successfully the TTestCaseInfo object is owned (and freed) 
       
   244         // by the TestServer. 
       
   245         User::LeaveIfError(aTestCases.Append ( newCase ) );
       
   246         
       
   247         // Pop TTestCaseInfo from the CleanupStack.
       
   248         CleanupStack::Pop( newCase );
       
   249         }
       
   250 
       
   251     return KErrNone;
       
   252     }
       
   253 
       
   254 // -----------------------------------------------------------------------------
       
   255 // CTestFlexTimer::RunTestCaseL
       
   256 // RunTestCaseL is used to run an individual test case specified 
       
   257 // by aTestCase. Test cases that can be run may be requested from 
       
   258 // Test Module by GetTestCases method before calling RunTestCase.
       
   259 // -----------------------------------------------------------------------------
       
   260 //
       
   261 TInt CTestFlexTimer::RunTestCaseL(
       
   262     const TInt aCaseNumber,
       
   263     const TFileName& /*aConfig*/,
       
   264     TTestResult& aResult )
       
   265     {
       
   266     SendTestModuleVersion();
       
   267 
       
   268     TInt execStatus = KErrNone;
       
   269 
       
   270     // Get the pointer to test case function
       
   271     TCaseInfo tmp = Case( aCaseNumber );
       
   272 
       
   273     _LIT( KLogInfo, "Starting testcase [%S]" );
       
   274     iLog->Log( KLogInfo, &tmp.iCaseName);
       
   275 
       
   276     // Check that case number was valid
       
   277     if ( tmp.iMethod != NULL )
       
   278         {
       
   279         //Open new log file with test case title in file name
       
   280         CreateTitleLoggerL();
       
   281     
       
   282         // Valid case was found, call it via function pointer
       
   283         iMethod = tmp.iMethod;        
       
   284 
       
   285         // Create and install an active scheduler for timers
       
   286         CActiveScheduler* scheduler = new (ELeave) CActiveScheduler;
       
   287         CleanupStack::PushL( scheduler );
       
   288         CActiveScheduler::Install( scheduler );
       
   289         //execStatus  = ( this->*iMethod )( aResult );
       
   290         TRAPD(err, execStatus  = ( *iMethod )( aResult, this ));
       
   291 
       
   292         CleanupStack::PopAndDestroy( scheduler );
       
   293 
       
   294         // Test case was executed
       
   295         DeleteTitleLogger();
       
   296 
       
   297         User::LeaveIfError(err);
       
   298         }
       
   299     else
       
   300         {
       
   301         // Valid case was not found, return error.
       
   302         execStatus = KErrNotFound;
       
   303         }
       
   304 
       
   305     // Return case execution status (not the result of the case execution)
       
   306     return execStatus;
       
   307     }
       
   308 
       
   309 // -----------------------------------------------------------------------------
       
   310 // CTestFlexTimer::OOMTestQueryL
       
   311 // Used to check if a particular test case should be run in OOM conditions and 
       
   312 // which memory allocations should fail.    
       
   313 //
       
   314 // NOTE: This method is virtual and must be implemented only if test case
       
   315 // should be executed using OOM conditions.  
       
   316 // -----------------------------------------------------------------------------
       
   317 //
       
   318 TBool CTestFlexTimer::OOMTestQueryL( 
       
   319                                 const TFileName& /* aTestCaseFile */, 
       
   320                                 const TInt /* aCaseNumber */, 
       
   321                                 TOOMFailureType& /* aFailureType */, 
       
   322                                 TInt& /* aFirstMemFailure */, 
       
   323                                 TInt& /* aLastMemFailure */ ) 
       
   324     {
       
   325     _LIT( KOOMTestQueryL, "CTestFlexTimer::OOMTestQueryL" );
       
   326     iLog->Log( KOOMTestQueryL ); 
       
   327 
       
   328     return EFalse;
       
   329     }
       
   330 
       
   331 // -----------------------------------------------------------------------------
       
   332 // CTestFlexTimer::OOMTestInitializeL
       
   333 // Used to perform the test environment setup for a particular OOM test case. 
       
   334 // Test Modules may use the initialization file to read parameters for Test 
       
   335 // Module initialization but they can also have their own configure file or 
       
   336 // some other routine to initialize themselves.  
       
   337 //
       
   338 // NOTE: This method is virtual and must be implemented only if test case
       
   339 // should be executed using OOM conditions.  
       
   340 // -----------------------------------------------------------------------------
       
   341 //
       
   342 void CTestFlexTimer::OOMTestInitializeL( 
       
   343                                 const TFileName& /* aTestCaseFile */, 
       
   344                                 const TInt /* aCaseNumber */ )
       
   345     {
       
   346     }
       
   347 
       
   348 // -----------------------------------------------------------------------------
       
   349 // CTestFlexTimer::OOMHandleWarningL
       
   350 // In some cases the heap memory allocation should be skipped, either due to
       
   351 // problems in the OS code or components used by the code being tested, or even 
       
   352 // inside the tested components which are implemented this way on purpose (by 
       
   353 // design), so it is important to give the tester a way to bypass allocation 
       
   354 // failures.
       
   355 //
       
   356 // NOTE: This method is virtual and must be implemented only if test case
       
   357 // should be executed using OOM conditions.  
       
   358 // -----------------------------------------------------------------------------
       
   359 //
       
   360 void CTestFlexTimer::OOMHandleWarningL( 
       
   361                                 const TFileName& /* aTestCaseFile */,
       
   362                                 const TInt /* aCaseNumber */, 
       
   363                                 TInt& /* aFailNextValue */ )
       
   364     {
       
   365     }
       
   366 
       
   367 // -----------------------------------------------------------------------------
       
   368 // CTestFlexTimer::OOMTestFinalizeL
       
   369 // Used to perform the test environment cleanup for a particular OOM test case.
       
   370 //
       
   371 // NOTE: This method is virtual and must be implemented only if test case
       
   372 // should be executed using OOM conditions.  
       
   373 // -----------------------------------------------------------------------------
       
   374 //                  
       
   375 void CTestFlexTimer::OOMTestFinalizeL( 
       
   376                                 const TFileName& /* aTestCaseFile */, 
       
   377                                 const TInt /* aCaseNumber */ )
       
   378     {
       
   379     }
       
   380 
       
   381 //-----------------------------------------------------------------------------
       
   382 // CTemplateScriptTestFlexTimer::SendTestModuleVersion
       
   383 // Method used to send version of test module
       
   384 //-----------------------------------------------------------------------------
       
   385 //
       
   386 void CTestFlexTimer::SendTestModuleVersion()
       
   387 	{
       
   388 	if(iVersionLogged)
       
   389 		{
       
   390 		return;
       
   391 		}
       
   392 	
       
   393 	TVersion moduleVersion;
       
   394 	moduleVersion.iMajor = TEST_MODULE_VERSION_MAJOR;
       
   395 	moduleVersion.iMinor = TEST_MODULE_VERSION_MINOR;
       
   396 	moduleVersion.iBuild = TEST_MODULE_VERSION_BUILD;
       
   397 	
       
   398 	TFileName moduleName;
       
   399 	moduleName = _L("TestFlexTimer.dll");
       
   400 
       
   401 	TBool newVersionOfMethod = ETrue;
       
   402 	TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod);
       
   403 	iVersionLogged = ETrue;
       
   404 	}
       
   405 
       
   406 // ---------------------------------------------------------------------------
       
   407 // This function contains an array of all available test cases 
       
   408 // i.e pair of case name and test function. If case specified by parameter
       
   409 // aCaseNumber is found from array, then that item is returned.
       
   410 //
       
   411 // The reason for this rather complicated function is to specify all the
       
   412 // test cases only in one place. It is not necessary to understand how
       
   413 // function pointers to class member functions works when adding new test
       
   414 // cases. See function body for instructions how to add new test case.
       
   415 // ---------------------------------------------------------------------------
       
   416 //
       
   417 const TCaseInfo CTestFlexTimer::Case( const TInt aCaseNumber ) const 
       
   418     {
       
   419     static TCaseInfoInternal const KCases[] =
       
   420         {
       
   421         // To add new test cases, add new items to this array
       
   422         
       
   423         // NOTE: When compiled to GCCE, there must be Classname::
       
   424         // declaration in front of the method name, e.g. 
       
   425         // CDemoModule::PrintTest. Otherwise the compiler
       
   426         // gives errors.
       
   427 
       
   428         // Start FlexTimer server monitoring
       
   429         ENTRY( "FlexTimerServer: Start crash monitoring", CTestFlexTimer::StartServerMonitoringL ),
       
   430 	    ENTRY( "FlexTimerClient: Change Priority: MuchMore", CTestFlexTimer::SetThreadPriorityMuchMore ),
       
   431         ENTRY( "FlexTimerClient: Change Priority: Normal", CTestFlexTimer::SetThreadPriorityNormal ),
       
   432 
       
   433         // CFlexPeriodic tests
       
   434         ENTRY( "CFlexPeriodic: Start one timer", CTestFlexPeriodic::StartOneTimerL ),
       
   435         ENTRY( "CFlexPeriodic: Start one timer with error CB", CTestFlexPeriodic::StartOneTimerWithErrorCbL ),
       
   436         ENTRY( "CFlexPeriodic: Restart timer in callback", CTestFlexPeriodic::CallbackRestartL ),
       
   437         ENTRY( "CFlexPeriodic: 32bit configure", CTestFlexPeriodic::ConfigureWindow32L ),
       
   438         ENTRY( "CFlexPeriodic: 64bit configure", CTestFlexPeriodic::ConfigureWindow64L ),
       
   439         ENTRY( "CFlexPeriodic: Mixed bit configure", CTestFlexPeriodic::ConfigureWindowMixL ),
       
   440         ENTRY( "CFlexPeriodic: Configure after start", CTestFlexPeriodic::ConfigureAfterStartL ),
       
   441         ENTRY( "CFlexPeriodic: Start timer twice", CTestFlexPeriodic::StartAfterStartL ),
       
   442         ENTRY( "CFlexPeriodic: Start timer in callback", CTestFlexPeriodic::StartInCallbackL ),
       
   443         ENTRY( "CFlexPeriodic: Start timer with negative delay (32 bit)", CTestFlexPeriodic::StartWithNegativeDelay32L ),
       
   444         ENTRY( "CFlexPeriodic: Start timer with zero interval (32 bit)", CTestFlexPeriodic::StartWithZeroInterval32L ),
       
   445         ENTRY( "CFlexPeriodic: Start timer with negative interval (32 bit)", CTestFlexPeriodic::StartWithNegativeInterval32L ),
       
   446         ENTRY( "CFlexPeriodic: Start timer with negative delay (64 bit)", CTestFlexPeriodic::StartWithNegativeDelay64L ),
       
   447         ENTRY( "CFlexPeriodic: Start timer with zero interval (64 bit)", CTestFlexPeriodic::StartWithZeroInterval64L ),
       
   448         ENTRY( "CFlexPeriodic: Start timer with negative interval (64 bit)", CTestFlexPeriodic::StartWithNegativeInterval64L ),
       
   449         ENTRY( "CFlexPeriodic: Configure timer with negative delay window (32 bit)", CTestFlexPeriodic::ConfigureWithNegativeDelayWindow32L ),
       
   450         ENTRY( "CFlexPeriodic: Configure timer with negative interval window (32 bit)", CTestFlexPeriodic::ConfigureWithNegativeIntervalWindow32L ),
       
   451         ENTRY( "CFlexPeriodic: Configure timer with negative delay window (64 bit)", CTestFlexPeriodic::ConfigureWithNegativeDelayWindow64L ),
       
   452         ENTRY( "CFlexPeriodic: Configure timer with negative interval window (64 bit)", CTestFlexPeriodic::ConfigureWithNegativeIntervalWindow64L ),
       
   453         ENTRY( "CFlexPeriodic: Start timer with min and max values", CTestFlexPeriodic::StartWithMinAndMaxL ),
       
   454         ENTRY( "CFlexPeriodic: Start timer with maximum delay (64 bit)", CTestFlexPeriodic::StartWithMaximumDelay64L ),
       
   455         ENTRY( "CFlexPeriodic: Start timer with maximum interval (64 bit)", CTestFlexPeriodic::StartWithMaximumInterval64L ),
       
   456         ENTRY( "CFlexPeriodic: Start timer NULL callback function (32 bit)", CTestFlexPeriodic::StartWithNullCallBack32L ),
       
   457         ENTRY( "CFlexPeriodic: Start timer NULL callback function (64 bit)", CTestFlexPeriodic::StartWithNullCallBack64L ),
       
   458         ENTRY( "CFlexPeriodic: Client crash", CTestFlexPeriodic::ClientCrashL ),
       
   459         //CFlexTimer tests
       
   460         ENTRY( "CFlexTimer: Create and destroy a timer - After", CTestCFlexTimer::CreateAndDestroyCFlexTimerL ),
       
   461         ENTRY( "CFlexTimer: Create and expire a timer - After", CTestCFlexTimer::CreateAndExpireCFlexTimerL ),
       
   462         ENTRY( "CFlexTimer: Create two timers and expire those - overlapping - After 32bit", CTestCFlexTimer::CreateAndExpireTwoOverlappingAfterTimersL ),
       
   463         ENTRY( "CFlexTimer: Create two timers and expire those - overlapping - After 64bit", CTestCFlexTimer::CreateAndExpireTwoOverlappingAfterTimers64L ),
       
   464         ENTRY( "CFlexTimer: Create two timers and expire those - non overlapping - After", CTestCFlexTimer::CreateAndExpireTwoNonOverlappingAfterTimersL ),
       
   465         ENTRY( "CFlexTimer: Create zillion timers and expire them at rapid sequence", CTestCFlexTimer::HumongousAmountOfTimeridelidilidousL ),
       
   466         ENTRY( "CFlexTimer: Create overlapping After and At timers and non-overlapping AtUTC", CTestCFlexTimer::CreateAndExpireThreeTimersL ),
       
   467         ENTRY( "CFlexTimer: Start and cancel timers", CTestCFlexTimer::NormalCancelL ),
       
   468         ENTRY( "CFlexTimer: Cancel timer that would have triggered another timer", CTestCFlexTimer::CancelTimerThatWouldHaveTriggeredAnotherTimerL ),
       
   469         ENTRY( "CFlexTimer: Configure 50 pct and 10 pct windows - overlap - 1", CTestCFlexTimer::ConfigureCTimerOverlap1L ),
       
   470         ENTRY( "CFlexTimer: Configure 50 pct and 10 pct windows - overlap - 2", CTestCFlexTimer::ConfigureCTimerOverlap2L ),
       
   471         ENTRY( "CFlexTimer: Configure 0 pct and 100 pct windows - overlap - 3", CTestCFlexTimer::ConfigureCTimerOverlap3L ),
       
   472         ENTRY( "CFlexTimer: Configure 0 pct and 10 pct windows - non-overlap - 1", CTestCFlexTimer::ConfigureCTimerNonOverlap1L ),
       
   473         ENTRY( "CFlexTimer: Configure 50 pct and 50 pct windows - non-overlap - 2", CTestCFlexTimer::ConfigureCTimerNonOverlap2L ),     
       
   474         ENTRY( "CFlexTimer: System Time Changes", CTestCFlexTimer::SystemTimeChangesL ),
       
   475         ENTRY( "CFlexTimer: Time zone changes", CTestCFlexTimer::TimeZoneChangesL ),
       
   476         ENTRY( "CFlexTimer: Dumbass parameters for CFlexTimer", CTestCFlexTimer::DumbAssParametersForCTimerL ),
       
   477         ENTRY( "CFlexTimer: 32bit After called with zero interval", CTestCFlexTimer::DumbAssParametersForCTimerZero32bitL ),
       
   478         ENTRY( "CFlexTimer: 64bit After called with zero interval", CTestCFlexTimer::DumbAssParametersForCTimerZero64bitL ),
       
   479         ENTRY( "CFlexTimer: 64bit After called with max interval", CTestCFlexTimer::DumbAssParametersForCTimer64MaxL ),
       
   480         ENTRY( "CFlexTimer: 64bit After called with three year interval", CTestCFlexTimer::DumbAssParametersForCTimer64ThreeYearsL ),
       
   481         ENTRY( "CFlexTimer: 64bit After called with one year interval", CTestCFlexTimer::DumbAssParametersForCTimer64OneYearL ),
       
   482         ENTRY( "CFlexTimer: After (32bit) called with negative value", CTestCFlexTimer::AfterWithNegativeValueL ),
       
   483         ENTRY( "CFlexTimer: At with current time", CTestCFlexTimer::AtWithCurrentTimeL ),
       
   484         ENTRY( "CFlexTimer: AtUTC with current time", CTestCFlexTimer::AtUTCWithCurrentTimeL ),
       
   485         ENTRY( "CFlexTimer: At with three year timer", CTestCFlexTimer::AtWithThreeYearsL ),
       
   486         ENTRY( "CFlexTimer: At with one year timer", CTestCFlexTimer::AtWithOneYearL ),
       
   487         ENTRY( "CFlexTimer: At() with time in the past", CTestCFlexTimer::AtWithTimeInThePastL ),
       
   488         ENTRY( "CFlexTimer: Cancel timer that is already expired", CTestCFlexTimer::CancelExpiredTimerL ),
       
   489         ENTRY( "CFlexTimer: Left side of the window is in the past", CTestCFlexTimer::ConfigureLeftSideInThePastL ),
       
   490         ENTRY( "CFlexTimer: Left side of the window is in the past", CTestCFlexTimer::ConfigureLeftSideInThePastWindowCheckL ),
       
   491         ENTRY( "CFlexTimer: Configure(32bit) called with negative window size", CTestCFlexTimer::ConfigureWithNegativeWindowSize32L ),
       
   492         ENTRY( "CFlexTimer: Configure(64bit) called with negative window size", CTestCFlexTimer::ConfigureWithNegativeWindowSize64L ),
       
   493         ENTRY( "CFlexTimer: Configure(32bit) called with max positive value", CTestCFlexTimer::ConfigureWithMaxWindow32L ),
       
   494         ENTRY( "CFlexTimer: Configure(64bit) called with three year value", CTestCFlexTimer::ConfigureWithThreeYearWindow64L ),
       
   495         ENTRY( "CFlexTimer: Configure(64bit) called with max positive value", CTestCFlexTimer::ConfigureWithMaxWindow64L ),
       
   496         ENTRY( "CFlexTimer: Configure called while timer is already in use", CTestCFlexTimer::ConfigureWhileTimerIsInUseL ),
       
   497         ENTRY( "CFlexTimer: Timer is started twise", CTestCFlexTimer::TimerIsStartedTwiceL ),
       
   498         ENTRY( "CFlexTimer: Two timers, while high CPU load.", CTestCFlexTimer::CpuLoadCreateAndExpireTwoOverlappingAfterTimersL ),
       
   499         ENTRY( "CFlexTimer: Many timers, while high CPU load.", CTestCFlexTimer::CpuLoadManyTimersL ),
       
   500         // RFlexTimer tests
       
   501         ENTRY( "RFlexTimer: Start timer with After (32 bit)", CTestRFlexTimer::ExpireAfter32L ),
       
   502         ENTRY( "RFlexTimer: Start timer with After (64 bit)", CTestRFlexTimer::ExpireAfter64L ),
       
   503         ENTRY( "RFlexTimer: Start timer with AfterTicks", CTestRFlexTimer::ExpireAfterTicksL ),
       
   504         ENTRY( "RFlexTimer: Start timer with At", CTestRFlexTimer::ExpireAtL ),
       
   505         ENTRY( "RFlexTimer: Start timer with AtUTC", CTestRFlexTimer::ExpireAtUtcL ),
       
   506         ENTRY( "RFlexTimer: Call After (32 bit) before Connect", CTestRFlexTimer::After32WithoutConnect ),
       
   507         ENTRY( "RFlexTimer: Call After (64 bit) before Connect", CTestRFlexTimer::After64WithoutConnect ),
       
   508         ENTRY( "RFlexTimer: Call AfterTicks before Connect", CTestRFlexTimer::AfterTicksWithoutConnect ),
       
   509         ENTRY( "RFlexTimer: Call At before Connect", CTestRFlexTimer::AtWithoutConnect ),
       
   510         ENTRY( "RFlexTimer: Call AtUTC before Connect", CTestRFlexTimer::AtUtcWithoutConnect ),
       
   511         ENTRY( "RFlexTimer: Call Configure (32 bit) before Connect", CTestRFlexTimer::Configure32WithoutConnect ),
       
   512         ENTRY( "RFlexTimer: Call Configure (64 bit) before Connect", CTestRFlexTimer::Configure64WithoutConnect ),
       
   513         ENTRY( "RFlexTimer: Call Cancel before Connect", CTestRFlexTimer::CancelWithoutConnect ),
       
   514         ENTRY( "RFlexTimer: Call After twice", CTestRFlexTimer::CallAfterTwiceL ),
       
   515         ENTRY( "RFlexTimer: Call AfterTicks twice", CTestRFlexTimer::CallAfterTicksTwiceL ),
       
   516         ENTRY( "RFlexTimer: Call At twice", CTestRFlexTimer::CallAtTwiceL ),
       
   517         ENTRY( "RFlexTimer: Call AtUTC twice", CTestRFlexTimer::CallAtUtcTwiceL ),
       
   518         ENTRY( "RFlexTimer: Call Connect twice", CTestRFlexTimer::CallConnectTwiceL ),
       
   519         ENTRY( "RFlexTimer: Reconnect to the server", CTestRFlexTimer::ReconnectL ),
       
   520         ENTRY( "RFlexTimer: Cancel before start", CTestRFlexTimer::CancelWithoutStart ),
       
   521         ENTRY( "RFlexTimer: Call AfterTicks with negative ticks", CTestRFlexTimer::NegativeTicksInAfterTicksL ),
       
   522         ENTRY( "RFlexTimer: Call AfterTicks with zero ticks", CTestRFlexTimer::ZeroTicksInAfterTicksL ),
       
   523         ENTRY( "RFlexTimer: Change time while AfterTicks running", CTestRFlexTimer::ChangeTimeWhileAfterTicksL ),
       
   524         ENTRY( "RFlexTimer: Test AfterTicks windows", CTestRFlexTimer::TestAfterTicksWindowL ),
       
   525         // High priority client tests
       
   526         ENTRY( "FlexTimerClient: Change Priority: MuchMore", CTestFlexTimer::SetThreadPriorityMuchMore ),
       
   527         ENTRY( "CFlexTimer: Two timers, while high CPU load.", CTestCFlexTimer::CpuLoadCreateAndExpireTwoOverlappingAfterTimersL ),
       
   528         ENTRY( "CFlexTimer: Many timers, while high CPU load.", CTestCFlexTimer::CpuLoadManyTimersL ),
       
   529         ENTRY( "FlexTimerClient: Change Priority: Normal", CTestFlexTimer::SetThreadPriorityNormal ),
       
   530         // FlexTimerServer tests
       
   531         ENTRY( "FlexTimerServer: Stop crash monitoring", CTestFlexTimer::StopServerMonitoringL ),
       
   532 
       
   533         ENTRY( "FlexTimerServer: Start second server", CTestFlexTimer::StartSecondServerL ),
       
   534         };
       
   535     
       
   536     // Verify that case number is valid
       
   537     if( (TUint) aCaseNumber >= sizeof( KCases ) / 
       
   538                                sizeof( TCaseInfoInternal ) )
       
   539         {
       
   540 
       
   541         // Invalid case, construct empty object
       
   542         TCaseInfo null( (const TText*) L"" );
       
   543         null.iMethod = NULL;
       
   544         null.iIsOOMTest = EFalse;
       
   545         null.iFirstMemoryAllocation = 0;
       
   546         null.iLastMemoryAllocation = 0;
       
   547         return null;
       
   548 
       
   549         } 
       
   550 
       
   551     // Construct TCaseInfo object and return it
       
   552     TCaseInfo tmp ( KCases[ aCaseNumber ].iCaseName );
       
   553     tmp.iMethod = KCases[ aCaseNumber ].iMethod;
       
   554     tmp.iIsOOMTest = KCases[ aCaseNumber ].iIsOOMTest;
       
   555     tmp.iFirstMemoryAllocation = KCases[ aCaseNumber ].iFirstMemoryAllocation;
       
   556     tmp.iLastMemoryAllocation = KCases[ aCaseNumber ].iLastMemoryAllocation;
       
   557     return tmp;
       
   558     }
       
   559 
       
   560 // ========== Server level test cases ==========
       
   561 
       
   562 // ---------------------------------------------------------------------------
       
   563 // TEST CASE: Start monitoring the FlexTimer server
       
   564 // ---------------------------------------------------------------------------
       
   565 TInt CTestFlexTimer::StartServerMonitoringL(
       
   566     TTestResult& aResult, 
       
   567     CTestFlexTimer* /* aCallback */ )
       
   568     {
       
   569     aResult.SetResult( KErrGeneral, _L("Test case leaved") );
       
   570 
       
   571     RFlexTimerServerMonitor monitor;
       
   572     User::LeaveIfError( monitor.Connect() );
       
   573     User::LeaveIfError( monitor.StartMonitoring() );
       
   574     monitor.Close();
       
   575 
       
   576     aResult.SetResult( KErrNone, _L("Test case passed") );
       
   577     
       
   578     return KErrNone;
       
   579     }
       
   580 
       
   581 // ---------------------------------------------------------------------------
       
   582 // TEST CASE: Stop monitoring the FlexTimer server and check has the server
       
   583 // crashded.
       
   584 // ---------------------------------------------------------------------------
       
   585 TInt CTestFlexTimer::StopServerMonitoringL(
       
   586     TTestResult& aResult, 
       
   587     CTestFlexTimer* /* aCallback */ )
       
   588     {
       
   589     aResult.SetResult( KErrGeneral, _L("Test case leaved") );
       
   590     
       
   591     RFlexTimerServerMonitor monitor;
       
   592     User::LeaveIfError( monitor.Connect() );
       
   593     
       
   594     TBool hasServerCrashed; 
       
   595     User::LeaveIfError( monitor.GetStatus( hasServerCrashed ) );
       
   596     
       
   597     User::LeaveIfError( monitor.StopMonitoring() );
       
   598     monitor.Close();
       
   599 
       
   600     // By default everything has gone ok 
       
   601     aResult.SetResult( KErrNone, _L("Test case passed") );
       
   602     if ( hasServerCrashed )
       
   603         {
       
   604         aResult.SetResult( 
       
   605             KErrGeneral,
       
   606             _L("Test case failed. FlexTimerServer has crashed.") );
       
   607         }
       
   608     
       
   609     return KErrNone;        
       
   610     }
       
   611 
       
   612 // ---------------------------------------------------------------------------
       
   613 // TEST CASE: Start second FlexTimerServer. Main purpose of this test case is 
       
   614 // to increase test coverage.
       
   615 // ---------------------------------------------------------------------------
       
   616 TInt CTestFlexTimer::StartSecondServerL(
       
   617     TTestResult& aResult, 
       
   618     CTestFlexTimer* /* aCallback */ )
       
   619     {
       
   620     __UHEAP_MARK;
       
   621 
       
   622     // Default result if anything leaves i.e. no analyze done.
       
   623     aResult.SetResult( KErrGeneral, _L("Test case leaved") );
       
   624 
       
   625     // Make sure that the server is up'n'running
       
   626     RFlexTimer timer;
       
   627     timer.Connect();
       
   628     timer.Close();
       
   629     
       
   630     // Open handle to the server process
       
   631     RProcess flexTimerServer;
       
   632     User::LeaveIfError( flexTimerServer.Create( 
       
   633             _L("FlexTimerServer.exe"), 
       
   634             _L(""), 
       
   635             EOwnerThread ) );
       
   636 
       
   637     // Kick the server runnin'
       
   638     flexTimerServer.Resume();
       
   639 
       
   640     // Wait until the server process has been started.
       
   641     TRequestStatus status;
       
   642     flexTimerServer.Rendezvous( status );
       
   643     User::WaitForRequest( status );
       
   644 
       
   645     // Kill the server - if it has been able to been created
       
   646     flexTimerServer.Kill( 0 );
       
   647     
       
   648     // Clean up
       
   649     flexTimerServer.Close();
       
   650 
       
   651     aResult.SetResult( KErrNone, _L("Test case passed") );
       
   652     
       
   653     __UHEAP_MARKEND;
       
   654 
       
   655     return KErrNone;
       
   656     }
       
   657 // ---------------------------------------------------------------------------
       
   658 // TEST CASE: This test case can be used to change client priority to 
       
   659 // EPriorityMuchMore.
       
   660 // ---------------------------------------------------------------------------
       
   661 TInt CTestFlexTimer::SetThreadPriorityMuchMore(
       
   662     TTestResult& aResult, 
       
   663     CTestFlexTimer* /* aCallback */ )
       
   664     {
       
   665     RThread thisThread;
       
   666     
       
   667     thisThread.SetPriority( EPriorityMuchMore );
       
   668 
       
   669     aResult.SetResult( KErrNone, _L("Test case passed") );
       
   670     return KErrNone;
       
   671     }
       
   672 // ---------------------------------------------------------------------------
       
   673 // TEST CASE: This test case can be used to change client priority to 
       
   674 // EPriorityMuchMore.
       
   675 // ---------------------------------------------------------------------------
       
   676 TInt CTestFlexTimer::SetThreadPriorityNormal(
       
   677     TTestResult& aResult, 
       
   678     CTestFlexTimer* /* aCallback */ )
       
   679     {
       
   680     RThread thisThread;
       
   681     
       
   682     thisThread.SetPriority( EPriorityNormal );
       
   683 
       
   684     aResult.SetResult( KErrNone, _L("Test case passed") );
       
   685     return KErrNone;
       
   686     }
       
   687 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   688 
       
   689 // -----------------------------------------------------------------------------
       
   690 // LibEntryL is a polymorphic Dll entry point
       
   691 // Returns: CTestModuleBase*: Pointer to Test Module object
       
   692 // -----------------------------------------------------------------------------
       
   693 //
       
   694 EXPORT_C CTestModuleBase* LibEntryL()
       
   695     {
       
   696     return CTestFlexTimer::NewL();
       
   697     }
       
   698 
       
   699 // -----------------------------------------------------------------------------
       
   700 // SetRequirements handles test module parameters(implements evolution
       
   701 // version 1 for test module's heap and stack sizes configuring).
       
   702 // Returns: TInt: Symbian error code.
       
   703 // -----------------------------------------------------------------------------
       
   704 //
       
   705 EXPORT_C TInt SetRequirements( CTestModuleParam*& /*aTestModuleParam*/, 
       
   706                                 TUint32& /*aParameterValid*/ )
       
   707     {
       
   708 
       
   709     /* --------------------------------- NOTE ---------------------------------
       
   710     USER PANICS occurs in test thread creation when:
       
   711     1) "The panic occurs when the value of the stack size is negative."
       
   712     2) "The panic occurs if the minimum heap size specified is less
       
   713        than KMinHeapSize".
       
   714        KMinHeapSize: "Functions that require a new heap to be allocated will
       
   715        either panic, or will reset the required heap size to this value if
       
   716        a smaller heap size is specified".
       
   717     3) "The panic occurs if the minimum heap size specified is greater than
       
   718        the maximum size to which the heap can grow".
       
   719     Other:
       
   720     1) Make sure that your hardware or Symbian OS is supporting given sizes.
       
   721        e.g. Hardware might support only sizes that are divisible by four.
       
   722     ------------------------------- NOTE end ------------------------------- */
       
   723 
       
   724     // Normally STIF uses default heap and stack sizes for test thread, see:
       
   725     // KTestThreadMinHeap, KTestThreadMinHeap and KStackSize.
       
   726     // If needed heap and stack sizes can be configured here by user. Remove
       
   727     // comments and define sizes.
       
   728 
       
   729 /*
       
   730     aParameterValid = KStifTestModuleParameterChanged;
       
   731 
       
   732     CTestModuleParamVer01* param = CTestModuleParamVer01::NewL();
       
   733     // Stack size
       
   734     param->iTestThreadStackSize= 16384; // 16K stack
       
   735     // Heap sizes
       
   736     param->iTestThreadMinHeap = 4096;   // 4K heap min
       
   737     param->iTestThreadMaxHeap = 1048576;// 1M heap max
       
   738 
       
   739     aTestModuleParam = param;
       
   740 */
       
   741     return KErrNone;
       
   742 
       
   743     }
       
   744 
       
   745 //  End of File