1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/vclnt/src/OpenFileByHandle0523.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,169 @@
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 "TestRecord.h"
1.20 +#include "OpenFileByHandle0523.h"
1.21 +
1.22 +#include <caf/caf.h>
1.23 +
1.24 +/**
1.25 + * Constructor
1.26 + */
1.27 +CTestMmfVclntOpenFile0523::CTestMmfVclntOpenFile0523(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 +CTestMmfVclntOpenFile0523* CTestMmfVclntOpenFile0523::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aRec)
1.39 + {
1.40 + CTestMmfVclntOpenFile0523* self = new (ELeave) CTestMmfVclntOpenFile0523(aTestName,aSectName,aKeyName,aRec);
1.41 + return self;
1.42 + }
1.43 +
1.44 +CTestMmfVclntOpenFile0523* CTestMmfVclntOpenFile0523::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aRec)
1.45 + {
1.46 + CTestMmfVclntOpenFile0523* self = CTestMmfVclntOpenFile0523::NewL(aTestName,aSectName,aKeyName,aRec);
1.47 + CleanupStack::PushL(self);
1.48 + return self;
1.49 + }
1.50 +
1.51 +void CTestMmfVclntOpenFile0523::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 CTestMmfVclntOpenFile0523::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 CTestMmfVclntOpenFile0523::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 CTestMmfVclntOpenFile0523::MvruoEvent(const TMMFEvent& /*aEvent*/)
1.73 + {
1.74 + }
1.75 +
1.76 +/**
1.77 + * Load and initialise an audio file.
1.78 + */
1.79 +TVerdict CTestMmfVclntOpenFile0523::DoTestStepL()
1.80 + {
1.81 + return( PerformTestStepL() );
1.82 + }
1.83 +
1.84 +TVerdict CTestMmfVclntOpenFile0523::PerformTestStepL()
1.85 + {
1.86 + TVerdict ret = EFail;
1.87 +
1.88 + INFO_PRINTF1(_L("Test : Video Recorder - OpenFileL(RFile&)"));
1.89 +
1.90 + RFs fs;
1.91 + RFile file;
1.92 +
1.93 + User::LeaveIfError(fs.Connect());
1.94 + CleanupClosePushL(fs);
1.95 + User::LeaveIfError(fs.ShareProtected());
1.96 +
1.97 + iError = KErrTimedOut;
1.98 +
1.99 + TPtrC filename;
1.100 + if(!GetStringFromConfig(iSectName,iKeyName,filename))
1.101 + {
1.102 + return EInconclusive;
1.103 + }
1.104 +
1.105 + User::LeaveIfError(file.Replace(fs,filename,EFileWrite));
1.106 + CleanupClosePushL(file);
1.107 +
1.108 + CVideoRecorderUtility* rec = CVideoRecorderUtility::NewL(*this);
1.109 + CleanupStack::PushL(rec);
1.110 +
1.111 + const TUid KVidTstControllerUid = {KMmfVideoTestControllerUid};
1.112 + TRAP(iError,rec->OpenFileL(file,
1.113 + NULL,
1.114 + KVidTstControllerUid,
1.115 + KUidMdaBmpClipFormat,
1.116 + KNullDesC8,
1.117 + KMMFFourCCCodeNULL));
1.118 +
1.119 + if(iError == KErrNone)
1.120 + {
1.121 + INFO_PRINTF1(_L("CVideoRecorderUtility: Open file"));
1.122 + // Wait for initialisation callback
1.123 + CActiveScheduler::Start();
1.124 + }
1.125 +
1.126 + if(iError == KErrNotSupported)
1.127 + {
1.128 + ret = EPass;
1.129 + }
1.130 +
1.131 + // Check for errors.
1.132 + if ((iError == KErrNone) && (rec != NULL))
1.133 + {
1.134 + rec->Prepare();
1.135 + CActiveScheduler::Start();
1.136 + if(iError != KErrNone)
1.137 + {
1.138 + INFO_PRINTF2(_L("Prepare callback : error %d"), iError);
1.139 + return EInconclusive;
1.140 + }
1.141 +
1.142 + if(iRec)
1.143 + {
1.144 + iError = KErrTimedOut;
1.145 + rec->Record();
1.146 + INFO_PRINTF1(_L("CVideoRecorderUtility: Record"));
1.147 + // Wait for init callback
1.148 + CActiveScheduler::Start();
1.149 + if(iError == KErrNone)
1.150 + {
1.151 + ret = EPass;
1.152 + }
1.153 + }
1.154 + else
1.155 + {
1.156 + ret = EPass;
1.157 + }
1.158 + }
1.159 +
1.160 + rec->Close();
1.161 +
1.162 + INFO_PRINTF1(_L("CVideoRecorderUtility: Destroy"));
1.163 + User::After(KOneSecond); // wait for deletion to shut down devsound
1.164 + if(iError != KErrNone)
1.165 + {
1.166 + ERR_PRINTF2( _L("CVideoRecorderUtility failed with error %d"),iError );
1.167 + }
1.168 +
1.169 + CleanupStack::PopAndDestroy(3,&fs);
1.170 +
1.171 + return ret;
1.172 + }