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