applayerprotocols/httptransportfw/Test/T_HttpPipeliningTest/CTestCase7.cpp
author Pat Downey <patd@symbian.org>
Wed, 01 Sep 2010 12:21:21 +0100
branchRCL_3
changeset 40 a0da872af3fa
parent 0 b16258d2340f
permissions -rw-r--r--
Revert incorrect RCL_3 drop: Revision: 201029 Kit: 201035

// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of "Eclipse Public License v1.0"
// which accompanies this distribution, and is available
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
//
// Initial Contributors:
// Nokia Corporation - initial contribution.
//
// Contributors:
//
// Description:
//

#include "CTestCase7.h"
#include "httptestutils.h"

const TInt KTransactionCount = 10;

CTestCase7* CTestCase7::NewL(CHTTPTestUtils& aTestUtils)
	{
	CTestCase7* self = new (ELeave) CTestCase7(aTestUtils);
	CleanupStack::PushL(self);
	self->ConstructL();
	CleanupStack::Pop(self);
	return self;
	}

CTestCase7::CTestCase7(CHTTPTestUtils& aTestUtils)
: CPipeliningTestCase(), iTestUtils(aTestUtils), iTransCount(KTransactionCount)
	{
	}

void CTestCase7::ConstructL()
	{
	}

CTestCase7::~CTestCase7()
	{
	}

const TDesC& CTestCase7::TestCaseName() const
	{
	_LIT(KTxtTitle, "Test Case 7");
	return KTxtTitle();
	}

TInt CTestCase7::TotalTransactionCount() const
	{
	return iTransCount;
	}
	
	
TInt CTestCase7::RealExpectedConnectionCount() const
 	{
 	return 1;
 	}	
 	
	
RHTTPTransaction CTestCase7::GetTransactionL(TInt aIndex, RHTTPSession aSession, MHTTPTransactionCallback& aClient)
	{
	__ASSERT_ALWAYS(aIndex<KTransactionCount, User::Invariant());
	
	RStringF method = aSession.StringPool().StringF(HTTP::EGET,RHTTPSession::GetTable());
	_LIT8(KTxtUri, "http://10.29.23.60/pipeline/hello.txt");
	TUriParser8 uri; 
	uri.Parse(KTxtUri());

	if( aIndex == 4 )
		{
		iTransToCancel = aSession.OpenTransactionL(uri, aClient, method);
		return iTransToCancel;
		}

	return aSession.OpenTransactionL(uri, aClient, method);
	}
	
const TDesC8& CTestCase7::GetRawRequest(TInt /*aConnectionIndex*/, TInt /*aTransIndex*/)
	{
	// This method shoulod never be called as we are going to a live server
	User::Invariant();
	
	return KNullDesC8();
	}
	
const TDesC8& CTestCase7::GetRawResponse(TInt /*aConnectionIndex*/, TInt /*aTransIndex*/)
	{
	// This method shoulod never be called as we are going to a live server
	User::Invariant();
	
	return KNullDesC8();
	}
	
TInt CTestCase7::ExpectedError(RHTTPTransaction aTrans)
	{
	if(!iIsTransCancelled)
		{
		if(aTrans.Id()==3)
			{
			iTransToCancel.Cancel();
			iIsTransCancelled = ETrue;
			--iTransCount;
			}
		}
		
	if( iTransToCancel.Id() == aTrans.Id() )
		return KErrCancel;

	return KErrNone;
	}