lafagnosticuifoundation/animation/tef/ActiveTestStep.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Mon, 15 Mar 2010 12:41:34 +0200
branchRCL_3
changeset 6 9f56a4e1b8ab
parent 0 2f259fa3e83a
permissions -rw-r--r--
Revision: 201009 Kit: 201010

// 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:
//

/**
 @file
 @test
 @internalComponent - Internal Symbian test code 
*/

#include "ActiveTestStep.h"
#include <test/appfwk_test_appui.h>

_LIT(KTestDied, "Test step died with errno = %d");

void CActiveTestStepScheduler::Error(TInt aError) const
	{
	iStep->Stop(aError); // Generally this doesn't work, but it's a good place to break
	};

CActiveTestStepLauncher::CActiveTestStepLauncher() :
CActive(EPriorityNormal),
iVerdict(EAbort)
	{
	}
	
CActiveTestStepLauncher::~CActiveTestStepLauncher()
	{
	Cancel();
	}

void CActiveTestStepLauncher::RunL()
	{
	TRAPD(err, iVerdict = iStep->doActiveTestStepL());
	iStep->Stop(err);
	}

void CActiveTestStepLauncher::DoCancel()
	{
	iStep->Stop(KErrCancel);
	}

void CActiveTestStepLauncher::Launch(CActiveTestStep* aStep)
	{
	iStep = aStep;
	CActiveScheduler::Add(this);
	TRequestStatus * status = &iStatus;
	User::RequestComplete(status, KErrNone);
	SetActive();
	}

CActiveTestStep::CActiveTestStep()
	{
	}
	
CActiveTestStep::~CActiveTestStep()
	{
	if(iLauncher)
		iLauncher->Cancel();
	delete iLauncher;
	delete iScheduler;
	}
	
TVerdict CActiveTestStep::doTestStepPreambleL()
	{
	SetTestStepResult(EPass);
	return TestStepResult();
	}
	
TVerdict CActiveTestStep::doTestStepL()
	{
	if(TestStepResult() == EPass)
		{
		iScheduler = new (ELeave) CActiveTestStepScheduler;
		CActiveScheduler::Install(iScheduler);
		
		iLauncher = new CActiveTestStepLauncher;
		iLauncher->Launch(this);
		iScheduler->Start();
		
		SetTestStepResult(iLauncher->TestStepResult());
		}
	return TestStepResult();
	}
	
TVerdict CActiveTestStep::doTestStepPostambleL()
	{
	return TestStepResult();
	}

void CActiveTestStep::Stop(TInt aError)
	{
	if(aError != KErrNone)
		{
		ERR_PRINTF2(KTestDied, aError);
		iLauncher->SetTestStepResult(EFail);
		}
	iScheduler->Stop();
	}