1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/vclnt/OpenFileByHandle1513.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,163 @@
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 "OpenFileByHandle1513.h"
1.21 +
1.22 +#include <caf/caf.h>
1.23 +
1.24 +/**
1.25 + * Constructor
1.26 + */
1.27 +CTestMmfVclntOpenFile1513::CTestMmfVclntOpenFile1513(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 +CTestMmfVclntOpenFile1513* CTestMmfVclntOpenFile1513::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aRec)
1.39 + {
1.40 + CTestMmfVclntOpenFile1513* self = new (ELeave) CTestMmfVclntOpenFile1513(aTestName,aSectName,aKeyName,aRec);
1.41 + return self;
1.42 + }
1.43 +
1.44 +CTestMmfVclntOpenFile1513* CTestMmfVclntOpenFile1513::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aRec)
1.45 + {
1.46 + CTestMmfVclntOpenFile1513* self = CTestMmfVclntOpenFile1513::NewL(aTestName,aSectName,aKeyName,aRec);
1.47 + CleanupStack::PushL(self);
1.48 + return self;
1.49 + }
1.50 +
1.51 +void CTestMmfVclntOpenFile1513::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 CTestMmfVclntOpenFile1513::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 CTestMmfVclntOpenFile1513::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 CTestMmfVclntOpenFile1513::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 CTestMmfVclntOpenFile1513::DoTestStepL()
1.80 + {
1.81 + return( PerformTestStepL() );
1.82 + }
1.83 +
1.84 +TVerdict CTestMmfVclntOpenFile1513::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 +
1.113 + TRAP(iError,rec->OpenFileL(file,
1.114 + NULL,
1.115 + KVidTstControllerUid,
1.116 + KUidMdaBmpClipFormat,
1.117 + KNullDesC8,
1.118 + KMMFFourCCCodeNULL));
1.119 +
1.120 + if(iError == KErrNone)
1.121 + {
1.122 + INFO_PRINTF1(_L("CVideoRecorderUtility: Open file"));
1.123 + // Wait for initialisation callback
1.124 + CActiveScheduler::Start();
1.125 + }
1.126 +
1.127 + // Check for errors.
1.128 + if ((iError == KErrNone) && (rec != NULL))
1.129 + {
1.130 + rec->Prepare();
1.131 + CActiveScheduler::Start();
1.132 + if(iError != KErrNone)
1.133 + {
1.134 + INFO_PRINTF2(_L("Prepare callback : error %d"), iError);
1.135 + ret = EInconclusive;
1.136 + }
1.137 +
1.138 + if(iRec)
1.139 + {
1.140 + iError = KErrTimedOut;
1.141 + rec->Record();
1.142 + INFO_PRINTF1(_L("CVideoRecorderUtility: Record"));
1.143 + // Wait for init callback
1.144 + CActiveScheduler::Start();
1.145 + if(iError == KErrNone)
1.146 + {
1.147 + ret = EPass;
1.148 + }
1.149 + }
1.150 + else
1.151 + {
1.152 + ret = EPass;
1.153 + }
1.154 + }
1.155 +
1.156 + INFO_PRINTF1(_L("CVideoRecorderUtility: Destroy"));
1.157 + User::After(KOneSecond); // wait for deletion to shut down devsound
1.158 + if(iError != KErrNone)
1.159 + {
1.160 + ERR_PRINTF2( _L("CVideoRecorderUtility failed with error %d"),iError );
1.161 + }
1.162 +
1.163 + CleanupStack::PopAndDestroy(3, &fs);
1.164 +
1.165 + return ret;
1.166 + }