sl@0: sl@0: // Copyright (c) 2002-2009 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: // This program is designed the test of the MMF_VCLNT. sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file TSI_MMFVCLNT.cpp sl@0: */ sl@0: sl@0: #include "TSI_MMFVCLNT.h" sl@0: sl@0: sl@0: TInt CVideoCallbackHandler::ID() sl@0: { sl@0: return iID; sl@0: } sl@0: sl@0: void CVideoCallbackHandler::MvpuoOpenComplete(TInt aError) sl@0: { sl@0: iMchObserver->MchoComplete(ID(),aError); sl@0: } sl@0: sl@0: void CVideoCallbackHandler::MvpuoFrameReady(CFbsBitmap& /*aFrame*/) sl@0: { sl@0: iMchObserver->MchoComplete(ID(),0); sl@0: } sl@0: sl@0: void CVideoCallbackHandler::MvpuoPlayComplete(TInt aError) sl@0: { sl@0: iMchObserver->MchoComplete(ID(),aError); sl@0: } sl@0: sl@0: CVideoRecorderCallbackHandler::CVideoRecorderCallbackHandler(const TInt aID, MCallbackHandlerObserver* aMchObserver) sl@0: : iMchObserver(aMchObserver) sl@0: , iID(aID) sl@0: {} sl@0: sl@0: TInt CVideoRecorderCallbackHandler::ID() sl@0: { sl@0: return iID; sl@0: } sl@0: sl@0: void CVideoRecorderCallbackHandler::MvruoOpenComplete(TInt aError) sl@0: { sl@0: iMchObserver->MchoComplete(ID(),aError); sl@0: } sl@0: sl@0: void CVideoRecorderCallbackHandler::MvruoRecordComplete(TInt aError) sl@0: { sl@0: iMchObserver->MchoComplete(ID(),aError); sl@0: } sl@0: sl@0: /** sl@0: * Timeout function sl@0: */ sl@0: void CTestMmfVclntStep::WaitWithTimeout(TRequestStatus& aStatus, TInt aNumberOfMicroSeconds) sl@0: { sl@0: TRequestStatus timerStatus; sl@0: RTimer timer ; sl@0: timer.CreateLocal() ; sl@0: timer.After(timerStatus,aNumberOfMicroSeconds); sl@0: sl@0: User::WaitForRequest(aStatus, timerStatus); sl@0: if (timerStatus == KRequestPending) sl@0: { sl@0: timer.Cancel(); sl@0: User::WaitForRequest(timerStatus); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("Time is over!!!")) ; sl@0: } sl@0: timer.Close() ; sl@0: } sl@0: sl@0: /** sl@0: * Time comparison utility function sl@0: * sl@0: * @param "const TUint aActual" sl@0: * The actual timer value produced sl@0: * @param "const TUint aExpected" sl@0: * Expected timer value sl@0: * @param "const TUint aDeviation" sl@0: * Allowed deviation of the expected value sl@0: * from the actual value. sl@0: * @return "TBool" sl@0: * Did actual timed value fall within deviation limits sl@0: */ sl@0: TBool CTestMmfVclntStep::TimeComparison(const TUint aActual, const TUint aExpected, const TUint aDeviation) sl@0: { sl@0: // save unnessary conditions sl@0: if(aActual == aExpected) sl@0: return ETrue; sl@0: sl@0: // Prevent unsigned wrapping errors sl@0: TUint difference; sl@0: if(aActual > aExpected) sl@0: difference = aActual - aExpected; sl@0: else sl@0: difference = aExpected - aActual; sl@0: sl@0: // comapare sl@0: if(difference < aDeviation) sl@0: return ETrue; sl@0: return EFalse; sl@0: } sl@0: sl@0: /** sl@0: * Test Preample routines. sl@0: * sl@0: * Creates our own Active Scheduler. sl@0: * sl@0: * @return "TVerdict" sl@0: * Did Preamble complete. sl@0: */ sl@0: TVerdict CTestMmfVclntStep::DoTestStepPreambleL() sl@0: { sl@0: iActiveScheduler = new(ELeave) CActiveScheduler; sl@0: CActiveScheduler::Install(iActiveScheduler); sl@0: sl@0: return EPass; sl@0: } sl@0: sl@0: /** sl@0: * Test Postample routines. sl@0: * sl@0: * Destroys our Active Scheduler. sl@0: * sl@0: * @return "TVerdict" sl@0: * Did Postamble complete. sl@0: */ sl@0: TVerdict CTestMmfVclntStep::DoTestStepPostambleL() sl@0: { sl@0: delete iActiveScheduler; sl@0: iActiveScheduler = NULL; sl@0: sl@0: delete iScreen; sl@0: delete iWindow; sl@0: iWs.Close(); sl@0: sl@0: return EPass; sl@0: } sl@0: sl@0: /** sl@0: * CTestMMFVCLNTStep Implementation sl@0: */ sl@0: CTestMmfVclntStep::CTestMmfVclntStep() sl@0: :iActiveScheduler( NULL ) sl@0: {} sl@0: sl@0: CTestMmfVclntStep::~CTestMmfVclntStep() sl@0: { sl@0: } sl@0: sl@0: void CTestMmfVclntStep::InitWservL() sl@0: { sl@0: TInt err = iWs.Connect(); sl@0: if (err != KErrNone) sl@0: { sl@0: // Access violation if ws is null sl@0: INFO_PRINTF1(_L("Cannot test, no window server available")); sl@0: User::Leave(err); sl@0: } sl@0: sl@0: iScreen = new (ELeave) CWsScreenDevice(iWs); // make device for this session sl@0: User::LeaveIfError(iScreen->Construct()); // and complete its construction sl@0: sl@0: RWindowGroup rootWindow = RWindowGroup(iWs); sl@0: User::LeaveIfError(rootWindow.Construct((TUint32)this, ETrue)); sl@0: sl@0: iWindow = new(ELeave) RWindow(iWs); sl@0: User::LeaveIfError(((RWindow*)iWindow)->Construct(rootWindow,((TUint32)(this)) + 1)); sl@0: iWindow->SetExtent(TPoint(0,0), TSize(100,100)); sl@0: iWindow->SetVisible(ETrue); sl@0: iWindow->Activate(); sl@0: iWs.Flush(); sl@0: }