1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/vclnt/src/OpenFileByHandle0034.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,176 @@
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 "TestPlayer.h"
1.20 +#include "OpenFileByHandle0034.h"
1.21 +
1.22 +#include <caf/caf.h>
1.23 +
1.24 +/**
1.25 + * Constructor
1.26 + */
1.27 +CTestMmfVclntOpenFile0034::CTestMmfVclntOpenFile0034(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
1.28 + :iPlay (aPlay)
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 + // expand heap, so we can load 80k video
1.38 + iHeapSize = 150000;
1.39 + }
1.40 +
1.41 +CTestMmfVclntOpenFile0034* CTestMmfVclntOpenFile0034::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
1.42 + {
1.43 + CTestMmfVclntOpenFile0034* self = new (ELeave) CTestMmfVclntOpenFile0034(aTestName,aSectName,aKeyName,aPlay);
1.44 + return self;
1.45 + }
1.46 +
1.47 +CTestMmfVclntOpenFile0034* CTestMmfVclntOpenFile0034::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
1.48 + {
1.49 + CTestMmfVclntOpenFile0034* self = CTestMmfVclntOpenFile0034::NewLC(aTestName,aSectName,aKeyName,aPlay);
1.50 + CleanupStack::PushL(self);
1.51 + return self;
1.52 + }
1.53 +
1.54 +void CTestMmfVclntOpenFile0034::MvpuoOpenComplete(TInt aError)
1.55 + {
1.56 + iError = aError;
1.57 + INFO_PRINTF1(_L("Open Complete callback"));
1.58 + CActiveScheduler::Stop();
1.59 + }
1.60 +
1.61 +void CTestMmfVclntOpenFile0034::MvpuoPrepareComplete(TInt aError)
1.62 + {
1.63 + iError = aError;
1.64 + INFO_PRINTF1(_L("Prepare Complete callback"));
1.65 + CActiveScheduler::Stop();
1.66 + }
1.67 +
1.68 +void CTestMmfVclntOpenFile0034::MvpuoFrameReady(CFbsBitmap& /*aFrame*/, TInt aError)
1.69 + {
1.70 + iError = aError;
1.71 + INFO_PRINTF1(_L("Frame Ready callback"));
1.72 + }
1.73 +
1.74 +void CTestMmfVclntOpenFile0034::MvpuoPlayComplete(TInt aError)
1.75 + {
1.76 + iError = aError;
1.77 + INFO_PRINTF1(_L("Play Complete callback"));
1.78 + CActiveScheduler::Stop();
1.79 + }
1.80 +
1.81 +void CTestMmfVclntOpenFile0034::MvpuoEvent(const TMMFEvent& /*aEvent*/)
1.82 + {
1.83 + }
1.84 +
1.85 +
1.86 +/**
1.87 + * Load and initialise an audio file.
1.88 + */
1.89 +TVerdict CTestMmfVclntOpenFile0034::DoTestStepL()
1.90 + {
1.91 + InitWservL();
1.92 +
1.93 + return( PerformTestStepL() );
1.94 + }
1.95 +
1.96 +TVerdict CTestMmfVclntOpenFile0034::PerformTestStepL()
1.97 + {
1.98 + TVerdict ret = EFail;
1.99 + iError = KErrTimedOut;
1.100 +
1.101 + INFO_PRINTF1(_L("Test : Video Player - OpenFileL(RFile&)"));
1.102 +
1.103 + RFs fs;
1.104 + RFile file;
1.105 +
1.106 + User::LeaveIfError(fs.Connect());
1.107 + CleanupClosePushL(fs);
1.108 + User::LeaveIfError(fs.ShareProtected());
1.109 +
1.110 + TPtrC filename;
1.111 + if(!GetStringFromConfig(iSectName,iKeyName,filename))
1.112 + {
1.113 + return EInconclusive;
1.114 + }
1.115 +
1.116 + User::LeaveIfError(file.Open(fs,filename,EFileRead));
1.117 + CleanupClosePushL(file);
1.118 +
1.119 + TRect rect, clipRect;
1.120 + CVideoPlayerUtility* player = CVideoPlayerUtility::NewL(*this, EMdaPriorityNormal,
1.121 + EMdaPriorityPreferenceTimeAndQuality,
1.122 + iWs, *iScreen, *iWindow, rect, clipRect);
1.123 + CleanupStack::PushL(player);
1.124 + TRAP(iError,player->OpenFileL(file));
1.125 +
1.126 + if(iError == KErrNone)
1.127 + {
1.128 + // Wait for initialisation callback
1.129 + INFO_PRINTF1(_L("CVideoPlayerUtility: Opening file"));
1.130 + CActiveScheduler::Start();
1.131 + }
1.132 +
1.133 + if(iError == KErrNotSupported)
1.134 + {
1.135 + ret = EPass;
1.136 + }
1.137 +
1.138 + // Check for errors.
1.139 + if (iError == KErrNone && player != NULL)
1.140 + {
1.141 + player->Prepare();
1.142 + CActiveScheduler::Start();
1.143 + }
1.144 +
1.145 + // Check for errors.
1.146 + if (iError == KErrNone && player != NULL)
1.147 + {
1.148 + if(iPlay)
1.149 + {
1.150 + iError = KErrTimedOut;
1.151 + player->Play();
1.152 + INFO_PRINTF1(_L("CVideoPlayerUtility: Playing file"));
1.153 + // Wait for init callback
1.154 + CActiveScheduler::Start();
1.155 + if(iError == KErrNone)
1.156 + {
1.157 + ret = EPass;
1.158 + }
1.159 + }
1.160 + else
1.161 + {
1.162 + ret = EPass;
1.163 + }
1.164 + }
1.165 +
1.166 + User::After(1000000);
1.167 + player->Stop();
1.168 + player->Close();
1.169 +
1.170 + INFO_PRINTF1(_L("CVideoPlayerUtility: Destroying"));
1.171 + CleanupStack::PopAndDestroy(player);
1.172 + if(iError != KErrNone)
1.173 + {
1.174 + ERR_PRINTF2( _L("CVideoPlayerUtility failed with error %d"),iError );
1.175 + }
1.176 +
1.177 + CleanupStack::PopAndDestroy(2, &fs);
1.178 + return ret;
1.179 + }