graphicscomposition/openwfsupport/test/tstreamoperation/tnativestream.h
changeset 0 5d03bc08d59c
child 121 d72fc2aace31
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     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 // Test class for interop implementation of NativeStream
       
    15 // 
       
    16 //
       
    17 
       
    18 #ifndef TESTNATIVESTREAM_H
       
    19 #define TESTNATIVESTREAM_H
       
    20 
       
    21 // INCLUDES
       
    22 #include <test/tefunit.h>
       
    23 #include <w32std.h>
       
    24 #include <khronos_types.h>
       
    25 #include "surfaceutility.h"
       
    26 
       
    27 #include <graphics/symbianstream.h>
       
    28 class CTestExecuteLogger;
       
    29 class CSurfaceStream;
       
    30 
       
    31 template <class Referee,class LoggerOwner>
       
    32 class	SafePointer
       
    33 	{
       
    34 public:
       
    35 	SafePointer(LoggerOwner* aOwner,Referee* aReferee=NULL):
       
    36 		iOwner(aOwner),	iReferee(aReferee)
       
    37 		{}
       
    38 	Referee*	operator=(Referee* aReferee)
       
    39 		{
       
    40 		return iReferee=aReferee;
       
    41 		}
       
    42 	Referee*&	operator()()
       
    43 		{
       
    44 		return iReferee;
       
    45 		}
       
    46 	Referee*	operator->()
       
    47 		{
       
    48 		if (iReferee==NULL)
       
    49 			{
       
    50 			iOwner -> INFO_PRINTF1(_L("Tried to dereference a pointer that is null!"));
       
    51 			User::Panic(_L("null pointer"),__LINE__);
       
    52 			}
       
    53 		return iReferee;
       
    54 		}
       
    55 private:
       
    56 	LoggerOwner* iOwner;
       
    57 	Referee* iReferee;
       
    58 	};
       
    59 
       
    60 
       
    61 // MAIN CLASS DECLARATION
       
    62 
       
    63 class TGlobalNativeStreamVar
       
    64 	{
       
    65 public:
       
    66 	static const TGlobalNativeStreamVar& Instance();
       
    67 	
       
    68 	void SetSurfaceID(TSurfaceId aSurfaceID);
       
    69 	void SetTestComplete (TBool aTestComplete);
       
    70 	void SetBuffers (TInt aBuffers);
       
    71 	
       
    72 	TSurfaceId SurfaceID() const;
       
    73 	TBool TestComplete() const;
       
    74 	TInt Buffers() const;
       
    75 	
       
    76 public:
       
    77 	TSurfaceId		iSurfaceID;
       
    78 	TBool			iTestComplete;
       
    79 	TInt			iBuffers;
       
    80 	TInt            iMultithreadCounter;
       
    81 	};
       
    82 
       
    83 struct TCallbackData
       
    84     {
       
    85     SymbianStreamType		iStream;
       
    86     TInt32	                iEvent;
       
    87     TAny*					iData;
       
    88     };
       
    89 
       
    90 /**
       
    91  *  CTestNativeStream
       
    92  * 
       
    93  */
       
    94 class CTestNativeStream : public CTestFixture
       
    95 	{
       
    96 public:
       
    97 	// Constructors and destructor
       
    98 
       
    99 	/**
       
   100 	 * Constructor for performing 1st stage construction
       
   101 	 */
       
   102 	CTestNativeStream();
       
   103 
       
   104 	/**
       
   105 	 * Destructor.
       
   106 	 */
       
   107 	~CTestNativeStream();
       
   108 
       
   109 	/**
       
   110 	 * test Suite furniture 
       
   111 	 **/
       
   112 	virtual void SetupL();
       
   113 	
       
   114 	/**
       
   115 	 * test Suite furniture 
       
   116 	 **/
       
   117 	virtual void TearDownL();
       
   118 
       
   119 
       
   120 	/**
       
   121 	 * test Suite furniture 
       
   122 	 **/
       
   123 	static CTestSuite* CreateSuiteL(const TDesC& aName);
       
   124 		
       
   125 	/**
       
   126 	 * Checks acquire or find native streams operations
       
   127 	 **/
       
   128 	SymbianStreamType NsCheckL(const TSurfaceId aId, TInt aCheck, TBool aFind);
       
   129 	
       
   130 	/**
       
   131 	 * For concurrent tests, create a shared stream for all threads to access.
       
   132 	 */
       
   133 	void CreateSharedNativeStreamL(TInt aBuffers);
       
   134 	
       
   135 	/**
       
   136 	 * For concurrent tests, destroy the shared stream.
       
   137 	 */	
       
   138 	void DestroySharedNativeStreamL();
       
   139 	
       
   140 	static void SourceStreamUpdatedCallback(SymbianStreamType aNs, 
       
   141 	        khronos_int32_t aEvents, void* aData, void* aParam);
       
   142 	
       
   143 	void CheckSourceStreamUpdated(SymbianStreamType aNs, void* aParam);
       
   144 	void RemoveNsNotifications();
       
   145 
       
   146 	/**
       
   147      * A helper function that returns the bytes per pixel for a given pixel format UID
       
   148      * @param aPixelFormat Pixel format UID to convert
       
   149      * @return Positive: bytes per pixel; negative is pixels per byte; 0 is error 
       
   150      */
       
   151     
       
   152     TInt BytesPerPixel(TUidPixelFormat aPixelFormat);
       
   153 	
       
   154 private:
       
   155 	// Private tests
       
   156 	void GRAPHICS_OPENWFC_NATIVESTREAM_0100L();
       
   157 	void GRAPHICS_OPENWFC_NATIVESTREAM_0101L();
       
   158 	void GRAPHICS_OPENWFC_NATIVESTREAM_0102L();
       
   159 	void GRAPHICS_OPENWFC_NATIVESTREAM_0103L();
       
   160 	void GRAPHICS_OPENWFC_NATIVESTREAM_0104L(TInt aNumBuffers);
       
   161 	void GRAPHICS_OPENWFC_NATIVESTREAM_0105L(TInt aNumBuffers);
       
   162 	void GRAPHICS_OPENWFC_NATIVESTREAM_0106L(TInt aNumBuffers);
       
   163 	void GRAPHICS_OPENWFC_NATIVESTREAM_0107_1L();
       
   164 	void GRAPHICS_OPENWFC_NATIVESTREAM_0107_2L();
       
   165 	void GRAPHICS_OPENWFC_NATIVESTREAM_0107_3L();
       
   166 	void GRAPHICS_OPENWFC_NATIVESTREAM_0108L(TInt aNumBuffers);
       
   167 	void GRAPHICS_OPENWFC_NATIVESTREAM_0109L();
       
   168 	void GRAPHICS_OPENWFC_NATIVESTREAM_0110L();
       
   169 	void GRAPHICS_OPENWFC_NATIVESTREAM_0111L();
       
   170 	void GRAPHICS_OPENWFC_NATIVESTREAM_0112_1L();
       
   171 	void GRAPHICS_OPENWFC_NATIVESTREAM_0112_2L();
       
   172 	void GRAPHICS_OPENWFC_NATIVESTREAM_0112_3L();
       
   173 	void GRAPHICS_OPENWFC_NATIVESTREAM_0112_4L();
       
   174 	void GRAPHICS_OPENWFC_NATIVESTREAM_0113L();
       
   175 	void GRAPHICS_OPENWFC_NATIVESTREAM_0114L();
       
   176 	void GRAPHICS_OPENWFC_NATIVESTREAM_0115L();
       
   177 	void GRAPHICS_OPENWFC_NATIVESTREAM_0116L();
       
   178 	void GRAPHICS_OPENWFC_NATIVESTREAM_0117_1L();
       
   179 	void GRAPHICS_OPENWFC_NATIVESTREAM_0117_2L();
       
   180 	void GRAPHICS_OPENWFC_NATIVESTREAM_0117_3L();
       
   181 	void GRAPHICS_OPENWFC_NATIVESTREAM_0117_4L();
       
   182 	void GRAPHICS_OPENWFC_NATIVESTREAM_0118_1L();
       
   183 	void GRAPHICS_OPENWFC_NATIVESTREAM_0118_2L();
       
   184 	void GRAPHICS_OPENWFC_NATIVESTREAM_0118_3L();
       
   185 	void GRAPHICS_OPENWFC_NATIVESTREAM_0118_4L();
       
   186 	void GRAPHICS_OPENWFC_NATIVESTREAM_0119_1L();
       
   187 	void GRAPHICS_OPENWFC_NATIVESTREAM_0119_2L();
       
   188 	void GRAPHICS_OPENWFC_NATIVESTREAM_0119_3L();
       
   189 	void GRAPHICS_OPENWFC_NATIVESTREAM_0120_1L();
       
   190 	void GRAPHICS_OPENWFC_NATIVESTREAM_0120_2L();
       
   191 	void GRAPHICS_OPENWFC_NATIVESTREAM_0120_3L();
       
   192 	void GRAPHICS_OPENWFC_NATIVESTREAM_0122L();
       
   193 	void GRAPHICS_OPENWFC_NATIVESTREAM_0130L();
       
   194 	void GRAPHICS_OPENWFC_NATIVESTREAM_0131L();
       
   195 	void GRAPHICS_OPENWFC_NATIVESTREAM_0132L();
       
   196 	void GRAPHICS_OPENWFC_NATIVESTREAM_0133L();
       
   197 	void GRAPHICS_OPENWFC_NATIVESTREAM_0140L(TInt aNumBuffers);
       
   198 	void GRAPHICS_OPENWFC_NATIVESTREAM_0141L(TInt aNumBuffers);
       
   199 	void GRAPHICS_OPENWFC_NATIVESTREAM_0142L();
       
   200 	
       
   201 private:
       
   202 
       
   203 	struct OWF_IMAGE_FORMAT;
       
   204 	TSurfaceId helperCreateSurfaceL(khronos_int32_t width,
       
   205 	        khronos_int32_t height,
       
   206 	        const OWF_IMAGE_FORMAT*   format,
       
   207 	        khronos_int32_t nbufs,
       
   208 	        TUidPixelFormat overridePixelFormat = EUidPixelFormatUnknown);
       
   209 	
       
   210 	SymbianStreamType helperCreateImageStream(khronos_int32_t width,
       
   211 			khronos_int32_t height,
       
   212 			const OWF_IMAGE_FORMAT*  format,
       
   213 			khronos_int32_t nbufs,
       
   214 			TUidPixelFormat overridePixelFormat = EUidPixelFormatUnknown);
       
   215 
       
   216 private:
       
   217 	//data
       
   218 	SafePointer<CSurfaceUtility,CTestNativeStream> iUtility;
       
   219 	khronos_int32_t iExpectedSourceStreamUpdatedEventMask;
       
   220     khronos_int32_t iImmediateAvailable;
       
   221     khronos_int32_t iImmediateVisible;
       
   222     khronos_int32_t iStreamUpdatedParameter;
       
   223     khronos_int32_t iStreamUpdatedSerialNumber;
       
   224 	SymbianStreamType iNs;
       
   225 	TInt32 iScreenNo;
       
   226 	void* iObserverAvailableParameter;
       
   227 	void* iObserverDisplayedParameter;
       
   228 	void* iObserverDisplayedXParameter;
       
   229 	khronos_int32_t iSourceStreamUpdatedCalled;
       
   230 	khronos_int32_t iContextUpdatedFlags;
       
   231 public:
       
   232 	static CTestNativeStream* iTester;
       
   233 	};
       
   234 
       
   235 _LIT(KComposeThreadSemaphore, "Composer Thread Semaphore");
       
   236 _LIT(KMainThreadSemaphore, "Main Thread Semaphore");
       
   237 
       
   238 #endif // TESTNATIVESTREAM_H