os/mm/mmlibs/mmfw/tsrc/mmfunittest/videorenderer/inc/testgceharness.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #ifndef TESTGCEHARNESS_H
    17 #define TESTGCEHARNESS_H
    18 
    19 #include <e32base.h>
    20 #include <graphics/surfaceupdateclient.h>
    21 
    22 // The default processing delay for displaty and available events. Test specific delays can be set using
    23 // SetBufferEventProcessingDelay().
    24 static const TInt KDefaultDisplayedProcessingDelay = 2000;
    25 static const TInt KDefaultAvailableProcessingDelay = 2000;
    26 
    27 class CTestGCEHarness : public CBase
    28 	{
    29 public:
    30 	class CTestTimer;
    31 	
    32 	enum TRendererEvent
    33 		{
    34 		EEventDisplayed,
    35 		EEventAvailable,
    36 		EEventAll
    37 		};
    38 	
    39 	// The following functions are for use by the testframework test steps only
    40 
    41 	// Create global instance
    42 	static CTestGCEHarness* NewL(TInt aNumBuffers);
    43 
    44 	// Remove global instance - object must have ben closed first. Video Renderer destruction calls
    45 	// RSurfaceUpdateSession::Close() whihc in turn calls CTestGCEHarness::Close()
    46 	static void Remove();
    47 
    48     // Resets object to use the supplied number of buffers
    49 	static void ResetBuffersL(TInt aNumBuffers);
    50 	
    51 	// Resets global pointer to NULL - used in test pre amble. Required because Panic tests leave the
    52     // pointer hanging which if left causes the following test to crash. 
    53 	static void ResetGlobalPointer();
    54 	
    55 	// Allows delay to be set on a per test basis. If used before call to NewL() will fail silently.
    56 	static void SetBufferEventProcessingDelay(TRendererEvent aEventType, TTimeIntervalMicroSeconds32 aDelay);
    57 	
    58 	// The following functions are for use by the test RSurfaceUpdateSession implementation only
    59 	
    60     // Returns pointer to global pointer - leaves if object has not been created previously 
    61     static CTestGCEHarness* RetrieveL();
    62 	
    63 	// The following are called directly from same named functions in test RSurfaceUpdateSession implementation
    64     TInt Connect();
    65 	void Close();
    66 	void CancelAllNotifications();
    67 	TInt SubmitUpdate(TInt aBuffer);
    68 	void NotifyWhenAvailable(TRequestStatus& aStatus);
    69 	void NotifyWhenDisplayed(TRequestStatus& aStatus, TTimeStamp& aTimeStamp);
    70     
    71     // destructor
    72     ~CTestGCEHarness();
    73     
    74     // data per buffer 
    75     struct TBufferUpdateData
    76     	{
    77     	TTimeIntervalMicroSeconds32 iDisplayedProcessingDelay;
    78     	TTimeIntervalMicroSeconds32 iAvailableProcessingDelay;
    79     	TInt iDisplayedCompleteReason;
    80        	TInt iAvailableCompleteReason;
    81        	TBool iDisplayedInProgress;
    82        	TBool iAvailableInProgress;
    83        	CTestTimer* iDisplayedTimer;
    84        	CTestTimer* iAvailableTimer;
    85        	TRequestStatus *iStatusAvailable;
    86     	};
    87 
    88 private:
    89     CTestGCEHarness();
    90 	void ConstructL(TInt aNumBuffers);
    91 	
    92 	TRequestStatus *iStatusAvailable;
    93 	TRequestStatus *iStatusDisplayed;
    94 	TTimeStamp* iTimeStamp;
    95 	RArray<TBufferUpdateData> iUpdateArray;
    96 	TInt iLastPosted;
    97 	TInt iResetBuffers;
    98 	
    99 	void OnTimer(TInt aBufferId, TRendererEvent aEvent);
   100 
   101 	class CTestTimer : public CTimer
   102 		{
   103 		public:
   104 			static CTestTimer* NewL(CTestGCEHarness& aContainer, TInt aBufferId, TRendererEvent aEvent);
   105 			CTestTimer(CTestGCEHarness& aContainer, TInt aBufferId, TRendererEvent aEvent):CTimer(EPriorityStandard),iContainer(aContainer),iBufferId(aBufferId), iEvent(aEvent)
   106 				{
   107 				CActiveScheduler::Add(this);	
   108 				}
   109 		protected:
   110 			void RunL()
   111 				{
   112 				iContainer.OnTimer(iBufferId, iEvent);
   113 				}
   114 		private:
   115 			CTestGCEHarness& iContainer;
   116 			TInt iBufferId;
   117 			TRendererEvent iEvent;
   118 		};
   119 	};
   120 
   121 #endif // TESTGCEHARNESS_H