messagingfw/wappushfw/tpushscriptbased/pushtests.h
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     1 // Copyright (c) 2007-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 __PUSHTESTS_H__
       
    17 #define __PUSHTESTS_H__
       
    18 
       
    19 #include "t_wappush.h"
       
    20 #include <msvapi.h>
       
    21 #include <mtclbase.h>
       
    22 #include "dummywapstack.h"		// MDummyWapStackObserver
       
    23 
       
    24 #include <push/pushlog.h>			// for test engine Rfs/Cwatcherlog
       
    25 #include "ConnMan.h"			// for connection manager
       
    26 #include <caf/manager.h>
       
    27 #include <caf/rightsmanager.h>
       
    28 #include "httptestutils.h"
       
    29 
       
    30 const TInt KBufferSize = 2048;
       
    31 
       
    32 class MWapPushLog;
       
    33 class CWapPushMsgGen;
       
    34 
       
    35 
       
    36 class MTimeoutCallback
       
    37 	{
       
    38 public:
       
    39 	virtual void Timeout() = 0;
       
    40 	};
       
    41 
       
    42 class CTestTimer : public CTimer
       
    43 	{
       
    44 public:
       
    45 	static CTestTimer* NewL(MTimeoutCallback* callback)
       
    46 		{
       
    47 		CTestTimer* self = new(ELeave) CTestTimer(callback);
       
    48 		CleanupStack::PushL(self);
       
    49 		self->ConstructL(); // CTimer
       
    50 		CActiveScheduler::Add(self);
       
    51 		CleanupStack::Pop();
       
    52 		return self;
       
    53 		}
       
    54 
       
    55 protected:
       
    56 	virtual void RunL() 
       
    57 		{ 
       
    58 		iCallback->Timeout(); 
       
    59 		}
       
    60 private:
       
    61 	CTestTimer(MTimeoutCallback* callback): CTimer(EPriorityLow), iCallback(callback)
       
    62 	{};
       
    63 	
       
    64 	MTimeoutCallback* iCallback;
       
    65 	};
       
    66 
       
    67 
       
    68 /**
       
    69  * 	Derived test case class which implementation the stack observer
       
    70  * 	to allow communication with the stack
       
    71  *
       
    72  *	This class has been made abstract to allow different derived classes
       
    73  *	to implement creating multiple test messages via PrepareTestMessageL()
       
    74  *	and the support of NumberTestCasesToRun()
       
    75  *	BOTH must be implimented in any derived class.
       
    76  *	ConfirmMessagesSavedL provides confirmation of message storage and 
       
    77  *  reports on number of messages found in store.
       
    78  */
       
    79 class CWapPushBaseMessageTest : public CWapPushTest, public MDummyWapStackObserver
       
    80 	{
       
    81 public:
       
    82 	virtual ~CWapPushBaseMessageTest();
       
    83 	virtual void RunL();
       
    84 	virtual TInt RunError(TInt aError);
       
    85 	virtual void DoCancel();
       
    86 	virtual const TDesC& TestName();
       
    87 	virtual TDesC8& Uri() const = 0;
       
    88 
       
    89 	virtual void NumberTestCasesToRun();
       
    90 	virtual void PrepareTestMessageL(TInt aCurrentTestCase) = 0;	// abstract class now!!!
       
    91 	virtual TBool ConfirmMessagesSavedL() = 0;
       
    92 	
       
    93 	// from MDummyWapStackObserver	
       
    94 	virtual void DWSOUnitWaitPushL(CDummyWSPCLConn& aDummyCLConn);
       
    95 	virtual void DWSOCancelUnitWaitPush(CDummyWSPCLConn& aDummyCLConn);
       
    96 	virtual void DWSOServerShutDown();
       
    97 	virtual void DWSOError(const TDesC& aDes, TInt aLineNum);
       
    98 	virtual void DWSOConnect(CDummyWSPCOConn& aDummyCOConn);
       
    99 	virtual void DWSOGetEventL(CDummyWSPCOConn& aDummyCOConn);
       
   100 	virtual void DWSOCancelGetEvent(CDummyWSPCOConn& aDummyCOConn);
       
   101 	virtual void DWSOAckTransaction(CDummyWSPCOTrans& aDummyCOTrans);
       
   102 protected:
       
   103 	void MoveToNextState();
       
   104 	void CompleteOwnRequest();
       
   105 
       
   106 	void InitialiseMsgService();
       
   107 	
       
   108 protected:
       
   109 	enum TState
       
   110 		{
       
   111 		EInitialisation,
       
   112 		EWaitForPush,
       
   113 		EFinished
       
   114 		};
       
   115 protected:
       
   116 	TState						iState;
       
   117 	
       
   118 	TBuf8<KBufferSize>			iBodyBuf;
       
   119 	TBuf8<KBufferSize>			iHeadersBuf;
       
   120 	HBufC8*						iBody;
       
   121 	HBufC8*						iHeaders;
       
   122 
       
   123 	CDummyWapStack* iWapStack;
       
   124 	CConnectionManager* iConnMan;
       
   125 	TBool iHasMsgBeenCompleted;
       
   126 	TBool iHasTestBeenCompleted;
       
   127 
       
   128 	TInt iNumberOfTestCases;			
       
   129 	TInt iCurrentTestCase;
       
   130 
       
   131 	};
       
   132 
       
   133 /** Wap Message derived test class */
       
   134 class CWapPushMessageTest : public CWapPushBaseMessageTest
       
   135 	{
       
   136 public:
       
   137 	CWapPushMessageTest(TInt aIndex, CHTTPTestUtils* aTestUtils);
       
   138 	virtual ~CWapPushMessageTest();
       
   139 	void ReadAndSetParamsFromIniFileL();
       
   140 	void RemoveQuotes(HBufC8* aHBuf8Ptr);
       
   141 	TDesC8& GetHRef() const;
       
   142 	TDesC8& GetAction() const;
       
   143 	
       
   144 	virtual const TDesC& TestName() = 0;
       
   145 	virtual void NumberTestCasesToRun() = 0;
       
   146 	virtual void PrepareTestMessageL(TInt aCurrentTestCase) = 0;
       
   147 	virtual TBool ConfirmMessagesSavedL() = 0;
       
   148 	virtual TDesC8& Uri() const = 0;
       
   149 
       
   150 protected:
       
   151 	TInt iSectionIndex;
       
   152 	HBufC8* iUri;
       
   153 	HBufC8* iHRef;
       
   154 	HBufC8* iAction;	
       
   155 	};
       
   156 	
       
   157 	
       
   158 /** SI Specific Derived Test Class **/
       
   159 class CWapPushSIMessageTest : public CWapPushMessageTest
       
   160 	{
       
   161 public:
       
   162 	CWapPushSIMessageTest(TInt aIndex, CHTTPTestUtils* aTestUtils);
       
   163 	void ReadAndSetSIParamsFromIniFileL();
       
   164 	~CWapPushSIMessageTest();
       
   165 	TDesC8& GetSiId() const;
       
   166 	TDesC8& GetSICreatedDate() const;
       
   167 	TDesC8& GetSIExpiresDate() const;
       
   168 	
       
   169 	const TDesC& TestName();
       
   170 	void NumberTestCasesToRun();
       
   171 	void PrepareTestMessageL(TInt aCurrentTestCase);
       
   172 	TBool ConfirmMessagesSavedL();
       
   173 	TDesC8& Uri() const;
       
   174 
       
   175 private:
       
   176 	HBufC8* iSiId;
       
   177 	HBufC8* iSiCreatedDate;
       
   178 	HBufC8* iSiExpiresDate;	
       
   179 	};	
       
   180 	
       
   181 
       
   182 /** SL Specific Derived Test Class **/
       
   183 class CWapPushSLMessageTest : public CWapPushMessageTest
       
   184 	{
       
   185 public:
       
   186 	CWapPushSLMessageTest(TInt aIndex, CHTTPTestUtils* aTestUtils);
       
   187 	
       
   188 	const TDesC& TestName();
       
   189 	void NumberTestCasesToRun();
       
   190 	void PrepareTestMessageL(TInt aCurrentTestCase);
       
   191 	TBool ConfirmMessagesSavedL();
       
   192 	TDesC8& Uri() const;
       
   193 	};		
       
   194 
       
   195 
       
   196 #endif