ximpfw/tsrc/tsrcutils/testcaseutils/prfwtestcontextwrapper.h
changeset 0 e6b17d312c8b
equal deleted inserted replaced
-1:000000000000 0:e6b17d312c8b
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Testing context wrapper
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CPRFWTESTCONTEXTWRAPPER_H
       
    20 #define CPRFWTESTCONTEXTWRAPPER_H 
       
    21 
       
    22 #include <e32base.h>
       
    23 
       
    24 #include "prfwteststatuseventlistener.h"
       
    25 
       
    26 class MXIMPClient;
       
    27 class MXIMPContext;
       
    28 class CXIMPTestStatusEventListener;
       
    29 class CXIMPTestMessenger;
       
    30 class CXIMPTestFileTool;
       
    31 class MPresenceFeatures;
       
    32 
       
    33 /**
       
    34  * Wrapper for testing.
       
    35  * Owns the things needed to test one host-plugin connection.
       
    36  *
       
    37  * @since S60 v4.0
       
    38  */
       
    39 class CXIMPTestContextWrapper : public CBase
       
    40     {
       
    41     public:
       
    42 
       
    43         /**
       
    44          * @param aIndex Index of wrapper (used for pubsub-messaging
       
    45          * between test plugin and test code).
       
    46          */
       
    47         IMPORT_C static CXIMPTestContextWrapper* NewL( TInt aIndex, MXIMPClient* aClient );
       
    48         virtual ~CXIMPTestContextWrapper();
       
    49 
       
    50     private:
       
    51 
       
    52         CXIMPTestContextWrapper( TInt aIndex, MXIMPClient* aClient );
       
    53         void ConstructL();
       
    54 
       
    55     public:
       
    56 
       
    57         // accessors
       
    58         IMPORT_C MXIMPContext* GetContext();
       
    59         IMPORT_C CXIMPTestStatusEventListener* GetEventListener();
       
    60         IMPORT_C CXIMPTestMessenger* GetMessenger();
       
    61         IMPORT_C MXIMPClient* GetClient();
       
    62         IMPORT_C RArray<TXIMPTestStatusEventSnapshot>* GetStatusTraits();
       
    63         IMPORT_C MPresenceFeatures* GetPresenceFeatures();
       
    64 
       
    65         // low-level test support - see e.g. t_sessionmng test for usage
       
    66         //
       
    67         /**
       
    68          * Delete the presence context and set it to NULL.
       
    69          */
       
    70         IMPORT_C void DeletePresenceContext();
       
    71 
       
    72         /**
       
    73          * Like SetupListenerL but sets no event template. Use AppendToTraitsL to set
       
    74          * the desired templates. Useful for certain test cases.
       
    75          */
       
    76         IMPORT_C void SetupEmptyListener();
       
    77 
       
    78         /**
       
    79          * Setup a listener using the given event template for the traits.
       
    80          * @param aEventType The event template to listen to.
       
    81          */
       
    82         IMPORT_C void SetupListenerL( TXIMPTestStatusEventTemplate aEventType );
       
    83 
       
    84         /**
       
    85          * Append the given template to the internal traits.
       
    86          * @param aEventType The event template to add.
       
    87          */
       
    88         IMPORT_C void AppendToTraitsL( TXIMPTestStatusEventTemplate aEventType );
       
    89 
       
    90         /**
       
    91          * Setup a listener for a request complete event. All other events from the
       
    92          * given template are ignored (except those given by aAdditionalEvents).
       
    93          * @param aEventType The event template.
       
    94          * @param aAdditionalEvents Additional events to listen to.
       
    95          */
       
    96         IMPORT_C void SetupListenerReqCompleteL( 
       
    97                 TXIMPTestStatusEventTemplate aEventType,
       
    98                 RArray< TInt32 >* aAdditionalEvents = NULL );
       
    99 
       
   100         /**
       
   101          * Clear the listener.
       
   102          */
       
   103         IMPORT_C void ClearListener();
       
   104         
       
   105         /**
       
   106          * Back to begin state of listener.
       
   107          */
       
   108         IMPORT_C void ResetListener(); 
       
   109 
       
   110         /**
       
   111          * Wait for the events and a request complete event for the given request id.
       
   112          * @param aReqId The request id for which a req. complete ends the wait
       
   113          */
       
   114         IMPORT_C void WaitRequestAndStackEvents( TXIMPRequestId aReqId );
       
   115 
       
   116         /**
       
   117          * Wait for any event to occur. Event ends the wait.
       
   118          */
       
   119         IMPORT_C void WaitAnyEvent();
       
   120 
       
   121         /**
       
   122          * Verify the event stack against the previously set template(s).
       
   123          * The description is printed to the EUnit log.
       
   124          * @param aDesc The description
       
   125          */
       
   126         IMPORT_C void VerifyEventStackL( const TPtrC8& aDesc );
       
   127 
       
   128         // high-level test support
       
   129         /**
       
   130          * Happy-path binding.
       
   131          */
       
   132         IMPORT_C void BindL( 
       
   133                 TUid aUid, 
       
   134                 const TDesC& aServer,
       
   135                 const TDesC& aUser,
       
   136                 const TDesC& aPassword );
       
   137         
       
   138         /**
       
   139          * Happy-path binding alternative method.
       
   140          * The server, userid and password are automatically modified
       
   141          * based on the given id:
       
   142          * Server: www.imps%d.no/wv
       
   143          * User:   user%d
       
   144          * Password: password%d.
       
   145          * @param aId An id used to modify server login data.
       
   146          */
       
   147         IMPORT_C void BindL( TInt aId );
       
   148         
       
   149         IMPORT_C void BindWithSettingsL( TInt aId );
       
   150         /**
       
   151          * Happy-path unbinding
       
   152          */
       
   153         IMPORT_C void UnbindL();
       
   154         
       
   155         /**
       
   156          * Access to filetool of wrapper.
       
   157          */
       
   158         IMPORT_C CXIMPTestFileTool& FileTool() const;
       
   159         
       
   160         /**
       
   161          * @return Instance id
       
   162          */
       
   163         IMPORT_C const TDesC16& InstanceId() const;        
       
   164 
       
   165     private: // data
       
   166 
       
   167         // not owned
       
   168         MXIMPClient* iClient;
       
   169 
       
   170         // owned
       
   171         MXIMPContext* iContext;
       
   172 
       
   173         // owned
       
   174         MPresenceFeatures* iPresFeatures;
       
   175 
       
   176 
       
   177         // owned
       
   178         CXIMPTestStatusEventListener* iListener;
       
   179 
       
   180         // owned
       
   181         CXIMPTestMessenger* iMessenger;
       
   182 
       
   183         // owned
       
   184         RArray< TXIMPTestStatusEventSnapshot > iStatusEventTraits;
       
   185 
       
   186         TInt iIndex;
       
   187         
       
   188         /**
       
   189          * Filetool 
       
   190          */
       
   191         CXIMPTestFileTool* iFileTool;
       
   192         
       
   193         HBufC16* iInstance;     // the global instance id        
       
   194 
       
   195     };
       
   196 
       
   197 #endif // CPRFWTESTCONTEXTWRAPPER_H