keepalive/flextimer/test/testflextimer/inc/testcflextimer.h
changeset 32 5c4486441ae6
equal deleted inserted replaced
31:c16e04725da3 32:5c4486441ae6
       
     1 /*
       
     2  * ============================================================================
       
     3  *  Name        : testflexperiodic.h
       
     4  *  Part of     : src / testflextimer
       
     5  *  Description : STIF test cases for CFlexPeriodic timer.
       
     6  *  Version     : %version: 1 %
       
     7  *
       
     8  *  Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     9  *  All rights reserved.
       
    10  *  This component and the accompanying materials are made available
       
    11  *  under the terms of the License "Eclipse Public License v1.0"
       
    12  *  which accompanies this distribution, and is available
       
    13  *  at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
    14  *
       
    15  *  Initial Contributors:
       
    16  *  Nokia Corporation - initial contribution.
       
    17  *
       
    18  *  Contributors:
       
    19  *  Nokia Corporation
       
    20  * ============================================================================
       
    21  * Template version: 4.2
       
    22  */
       
    23 
       
    24 #ifndef TESTCFLEXTIMER_H
       
    25 #define TESTCFLEXTIMER_H
       
    26 
       
    27 #include <e32base.h>
       
    28 #include "testflextimer.h"
       
    29 #include "inheritedcflextimer2.h"
       
    30 // FORWARD DECLARATIONS
       
    31 class CTestFlexTimer;
       
    32 
       
    33 class TTimerStruct
       
    34     {
       
    35 public:
       
    36     CInheritedCFlexTimer2 *iTimer;
       
    37     TExtendedTestResult *iEResult;
       
    38     TInt iTimersRunning; //For quick check that how many timers are currently running
       
    39     TInt iCurrentlyActive; // Stupid as hell, but won't do another container
       
    40     // This is only valid in first item and tells which item
       
    41     // e.g CB belongs to.
       
    42     CPeriodic *iStartTimer; // Same but this is start timer pointer.
       
    43     TTimerStruct() :
       
    44         iTimer(0), iEResult(0), iTimersRunning(0), iCurrentlyActive(0),
       
    45                 iStartTimer(0)
       
    46         {
       
    47         }
       
    48     ;
       
    49     };
       
    50 
       
    51 /**
       
    52  *  STIF test cases for CFlexTimer class.
       
    53  *  This class implements test cases for testing CFlexTimer class.
       
    54  *
       
    55  *  @since TB10.1
       
    56  */
       
    57 NONSHARABLE_CLASS( CTestCFlexTimer ) : public CBase
       
    58     {
       
    59 
       
    60 public:
       
    61 
       
    62     /**
       
    63      * Destructor.
       
    64      */
       
    65     virtual ~CTestCFlexTimer();
       
    66 
       
    67     // Creating and firing timers - normal cases
       
    68 
       
    69     /**
       
    70      * @brief Create and destroy a timer - After
       
    71      * 
       
    72      * Test that timer can be instantiated and deleted.<BR><BR>
       
    73      * - Use class that is inherited from CFlexTimer.<BR>
       
    74      * - Create, start and delete timer.
       
    75      * 
       
    76      * @param aResult Result of the test for the FW.
       
    77      * @return The status of execution of the test. KErrNone if the test
       
    78      *         was executed ok, any system wide errorcode otherwise.
       
    79      */
       
    80     static TInt CreateAndDestroyCFlexTimerL( TTestResult& aResult,
       
    81             CTestFlexTimer *cb );
       
    82 
       
    83     /**
       
    84      * @brief Create and expire a timer - After
       
    85      * 
       
    86      * Test that timer expires at it's max time <BR><BR>
       
    87      * - Use class that is inherited from CFlexTimer.<BR>
       
    88      * - See that timeout is happening at latest possible moment.
       
    89      * 
       
    90      * @param aResult Result of the test for the FW.
       
    91      * @return The status of execution of the test. KErrNone if the test
       
    92      *         was executed ok, any system wide errorcode otherwise.
       
    93      */
       
    94     static TInt CreateAndExpireCFlexTimerL( TTestResult& aResult,
       
    95             CTestFlexTimer *cb );
       
    96 
       
    97     /**
       
    98      * @brief Create two timers and expire those - overlapping - After 32bit
       
    99      * 
       
   100      * Test that two overlapping timers are fired at latest possible moment<BR><BR>
       
   101      * - Use class that is inherited from CFlexTimer.<BR>
       
   102      * - Use overlapping time windows. (default window).<BR>
       
   103      * - See that both timers expire when first timer expires.<BR>
       
   104      * - Use 32bit After()
       
   105      * 
       
   106      * @param aResult Result of the test for the FW.
       
   107      * @return The status of execution of the test. KErrNone if the test
       
   108      *         was executed ok, any system wide errorcode otherwise.
       
   109      */
       
   110     static TInt CreateAndExpireTwoOverlappingAfterTimersL(
       
   111             TTestResult& aResult, CTestFlexTimer *cb );
       
   112 
       
   113     /**
       
   114      * @brief Create two timers and expire those - overlapping - After 64bit
       
   115      * 
       
   116      * Test that two overlapping timers are fired at latest possible moment<BR><BR>
       
   117      * - Use class that is inherited from CFlexTimer.<BR>
       
   118      * - Use overlapping time windows. (default window).<BR>
       
   119      * - See that both timers expire when first timer expires.<BR>
       
   120      * - use 64bit After().
       
   121      * 
       
   122      * @param TBD
       
   123      * @return The status of execution of the test. KErrNone if the test
       
   124      *         was executed ok, any system wide errorcode otherwise.
       
   125      */
       
   126     static TInt CreateAndExpireTwoOverlappingAfterTimers64L(
       
   127             TTestResult& aResult, CTestFlexTimer *cb );
       
   128 
       
   129     /**
       
   130      * @brief Create two timers and expire those - not overlapping - After
       
   131      * 
       
   132      * Test that two timer that are not overlapping are fired at their own max time.<BR><BR>
       
   133      * - Use class that is inherited from CFlexTimer.<BR>
       
   134      * - Use non-overlapping time windows. (default window).<BR>
       
   135      * - See that both timers expire at latest possible moment.<BR>
       
   136      * 
       
   137      * @param TBD
       
   138      * @return The status of execution of the test. KErrNone if the test
       
   139      *         was executed ok, any system wide errorcode otherwise.
       
   140      */
       
   141     static TInt CreateAndExpireTwoNonOverlappingAfterTimersL(
       
   142             TTestResult& aResult, CTestFlexTimer *cb );
       
   143 
       
   144     /**
       
   145      * @brief Create 2000 timers and expire those - After
       
   146      * 
       
   147      * Test that many timers are started and expired at rapid sequence<BR><BR>
       
   148      * - Use class that is inherited from CFlexTimer.
       
   149      * - Start and expire at 2000 timers. Some of having overlapping
       
   150      * windows (default window)with each other and others not having.<BR> 
       
   151      * - See that all timers expire within their window. Start timers so that at least 1000 timers.
       
   152      * - are running simultaneously. <BR>
       
   153      * - No need to check that they expire at latest possible moment
       
   154      * - that is checked in algorithm tests.
       
   155      * 
       
   156      * @param TBD
       
   157      * @return The status of execution of the test. KErrNone if the test
       
   158      *         was executed ok, any system wide errorcode otherwise.
       
   159      */
       
   160     static TInt HumongousAmountOfTimeridelidilidousL( TTestResult& aResult,
       
   161             CTestFlexTimer *cb );
       
   162 
       
   163     /**
       
   164      * @brief Create and expire three timers - After/At/AtUTC
       
   165      * 
       
   166      * Test that At, After and AtUTC are handled equally<BR><BR>
       
   167      * - Use class that is inherited from CFlexTimer.<BR>
       
   168      * - Start timers and wait for them to expire.<BR>
       
   169      * - Start timers so that timers started with After and At
       
   170      * overlap and timer started with AtUTC does not overlap.<BR>
       
   171      * - See that After and At expire at the same time and that
       
   172      * - AT UTC expires at it's max time
       
   173      * 
       
   174      * @param TBD
       
   175      * @return The status of execution of the test. KErrNone if the test
       
   176      *         was executed ok, any system wide errorcode otherwise.
       
   177      */
       
   178     static TInt CreateAndExpireThreeTimersL( TTestResult& aResult,
       
   179             CTestFlexTimer *cb );
       
   180 
       
   181     // Cancelling timers - normal cases
       
   182 
       
   183     /**
       
   184      * @brief Cancel a timer
       
   185      * 
       
   186      * See that normal cancelling works<BR><BR>
       
   187      * - Use class that is inherited from CFlexTimer.<BR>
       
   188      * - Start timers With At, AtUTC and After.<BR>
       
   189      * - Cancel a running timers and see that those do not expire anymore.<BR>
       
   190      * 
       
   191      * @param TBD
       
   192      * @return The status of execution of the test. KErrNone if the test
       
   193      *         was executed ok, any system wide errorcode otherwise.
       
   194      */
       
   195     static TInt NormalCancelL( TTestResult& aResult, CTestFlexTimer *cb );
       
   196 
       
   197     /**
       
   198      * @brief Cancel a timer that would have triggered another timer - After
       
   199      * 
       
   200      * Test that canceling timer actually cancels it<BR><BR>
       
   201      * - Use class that is inherited from CFlexTimer.<BR>
       
   202      * - Start two timers with overlapping windows.<BR>
       
   203      * - Cancel first timer before it expires and check that
       
   204      * second timer is fired at it's max time.
       
   205      * 
       
   206      * @param TBD
       
   207      * @return The status of execution of the test. KErrNone if the test
       
   208      *         was executed ok, any system wide errorcode otherwise.
       
   209      */
       
   210     static TInt CancelTimerThatWouldHaveTriggeredAnotherTimerL(
       
   211             TTestResult& aResult, CTestFlexTimer *cb );
       
   212 
       
   213     //Configuring align window
       
   214 
       
   215     /**
       
   216      * @brief Configure time window - overlap 1
       
   217      * 
       
   218      * Test that Timers are triggered correctly after Configure<BR><BR> 
       
   219      * - Use class that is inherited from CFlexTimer.<BR>
       
   220      * - Use two timers. Set first timer having 50% window
       
   221      * and second having 10% window.<BR>
       
   222      * - Set timers so that first timers max window overlaps 1s with
       
   223      * second timers window -> first timer causes second timer to be fired 
       
   224      * 
       
   225      * @param TBD
       
   226      * @return The status of execution of the test. KErrNone if the test
       
   227      *         was executed ok, any system wide errorcode otherwise.
       
   228      */
       
   229     static TInt ConfigureCTimerOverlap1L( TTestResult& aResult,
       
   230             CTestFlexTimer *cb );
       
   231 
       
   232     /**
       
   233      * @brief Configure time window - overlap 2
       
   234      * 
       
   235      * Test that Timers are triggered correctly after Configure<BR><BR> 
       
   236      * - Use class that is inherited from CFlexTimer.<BR>
       
   237      * - Use 64bit IF.
       
   238      * - Use two timers. Set first timer having 50% window
       
   239      * and second having 10% window.<BR>
       
   240      * - Set timers so that first timers min window overlaps 1s with
       
   241      * second timers window -> second timer causes first timer to be fired 
       
   242      * 
       
   243      * @param TBD
       
   244      * @return The status of execution of the test. KErrNone if the test
       
   245      *         was executed ok, any system wide errorcode otherwise.
       
   246      */
       
   247     static TInt ConfigureCTimerOverlap2L( TTestResult& aResult,
       
   248             CTestFlexTimer *cb );
       
   249 
       
   250     /**
       
   251      * @brief Configure time window - overlap 3
       
   252      * 
       
   253      * Test that if many Configures are used, latest is the one that remains. Also test 0 and 100% values<BR><BR>
       
   254      * - Use class that is inherited from CFlexTimer.<BR>
       
   255      * - Use two timers. Set first timer having 0% window
       
   256      * then overwrite that by giving 100% window to first timer.<BR>
       
   257      * - Give second timer 0% window.<BR>
       
   258      * - Start second timer so that it overlaps with first timer<BR>
       
   259      * - See that first timer is fired when second is fired. 
       
   260      * 
       
   261      * @param TBD
       
   262      * @return The status of execution of the test. KErrNone if the test
       
   263      *         was executed ok, any system wide errorcode otherwise.
       
   264      */
       
   265     static TInt ConfigureCTimerOverlap3L( TTestResult& aResult,
       
   266             CTestFlexTimer *cb );
       
   267 
       
   268     /**
       
   269      * @brief Configure time window - non-overlap
       
   270      * 
       
   271      * Test that Timers are triggered correctly after Configure<BR><BR>
       
   272      * - Use class that is inherited from CFlexTimer.<BR>
       
   273      * - Use two timers. Set first timer having 0% window
       
   274      * and second having 10% window.<BR>
       
   275      * - Set timers so that second timers max window is 1 seconds earlier than first timers
       
   276      * min window.<BR>
       
   277      * - See that both timers fire at max time
       
   278      * 
       
   279      * @param TBD
       
   280      * @return The status of execution of the test. KErrNone if the test
       
   281      *         was executed ok, any system wide errorcode otherwise.
       
   282      */
       
   283     static TInt ConfigureCTimerNonOverlap1L( TTestResult& aResult,
       
   284             CTestFlexTimer *cb );
       
   285 
       
   286     /**
       
   287      * @brief Configure time window - non-overlap 2
       
   288      * 
       
   289      * Test that Timers are triggered correctly after Configure<BR><BR>
       
   290      * - Use class that is inherited from CFlexTimer.<BR>
       
   291      * - Use two timers. Set first timer having 100% window
       
   292      * - then overwrite that by giving first timer 50% window.<BR>
       
   293      * - Give second timer 50% window.<BR>
       
   294      * - Set timers so that second timers max window is 1 seconds earlier than first timers
       
   295      * min window.<BR>
       
   296      * - See that both timers fire at max time
       
   297      * 
       
   298      * @param TBD
       
   299      * @return The status of execution of the test. KErrNone if the test
       
   300      *         was executed ok, any system wide errorcode otherwise.
       
   301      */
       
   302     static TInt ConfigureCTimerNonOverlap2L( TTestResult& aResult,
       
   303             CTestFlexTimer *cb );
       
   304 
       
   305     //Time changes
       
   306     /**
       
   307      * @brief System time changes
       
   308      * 
       
   309      * Test that changing system time cancels AT and AtUTC timers and leaves After timers running<BR><BR>
       
   310      * - Use class that is inherited from CFlexTimer.<BR>
       
   311      * - Start three timers. At/AtUTC/After<BR>
       
   312      * - Change system time e.g. User::SetHomeTime()<BR>
       
   313      * - See that At/AtUTC timers are cancelled with error code KErrAbort<BR>
       
   314      * - See that remaining timer is fired at max time<BR>
       
   315      * 
       
   316      * @param TBD
       
   317      * @return The status of execution of the test. KErrNone if the test
       
   318      *         was executed ok, any system wide errorcode otherwise.
       
   319      */
       
   320     static TInt SystemTimeChangesL( TTestResult& aResult, CTestFlexTimer *cb );
       
   321 
       
   322     /**
       
   323      * @brief Timezone changes
       
   324      * 
       
   325      * Test that changing time zone cancels AT and AtUTC timers and leaves After timers running<BR><BR>
       
   326      * - Use class that is inherited from CFlexTimer.<BR>
       
   327      * - Start three timers. At/AtUTC/After<BR>
       
   328      * - Change timezone e.g. User::SetUTCOffset()<BR>
       
   329      * - See that At/AtUTC timers are cancelled with error code KErrAbort<BR>
       
   330      * - See that remaining timer is fired at max time
       
   331      * 
       
   332      * @param TBD
       
   333      * @return The status of execution of the test. KErrNone if the test
       
   334      *         was executed ok, any system wide errorcode otherwise.
       
   335      */
       
   336     static TInt TimeZoneChangesL( TTestResult& aResult, CTestFlexTimer *cb );
       
   337 
       
   338     // Misuse of API cases
       
   339     /**
       
   340      * @brief call After with dumbass parameters 
       
   341      * 
       
   342      * Test that stupid parameters do not cause any harm<BR><BR>
       
   343      * - Use class that is inherited from CFlexTimer.<BR>
       
   344      * - Call After(32bit) with interval 1. See that timer expires almost right away<BR>
       
   345      * - Call After(32bit) with interval 0x7FFFFFFF. Cancel timer<BR>
       
   346      * - Call After(64bit) with interval 1. See that timer expires almost right away<BR>
       
   347      * 
       
   348      * @param TBD
       
   349      * @return The status of execution of the test. KErrNone if the test
       
   350      *         was executed ok, any system wide errorcode otherwise.
       
   351      */
       
   352     static TInt DumbAssParametersForCTimerL( TTestResult& aResult,
       
   353             CTestFlexTimer *cb );
       
   354     
       
   355     /**
       
   356      * @brief call After with dumbass parameters 
       
   357      * 
       
   358      * Test that calling After(32bit) with zero interval panics client<BR><BR>
       
   359      * - Use class that is inherited from CFlexTimer.<BR>
       
   360      * - Call After(32bit) with interval 0.
       
   361      * - See that client is paniced
       
   362      * 
       
   363      * @param TBD
       
   364      * @return The status of execution of the test. KErrNone if the test
       
   365      *         was executed ok, any system wide errorcode otherwise.
       
   366      */
       
   367     static TInt DumbAssParametersForCTimerZero32bitL( TTestResult& aResult,
       
   368             CTestFlexTimer *cb );
       
   369     
       
   370     /**
       
   371      * @brief call After with dumbass parameters 
       
   372      * 
       
   373      * Test that calling After(64bit) with zero interval panics client<BR><BR>
       
   374      * - Use class that is inherited from CFlexTimer.<BR>
       
   375      * - Call After(64bit) with interval 0.
       
   376      * - See that client is paniced
       
   377      * 
       
   378      * @param TBD
       
   379      * @return The status of execution of the test. KErrNone if the test
       
   380      *         was executed ok, any system wide errorcode otherwise.
       
   381      */
       
   382     static TInt DumbAssParametersForCTimerZero64bitL( TTestResult& aResult,
       
   383             CTestFlexTimer *cb );
       
   384     
       
   385     /**
       
   386      * @brief call After with dumbass parameters 
       
   387      * 
       
   388      * Test that calling After(64bit) with 0xFFFFFFFFFFFFFFFF interval panics client<BR><BR>
       
   389      * - Use class that is inherited from CFlexTimer.<BR>
       
   390      * - Call After(64bit) with interval 0xFFFFFFFFFFFFFFFF.
       
   391      * - See that client is paniced
       
   392      * 
       
   393      * @param TBD
       
   394      * @return The status of execution of the test. KErrNone if the test
       
   395      *         was executed ok, any system wide errorcode otherwise.
       
   396      */
       
   397     static TInt DumbAssParametersForCTimer64MaxL( TTestResult& aResult,
       
   398             CTestFlexTimer *cb );
       
   399     
       
   400     /**
       
   401      * @brief call After with dumbass parameters 
       
   402      * 
       
   403      * Test that calling After(64bit) with three years interval panics client<BR><BR>
       
   404      * - Use class that is inherited from CFlexTimer.<BR>
       
   405      * - Call After(64bit) with interval 93312000*1000*1000.
       
   406      * - See that client is paniced
       
   407      * 
       
   408      * @param TBD
       
   409      * @return The status of execution of the test. KErrNone if the test
       
   410      *         was executed ok, any system wide errorcode otherwise.
       
   411      */
       
   412     static TInt DumbAssParametersForCTimer64ThreeYearsL( TTestResult& aResult,
       
   413             CTestFlexTimer *cb );
       
   414     
       
   415     /**
       
   416      * @brief call After with dumbass parameters 
       
   417      * 
       
   418      * Test that calling After(64bit) with one year interval panics client<BR><BR>
       
   419      * - Use class that is inherited from CFlexTimer.<BR>
       
   420      * - Call After(64bit) with interval 30*1000*1000*1000*1000.
       
   421      * - Cancel timer
       
   422      * 
       
   423      * @param TBD
       
   424      * @return The status of execution of the test. KErrNone if the test
       
   425      *         was executed ok, any system wide errorcode otherwise.
       
   426      */
       
   427     static TInt DumbAssParametersForCTimer64OneYearL( TTestResult& aResult,
       
   428             CTestFlexTimer *cb );
       
   429 
       
   430     /**
       
   431      * @brief call After with invalid parameters 
       
   432      * 
       
   433      * Test that negative intervals cause panic in After()<BR><BR>
       
   434      * - Use class that is inherited from CFlexTimer.<BR>
       
   435      * - Call After(32bit) with negative interval See that it causes a panic.<BR>
       
   436      * TODO what panic? Shouldn't this read in documentation
       
   437      * 
       
   438      * @param TBD
       
   439      * @return The status of execution of the test. KErrNone if the test
       
   440      *         was executed ok, any system wide errorcode otherwise.
       
   441      */
       
   442     static TInt AfterWithNegativeValueL( TTestResult& aResult,
       
   443             CTestFlexTimer *cb );
       
   444     
       
   445     /**
       
   446      * @brief call After(64bit) with invalid parameters 
       
   447      * 
       
   448      * Test that negative intervals cause panic in After()<BR><BR>
       
   449      * - Use class that is inherited from CFlexTimer.<BR>
       
   450      * - Call After(64bit) with negative interval See that it causes a panic.<BR>
       
   451      * TODO what panic? Shouldn't this read in documentation
       
   452      * 
       
   453      * @param TBD
       
   454      * @return The status of execution of the test. KErrNone if the test
       
   455      *         was executed ok, any system wide errorcode otherwise.
       
   456      */
       
   457     static TInt AfterWithNegativeValue64L( TTestResult& aResult,
       
   458             CTestFlexTimer *cb );
       
   459 
       
   460     /**
       
   461      * @brief call At with current time 
       
   462      * 
       
   463      * Test that At() with current time panics<BR><BR>
       
   464      * - Use class that is inherited from CFlexTimer.<BR>
       
   465      * - Call At with current time. See that client panics<BR>
       
   466      * 
       
   467      * @param TBD
       
   468      * @return The status of execution of the test. KErrNone if the test
       
   469      *         was executed ok, any system wide errorcode otherwise.
       
   470      */
       
   471     static TInt AtWithCurrentTimeL( TTestResult& aResult,
       
   472             CTestFlexTimer *cb );
       
   473     
       
   474     /**
       
   475      * @brief call AtUTC with current time 
       
   476      * 
       
   477      * Test that AtUTC() with current time panics<BR><BR>
       
   478      * - Use class that is inherited from CFlexTimer.<BR>
       
   479      * - Call At with current time. See that client panics<BR>
       
   480      * 
       
   481      * @param TBD
       
   482      * @return The status of execution of the test. KErrNone if the test
       
   483      *         was executed ok, any system wide errorcode otherwise.
       
   484      */
       
   485     static TInt AtUTCWithCurrentTimeL( TTestResult& aResult,
       
   486             CTestFlexTimer *cb );
       
   487     /**
       
   488      * @brief call At with time three years from now 
       
   489      * 
       
   490      * Test that At() with three years from now panics<BR><BR>
       
   491      * - Use class that is inherited from CFlexTimer.<BR>
       
   492      * - Call At with three years from now. See that client panics<BR>
       
   493      * 
       
   494      * @param TBD
       
   495      * @return The status of execution of the test. KErrNone if the test
       
   496      *         was executed ok, any system wide errorcode otherwise.
       
   497      */
       
   498     static TInt AtWithThreeYearsL( TTestResult& aResult,
       
   499             CTestFlexTimer *cb );
       
   500     /**
       
   501      * @brief call At with time one year from now 
       
   502      * 
       
   503      * Test that At() with one year from now panics<BR><BR>
       
   504      * - Use class that is inherited from CFlexTimer.<BR>
       
   505      * - Call At with one year from now. 
       
   506      * - Cancel timer<BR>
       
   507      * 
       
   508      * @param TBD
       
   509      * @return The status of execution of the test. KErrNone if the test
       
   510      *         was executed ok, any system wide errorcode otherwise.
       
   511      */
       
   512     static TInt AtWithOneYearL( TTestResult& aResult,
       
   513             CTestFlexTimer *cb );
       
   514 
       
   515     /**
       
   516      * @brief call At/AtUTC with invalid parameters 
       
   517      * 
       
   518      * Test that calling At() with time that is in the past causes panic<BR><BR>
       
   519      * - Use class that is inherited from CFlexTimer.<BR>
       
   520      * - Call At with time in the past<BR>
       
   521      * See that it causes panic TODO what panic? Shouldn't this read in documentation
       
   522      * 
       
   523      * @param TBD
       
   524      * @return The status of execution of the test. KErrNone if the test
       
   525      *         was executed ok, any system wide errorcode otherwise.
       
   526      */
       
   527     static TInt AtWithTimeInThePastL( TTestResult& aResult,
       
   528             CTestFlexTimer *cb );
       
   529 
       
   530     /**
       
   531      * @brief Cancel an expired timer - After
       
   532      * 
       
   533      * Test that calling already expired timer does not cause any harm<BR><BR>
       
   534      * - Use class that is inherited from CFlexTimer.<BR>
       
   535      * - Start timer and wait for it to expire. After it expires
       
   536      * cancel it<BR>
       
   537      * - Start timer again and see that it expires normally.
       
   538      * 
       
   539      * 
       
   540      * @param TBD
       
   541      * @return The status of execution of the test. KErrNone if the test
       
   542      *         was executed ok, any system wide errorcode otherwise.
       
   543      */
       
   544     static TInt
       
   545             CancelExpiredTimerL( TTestResult& aResult, CTestFlexTimer *cb );
       
   546 
       
   547     // Hilarious Configure calls
       
   548     /**
       
   549      * @brief Left edge of the time window lays in the past - max check
       
   550      * 
       
   551      * Test that no harm is done if left side of the window lays in the past<BR><BR>
       
   552      * - Use class that is inherited from CFlexTimer.<BR>
       
   553      * - Call Configure with window_size x.<BR>
       
   554      * - Call After with interval < x.<BR>
       
   555      * - See that timer expires when max time is reached
       
   556      * 
       
   557      * @param TBD
       
   558      * @return The status of execution of the test. KErrNone if the test
       
   559      *         was executed ok, any system wide errorcode otherwise.
       
   560      */
       
   561     static TInt ConfigureLeftSideInThePastL( TTestResult& aResult,
       
   562             CTestFlexTimer *cb );
       
   563 
       
   564     /**
       
   565      * @brief Left edge of the time window lays in the past - window check
       
   566      * 
       
   567      * Test that window works when left side of the window lays in the past <BR><BR>
       
   568      * - Use class that is inherited from CFlexTimer.<BR>
       
   569      * - Call Configure with window_size x.<BR>
       
   570      * - Call After with interval < x.<BR>
       
   571      * - Start another timer that expires before first timer.<BR>
       
   572      * - See that both timers expire when max time of the second timer is reached.
       
   573      * 
       
   574      * @param TBD
       
   575      * @return The status of execution of the test. KErrNone if the test
       
   576      *         was executed ok, any system wide errorcode otherwise.
       
   577      */
       
   578     static TInt ConfigureLeftSideInThePastWindowCheckL( TTestResult& aResult,
       
   579             CTestFlexTimer *cb );
       
   580 
       
   581     /**
       
   582      * @brief Configure(32bit) with negative window_size
       
   583      * 
       
   584      * Test that negative window panics client <BR><BR>
       
   585      * - Use class that is inherited from CFlexTimer.<BR>
       
   586      * - Call Configure(32bit) with negative window_size value.<BR>
       
   587      * - See that it causes panic TODO what panic? Shouldn't this read in documentation
       
   588      * 
       
   589      * @param TBD
       
   590      * @return The status of execution of the test. KErrNone if the test
       
   591      *         was executed ok, any system wide errorcode otherwise.
       
   592      */
       
   593     static TInt ConfigureWithNegativeWindowSize32L( TTestResult& aResult,
       
   594             CTestFlexTimer *cb );
       
   595 
       
   596     /**
       
   597      * @brief Configure(64bit) with negative window_size
       
   598      * 
       
   599      * Test that negative window panics client <BR><BR>
       
   600      * - Use class that is inherited from CFlexTimer.<BR>
       
   601      * - Call Configure(64bit) with negative window_size value.<BR>
       
   602      * - See that it causes panic TODO what panic? Shouldn't this read in documentation
       
   603      * 
       
   604      * @param TBD
       
   605      * @return The status of execution of the test. KErrNone if the test
       
   606      *         was executed ok, any system wide errorcode otherwise.
       
   607      */
       
   608     static TInt ConfigureWithNegativeWindowSize64L( TTestResult& aResult,
       
   609             CTestFlexTimer *cb );
       
   610 
       
   611     /**
       
   612      * @brief Configure(32bit) with 0xFFFFFFFF window_size
       
   613      * 
       
   614      * Test that 0xFFFFFFFF is valid window size <BR><BR>
       
   615      * - Use class that is inherited from CFlexTimer.<BR>
       
   616      * - Call Configure(32bit) with 0xFFFFFFFF window_size value.<BR>
       
   617      * - See that it causes no harm
       
   618      *  
       
   619      * @param TBD
       
   620      * @return The status of execution of the test. KErrNone if the test
       
   621      *         was executed ok, any system wide errorcode otherwise.
       
   622      */
       
   623     static TInt ConfigureWithMaxWindow32L( TTestResult& aResult,
       
   624             CTestFlexTimer *cb );
       
   625     
       
   626     /**
       
   627      * @brief Configure(64bit) with three year window_size
       
   628      * 
       
   629      * Test that negative window panics client <BR><BR>
       
   630      * - Use class that is inherited from CFlexTimer.<BR>
       
   631      * - Call Configure(64bit) with three year window_size value.<BR>
       
   632      * - See that it causes panic TODO what panic? Shouldn't this read in documentation
       
   633      * 
       
   634      * @param TBD
       
   635      * @return The status of execution of the test. KErrNone if the test
       
   636      *         was executed ok, any system wide errorcode otherwise.
       
   637      */
       
   638     static TInt ConfigureWithThreeYearWindow64L( TTestResult& aResult,
       
   639             CTestFlexTimer *cb );
       
   640     
       
   641     /**
       
   642      * @brief Configure(64bit) with max window_size
       
   643      * 
       
   644      * Test that negative window panics client <BR><BR>
       
   645      * - Use class that is inherited from CFlexTimer.<BR>
       
   646      * - Call Configure(64bit) with max window_size value.<BR>
       
   647      * - See that it causes panic TODO what panic? Shouldn't this read in documentation
       
   648      * 
       
   649      * @param TBD
       
   650      * @return The status of execution of the test. KErrNone if the test
       
   651      *         was executed ok, any system wide errorcode otherwise.
       
   652      */
       
   653     static TInt ConfigureWithMaxWindow64L( TTestResult& aResult,
       
   654             CTestFlexTimer *cb );
       
   655         
       
   656     /**
       
   657      * @brief Call configure after starting timer
       
   658      * 
       
   659      * Test that configure is not used and returns error while timer is already running <BR><BR>
       
   660      * - Use class that is inherited from CFlexTimer.<BR>
       
   661      * - Start timer.<BR>
       
   662      * - Call Configure.<BR>
       
   663      * - See that configure returns KErrInUse.<BR>
       
   664      * - See that timer expires normally.
       
   665      * 
       
   666      * @param TBD
       
   667      * @return The status of execution of the test. KErrNone if the test
       
   668      *         was executed ok, any system wide errorcode otherwise.
       
   669      */
       
   670     static TInt ConfigureWhileTimerIsInUseL( TTestResult& aResult,
       
   671             CTestFlexTimer *cb );
       
   672 
       
   673     /**
       
   674      * @brief Start timer twice
       
   675      * 
       
   676      * Test that client is paniced if timer is started twise <BR><BR>
       
   677      * - Use class that is inherited from CFlexTimer.<BR>
       
   678      * - Start timer with After()<BR>
       
   679      * - Start timer again with At()<BR>
       
   680      * - See that client panics with code EFlexTimerServerErrorPendingTimer //TODO referense in documentation
       
   681      * 
       
   682      * @param TBD
       
   683      * @return The status of execution of the test. KErrNone if the test
       
   684      *         was executed ok, any system wide errorcode otherwise.
       
   685      */
       
   686     static TInt TimerIsStartedTwiceL( TTestResult& aResult,
       
   687             CTestFlexTimer *cb );
       
   688 
       
   689     /*****************************************
       
   690      * CB functions used by CFlexTimer tests *
       
   691      /*****************************************/
       
   692 
       
   693     /**
       
   694      * @brief Check timer stop code and stop active scheduler
       
   695      * 
       
   696      * Simple function that stops the active scheduler. Checks that Error code is KErrNone
       
   697      * 
       
   698      * @param N/A
       
   699      * @return N/A
       
   700      */
       
   701     static TInt InheritedFlexTimerCallbackStopSchedulerKErrNone(
       
   702             TAny* aArgument );
       
   703 
       
   704     /**
       
   705      * @brief Check timer stop code and stop active scheduler
       
   706      * 
       
   707      * Simple function that stops the active scheduler. Checks that Error code is KErrCancel
       
   708      * 
       
   709      * @param N/A
       
   710      * @return N/A
       
   711      */
       
   712     static TInt InheritedFlexTimerCallbackStopSchedulerKErrCancel(
       
   713             TAny* aArgument );
       
   714 
       
   715     /**
       
   716      * @brief Check timer stop code and stop active scheduler
       
   717      * 
       
   718      * Simple function that stops the active scheduler. Checks that Error code is KErrAbort
       
   719      * 
       
   720      * @param N/A
       
   721      * @return N/A
       
   722      */
       
   723     static TInt InheritedFlexTimerCallbackStopSchedulerKErrAbort(
       
   724             TAny* aArgument );
       
   725 
       
   726     /**
       
   727      * @brief Check timer stop code
       
   728      * 
       
   729      * Simple function that checks that Error code is KErrNone
       
   730      * 
       
   731      * @param N/A
       
   732      * @return N/A
       
   733      */
       
   734     static TInt InheritedFlexTimerCallbackKErrNone( TAny* aArgument );
       
   735 
       
   736     /**
       
   737      * @brief Check timer stop code
       
   738      * 
       
   739      * Simple function that checks that Error code is KErrAbort
       
   740      * 
       
   741      * @param N/A
       
   742      * @return N/A
       
   743      */
       
   744     static TInt InheritedFlexTimerCallbackKErrAbort( TAny* aArgument );
       
   745 
       
   746     /**
       
   747      * @brief Check error code and mark timestamps
       
   748      * 
       
   749      * Function that checks that Error code is KErrNone. ans saves timestamps
       
   750      * @see CreateAndExpireTwoOverlappingAfterTimersL
       
   751      * 
       
   752      * @param N/A
       
   753      * @return N/A
       
   754      */
       
   755     static TInt InheritedFlexTimerCallbackKErrNoneMarkTimestamp(
       
   756             TAny* aArgument );
       
   757 
       
   758     /**
       
   759      * @brief Check error code and mark timestamps
       
   760      * 
       
   761      * Function that checks that Error code is KErrNone. ans saves timestamps
       
   762      * @see CreateAndExpireTwoOverlappingAfterTimersL
       
   763      * 
       
   764      * @param N/A
       
   765      * @return N/A
       
   766      */
       
   767     static TInt InheritedFlexTimerCallbackKErrNoneMarkTimestampStopScheduler(
       
   768             TAny* aArgument );
       
   769 
       
   770     /**
       
   771      * @brief Stop active scheduler
       
   772      * 
       
   773      * Function that stops the active scheduler
       
   774      * 
       
   775      * @param N/A
       
   776      * @return N/A
       
   777      */
       
   778     static TInt StopActiveScheduler( TAny* aArgument );
       
   779 
       
   780     /**
       
   781      * @brief Changes system time and cancels CPeriodic given as parameter
       
   782      * 
       
   783      * N/A
       
   784      * 
       
   785      * @param N/A
       
   786      * @return N/A
       
   787      */
       
   788     static TInt ChangeSystemTime1sAndCancel( TAny* aArgument );
       
   789 
       
   790     /**
       
   791      * @brief Changes system time and cancels CPeriodic given as parameter
       
   792      * 
       
   793      * N/A
       
   794      * 
       
   795      * @param N/A
       
   796      * @return N/A
       
   797      */
       
   798     static TInt ChangeTimeZoneAndCancel( TAny* aArgument );
       
   799 
       
   800     /**
       
   801      * @brief Changes system time and cancels CPeriodic given as parameter
       
   802      * 
       
   803      * N/A
       
   804      * 
       
   805      * @param N/A
       
   806      * @return N/A
       
   807      */
       
   808     static TInt ChangeSecureTimeAndCancel( TAny* aArgument );
       
   809 
       
   810     /**
       
   811      * @brief cancel CFlexTimer given as parameter
       
   812      * 
       
   813      * N/A
       
   814      * 
       
   815      * @param N/A
       
   816      * @return N/A
       
   817      */
       
   818     static TInt CancelCFlexTimer( TAny* aArgument );
       
   819 
       
   820     /**
       
   821      * @brief See that expiry reason is correct. Array versio
       
   822      * 
       
   823      * N/A
       
   824      * 
       
   825      * @param N/A
       
   826      * @return N/A
       
   827      */
       
   828     static TInt StopSchedulerKErrNoneArray( TAny* aArgument );
       
   829 
       
   830     /**
       
   831      * @brief cancel CFlexTimer given as parameter also cancel CPeriodic
       
   832      * 
       
   833      * N/A
       
   834      * 
       
   835      * @param N/A
       
   836      * @return N/A
       
   837      */
       
   838     static TInt CancelCFlexTimerCancelPeriodic( TAny* aArgument );
       
   839     /**
       
   840      * @brief cancel CFlexTimer given as parameter
       
   841      * 
       
   842      * N/A
       
   843      * 
       
   844      * @param N/A
       
   845      * @return N/A
       
   846      */
       
   847     static TInt CancelCFlexTimerArray( TAny* aArgument );
       
   848     /**
       
   849      * @brief cancel CFlexTimer given as parameter and stops active scheduler
       
   850      * 
       
   851      * N/A
       
   852      * 
       
   853      * @param N/A
       
   854      * @return N/A
       
   855      */
       
   856     static TInt CancelCFlexTimerAndStopActiveScheduler( TAny* aArgument );
       
   857 
       
   858     /**
       
   859      * @brief stops activescheduler and cancels it self
       
   860      * 
       
   861      * N/A
       
   862      * 
       
   863      * @param N/A
       
   864      * @return N/A
       
   865      */
       
   866     static TInt StopSchedulerAndCancel( TAny* aArgument );
       
   867 
       
   868     /**
       
   869      * @brief Not called CB
       
   870      * 
       
   871      * Fails if gets called
       
   872      * 
       
   873      * @param N/A
       
   874      * @return N/A
       
   875      */
       
   876     static TInt NotCalledCB( TAny* aArgument );
       
   877     
       
   878     /**
       
   879      * @brief Callback function, that calls StartTimerAndAddToList
       
   880      * 
       
   881      * -
       
   882      * 
       
   883      * @param N/A
       
   884      * @return N/A
       
   885      */
       
   886     static TInt CTestCFlexTimer::StartTimerAndAddToListCB( TAny* aArgument );
       
   887     /**
       
   888      * @brief Start random timer and add it to list given as parameter
       
   889      * 
       
   890      * -
       
   891      * 
       
   892      * @param N/A
       
   893      * @return N/A
       
   894      */
       
   895     static TInt StartTimerAndAddToList(
       
   896         RArray<TTimerStruct>* aArgument, TInt aTimers );
       
   897 
       
   898     /**
       
   899      * @brief Stop timer and mark time to list given as parameter
       
   900      * 
       
   901      * -
       
   902      * 
       
   903      * @param N/A
       
   904      * @return N/A
       
   905      */
       
   906     static TInt StopTimer( TAny* aArgument );
       
   907     /**
       
   908      * @brief Try to configure timer and see that KErrInUse is returned
       
   909      * 
       
   910      * -
       
   911      * 
       
   912      * @param N/A
       
   913      * @return N/A
       
   914      */
       
   915     static TInt ConfigureKErrInUseArray( TAny* aArgument );
       
   916 
       
   917     /**
       
   918      * @brief start timer again
       
   919      * 
       
   920      * -
       
   921      * 
       
   922      * @param N/A
       
   923      * @return N/A
       
   924      */
       
   925     static TInt StartTimerAgainArray( TAny* aArgument );
       
   926     
       
   927     /**
       
   928      * @brief Create two overlapping timers and start, run and expire them
       
   929      * during high CPU load.
       
   930      * 
       
   931      * Test steps:<BR>
       
   932      * 1. Create CFlexTimer_1, (inteval = 10s, window=0.2*10s (default))<BR>
       
   933      * 2. Create CFlexTimer_2, (inteval = 8s, window=0.2*8s (default))<BR>
       
   934      * 3. Start 99% CPU Load<BR>
       
   935      * 4. Start timers<BR>
       
   936      * 5. Wait timers to expire<BR>
       
   937      * 6. Stop CPU load<BR>
       
   938      * 5. Check that timers expired within ~8sec<BR>
       
   939      * 
       
   940      * @param N/A
       
   941      * @return N/A
       
   942      */
       
   943     static TInt CTestCFlexTimer::CpuLoadCreateAndExpireTwoOverlappingAfterTimersL(
       
   944             TTestResult& aResult, CTestFlexTimer *cb );
       
   945     
       
   946     /**
       
   947      * @brief Create 100  timers and start, run and expire them during high
       
   948      *  CPU load.
       
   949      * 
       
   950      * Test steps:<BR>
       
   951      * 1. Create 100 random timers with random interval and window.<BR>
       
   952      * 3. Start 98% CPU Load<BR>
       
   953      * 4. Start timers<BR>
       
   954      * 5. Wait timers to expire<BR>
       
   955      * 6. Stop CPU load<BR>
       
   956      * 5. Check that timers expired within expected limits.<BR>
       
   957      * 
       
   958      * @param N/A
       
   959      * @return N/A
       
   960      */
       
   961     static TInt CTestCFlexTimer::CpuLoadManyTimersL(
       
   962             TTestResult& aResult, CTestFlexTimer *cb );
       
   963 private:
       
   964 
       
   965     /**
       
   966      * Constructor is private to prevent instantiation of the class. 
       
   967      */
       
   968     CTestCFlexTimer();
       
   969 
       
   970     };
       
   971 
       
   972 #endif // TESTCFLEXTIMER_H