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