applayerprotocols/httptransportfw/Test/T_HttpPipeliningTest/MPipeliningTestCase.h
changeset 0 b16258d2340f
equal deleted inserted replaced
-1:000000000000 0:b16258d2340f
       
     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 __MPIPELININGTESTCASE_H__
       
    17 #define __MPIPELININGTESTCASE_H__
       
    18 
       
    19 #include <e32base.h>
       
    20 #include <http.h>
       
    21 
       
    22 /*
       
    23 The MPipeliningTestCase class is a pure virtual class used to derive/create test cases
       
    24 for use with the t_httppipeliningtest test harness.
       
    25 
       
    26 To write a test case for the t_httppipeliningtest test harness, it is a simple task of
       
    27 creating a C class that is derived from the pure virtual class MPipeliningTestCase.
       
    28 The test case class must implement the methods detailed below in order for the test case
       
    29 to be executed. Writing a test case assumes knowledge of the HTTP Transport Framework
       
    30 and how it is supposed to behave. The input data is all provided by the test case as well
       
    31 as the server responses and the expected behaviour.
       
    32 
       
    33 The test harness provides a simple HTTP client and server that query the test case on how
       
    34 it should behave based on various parameters. The description is provided below with each
       
    35 of the pure virtual methods in this class.
       
    36 
       
    37 To use the test server functionality all requests must be directed to http://127.0.0.1 on
       
    38 port 80.
       
    39 
       
    40 Once the test case class has been implemented, the class must be added to the test engine
       
    41 in CPipeliningTestEngine::DoTestsL(). To do this the following code must be added...
       
    42 
       
    43   CTestCaseExample* testCase = CTestCaseExample::NewL(*iTestUtils);
       
    44   CleanupStack::PushL(testCase);
       
    45   RunTestL(*testCase);
       
    46   CleanupStack::PopAndDestroy(testCase);
       
    47 
       
    48 The construction parameters iTestUtils is optional, but is simply a reference to the
       
    49 CHTTPTestUtils class to provide standard HTTP logging functionality.
       
    50 */
       
    51 class MPipeliningTestCase
       
    52 	{
       
    53 public:
       
    54 	/*
       
    55 	This method should return a descriptor that contains the display name of the test case.
       
    56 	*/
       
    57 	virtual const TDesC& TestCaseName() const = 0;
       
    58 
       
    59 	/*
       
    60 	This method should return the total number of transactions that are opened and involved
       
    61 	in the test case. This number can be dynamic during the running of the test, an example
       
    62 	of this would be if transactions are cancelled and therefore those should removed from
       
    63 	the count. The test HTTP client uses this value so it knows when all the transactions
       
    64 	have completed.
       
    65 	*/
       
    66 	virtual TInt TotalTransactionCount() const = 0;
       
    67 
       
    68 	/*
       
    69 	This method should return the number of transactions on a giving connection index. For
       
    70 	tests that open a number of connections on a server, this method should return the
       
    71 	number of transactions on a connection identified by its index (ie starting from 0).
       
    72 	Tests that don't use multiple conenctions, this should simply return the same value as
       
    73 	TotalTransactionCount(0).
       
    74 	*/
       
    75 	virtual TInt TransactionCount(TInt aConnectionIndex) const = 0;
       
    76 
       
    77 	/*
       
    78 	This method should create the RHTTPTransaction that will be used in the test. The index
       
    79 	value passed in indicates what transaction should be created (based on the
       
    80 	TotalTransactionCount() value and will be called that many times. The HTTP Session and
       
    81 	the client transaction callback that should be used is also provided in the parameters.
       
    82 	*/
       
    83 	virtual RHTTPTransaction GetTransactionL(TInt aIndex, RHTTPSession aSession, MHTTPTransactionCallback& aClient) = 0;
       
    84 
       
    85 	/*
       
    86 	This method allows the test case to set an option into how the transactions are
       
    87 	submitted. If this method returns ETrue, the transaction will be batched where they are
       
    88 	all opened first and then submitted all together, or else return EFalse so transactions
       
    89 	are submitted as they are opened.
       
    90 	*/
       
    91 	virtual TBool BatchTransactions() const = 0;
       
    92 
       
    93 	/*
       
    94 	When the client receives a transaction event, the error code can be checked to verify
       
    95 	what (if any) error code is expected. The transaction is supplied so that the test case
       
    96 	can identify the transaction by Id(). If no error codes are expected, this method should
       
    97 	return KErrNone.
       
    98 	*/
       
    99 	virtual TInt ExpectedError(RHTTPTransaction aTrans) = 0;
       
   100 
       
   101 	/*
       
   102 	This method should return the raw request data that is expected to be reeived by the
       
   103 	server for a giving connection and transaction on that connection. The connection
       
   104 	is indentified by its index and then the transaction index on that connection. For
       
   105 	instance, for the 3rd transaction on the 2nd connection will result in aConnectionIndex = 1
       
   106 	and aTransIndex = 2.
       
   107 	*/
       
   108 	virtual const TDesC8& GetRawRequest(TInt aConnectionIndex, TInt aTransIndex) = 0;
       
   109 
       
   110 	/*
       
   111 	This method should return the raw response data that the server should return for a
       
   112 	given transaction. This is similar to GetRawRequest() with the parameter values.
       
   113 	*/
       
   114 	virtual const TDesC8& GetRawResponse(TInt aConnectionIndex, TInt aTransIndex) = 0;
       
   115 
       
   116 	/*
       
   117 	This method should return the number of connections that is expected to open with the
       
   118 	test server in the test case. If the test server is not being used (ie. transactions are
       
   119 	going to 'real' servers) then this should return 0.
       
   120 	*/
       
   121 	virtual TInt ConnectionCount() const = 0;
       
   122 
       
   123 	/*
       
   124 	This method should return the number of expected connections opened with real servers. 
       
   125 	This information is stored by the protocol handler in debug mode only and checked.
       
   126 	
       
   127 	When using the test server this should return the same as ConnectionCount()
       
   128 	*/
       
   129 	virtual TInt RealExpectedConnectionCount() const = 0;
       
   130 
       
   131 	/*
       
   132 	This method will indicate whether to enable batching (request buffering). The test engine
       
   133 	will use this to enable/disable batching by setting the appropriate session property.
       
   134 	*/
       
   135 	virtual TBool EnableBatching() const = 0;
       
   136 	
       
   137 	/*
       
   138 	This method is called when the EGotResponseHeaders event is received and gives the 
       
   139 	opportunity for the test case to process the headers. 
       
   140 	*/
       
   141 	virtual void ProcessHeadersL(RHTTPTransaction aTrans) = 0;
       
   142 	
       
   143 	/*
       
   144 	The AO priority of the transport handler will be set to EPriorityHigh if this method returns ETrue.
       
   145 	Else the AO priority of the transport handler will be set to EPriorityStandard.
       
   146 	*/
       
   147 	virtual TBool TransportHandlerPriority() const = 0;
       
   148 	
       
   149 	};
       
   150 	
       
   151 #endif // __MPIPELININGTESTCASE_H__