emailservices/emailstore/tsrc/message_store_test/inc/AsyncTestCaseBase.h
changeset 1 12c456ceeff2
equal deleted inserted replaced
0:8466d47a6819 1:12c456ceeff2
       
     1 /*
       
     2 * Copyright (c) 2002 - 2007 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:  t_ImsIdsPlugin test module.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef ASYNC_TESTCASE_BASE_H
       
    21 #define ASYNC_TESTCASE_BASE_H
       
    22 
       
    23 // INCLUDES
       
    24 #include "StifTestModule.h"
       
    25 #include <StifLogger.h>
       
    26 #include <NormalHardcodedAssert.h>
       
    27 #include <msgstoreapi.h>
       
    28 
       
    29 //Forward declaration
       
    30 
       
    31 class CYieldHelper : public CTimer
       
    32     {
       
    33     public:
       
    34         static CYieldHelper* NewL();
       
    35         virtual ~CYieldHelper();
       
    36 
       
    37         void Yield( TInt aMicroSeconds );
       
    38         
       
    39     private:
       
    40         CYieldHelper();
       
    41         void ConstructL();
       
    42         
       
    43         // inherited from CActive
       
    44         virtual void RunL();
       
    45         virtual void DoCancel();
       
    46         
       
    47     private:
       
    48         CActiveSchedulerWait* iYieldWait;        
       
    49     };
       
    50 
       
    51 // CLASS DECLARATION
       
    52 class RDebugSession : public RSessionBase 
       
    53     {
       
    54     public:
       
    55     
       
    56         // SERVER MUST BE ALREADY RUNNING!
       
    57         TInt Connect();
       
    58 
       
    59         void Close();
       
    60                 
       
    61         void SendBackupRestoreEventL( TUint aEvent );  
       
    62         
       
    63         void SendPointSecEventL( TBool aLock );
       
    64         
       
    65         void SimulateLowDiskSpaceL( TUint aLatency );        
       
    66         
       
    67         TInt GetEncryptionStateL();
       
    68         
       
    69         void ShutdownServerL();
       
    70     };
       
    71 
       
    72 
       
    73 // CLASS DECLARATION
       
    74 class CAsyncTestCaseBase : public CTimer
       
    75     {
       
    76     public:  // Constructors and destructor
       
    77 
       
    78         virtual ~CAsyncTestCaseBase();
       
    79         
       
    80         inline TInt Result() { return iResult; }
       
    81 
       
    82     protected:
       
    83         enum TState
       
    84             {
       
    85             EStateInit,
       
    86             EStateExecute,
       
    87             EStateDone,
       
    88             };
       
    89         
       
    90         /**
       
    91         * C++ default constructor.
       
    92         */
       
    93         CAsyncTestCaseBase( CStifLogger* aLogger );
       
    94 
       
    95         /**
       
    96         * By default Symbian 2nd phase constructor is private.
       
    97         */
       
    98         void ConstructL();
       
    99         
       
   100         //steps for preparing the test cases
       
   101         virtual void BeforeTestL();
       
   102         
       
   103         //abstract method to start executing the real test case
       
   104         // return ETrue if execution is done
       
   105         virtual TBool ExecuteL() = 0;
       
   106 
       
   107         //steps for after the test cases, make sure this is always run
       
   108         virtual void AfterTestL();
       
   109         
       
   110         //stop the execution
       
   111         virtual void Stop();
       
   112         
       
   113         //From CTimer
       
   114         virtual void RunL();
       
   115         virtual TInt RunError(TInt aError);
       
   116         virtual void DoCancel();
       
   117         
       
   118         void LogHeader( const TDesC& aTestType );
       
   119         
       
   120         void CheckCondition( const TDesC& aCondition, TBool aPassed, TBool aLog=ETrue );
       
   121         
       
   122         void ComparePropertiesL( const CMsgStorePropertyContainer& aProperties1, 
       
   123                                  const CMsgStorePropertyContainer& aProperties2 );
       
   124 
       
   125         void SimulateLowDiskSpaceL( TUint aLatency );
       
   126         void TriggerBackupRestoreEventL( TUint aEvent );
       
   127         void TriggerPointSecEventL( TBool aLock );
       
   128         void ShutdownServerL();
       
   129         void Yield( TInt aMicroSeconds  );
       
   130         void WaitForServerToTerminate();
       
   131         
       
   132         TUint TestAddIntegerPropertyL( CMsgStorePropertyContainer& aProperties, const TDesC8& aName, TUint32 aValue, TBool aUseAddOrUpdate = EFalse );
       
   133         TUint TestAddBoolPropertyL( CMsgStorePropertyContainer& aProperties, const TDesC8& aName, TBool aValue, TBool aUseAddOrUpdate = EFalse  );
       
   134         TUint TestAddDes8PropertyL( CMsgStorePropertyContainer& aProperties, const TDesC8& aName, const TDesC8& aValue, TBool aUseAddOrUpdate = EFalse  );
       
   135         TUint TestAddDesPropertyL( CMsgStorePropertyContainer& aProperties, const TDesC8& aName, const TDesC& aValue, TBool aUseAddOrUpdate = EFalse  );
       
   136         TUint TestAddContainerPropertyL( CMsgStorePropertyContainer& aProperties, const TDesC8& aName, const CMsgStorePropertyContainer& aValue, TBool aUseAddOrUpdate = EFalse );
       
   137         TUint TestAddTimePropertyL( CMsgStorePropertyContainer& aProperties, const TDesC8& aName, const TTime& aValue, TBool aUseAddOrUpdate = EFalse );
       
   138         TUint TestAddAddressPropertyL( CMsgStorePropertyContainer& aProperties, const TDesC8& aName, const RMsgStoreAddress& aValue, TBool aUseAddOrUpdate = EFalse );
       
   139 
       
   140         void TestRemovePropertyL( CMsgStorePropertyContainer& aProperties, TUint aIndex );
       
   141 
       
   142         void TestUpdateDes8PropertyL( CMsgStorePropertyContainer& aProperties, 
       
   143                                       TUint aIndex, 
       
   144                                       const TDesC8& aNewValue, 
       
   145                                       TBool aUseAddOrUpdate = EFalse );
       
   146         
       
   147         void TestUpdateDesPropertyL( CMsgStorePropertyContainer& aProperties, 
       
   148                                      TUint aIndex, 
       
   149                                      const TDesC& aNewValue, 
       
   150                                      TBool aUseAddOrUpdate = EFalse );
       
   151         
       
   152         void TestUpdateContainerPropertyL( CMsgStorePropertyContainer& aProperties, 
       
   153                                            TUint aIndex, 
       
   154                                            CMsgStorePropertyContainer& aNewValue, 
       
   155                                            TBool aUseAddOrUpdate = EFalse );
       
   156         
       
   157         void TestUpdateBoolPropertyL( CMsgStorePropertyContainer& aProperties, 
       
   158                                       TUint aIndex, 
       
   159                                       TBool aNewValue, 
       
   160                                       TBool aUseAddOrUpdate = EFalse );
       
   161         
       
   162         void TestUpdateIntegerPropertyL( CMsgStorePropertyContainer& aProperties, 
       
   163                                          TUint aIndex, 
       
   164                                          TUint32 aNewValue, 
       
   165                                          TBool aUseAddOrUpdate = EFalse );
       
   166         
       
   167         void TestUpdateTimePropertyL( CMsgStorePropertyContainer& aProperties, 
       
   168                                       TUint aIndex, 
       
   169                                       const TTime& aNewValue, 
       
   170                                       TBool aUseAddOrUpdate = EFalse );
       
   171         
       
   172         void TestUpdateAddressPropertyL( CMsgStorePropertyContainer& aProperties, 
       
   173                                          TUint aIndex, 
       
   174                                          const RMsgStoreAddress& aNewValue, 
       
   175                                          TBool aUseAddOrUpdate = EFalse );
       
   176         
       
   177         void CopyDesToDes8( const TDesC& aDes, TDes8& aDes8 );
       
   178         
       
   179         void CreateFileL( const TDesC& aName, 
       
   180                          TUint aTotalLength,
       
   181                          TChar aFillChar, 
       
   182                          const TDesC& aString, 
       
   183                          TUint aOffset );
       
   184         
       
   185         void CreateRandomMessagesL( CMsgStoreMailBox* aMailBox1, 
       
   186                                     TMsgStoreId aFolder1Id, 
       
   187                                     TInt aCount, 
       
   188                                     TBool aKeepIds = EFalse, 
       
   189                                     TBool aLog = EFalse );
       
   190         
       
   191         void CreateRandomString( TDes& aString, TInt aLength, TInt64& aSeed );
       
   192         
       
   193         void SetMessageContentL( CMsgStoreMessage* aMessage, const TDesC8& aContent );
       
   194         
       
   195     protected:
       
   196         // Pointer to logger
       
   197         CStifLogger*       iLog;
       
   198         
       
   199         CActiveScheduler*  iActiveScheduler;
       
   200         CMsgStore*         iMsgStore;
       
   201         
       
   202         TState             iState;
       
   203         TInt               iResult;
       
   204         TInt               iCaseId;
       
   205         
       
   206         RArray<TMsgStoreId> iMatches;
       
   207         RPointerArray<CMsgStoreMessage> iMessages;
       
   208         
       
   209     private:
       
   210         CYieldHelper*      iYieldHelper;
       
   211     };
       
   212 
       
   213 #endif      // ASYNC_TESTCASE_BASE_H
       
   214 
       
   215 // End of File