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