os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/vclnt/src/OpenFileByHandle_PlayText.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/vclnt/src/OpenFileByHandle_PlayText.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,180 @@
1.4 +// Copyright (c) 2004-2010 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 +// OpenFileByHandlePlayTextFile.CPP
1.18 +//
1.19 +//
1.20 +
1.21 +#include "TestPlayer.h"
1.22 +#include "OpenFileByHandle_PlayText.h"
1.23 +
1.24 +#include <caf/caf.h>
1.25 +
1.26 +/**
1.27 + * Constructor
1.28 + */
1.29 +CTestMmfVclntOpenFilePlayTextFile::CTestMmfVclntOpenFilePlayTextFile(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
1.30 + :iPlay (aPlay)
1.31 + {
1.32 + // store the name of this test case
1.33 + // this is the name that is used by the script file
1.34 + // Each test step initialises it's own name
1.35 + iTestStepName = aTestName;
1.36 + iSectName = aSectName;
1.37 + iKeyName = aKeyName;
1.38 +
1.39 + // expand heap, so we can load 80k video
1.40 + iHeapSize = 150000;
1.41 + }
1.42 +
1.43 +CTestMmfVclntOpenFilePlayTextFile* CTestMmfVclntOpenFilePlayTextFile::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
1.44 + {
1.45 + CTestMmfVclntOpenFilePlayTextFile* self = new (ELeave) CTestMmfVclntOpenFilePlayTextFile(aTestName,aSectName,aKeyName,aPlay);
1.46 + return self;
1.47 + }
1.48 +
1.49 +CTestMmfVclntOpenFilePlayTextFile* CTestMmfVclntOpenFilePlayTextFile::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
1.50 + {
1.51 + CTestMmfVclntOpenFilePlayTextFile* self = CTestMmfVclntOpenFilePlayTextFile::NewLC(aTestName,aSectName,aKeyName,aPlay);
1.52 + CleanupStack::PushL(self);
1.53 + return self;
1.54 + }
1.55 +
1.56 +void CTestMmfVclntOpenFilePlayTextFile::MvpuoOpenComplete(TInt aError)
1.57 + {
1.58 + iError = aError;
1.59 + INFO_PRINTF1(_L("Open Complete callback"));
1.60 + CActiveScheduler::Stop();
1.61 + }
1.62 +
1.63 +void CTestMmfVclntOpenFilePlayTextFile::MvpuoPrepareComplete(TInt aError)
1.64 + {
1.65 + iError = aError;
1.66 + INFO_PRINTF1(_L("Open Complete callback"));
1.67 + CActiveScheduler::Stop();
1.68 + }
1.69 +
1.70 +void CTestMmfVclntOpenFilePlayTextFile::MvpuoFrameReady(CFbsBitmap& /*aFrame*/, TInt aError)
1.71 + {
1.72 + iError = aError;
1.73 + INFO_PRINTF1(_L("Frame Ready callback"));
1.74 + }
1.75 +
1.76 +void CTestMmfVclntOpenFilePlayTextFile::MvpuoPlayComplete(TInt aError)
1.77 + {
1.78 + iError = aError;
1.79 + INFO_PRINTF1(_L("Play Complete callback"));
1.80 + CActiveScheduler::Stop();
1.81 + }
1.82 +
1.83 +void CTestMmfVclntOpenFilePlayTextFile::MvpuoEvent(const TMMFEvent& /*aEvent*/)
1.84 + {
1.85 + }
1.86 +
1.87 +
1.88 +/**
1.89 + * Load and initialise an audio file.
1.90 + */
1.91 +TVerdict CTestMmfVclntOpenFilePlayTextFile::DoTestStepL()
1.92 + {
1.93 + return( PerformTestStepL() );
1.94 + }
1.95 +
1.96 +TVerdict CTestMmfVclntOpenFilePlayTextFile::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 + InitWservL();
1.120 +
1.121 + TRect rect, clipRect;
1.122 + CVideoPlayerUtility* player = CVideoPlayerUtility::NewL(*this, EMdaPriorityNormal,
1.123 + EMdaPriorityPreferenceTimeAndQuality,
1.124 + iWs, *iScreen, *iWindow, rect, clipRect);
1.125 + CleanupStack::PushL(player);
1.126 + TRAP(iError,player->OpenFileL(file));
1.127 +
1.128 + if(iError == KErrNone)
1.129 + {
1.130 + // Wait for initialisation callback
1.131 + INFO_PRINTF1(_L("CVideoPlayerUtility: Opening file"));
1.132 + CActiveScheduler::Start();
1.133 + }
1.134 +
1.135 + // text file is not supported
1.136 + if(iError == KErrNotSupported)
1.137 + {
1.138 + ret = EPass;
1.139 + }
1.140 +
1.141 + // Check for errors.
1.142 + if (iError == KErrNone && player != NULL)
1.143 + {
1.144 + player->Prepare();
1.145 + CActiveScheduler::Start();
1.146 + }
1.147 +
1.148 + // Check for errors.
1.149 + if (iError == KErrNone && player != NULL)
1.150 + {
1.151 + if(iPlay)
1.152 + {
1.153 + iError = KErrTimedOut;
1.154 + player->Play();
1.155 + INFO_PRINTF1(_L("CVideoPlayerUtility: Playing file"));
1.156 + // Wait for init callback
1.157 + CActiveScheduler::Start();
1.158 + if(iError == KErrNone)
1.159 + {
1.160 + ret = EPass;
1.161 + }
1.162 + }
1.163 + else
1.164 + {
1.165 + ret = EPass;
1.166 + }
1.167 + }
1.168 +
1.169 + User::After(500000);
1.170 + player->Stop();
1.171 + player->Close();
1.172 +
1.173 + INFO_PRINTF1(_L("CVideoPlayerUtility: Destroying"));
1.174 + if(iError != KErrNone)
1.175 + {
1.176 + ERR_PRINTF2( _L("CVideoPlayerUtility failed with error %d"),iError );
1.177 + }
1.178 +
1.179 + CleanupStack::PopAndDestroy(3, &fs);
1.180 +
1.181 + return ret;
1.182 + }
1.183 +