messagingappbase/obexmtms/TObexMTM/testutils/msgth/inc/harness.h
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef __HARNESS_H
       
    17 #define __HARNESS_H
       
    18 
       
    19 #include <e32test.h>
       
    20 #include <badesca.h>
       
    21 #include "MsvTestUtils.h"
       
    22 #include "testframeutils.h"
       
    23 
       
    24 //
       
    25 //
       
    26 // MBaseTestState
       
    27 //
       
    28 
       
    29 class MBaseTestState
       
    30 	{
       
    31 public:
       
    32 	IMPORT_C virtual void StartL(TRequestStatus& aStatus) = 0;
       
    33 	IMPORT_C virtual ~MBaseTestState();
       
    34 
       
    35 	IMPORT_C void SetDebugInfo(const TTestDebugInfo& aDebugInfo);
       
    36 	IMPORT_C const TTestDebugInfo& GetDebugInfo() const;
       
    37 
       
    38 protected:
       
    39 	TTestDebugInfo iDebugInfo;
       
    40 	};
       
    41 
       
    42 class TTestDebugInfo;
       
    43 
       
    44 class CActiveTestState : public CActive, public MBaseTestState
       
    45 /**
       
    46  * This is a base class for all active object test states. It provides
       
    47  * a RunError() function which notifies the test harness appropriately
       
    48  * when the test state's RunL() function leaves. This avoids a panic.
       
    49  */
       
    50 	{
       
    51 public:
       
    52 	IMPORT_C CActiveTestState(TInt aPriority);
       
    53 	IMPORT_C virtual TInt RunError(TInt aError);
       
    54 
       
    55 protected:
       
    56 	TRequestStatus* iReportStatus;
       
    57 	};
       
    58 
       
    59 //
       
    60 //
       
    61 // CBaseTestHarness
       
    62 //
       
    63 
       
    64 class CBaseTestHarness : public CActive, public MBaseTestState
       
    65 	{
       
    66 public:
       
    67 	IMPORT_C virtual ~CBaseTestHarness();
       
    68 
       
    69 	IMPORT_C virtual void StartL(TRequestStatus& aStatus);
       
    70 
       
    71 	IMPORT_C virtual void AddStateL(MBaseTestState* aTestState, TTestDebugInfo aDebugInfo);
       
    72 
       
    73 	IMPORT_C virtual void LogCommentL(const TDesC& aError);
       
    74 	
       
    75 	IMPORT_C virtual void SetHeapFailureTesting(TBool aTest);
       
    76 
       
    77 	// From CActive
       
    78 	IMPORT_C void RunL();
       
    79 	IMPORT_C void DoCancel();
       
    80 	IMPORT_C TInt RunError(TInt aError);
       
    81 	IMPORT_C RTest& TestConsole();
       
    82 
       
    83 protected:
       
    84 	IMPORT_C virtual void ConstructL();
       
    85 	IMPORT_C CBaseTestHarness(RTest& aTest);
       
    86 
       
    87 	TInt iCurrentState;
       
    88 	TRequestStatus* iReportStatus;
       
    89 
       
    90 	RTest& iTest;
       
    91 	CArrayPtrFlat<MBaseTestState>* iStateList;
       
    92 
       
    93 	TBool iTestHeapFailure;
       
    94 
       
    95 private:
       
    96 //	CTestScript& iScript;
       
    97 	TInt iHeapFailureCount;
       
    98 	};
       
    99 
       
   100 
       
   101 //
       
   102 //
       
   103 // CMainTestHarness
       
   104 //
       
   105 
       
   106 class CMainTestHarness : public CBaseTestHarness
       
   107 	{
       
   108 public:
       
   109 	IMPORT_C static CMainTestHarness* NewL(RTest& aTest);
       
   110 	IMPORT_C virtual void StartL(TRequestStatus& aStatus);
       
   111 
       
   112 protected:
       
   113 	IMPORT_C virtual void ConstructL();
       
   114 	IMPORT_C CMainTestHarness(RTest& aTest);
       
   115 	};
       
   116 
       
   117 
       
   118 //
       
   119 //
       
   120 // CMsvClientTest
       
   121 //
       
   122 
       
   123 class CMsvClientTest : public CBaseTestHarness
       
   124 	{
       
   125 public:
       
   126 	IMPORT_C static CMsvClientTest* NewL(CMsvTestUtils& aTestUtils, RTest& aTest);
       
   127 	IMPORT_C static CMsvClientTest* NewL(CMsvTestUtils* aTestUtils, RTest& aTest);
       
   128 	IMPORT_C virtual ~CMsvClientTest();
       
   129 	IMPORT_C CMsvTestUtils& MsvTestUtils();
       
   130 	IMPORT_C void DoCancel();
       
   131 	IMPORT_C void SetCurrentOperation(CMsvOperation* aOperation);
       
   132 	IMPORT_C CMsvOperation& CurrentOperation();
       
   133 	IMPORT_C virtual void Reset();
       
   134 
       
   135 protected:
       
   136 	IMPORT_C virtual void ConstructL();
       
   137 	IMPORT_C CMsvClientTest(CMsvTestUtils& aMsvTestUtils, RTest& aTest);
       
   138 	IMPORT_C CMsvClientTest(CMsvTestUtils* aMsvTestUtils, RTest& aTest);
       
   139 
       
   140 public:
       
   141 	CMsvEntrySelection* iCurrentSelection;
       
   142 	TMsvId iSelectedFolder;
       
   143 	TMsvId iDestinationFolder;
       
   144 	TMsvId iCurrentServiceId;
       
   145 
       
   146 protected:
       
   147 	CMsvTestUtils& iMsvTestUtils;
       
   148 
       
   149 private:
       
   150 	CMsvTestUtils* iOwnedMsvTestUtils;
       
   151 	CMsvOperation* iOperation;
       
   152 	};
       
   153 
       
   154 
       
   155 #endif