sl@0: // Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // OpenFileByHandlePlayTextFile.CPP sl@0: // sl@0: // sl@0: sl@0: #include "TestPlayer.h" sl@0: #include "OpenFileByHandle_PlayText.h" sl@0: sl@0: #include sl@0: sl@0: /** sl@0: * Constructor sl@0: */ sl@0: CTestMmfVclntOpenFilePlayTextFile::CTestMmfVclntOpenFilePlayTextFile(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay) sl@0: :iPlay (aPlay) sl@0: { sl@0: // store the name of this test case sl@0: // this is the name that is used by the script file sl@0: // Each test step initialises it's own name sl@0: iTestStepName = aTestName; sl@0: iSectName = aSectName; sl@0: iKeyName = aKeyName; sl@0: sl@0: // expand heap, so we can load 80k video sl@0: iHeapSize = 150000; sl@0: } sl@0: sl@0: CTestMmfVclntOpenFilePlayTextFile* CTestMmfVclntOpenFilePlayTextFile::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay) sl@0: { sl@0: CTestMmfVclntOpenFilePlayTextFile* self = new (ELeave) CTestMmfVclntOpenFilePlayTextFile(aTestName,aSectName,aKeyName,aPlay); sl@0: return self; sl@0: } sl@0: sl@0: CTestMmfVclntOpenFilePlayTextFile* CTestMmfVclntOpenFilePlayTextFile::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay) sl@0: { sl@0: CTestMmfVclntOpenFilePlayTextFile* self = CTestMmfVclntOpenFilePlayTextFile::NewLC(aTestName,aSectName,aKeyName,aPlay); sl@0: CleanupStack::PushL(self); sl@0: return self; sl@0: } sl@0: sl@0: void CTestMmfVclntOpenFilePlayTextFile::MvpuoOpenComplete(TInt aError) sl@0: { sl@0: iError = aError; sl@0: INFO_PRINTF1(_L("Open Complete callback")); sl@0: CActiveScheduler::Stop(); sl@0: } sl@0: sl@0: void CTestMmfVclntOpenFilePlayTextFile::MvpuoPrepareComplete(TInt aError) sl@0: { sl@0: iError = aError; sl@0: INFO_PRINTF1(_L("Open Complete callback")); sl@0: CActiveScheduler::Stop(); sl@0: } sl@0: sl@0: void CTestMmfVclntOpenFilePlayTextFile::MvpuoFrameReady(CFbsBitmap& /*aFrame*/, TInt aError) sl@0: { sl@0: iError = aError; sl@0: INFO_PRINTF1(_L("Frame Ready callback")); sl@0: } sl@0: sl@0: void CTestMmfVclntOpenFilePlayTextFile::MvpuoPlayComplete(TInt aError) sl@0: { sl@0: iError = aError; sl@0: INFO_PRINTF1(_L("Play Complete callback")); sl@0: CActiveScheduler::Stop(); sl@0: } sl@0: sl@0: void CTestMmfVclntOpenFilePlayTextFile::MvpuoEvent(const TMMFEvent& /*aEvent*/) sl@0: { sl@0: } sl@0: sl@0: sl@0: /** sl@0: * Load and initialise an audio file. sl@0: */ sl@0: TVerdict CTestMmfVclntOpenFilePlayTextFile::DoTestStepL() sl@0: { sl@0: return( PerformTestStepL() ); sl@0: } sl@0: sl@0: TVerdict CTestMmfVclntOpenFilePlayTextFile::PerformTestStepL() sl@0: { sl@0: TVerdict ret = EFail; sl@0: iError = KErrTimedOut; sl@0: sl@0: INFO_PRINTF1(_L("Test : Video Player - OpenFileL(RFile&)")); sl@0: sl@0: RFs fs; sl@0: RFile file; sl@0: sl@0: User::LeaveIfError(fs.Connect()); sl@0: CleanupClosePushL(fs); sl@0: User::LeaveIfError(fs.ShareProtected()); sl@0: sl@0: TPtrC filename; sl@0: if(!GetStringFromConfig(iSectName,iKeyName,filename)) sl@0: { sl@0: return EInconclusive; sl@0: } sl@0: sl@0: User::LeaveIfError(file.Open(fs,filename,EFileRead)); sl@0: CleanupClosePushL(file); sl@0: sl@0: InitWservL(); sl@0: sl@0: TRect rect, clipRect; sl@0: CVideoPlayerUtility* player = CVideoPlayerUtility::NewL(*this, EMdaPriorityNormal, sl@0: EMdaPriorityPreferenceTimeAndQuality, sl@0: iWs, *iScreen, *iWindow, rect, clipRect); sl@0: CleanupStack::PushL(player); sl@0: TRAP(iError,player->OpenFileL(file)); sl@0: sl@0: if(iError == KErrNone) sl@0: { sl@0: // Wait for initialisation callback sl@0: INFO_PRINTF1(_L("CVideoPlayerUtility: Opening file")); sl@0: CActiveScheduler::Start(); sl@0: } sl@0: sl@0: // text file is not supported sl@0: if(iError == KErrNotSupported) sl@0: { sl@0: ret = EPass; sl@0: } sl@0: sl@0: // Check for errors. sl@0: if (iError == KErrNone && player != NULL) sl@0: { sl@0: player->Prepare(); sl@0: CActiveScheduler::Start(); sl@0: } sl@0: sl@0: // Check for errors. sl@0: if (iError == KErrNone && player != NULL) sl@0: { sl@0: if(iPlay) sl@0: { sl@0: iError = KErrTimedOut; sl@0: player->Play(); sl@0: INFO_PRINTF1(_L("CVideoPlayerUtility: Playing file")); sl@0: // Wait for init callback sl@0: CActiveScheduler::Start(); sl@0: if(iError == KErrNone) sl@0: { sl@0: ret = EPass; sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ret = EPass; sl@0: } sl@0: } sl@0: sl@0: User::After(500000); sl@0: player->Stop(); sl@0: player->Close(); sl@0: sl@0: INFO_PRINTF1(_L("CVideoPlayerUtility: Destroying")); sl@0: if(iError != KErrNone) sl@0: { sl@0: ERR_PRINTF2( _L("CVideoPlayerUtility failed with error %d"),iError ); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(3, &fs); sl@0: sl@0: return ret; sl@0: } sl@0: