os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/vclnt/src/OpenFileByHandle1011.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/vclnt/src/OpenFileByHandle1011.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,172 @@
     1.4 +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include "TestPlayer.h"
    1.20 +#include "OpenFileByHandle1011.h"
    1.21 +
    1.22 +#include <caf/caf.h>
    1.23 +
    1.24 +/**
    1.25 + * Constructor
    1.26 + */
    1.27 +CTestMmfVclntOpenFile1011::CTestMmfVclntOpenFile1011(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName,const TBool aRec)
    1.28 +	:iRec (aRec)
    1.29 +	{
    1.30 +	// store the name of this test case
    1.31 +	// this is the name that is used by the script file
    1.32 +	// Each test step initialises it's own name
    1.33 +	iTestStepName = aTestName;
    1.34 +	iSectName = aSectName;
    1.35 +	iKeyName = aKeyName;
    1.36 +	}
    1.37 +
    1.38 +CTestMmfVclntOpenFile1011* CTestMmfVclntOpenFile1011::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aRec)
    1.39 +	{
    1.40 +	CTestMmfVclntOpenFile1011* self = new (ELeave) CTestMmfVclntOpenFile1011(aTestName,aSectName,aKeyName,aRec);
    1.41 +	return self;
    1.42 +	}
    1.43 +
    1.44 +CTestMmfVclntOpenFile1011* CTestMmfVclntOpenFile1011::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aRec)
    1.45 +	{
    1.46 +	CTestMmfVclntOpenFile1011* self = CTestMmfVclntOpenFile1011::NewL(aTestName,aSectName,aKeyName,aRec);
    1.47 +	CleanupStack::PushL(self);
    1.48 +	return self;
    1.49 +	}
    1.50 +
    1.51 +void CTestMmfVclntOpenFile1011::MvruoOpenComplete(TInt aError)
    1.52 +	{
    1.53 +	iError = aError;
    1.54 +	INFO_PRINTF1(_L("Open complete callback"));
    1.55 +	CActiveScheduler::Stop();
    1.56 +	}
    1.57 +
    1.58 +void CTestMmfVclntOpenFile1011::MvruoRecordComplete(TInt aError)
    1.59 +	{
    1.60 +	iError = aError;
    1.61 +	INFO_PRINTF1(_L("Record complete callback"));
    1.62 +	CActiveScheduler::Stop();
    1.63 +	}
    1.64 +
    1.65 +void CTestMmfVclntOpenFile1011::MvruoPrepareComplete(TInt aError)
    1.66 +	{
    1.67 +	iError = aError;
    1.68 +	INFO_PRINTF1(_L("Prepare complete callback"));
    1.69 +	CActiveScheduler::Stop();
    1.70 +	}
    1.71 +	
    1.72 +void CTestMmfVclntOpenFile1011::MvruoEvent(const TMMFEvent& /*aEvent*/)
    1.73 +	{
    1.74 +	}
    1.75 +
    1.76 +/**
    1.77 + * Load and initialise an audio file.
    1.78 + */
    1.79 +#define KInvalidControllerUid	0xA0A0A0A0
    1.80 +
    1.81 +TVerdict CTestMmfVclntOpenFile1011::DoTestStepL()
    1.82 +	{
    1.83 +	TVerdict ret = EFail;
    1.84 +
    1.85 +	INFO_PRINTF1(_L("Test : Video Recorder - OpenFileL(RFile&)"));
    1.86 +
    1.87 +	RFs		fs;
    1.88 +	RFile	file;
    1.89 +
    1.90 +	User::LeaveIfError(fs.Connect());
    1.91 +	CleanupClosePushL(fs);
    1.92 +	User::LeaveIfError(fs.ShareProtected());
    1.93 +
    1.94 +	iError = KErrTimedOut;
    1.95 +
    1.96 +	TPtrC filename;
    1.97 +	if(!GetStringFromConfig(iSectName,iKeyName,filename))
    1.98 +		{
    1.99 +		return EInconclusive;
   1.100 +		}
   1.101 +
   1.102 +	User::LeaveIfError(file.Replace(fs,filename,EFileWrite));
   1.103 +	CleanupClosePushL(file);
   1.104 +
   1.105 +	CVideoRecorderUtility* rec = CVideoRecorderUtility::NewL(*this);
   1.106 +	CleanupStack::PushL(rec);
   1.107 +
   1.108 +	const TUid KVidTstControllerUid = {KInvalidControllerUid};
   1.109 +	TRAP(iError,rec->OpenFileL(file,
   1.110 +							   NULL,
   1.111 +							   /*KNullUid*/ KVidTstControllerUid,
   1.112 +							   KUidMdaBmpClipFormat ));
   1.113 +
   1.114 +	if(iError == KErrNone)
   1.115 +		{
   1.116 +		INFO_PRINTF1(_L("CVideoRecorderUtility: Open file"));
   1.117 +		// Wait for initialisation callback
   1.118 +		CActiveScheduler::Start();
   1.119 +		}
   1.120 +
   1.121 +	// Controller not found
   1.122 +	if(iError == KErrNotFound)
   1.123 +		{
   1.124 +		ret = EPass;
   1.125 +		}
   1.126 +
   1.127 +	if(iError == KErrNotSupported)
   1.128 +		{
   1.129 +		ret = EPass;
   1.130 +		}
   1.131 +
   1.132 +	// Check for errors.
   1.133 +	if ((iError == KErrNone) && (rec != NULL))
   1.134 +		{
   1.135 +		rec->Prepare();
   1.136 +		CActiveScheduler::Start();
   1.137 +		if(iError != KErrNone)
   1.138 +			{
   1.139 +			INFO_PRINTF2(_L("Prepare callback : error %d"), iError);
   1.140 +			ret = EInconclusive;
   1.141 +			}
   1.142 +
   1.143 +		if(iRec)
   1.144 +			{
   1.145 +			iError = KErrTimedOut;
   1.146 +			rec->Record();
   1.147 +			INFO_PRINTF1(_L("CVideoRecorderUtility: Record"));
   1.148 +			// Wait for init callback
   1.149 +			CActiveScheduler::Start();
   1.150 +			if(iError == KErrNone)
   1.151 +				{
   1.152 +				ret = EPass;
   1.153 +				}
   1.154 +			User::After(500000);
   1.155 +			rec->Stop();
   1.156 +			}
   1.157 +		else
   1.158 +			{
   1.159 +			ret = EPass;
   1.160 +			}
   1.161 +		}
   1.162 +
   1.163 +	rec->Close();
   1.164 +
   1.165 +	INFO_PRINTF1(_L("CVideoRecorderUtility: Destroy"));
   1.166 +	CleanupStack::PopAndDestroy(3, &fs);
   1.167 +
   1.168 +	User::After(KOneSecond); // wait for deletion to shut down devsound
   1.169 +	if(iError != KErrNone && ret != EPass)
   1.170 +		{
   1.171 +		ERR_PRINTF2( _L("CVideoRecorderUtility reported error %d"),iError );
   1.172 +		}
   1.173 +
   1.174 +	return	ret;
   1.175 +	}