common/tools/ats/smoketest/lbs/common/src/ctlbsactiveyield.cpp
author victorp@symbian.org
Wed, 03 Feb 2010 16:06:24 +0000
changeset 872 17498133d9ad
parent 748 e13acd883fbe
permissions -rw-r--r--
adding EPL headers to smoke test

// 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 the License "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:
// Common utils used by hybrid plugin tests
// 
//



/**
 @file ctlbsactiveyield.cpp
*/

#include <e32base.h>
#include <e32std.h>

#include <testexecutestepbase.h>


void CheckForObserverEventTestsL(TTimeIntervalMicroSeconds32 aTimeout, CTestStep& aStep)
	{
	class CTimeout : public CTimer
		{
		CTestStep& iStep;

		void RunL()  
	    	{
	    	iStep.SetTestStepError(KErrTimedOut);
	    	CActiveScheduler::Stop();
			}

		CTimeout(CTestStep& aTestStep) : CTimer(EPriorityLow), iStep(aTestStep) { ; }
		
	public:
		static CTimeout* NewL(CTestStep& aTestStep)
			{
			CTimeout* p = new (ELeave) CTimeout(aTestStep);
			CleanupStack::PushL(p);
			p->ConstructL();
			CActiveScheduler::Add(p);
			CleanupStack::Pop(p);
			return p;
			}
		};
		
	CTimeout *pTimeout = CTimeout::NewL(aStep);
	pTimeout->After(aTimeout);	
	
	CActiveScheduler::Start();

	if(pTimeout->iStatus == KRequestPending)
		{
		pTimeout->Cancel();
//		User::WaitForRequest(pTimeout->iStatus);
		}
	
	pTimeout->Deque();
	delete pTimeout;
	
	if(EPass != aStep.TestStepResult())
		{
		User::Leave(aStep.TestStepResult());
		}
	}
	

void ReturnToTestStep()
	{
	CActiveScheduler::Stop();
	}