email/imap4mtm/imapsession/test/inc/cfakeoutputstream.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 11 May 2010 16:10:04 +0300
branchRCL_3
changeset 18 fbb813aef148
parent 0 72b543305e3a
permissions -rw-r--r--
Revision: 201017 Kit: 201019

// Copyright (c) 2006-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:
//

#ifndef CFAKEOUTPUTSTREAM_H
#define CFAKEOUTPUTSTREAM_H

#include <e32base.h>
#include <test/tefunit.h>
#include "moutputstream.h"

class MOutputStreamObserver;
class MOutputStreamSecureObserver;

/**
A dummy output stream object.
This object records data that is "sent" via SendDataReq()
The owner of this object can access this data via PtrOutput() in order
to test that expected data has been sent.
@internalTechnology
@prototype
*/
class CFakeOutputStream : public CBase
						, public MOutputStream
	{
public:
	static CFakeOutputStream* NewL(CTestExecuteLogger& aLogger);	
	~CFakeOutputStream();	

	// Implement MOutputStream
	void Bind(MOutputStreamObserver& aObserver, TInt aLogId);
	void BindSecure(MOutputStreamSecureObserver& aObserver);
	void SendDataReq(const TDesC8& aBuffer, TInt aIdleTime = 0);
	void SecureClientReq(const TDesC8& aHostName);
	void Close();
	
	// Access to recorded output data
	TPtrC8 PtrOutput();
	void ResetOutput();
	
	// Logging
	inline CTestExecuteLogger& Logger() { return iLogger; }
	
private:
	CFakeOutputStream(CTestExecuteLogger& aLogger);
	void ConstructL();
	
	/**
	Records data that has been sent via SendDataReq()
	*/
	CBufFlat* iOutputBuffer;

	CTestExecuteLogger&	iLogger;
	
	MOutputStreamObserver* iOutputStreamObserver;
	};

#endif // CFAKEOUTPUTSTREAM_H