diff -r 000000000000 -r b16258d2340f applayerprotocols/httptransportfw/Test/T_HttpOnline/CINC102380.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/applayerprotocols/httptransportfw/Test/T_HttpOnline/CINC102380.cpp Tue Feb 02 01:09:52 2010 +0200 @@ -0,0 +1,202 @@ +// Copyright (c) 2007-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: +// defines test class: CINC102380 +// +// + +#include "CINC102380.h" +#include "examplecookiemanager.h" +#include + +// User include +#include "csrvaddrval.h" + +// Literals used in the file +_LIT8(KHttpAuthenticationUrl, "http://remix.kwed.org"); + + +/** + This function is called to create a new instance of the class + CINC102380 + + @param aTestNumber The test number that has to be executed + @param aIniSettingsFile The script file that holds the sections + from which the value has to be retrieved + @leave Leaves with a standard error +*/ +CINC102380* CINC102380::NewL(TInt aTestNumber, CScriptFile* aIniSettingsFile) + { + CINC102380* self = new(ELeave)CINC102380(aTestNumber, aIniSettingsFile); + CleanupStack::PushL(self); + CleanupStack::Pop(self); + return self; + } + +/** + Destructor +*/ +CINC102380::~CINC102380() + { + } + +/** + This C++ constructor is called in the NewL function and is used to + instantiate iTestNumber and iIniSettingsFile + + @param aTestNumber - The test number that has to be executed + @param aIniSettingsFile - The script file that holds the sections + from which the value has to be retrieved +*/ +CINC102380::CINC102380(TInt aTestNumber, CScriptFile* aIniSettingsFile) : + iIniSettingsFile(aIniSettingsFile), + iTestNumber(aTestNumber) + { + // does nothing + } + +/** + This function is called to initiate the tests. + + @leave Leaves with a standard error. +*/ +void CINC102380::DoRunL() + { + TUriParser8 up; + up.Parse(KHttpAuthenticationUrl); + + // Open the HTTP session + iSession.OpenL(); + CleanupClosePushL(iSession); + + RStringPool strP = iSession.StringPool(); + + // Open a GET transactions, specifying this object as the request body data supplier + iTransaction = iSession.OpenTransactionL(up, *this, strP.StringF(HTTP::EGET,RHTTPSession::GetTable())); + + iTransaction.SubmitL(); + CActiveScheduler::Start(); + + CleanupStack::PopAndDestroy(&iSession); //close iSession + + } + +/** + If a test is failed then is function is executed to log the error code + with which the test failed + + @param aErr The error code with which the test failed. +*/ +TInt CINC102380::RunError(TInt aErr) + { + iEngine->Utils().LogIt(_L("\nTest failed with error code %d\n"), aErr); + return KErrNone; + } + +void CINC102380::DoCancel() + { + } + +const TDesC& CINC102380::TestName() + { + _LIT(KHeaderTestName,"CINC102380"); + return KHeaderTestName; + } + +TInt CINC102380::MHFRunError(TInt aError, RHTTPTransaction aTransaction, const THTTPEvent& /*aEvent*/) + { + _LIT(KLogDescription, "\nTest failed with error code %d on transaction ID=%d\n"); + iEngine->Utils().LogIt(KLogDescription, aError, aTransaction.Id()); + iFailureError = aError; + CActiveScheduler::Stop(); + return KErrNone; + } + +void CINC102380::MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent) + { + switch (aEvent.iStatus) + { + case THTTPEvent::EGotResponseHeaders: + { + // HTTP response headers have been received + iEngine->Utils().LogIt(_L("")); + MHTTPDataSupplier* body = aTransaction.Response().Body (); + if ( body ) + { + body->ReleaseData (); + } + } break; + case THTTPEvent::ESubmit: + { + } break; + case THTTPEvent::EGotResponseBodyData: + { + // Some (more) body data has been received (in the HTTP response) + iEngine->Utils().LogIt(_L("")); + // Get the body data supplier + MHTTPDataSupplier* iRespBody = aTransaction.Response().Body(); + // Append to the output file. + TPtrC8 bodyData; + TBool lastChunk = iRespBody->GetNextDataPart( bodyData ); + iRespBody->ReleaseData(); + } break; + case THTTPEvent::EResponseComplete: + { + // The transaction's response is complete + iEngine->Utils().LogIt(_L("")); + } break; + case THTTPEvent::ESucceeded: + { + // The transaction succeeded + iEngine->Utils().LogIt(_L("")); + aTransaction.Close(); + CActiveScheduler::Stop(); + } + break; + case THTTPEvent::EFailed: + { + // The transaction failed so fail the test + iEngine->Utils().LogIt(_L("")); + aTransaction.Close(); + CActiveScheduler::Stop(); + } break; + default: + { + _LIT(KLogDescription, " %d"); + iEngine->Utils().LogIt(KLogDescription,aEvent.iStatus); + if (aEvent.iStatus < 0) + { + iFailureError = aEvent.iStatus; + CActiveScheduler::Stop(); + } + } + break; + } + + return; + } + + +void CINC102380::ConfigureSessionFiltersL(TFilterConfigurationIterator* /*aFilterConfigIter*/) + { + if (iTestNumber == 11) + { + User::Leave(KErrNone); + } + + iCookieManager = CExampleCookieManager::NewL(iSession.StringPool()); + + CCookieFilterInterface::InstallFilterL(iSession, iCookieManager); + } + +