http/src/testhttpbasestep.cpp
branchSymbian2
changeset 1 8758140453c0
child 6 c108117318cb
equal deleted inserted replaced
0:e8c1ea2c6496 1:8758140453c0
       
     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 the License "Symbian Foundation License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Contains implementation of CTestHttpBaseStep class
       
    15 // @internalAll
       
    16 // 
       
    17 //
       
    18 
       
    19 // System Include
       
    20 // for StartC32()
       
    21 #include <c32comm.h>
       
    22 #include <e32base.h>
       
    23 #include <http.h>
       
    24 // User Include
       
    25 #include "testhttpbasestep.h"
       
    26 
       
    27 // File system root
       
    28 _LIT(KFileSystemRoot,"C:\\");
       
    29 
       
    30 // PDD names for the physical device drivers that are loaded in wins or arm
       
    31 #if defined (__WINS__)
       
    32 #define PDD_NAME		_L("ECDRV")
       
    33 #else
       
    34 #define PDD_NAME		_L("EUART1")
       
    35 #define PDD2_NAME		_L("EUART2")
       
    36 #define PDD3_NAME		_L("EUART3")
       
    37 #define PDD4_NAME		_L("EUART4")
       
    38 #endif
       
    39 
       
    40 #define LDD_NAME		_L("ECOMM")
       
    41 
       
    42 
       
    43 // Loads the physical device drivers
       
    44 void CTestHttpBaseStep::InitCommsL()
       
    45 	{
       
    46 	TInt ret = User::LoadPhysicalDevice(PDD_NAME);
       
    47 	User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
       
    48 
       
    49 #ifndef __WINS__
       
    50 	ret = User::LoadPhysicalDevice(PDD2_NAME);
       
    51 	ret = User::LoadPhysicalDevice(PDD3_NAME);
       
    52 	ret = User::LoadPhysicalDevice(PDD4_NAME);
       
    53 #endif
       
    54 
       
    55 	ret = User::LoadLogicalDevice(LDD_NAME);
       
    56 	User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
       
    57 	ret = StartC32();
       
    58 	User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
       
    59 	}
       
    60 	
       
    61 
       
    62 /**
       
    63 Constructor: Sets the test step name.
       
    64 @internalTechnology
       
    65 @test
       
    66 */
       
    67 CTestHttpBaseStep::CTestHttpBaseStep()
       
    68 	{
       
    69 	//Call base class method to set human readable name for test step
       
    70 	SetTestStepName(KTestHttpBaseStep);
       
    71 	}
       
    72 
       
    73 
       
    74 /**
       
    75 Destructor: Closes the iFileServ.
       
    76 @internalTechnology
       
    77 @test
       
    78 */
       
    79 CTestHttpBaseStep::~CTestHttpBaseStep()
       
    80 	{
       
    81 	iFileServ.Close();
       
    82 	delete iSched;
       
    83 	//CleanupStack::PopAndDestroy(); // iSched
       
    84 	iSched = NULL;
       
    85 	}
       
    86 	
       
    87 
       
    88 /**
       
    89 Base class virtual doTestStepPreambleL(): 
       
    90 Create and install the active scheduler and connect to iFileServ (RFs).
       
    91 @internalTechnology
       
    92 @test
       
    93 @param		None
       
    94 @return		EPass or EFail.
       
    95 */
       
    96 TVerdict CTestHttpBaseStep::doTestStepPreambleL()
       
    97 	{
       
    98 	iSched = new(ELeave) CActiveScheduler;
       
    99 	CActiveScheduler::Install(iSched);
       
   100 	User::LeaveIfError(iFileServ.Connect());
       
   101     return TestStepResult();
       
   102 	}	// doTestPreambleL
       
   103 
       
   104 
       
   105 /**
       
   106 Base class pure virtual doTestStepL(): 
       
   107 Tests the ebo support in http.
       
   108 @internalTechnology
       
   109 @test
       
   110 @param		None
       
   111 @return		EPass or EFail indicating the result of the test step.
       
   112 */
       
   113 TVerdict CTestHttpBaseStep::doTestStepL()
       
   114 	{
       
   115 //	__UHEAP_MARK;
       
   116 	INFO_PRINTF1(_L("\n"));
       
   117 	// Start C32 and initalize some device drivers. This is necessary when running a test console as these won't 
       
   118 	// have been started
       
   119 	TRAPD(err,InitCommsL());
       
   120 	if (err != KErrNone)
       
   121 		{
       
   122 		ERR_PRINTF2(_L("Teststep Failed: Leave occured in CTestHttpBaseStep::InitCommsL: %D\n"
       
   123 					  ),err
       
   124 				   );
       
   125 		SetTestStepResult(EFail);
       
   126 		}
       
   127 	else
       
   128 		{
       
   129 		// Opening session
       
   130 		iSess.OpenL();
       
   131 		// start the client
       
   132 		TRAP(err,StartClientL());
       
   133 		if (err != KErrNone)
       
   134 			{
       
   135 			ERR_PRINTF2(_L("Teststep Failed: Leave occured in CTestHttpBaseStep::StartClientL: %D\n"
       
   136 						  ),err
       
   137 					   );
       
   138 			SetTestStepResult(EFail);
       
   139 			}
       
   140 		// Closing session
       
   141 		iSess.Close();
       
   142 		}
       
   143 //	__UHEAP_MARKEND; 
       
   144 	
       
   145 	INFO_PRINTF1(_L("\n"));
       
   146 	return TestStepResult();
       
   147 	}	// doTestStepL
       
   148 	
       
   149 
       
   150 /**
       
   151 Sets the headers.
       
   152 @internalTechnology
       
   153 @test
       
   154 @param		aHeaders 	Headers collection
       
   155 @param		aHdrField 	Header field to be added
       
   156 @return		aHdrValue	Header value to be added	
       
   157 */
       
   158 void CTestHttpBaseStep::SetHeaderL(RHTTPHeaders aHeaders, TInt aHdrField, const TDesC8& aHdrValue)
       
   159 	{
       
   160 	RStringF valStr = iSess.StringPool().OpenFStringL(aHdrValue);
       
   161 	THTTPHdrVal val(valStr);
       
   162 	aHeaders.SetFieldL(iSess.StringPool().StringF(aHdrField,RHTTPSession::GetTable()), val);
       
   163 	valStr.Close();
       
   164 	}
       
   165 	
       
   166