os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/vclnt/src/TSI_MMFVCLNT.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 
     2 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 // All rights reserved.
     4 // This component and the accompanying materials are made available
     5 // under the terms of "Eclipse Public License v1.0"
     6 // which accompanies this distribution, and is available
     7 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 //
     9 // Initial Contributors:
    10 // Nokia Corporation - initial contribution.
    11 //
    12 // Contributors:
    13 //
    14 // Description:
    15 // This program is designed the test of the MMF_VCLNT.
    16 // 
    17 //
    18 
    19 /**
    20  @file TSI_MMFVCLNT.cpp
    21 */
    22 
    23 #include "TSI_MMFVCLNT.h"
    24 
    25 
    26 TInt CVideoCallbackHandler::ID()
    27 	{
    28 	return iID;
    29 	}
    30 
    31 void CVideoCallbackHandler::MvpuoOpenComplete(TInt aError)
    32 	{
    33 	iMchObserver->MchoComplete(ID(),aError);
    34 	}
    35 
    36 void CVideoCallbackHandler::MvpuoFrameReady(CFbsBitmap& /*aFrame*/)
    37 	{
    38 	iMchObserver->MchoComplete(ID(),0); 
    39 	}
    40 
    41 void CVideoCallbackHandler::MvpuoPlayComplete(TInt aError)
    42 	{
    43 	iMchObserver->MchoComplete(ID(),aError); 
    44 	}
    45 
    46 CVideoRecorderCallbackHandler::CVideoRecorderCallbackHandler(const TInt aID, MCallbackHandlerObserver* aMchObserver)
    47 	: iMchObserver(aMchObserver)
    48 	, iID(aID) 
    49 	{}
    50 
    51 TInt CVideoRecorderCallbackHandler::ID() 
    52 	{ 
    53 	return iID; 
    54 	}
    55 
    56 void CVideoRecorderCallbackHandler::MvruoOpenComplete(TInt aError)
    57 	{
    58 	iMchObserver->MchoComplete(ID(),aError); 
    59 	}
    60 
    61 void CVideoRecorderCallbackHandler::MvruoRecordComplete(TInt aError)
    62 	{
    63 	iMchObserver->MchoComplete(ID(),aError); 
    64 	}
    65 
    66 /**
    67  * Timeout function
    68  */
    69 void CTestMmfVclntStep::WaitWithTimeout(TRequestStatus& aStatus, TInt aNumberOfMicroSeconds)
    70 	{
    71 	TRequestStatus timerStatus;
    72 	RTimer timer ;
    73 	timer.CreateLocal() ;
    74 	timer.After(timerStatus,aNumberOfMicroSeconds);
    75 
    76 	User::WaitForRequest(aStatus, timerStatus);
    77 	if (timerStatus == KRequestPending)
    78 		{
    79 		timer.Cancel();
    80 		User::WaitForRequest(timerStatus);
    81 		}
    82 	else
    83 		{
    84 		INFO_PRINTF1(_L("Time is over!!!")) ;
    85 		}
    86 	timer.Close() ;
    87 	}
    88 
    89 /**
    90  * Time comparison utility function
    91  *
    92  * @param	"const TUint aActual"
    93  *			The actual timer value produced
    94  * @param	"const TUint aExpected"
    95  *			Expected timer value
    96  * @param	"const TUint aDeviation"
    97  *			Allowed deviation of the expected value
    98  *			from the actual value.
    99  * @return	"TBool"
   100  *			Did actual timed value fall within deviation limits
   101  */ 
   102 TBool CTestMmfVclntStep::TimeComparison(const TUint aActual, const TUint aExpected, const TUint aDeviation)
   103 	{
   104 	// save unnessary conditions
   105 	if(aActual == aExpected)
   106 		return ETrue;	
   107 
   108 	// Prevent unsigned wrapping errors 
   109 	TUint difference;
   110 	if(aActual > aExpected)
   111 		difference = aActual - aExpected;
   112 	else
   113 		difference = aExpected - aActual;
   114 
   115 	// comapare
   116 	if(difference < aDeviation)
   117 		return ETrue;
   118 	return EFalse;
   119 	}
   120 
   121 /**
   122  * Test Preample routines.
   123  *
   124  * Creates our own Active Scheduler.
   125  *
   126  * @return	"TVerdict"
   127  *			Did Preamble complete.
   128  */
   129 TVerdict CTestMmfVclntStep::DoTestStepPreambleL()
   130 	{
   131 	iActiveScheduler = new(ELeave) CActiveScheduler;
   132 	CActiveScheduler::Install(iActiveScheduler);
   133 
   134 	return EPass;
   135 	}
   136 
   137 /**
   138  * Test Postample routines.
   139  *
   140  * Destroys our Active Scheduler.
   141  *
   142  * @return	"TVerdict"
   143  *			Did Postamble complete.
   144  */
   145 TVerdict CTestMmfVclntStep::DoTestStepPostambleL()
   146 	{
   147 	delete iActiveScheduler;
   148 	iActiveScheduler = NULL;
   149 
   150 	delete iScreen;
   151 	delete iWindow;
   152 	iWs.Close();
   153 
   154 	return EPass;
   155 	}
   156 
   157 /**
   158  * CTestMMFVCLNTStep Implementation
   159  */
   160 CTestMmfVclntStep::CTestMmfVclntStep()
   161 	:iActiveScheduler( NULL )
   162 	{}
   163 
   164 CTestMmfVclntStep::~CTestMmfVclntStep()
   165 	{
   166 	}
   167 	
   168 void CTestMmfVclntStep::InitWservL()
   169 	{
   170 	TInt err = iWs.Connect();
   171 	if (err != KErrNone)
   172 		{
   173 		// Access violation if ws is null
   174 		INFO_PRINTF1(_L("Cannot test, no window server available"));
   175 		User::Leave(err);
   176 		}
   177 
   178 	iScreen = new (ELeave) CWsScreenDevice(iWs); // make device for this session
   179 	User::LeaveIfError(iScreen->Construct()); // and complete its construction
   180 
   181 	RWindowGroup rootWindow = RWindowGroup(iWs);
   182 	User::LeaveIfError(rootWindow.Construct((TUint32)this, ETrue));
   183 
   184 	iWindow = new(ELeave) RWindow(iWs);
   185 	User::LeaveIfError(((RWindow*)iWindow)->Construct(rootWindow,((TUint32)(this)) + 1));
   186 	iWindow->SetExtent(TPoint(0,0), TSize(100,100));
   187 	iWindow->SetVisible(ETrue);
   188 	iWindow->Activate();
   189 	iWs.Flush();
   190 	}