stif/TestInterference/inc/TestInterferenceImplementation.h
changeset 36 813b186005b6
parent 30 86a2e675b80a
child 41 838cdffd57ce
equal deleted inserted replaced
30:86a2e675b80a 36:813b186005b6
     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: This file contains declaration of STIF interference
       
    15 * classes.
       
    16 *
       
    17 */
       
    18 
       
    19 #ifndef TESTINTERFERENCEIMPLEMENTATION_H
       
    20 #define TESTINTERFERENCEIMPLEMENTATION_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <StifTestInterference.h>
       
    24 #include <StifLogger.h>
       
    25 #include <e32std.h>
       
    26 #include <e32base.h>
       
    27 #include <e32svr.h>
       
    28 
       
    29 // Needed by interference test cases
       
    30 #include <f32file.h>
       
    31 // CONSTANTS
       
    32 //const ?type ?constant_var = ?constant;
       
    33 
       
    34 // MACROS
       
    35 //#define ?macro ?macro_def
       
    36 
       
    37 // DATA TYPES
       
    38 //enum ?declaration
       
    39 //typedef ?declaration
       
    40 //extern ?data_type;
       
    41 
       
    42 // FUNCTION PROTOTYPES
       
    43 //?type ?function_name(?arg_list);
       
    44 
       
    45 // FORWARD DECLARATIONS
       
    46 class CExecuteInterference;
       
    47 
       
    48 // CLASS DECLARATION
       
    49 
       
    50 /**
       
    51 *  This is a CSTIFInterferenceAO class.
       
    52 *  This class is inherited from CActive and class implements MSTIFTestInterference.
       
    53 *
       
    54 *  @lib ?library
       
    55 *  @since ?Series60_version
       
    56 */
       
    57 NONSHARABLE_CLASS( CSTIFInterferenceAO ) : public CActive, 
       
    58 										   public MSTIFTestInterference
       
    59     {
       
    60 
       
    61      public:  // Constructors and destructor
       
    62 
       
    63         /**
       
    64         * Two-phased constructor.
       
    65         */
       
    66         static CSTIFInterferenceAO* NewL();
       
    67 
       
    68         /**
       
    69         * Destructor.
       
    70         */
       
    71         virtual ~CSTIFInterferenceAO();
       
    72 
       
    73     public: // New functions
       
    74 
       
    75         /**
       
    76         * StartL method starts test interference.
       
    77         */
       
    78         TInt StartL( TStifTestInterferenceType aType,
       
    79                     TInt aIdleTime,
       
    80                     TInt aActiveTime );
       
    81 
       
    82         /**
       
    83         * Stop method stops test interference.
       
    84         */
       
    85         TInt Stop();
       
    86 
       
    87         /**
       
    88         * Sets thread or active object priority. This should use before
       
    89         * test interference is started otherwise error code will return.
       
    90         */
       
    91         TInt SetPriority( TInt aPriority );
       
    92 
       
    93         /**
       
    94         * ?member_description.
       
    95         * @since ?Series60_version
       
    96         * @param ?arg1 ?description
       
    97         * @return ?description
       
    98         */
       
    99         //?type ?member_function( ?type ?arg1 );
       
   100 
       
   101     public: // Functions from base classes
       
   102 
       
   103         /**
       
   104         * From CActive RunL handles request completion.
       
   105         */
       
   106         void RunL();
       
   107 
       
   108         /**
       
   109         * From CActive DoCancel handles request cancellation.
       
   110         */
       
   111         void DoCancel();
       
   112 
       
   113         /**
       
   114         * From CActive RunError handles error situations.
       
   115         */
       
   116         TInt RunError( TInt aError );
       
   117 
       
   118         /**
       
   119         * ?member_description.
       
   120         * @since ?Series60_version
       
   121         * @param ?arg1 ?description
       
   122         * @return ?description
       
   123         */
       
   124         //?type ?member_function( ?type ?arg1 );
       
   125 
       
   126     protected:  // New functions
       
   127 
       
   128         /**
       
   129         * ?member_description.
       
   130         * @since ?Series60_version
       
   131         * @param ?arg1 ?description
       
   132         * @return ?description
       
   133         */
       
   134         //?type ?member_function( ?type ?arg1 );
       
   135 
       
   136     protected:  // Functions from base classes
       
   137 
       
   138         /**
       
   139         * From ?base_class ?member_description
       
   140         */
       
   141         //?type ?member_function();
       
   142 
       
   143     private:
       
   144 
       
   145         /**
       
   146         * C++ default constructor.
       
   147         */
       
   148         CSTIFInterferenceAO();
       
   149 
       
   150         /**
       
   151         * By default Symbian 2nd phase constructor is private.
       
   152         */
       
   153         void ConstructL();
       
   154 
       
   155         // Prohibit copy constructor if not deriving from CBase.
       
   156         // ?classname( const ?classname& );
       
   157         // Prohibit assigment operator if not deriving from CBase.
       
   158         // ?classname& operator=( const ?classname& );
       
   159 
       
   160     public:     // Data
       
   161         // ?one_line_short_description_of_data
       
   162         //?data_declaration;
       
   163 
       
   164         // 
       
   165         TStifTestInterferenceType   iInterferenceType;
       
   166         // Test interference idle time
       
   167         TInt                        iIdleTime;
       
   168         // Test interference active time
       
   169         TInt                        iActiveTime;
       
   170 
       
   171         // Timer for executing idle time
       
   172         RTimer                      iAOIdleTimer;
       
   173 
       
   174     protected:  // Data
       
   175         // ?one_line_short_description_of_data
       
   176         //?data_declaration;
       
   177 
       
   178     private:    // Data
       
   179 
       
   180         // CExecuteInterference object
       
   181         CExecuteInterference*       iExecuteInterference;
       
   182 
       
   183         // ?one_line_short_description_of_data
       
   184         //?data_declaration;
       
   185 
       
   186         // Reserved pointer for future extension
       
   187         //TAny* iReserved;
       
   188 
       
   189     public:     // Friend classes
       
   190         //?friend_class_declaration;
       
   191     protected:  // Friend classes
       
   192         //?friend_class_declaration;
       
   193     private:    // Friend classes
       
   194         //?friend_class_declaration;
       
   195 
       
   196     };
       
   197 
       
   198 /**
       
   199 *  This a CSTIFInterferenceThread class.
       
   200 *  This class is inherited from CBase and class implements MSTIFTestInterference.
       
   201 *
       
   202 *  @lib ?library
       
   203 *  @since ?Series60_version
       
   204 */
       
   205 NONSHARABLE_CLASS( CSTIFInterferenceThread ) : public CBase,
       
   206 											   public MSTIFTestInterference
       
   207     {
       
   208 
       
   209     public:  // Constructors and destructor
       
   210 
       
   211         /**
       
   212         * Two-phased constructor.
       
   213         */
       
   214         static CSTIFInterferenceThread* NewL( CTestModuleBase* aTestModuleBase );
       
   215 
       
   216         /**
       
   217         * Destructor.
       
   218         */
       
   219         virtual ~CSTIFInterferenceThread();
       
   220 
       
   221     public: // New functions
       
   222 
       
   223         /**
       
   224         * StartL method starts test interference.
       
   225         */
       
   226         TInt StartL( TStifTestInterferenceType aType,
       
   227                     TInt aIdleTime,
       
   228                     TInt aActiveTime );
       
   229 
       
   230         /**
       
   231         * Stop method stops test interference.
       
   232         */
       
   233         TInt Stop();
       
   234 
       
   235         /**
       
   236         * Sets thread or active object priority. This should use before
       
   237         * test interference is started otherwise error code will return.
       
   238         */
       
   239         TInt SetPriority( TInt aPriority );
       
   240 
       
   241         /**
       
   242         * ?member_description.
       
   243         * @since ?Series60_version
       
   244         * @param ?arg1 ?description
       
   245         * @return ?description
       
   246         */
       
   247         //?type ?member_function( ?type ?arg1 );
       
   248 
       
   249         static TInt ThreadFunction( TAny* aStarted );
       
   250 
       
   251         /**
       
   252         * Executes interference.
       
   253         */
       
   254         static void ExecuteInterferenceL( TStifTestInterferenceType aType, TInt aIdleTime, TInt aActiveTime );
       
   255     public: // Functions from base classes
       
   256 
       
   257         /**
       
   258         * ?member_description.
       
   259         * @since ?Series60_version
       
   260         * @param ?arg1 ?description
       
   261         * @return ?description
       
   262         */
       
   263         //?type ?member_function( ?type ?arg1 );
       
   264 
       
   265     protected:  // New functions
       
   266 
       
   267         /**
       
   268         * ?member_description.
       
   269         * @since ?Series60_version
       
   270         * @param ?arg1 ?description
       
   271         * @return ?description
       
   272         */
       
   273         //?type ?member_function( ?type ?arg1 );
       
   274 
       
   275     protected:  // Functions from base classes
       
   276 
       
   277         /**
       
   278         * From ?base_class ?member_description
       
   279         */
       
   280         //?type ?member_function();
       
   281 
       
   282     private:
       
   283 
       
   284         /**
       
   285         * C++ default constructor.
       
   286         */
       
   287         CSTIFInterferenceThread();
       
   288 
       
   289         /**
       
   290         * By default Symbian 2nd phase constructor is private.
       
   291         */
       
   292         void ConstructL( CTestModuleBase* aTestModuleBase );
       
   293 
       
   294         // Prohibit copy constructor if not deriving from CBase.
       
   295         // ?classname( const ?classname& );
       
   296         // Prohibit assigment operator if not deriving from CBase.
       
   297         // ?classname& operator=( const ?classname& );
       
   298 
       
   299     public:     // Data
       
   300         // ?one_line_short_description_of_data
       
   301         //?data_declaration;
       
   302 
       
   303     protected:  // Data
       
   304         // ?one_line_short_description_of_data
       
   305         //?data_declaration;
       
   306 
       
   307     private:    // Data
       
   308 
       
   309         // Struct that keeps thread related informations.
       
   310         struct TThreadParam
       
   311             {
       
   312             RSemaphore                  iStarted;
       
   313             TStifTestInterferenceType   iType;
       
   314             TInt                        iIdleTime;
       
   315             TInt                        iActiveTime;
       
   316             // Note: Be carefully if adding pointers to struct
       
   317             };
       
   318 
       
   319         // RThread object
       
   320         RThread                         iThread;
       
   321 
       
   322         // TThreadParam object(Struct that keeps thread related informations)
       
   323         TThreadParam*                   iThreadParam;
       
   324 
       
   325         // Pointer to STIF size
       
   326         CTestModuleBase*                iTestModuleBase;
       
   327 
       
   328         // ?one_line_short_description_of_data
       
   329         //?data_declaration;
       
   330 
       
   331         // Reserved pointer for future extension
       
   332         //TAny* iReserved;
       
   333 
       
   334     public:     // Friend classes
       
   335         //?friend_class_declaration;
       
   336     protected:  // Friend classes
       
   337         //?friend_class_declaration;
       
   338     private:    // Friend classes
       
   339         //?friend_class_declaration;
       
   340 
       
   341     };
       
   342 
       
   343 /**
       
   344 *  This is a CExecuteInterference class.
       
   345 *  @lib ?library
       
   346 *  @since ?Series60_version
       
   347 */
       
   348 NONSHARABLE_CLASS( CExecuteInterference ) : public CBase
       
   349     {
       
   350     public:  // Constructors and destructor
       
   351 
       
   352         /**
       
   353         * Two-phased constructor.
       
   354         */
       
   355         static CExecuteInterference* NewL();
       
   356 
       
   357         /**
       
   358         * Destructor.
       
   359         */
       
   360         virtual ~CExecuteInterference();
       
   361 
       
   362     public: // New functions
       
   363 
       
   364         /**
       
   365         * Start implement the test interference according to aType parameter.
       
   366         */
       
   367         TInt InterferenceL( 
       
   368                     MSTIFTestInterference::TStifTestInterferenceType aType,
       
   369                     TInt aActiveTime );
       
   370 
       
   371         /**
       
   372         * ?member_description.
       
   373         * @since ?Series60_version
       
   374         * @param ?arg1 ?description
       
   375         * @return ?description
       
   376         */
       
   377         //?type ?member_function( ?type ?arg1 );
       
   378 
       
   379     public: // Functions from base classes
       
   380 
       
   381         /**
       
   382         * ?member_description.
       
   383         * @since ?Series60_version
       
   384         * @param ?arg1 ?description
       
   385         * @return ?description
       
   386         */
       
   387         //?type ?member_function( ?type ?arg1 );
       
   388 
       
   389     protected:  // New functions
       
   390 
       
   391         /**
       
   392         * ?member_description.
       
   393         * @since ?Series60_version
       
   394         * @param ?arg1 ?description
       
   395         * @return ?description
       
   396         */
       
   397         //?type ?member_function( ?type ?arg1 );
       
   398 
       
   399     protected:  // Functions from base classes
       
   400 
       
   401         /**
       
   402         * From ?base_class ?member_description
       
   403         */
       
   404         //?type ?member_function();
       
   405 
       
   406     private:
       
   407 
       
   408         /**
       
   409         * C++ default constructor.
       
   410         */
       
   411         CExecuteInterference();
       
   412 
       
   413         /**
       
   414         * By default Symbian 2nd phase constructor is private.
       
   415         */
       
   416         void ConstructL();
       
   417 
       
   418         // Prohibit copy constructor if not deriving from CBase.
       
   419         // ?classname( const ?classname& );
       
   420         // Prohibit assigment operator if not deriving from CBase.
       
   421         // ?classname& operator=( const ?classname& );
       
   422 
       
   423         /**
       
   424         * Searches a file from given drive
       
   425         */        
       
   426         TInt SearchAFileForReading( TDes &aDriveName, RFs &aFileserver );
       
   427 
       
   428         /**
       
   429         * Prepares file system for test cases
       
   430         */        
       
   431         TInt PrepareFileSystemL( TDesC &aDriveName,
       
   432                                  TDesC &aFileName );
       
   433 
       
   434         /**
       
   435         * Deletes files recursively starting from aStartDirectory
       
   436         */        
       
   437         TInt DeleteFilesRecursivelyL( RFs &aFileserver, 
       
   438                                       TDes &aStartDirectory,
       
   439                                       const TTime &aEndTime );
       
   440 
       
   441         /**
       
   442         * Empties file system using DeleteFilesRecursivelyL method
       
   443         */        
       
   444         TInt EmptyTheFileSystemL( TDes &aFilePath,
       
   445                                  const TTime &aEndTime );
       
   446 
       
   447         /**
       
   448         * Creates CPU load
       
   449         */        
       
   450         TInt CPULoad( const TTimeIntervalMicroSeconds32 &aActiveTime );
       
   451        
       
   452         /**
       
   453         * Writes data to file asynchronously
       
   454         */                   
       
   455         TInt WriteToFileAsynchL( TDes &aFilePath,
       
   456                                 RFs &aFileserver,
       
   457                                 const TTime & aEndTime );
       
   458         /**
       
   459         * Repeats write until aActiveTime has expired
       
   460         */                                       
       
   461         TInt RepeatWriteToFileL( 
       
   462                     TDes &aFilePath,
       
   463                     const TTime &aActiveTime );
       
   464         
       
   465         /**
       
   466         * Repeats read until aActiveTime has expired
       
   467         */              
       
   468         TInt RepeatReadFromFileL( TDes &aFilePath,
       
   469                                  const TTimeIntervalMicroSeconds32 &aActiveTime );
       
   470                 
       
   471     public:     // Data
       
   472         // ?one_line_short_description_of_data
       
   473         //?data_declaration;
       
   474 
       
   475     protected:  // Data
       
   476         // ?one_line_short_description_of_data
       
   477         //?data_declaration;
       
   478 
       
   479     private:    // Data
       
   480 
       
   481         // RTimer object
       
   482         RTimer                          iTimer;
       
   483 
       
   484         // ?one_line_short_description_of_data
       
   485         //?data_declaration;
       
   486 
       
   487         // Reserved pointer for future extension
       
   488         //TAny* iReserved;
       
   489 
       
   490     public:     // Friend classes
       
   491         //?friend_class_declaration;
       
   492     protected:  // Friend classes
       
   493         //?friend_class_declaration;
       
   494     private:    // Friend classes
       
   495         //?friend_class_declaration;
       
   496 
       
   497     };
       
   498 
       
   499 #endif      // TESTINTERFERENCEIMPLEMENTATION_H
       
   500 
       
   501 // End of File