applayerprotocols/httptransportfw/Test/T_WspEncoder/WspHeaderWriterUnitTestContext.inl
changeset 0 b16258d2340f
equal deleted inserted replaced
-1:000000000000 0:b16258d2340f
       
     1 // Copyright (c) 2001-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 // The context for the unit tests upon the CWspHeaderWriter class methods.
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file WspHeaderWriterUnitTestContext.inl
       
    20 */
       
    21 
       
    22 #include "WspHeaderWriterTransitions.h"
       
    23 #include "cheaders.h"
       
    24 #include "cheaderfield.h"
       
    25 
       
    26 // System includes
       
    27 #include <wspstringconstants.h>
       
    28 
       
    29 _LIT8(KTxtTestHeader, "TestHeader");
       
    30 
       
    31 // ______________________________________________________________________________
       
    32 //
       
    33 inline CWspHeaderWriter_UnitTestContext::CWspHeaderWriter_UnitTestContext(CDataLogger& aDataLogger,
       
    34 												MStateAccessor& aStateAccessor,
       
    35 												MTransitionObserver& aObserver,
       
    36 												const TStringTable& aStrTable)
       
    37 : CUnitTestContext(aDataLogger, aStateAccessor, aObserver), iStrTable(aStrTable)
       
    38 	{
       
    39 	//Do nothing
       
    40 	}
       
    41 
       
    42 inline CWspHeaderWriter_UnitTestContext::~CWspHeaderWriter_UnitTestContext()
       
    43 	{
       
    44 	delete iExpectedData;
       
    45 	delete iOutputData;
       
    46 	delete iTestHeader;
       
    47 	delete iHeaderField;
       
    48 	delete iHeader;
       
    49 	delete iCodec;
       
    50 	iStrPool.Close();
       
    51 	}
       
    52 
       
    53 inline void CWspHeaderWriter_UnitTestContext::ConstructL(TInt aHeaderName)
       
    54 	{
       
    55 	iHeaderToken = aHeaderName;
       
    56 	iStrPool.OpenL(iStrTable);
       
    57 	iCodec = CWspHeaderCodec::NewL(iStrPool, iStrTable);
       
    58 	REINTERPRET_CAST(CWspHeaderCodec*, iCodec)->SetWspVersion(CWspHeaderCodec::EVersion1_4);
       
    59 	iHeader = CHeaders::NewL(*iCodec);
       
    60 	if( iHeaderToken == KErrNotFound )
       
    61 		{
       
    62 		RStringF testHeader = iStrPool.OpenFStringL(KTxtTestHeader());
       
    63 		CleanupClosePushL(testHeader);
       
    64 		iHeaderField = CHeaderField::NewL(testHeader, *iHeader);
       
    65 		CleanupStack::PopAndDestroy(&testHeader);
       
    66 		}
       
    67 	else
       
    68 		{
       
    69 		iHeaderField = CHeaderField::NewL(iStrPool.StringF(aHeaderName, iStrTable), *iHeader);
       
    70 		}
       
    71 	iTestHeader = new(ELeave) RHeaderField(*iHeaderField);
       
    72 	}
       
    73 
       
    74 inline void CWspHeaderWriter_UnitTestContext::SetOutputL()
       
    75 	{
       
    76 	TPtrC8 rawData;
       
    77 	iTestHeader->RawDataL(rawData);
       
    78 	iOutputData = rawData.AllocL();
       
    79 	}
       
    80 
       
    81 inline void CWspHeaderWriter_UnitTestContext::SetExpectedL(const TDesC8& aExpectedData)
       
    82 	{
       
    83 	iExpectedData = aExpectedData.AllocL();
       
    84 	}
       
    85 
       
    86 inline void CWspHeaderWriter_UnitTestContext::SetTrapOutputL()
       
    87 	{
       
    88 	TPtrC8 rawData;
       
    89 	TRAPD(err, iTestHeader->RawDataL(rawData));
       
    90 	if(err == KErrNoMemory)
       
    91 		User::Leave(err);
       
    92 
       
    93 	TBuf8<25> convertNum;
       
    94 	convertNum.Num(err);
       
    95 	iOutputData = convertNum.AllocL();
       
    96 	}