datacommsserver/esockserver/test/TE_ESockSSA/src/TestStepESockSSA.h
author Pat Downey <patd@symbian.org>
Wed, 01 Sep 2010 12:35:48 +0100
branchRCL_3
changeset 70 b564fb5fd78b
parent 0 dfb7c4ff071f
permissions -rw-r--r--
Revert incorrect RCL_3 drop: Revision: 201035 Kit: 201035

// Copyright (c) 2005-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:
// Contains declaration of CTestStepESockSSA class that is
// base class for all test step classes in this test.
// 
//

#if !defined(SYMBIAN_NETWORKING_ESOCKTEST_TESTSTEPESOCKSSA_H_)
#define SYMBIAN_NETWORKING_ESOCKTEST_TESTSTEPESOCKSSA_H_

#include <test/testexecutestepbase.h>


// Relies upon no competing use of the thread semaphore, ie no request completions/AOs
class RMultipleWait : public RFastLock
	{
public:
	RMultipleWait(TInt aInitialCount);
	void Close();
	void Signal(TInt aDelta);
	void Wait();

	typedef RFastLock inherited;
private:
	TInt iCount;
	RThread iOwnerThread;
	};


class CTestStepESockSSA : public CTestStep
	{
public:
	enum { KBlockedRequestIssueDelay = 1000000, KBlockedRequestCompletionDelay = 1000000 };

	CTestStepESockSSA();
	~CTestStepESockSSA();
	
	virtual TVerdict doTestStepPreambleL();
	virtual TVerdict doTestStepPostambleL();

protected:
	class TDataThreadControl
		{
	public:
		TDataThreadControl(RMultipleWait& aBlockSemaphore, TInt aExpectedResult)
		: iBlockSemaphore(aBlockSemaphore),
		  iExpectedResult(aExpectedResult)
			{
			}
	public:
		enum TRequestType
			{ 
			ESocketOpen, 
			EHostResolverOpen,
			EHostResolverOpenMulti,
			EServiceResolverOpen, 
			ENetDBOpen, 
			ENumProtocols, 
			EGetProtocolInfo,
			EFindProtocol
			};
		TRequestType iRequest;
		RMultipleWait& iBlockSemaphore;
		TBool iBlocked;
		TInt iResult;
		TInt iExpectedResult;
		RThread iThread;
		RSocketServ iSession;
		};

	typedef TInt (*TDataThreadEntryPt)(TDataThreadControl&);
protected:
	void SetDummyBlocking();
	void ClearDummyBlocking();

	TInt CreateDataThread(TDataThreadControl::TRequestType aRequest, TDataThreadControl& aControl);
	TVerdict WaitForDataThreadsToBlock(TDataThreadControl* aThreads, TInt aNumThreads);
	TVerdict WaitForDataThreadsToComplete(TDataThreadControl* aThreads, TInt aNumThreads);

	static TInt DataThreadEntry(TDataThreadControl& aControl);
private:
	static void DoDataThreadL(TDataThreadControl& aControl);
	void UnloadBlockerL();
	void KillC32Start();
	};
	
#endif /* SYMBIAN_NETWORKING_ESOCKTEST_TESTSTEPESOCKSSA_H_ */