os/graphics/graphicscomposition/openwfsupport/test/tstreamoperation/tnativestream.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/graphicscomposition/openwfsupport/test/tstreamoperation/tnativestream.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,240 @@
     1.4 +// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// Test class for interop implementation of NativeStream
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#ifndef TESTNATIVESTREAM_H
    1.22 +#define TESTNATIVESTREAM_H
    1.23 +
    1.24 +// INCLUDES
    1.25 +#include <test/tefunit.h>
    1.26 +#include <w32std.h>
    1.27 +#include <khronos_types.h>
    1.28 +#include "surfaceutility.h"
    1.29 +
    1.30 +#include <graphics/symbianstream.h>
    1.31 +class CTestExecuteLogger;
    1.32 +class CSurfaceStream;
    1.33 +
    1.34 +template <class Referee,class LoggerOwner>
    1.35 +class	SafePointer
    1.36 +	{
    1.37 +public:
    1.38 +	SafePointer(LoggerOwner* aOwner,Referee* aReferee=NULL):
    1.39 +		iOwner(aOwner),	iReferee(aReferee)
    1.40 +		{}
    1.41 +	Referee*	operator=(Referee* aReferee)
    1.42 +		{
    1.43 +		return iReferee=aReferee;
    1.44 +		}
    1.45 +	Referee*&	operator()()
    1.46 +		{
    1.47 +		return iReferee;
    1.48 +		}
    1.49 +	Referee*	operator->()
    1.50 +		{
    1.51 +		if (iReferee==NULL)
    1.52 +			{
    1.53 +			iOwner -> INFO_PRINTF1(_L("Tried to dereference a pointer that is null!"));
    1.54 +			User::Panic(_L("null pointer"),__LINE__);
    1.55 +			}
    1.56 +		return iReferee;
    1.57 +		}
    1.58 +private:
    1.59 +	LoggerOwner* iOwner;
    1.60 +	Referee* iReferee;
    1.61 +	};
    1.62 +
    1.63 +
    1.64 +// MAIN CLASS DECLARATION
    1.65 +
    1.66 +class TGlobalNativeStreamVar
    1.67 +	{
    1.68 +public:
    1.69 +	static const TGlobalNativeStreamVar& Instance();
    1.70 +	
    1.71 +	void SetSurfaceID(TSurfaceId aSurfaceID);
    1.72 +	void SetTestComplete (TBool aTestComplete);
    1.73 +	void SetBuffers (TInt aBuffers);
    1.74 +	
    1.75 +	TSurfaceId SurfaceID() const;
    1.76 +	TBool TestComplete() const;
    1.77 +	TInt Buffers() const;
    1.78 +	
    1.79 +public:
    1.80 +	TSurfaceId		iSurfaceID;
    1.81 +	TBool			iTestComplete;
    1.82 +	TInt			iBuffers;
    1.83 +	TInt            iMultithreadCounter;
    1.84 +	};
    1.85 +
    1.86 +struct TCallbackData
    1.87 +    {
    1.88 +    SymbianStreamType		iStream;
    1.89 +    TInt32	                iEvent;
    1.90 +    TAny*					iData;
    1.91 +    };
    1.92 +
    1.93 +/**
    1.94 + *  CTestNativeStream
    1.95 + * 
    1.96 + */
    1.97 +class CTestNativeStream : public CTestFixture
    1.98 +	{
    1.99 +public:
   1.100 +	// Constructors and destructor
   1.101 +
   1.102 +	/**
   1.103 +	 * Constructor for performing 1st stage construction
   1.104 +	 */
   1.105 +	CTestNativeStream();
   1.106 +
   1.107 +	/**
   1.108 +	 * Destructor.
   1.109 +	 */
   1.110 +	~CTestNativeStream();
   1.111 +
   1.112 +	/**
   1.113 +	 * test Suite furniture 
   1.114 +	 **/
   1.115 +	virtual void SetupL();
   1.116 +	
   1.117 +	/**
   1.118 +	 * test Suite furniture 
   1.119 +	 **/
   1.120 +	virtual void TearDownL();
   1.121 +
   1.122 +
   1.123 +	/**
   1.124 +	 * test Suite furniture 
   1.125 +	 **/
   1.126 +	static CTestSuite* CreateSuiteL(const TDesC& aName);
   1.127 +		
   1.128 +	/**
   1.129 +	 * Checks acquire or find native streams operations
   1.130 +	 **/
   1.131 +	SymbianStreamType NsCheckL(const TSurfaceId aId, TInt aCheck, TBool aFind);
   1.132 +	
   1.133 +	/**
   1.134 +	 * For concurrent tests, create a shared stream for all threads to access.
   1.135 +	 */
   1.136 +	void CreateSharedNativeStreamL(TInt aBuffers);
   1.137 +	
   1.138 +	/**
   1.139 +	 * For concurrent tests, destroy the shared stream.
   1.140 +	 */	
   1.141 +	void DestroySharedNativeStreamL();
   1.142 +	
   1.143 +	static void SourceStreamUpdatedCallback(SymbianStreamType aNs, 
   1.144 +	        khronos_int32_t aEvents, void* aData, void* aParam);
   1.145 +	
   1.146 +	void CheckSourceStreamUpdated(SymbianStreamType aNs, void* aParam);
   1.147 +	void RemoveNsNotifications();
   1.148 +
   1.149 +	/**
   1.150 +     * A helper function that returns the bytes per pixel for a given pixel format UID
   1.151 +     * @param aPixelFormat Pixel format UID to convert
   1.152 +     * @return Positive: bytes per pixel; negative is pixels per byte; 0 is error 
   1.153 +     */
   1.154 +    
   1.155 +    TInt BytesPerPixel(TUidPixelFormat aPixelFormat);
   1.156 +	
   1.157 +private:
   1.158 +	// Private tests
   1.159 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0100L();
   1.160 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0101L();
   1.161 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0102L();
   1.162 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0103L();
   1.163 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0104L(TInt aNumBuffers);
   1.164 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0105L(TInt aNumBuffers);
   1.165 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0106L(TInt aNumBuffers);
   1.166 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0107_1L();
   1.167 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0107_2L();
   1.168 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0107_3L();
   1.169 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0108L(TInt aNumBuffers);
   1.170 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0109L();
   1.171 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0110L();
   1.172 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0111L();
   1.173 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0112_1L();
   1.174 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0112_2L();
   1.175 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0112_3L();
   1.176 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0112_4L();
   1.177 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0113L();
   1.178 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0114L();
   1.179 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0115L();
   1.180 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0116L();
   1.181 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0117_1L();
   1.182 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0117_2L();
   1.183 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0117_3L();
   1.184 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0117_4L();
   1.185 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0118_1L();
   1.186 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0118_2L();
   1.187 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0118_3L();
   1.188 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0118_4L();
   1.189 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0119_1L();
   1.190 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0119_2L();
   1.191 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0119_3L();
   1.192 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0120_1L();
   1.193 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0120_2L();
   1.194 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0120_3L();
   1.195 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0122L();
   1.196 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0130L();
   1.197 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0131L();
   1.198 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0132L();
   1.199 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0133L();
   1.200 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0140L(TInt aNumBuffers);
   1.201 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0141L(TInt aNumBuffers);
   1.202 +	void GRAPHICS_OPENWFC_NATIVESTREAM_0142L();
   1.203 +    void GRAPHICS_OPENWFC_NATIVESTREAM_0143L();
   1.204 +    void GRAPHICS_OPENWFC_NATIVESTREAM_0144L();
   1.205 +	
   1.206 +private:
   1.207 +
   1.208 +	struct OWF_IMAGE_FORMAT;
   1.209 +	TSurfaceId helperCreateSurfaceL(khronos_int32_t width,
   1.210 +	        khronos_int32_t height,
   1.211 +	        const OWF_IMAGE_FORMAT*   format,
   1.212 +	        khronos_int32_t nbufs,
   1.213 +	        TUidPixelFormat overridePixelFormat = EUidPixelFormatUnknown);
   1.214 +	
   1.215 +	SymbianStreamType helperCreateImageStream(khronos_int32_t width,
   1.216 +			khronos_int32_t height,
   1.217 +			const OWF_IMAGE_FORMAT*  format,
   1.218 +			khronos_int32_t nbufs,
   1.219 +			TUidPixelFormat overridePixelFormat = EUidPixelFormatUnknown);
   1.220 +
   1.221 +private:
   1.222 +	//data
   1.223 +	SafePointer<CSurfaceUtility,CTestNativeStream> iUtility;
   1.224 +	khronos_int32_t iExpectedSourceStreamUpdatedEventMask;
   1.225 +    khronos_int32_t iImmediateAvailable;
   1.226 +    khronos_int32_t iImmediateVisible;
   1.227 +    khronos_int32_t iStreamUpdatedParameter;
   1.228 +    khronos_int32_t iStreamUpdatedSerialNumber;
   1.229 +	SymbianStreamType iNs;
   1.230 +	TInt32 iScreenNo;
   1.231 +	void* iObserverAvailableParameter;
   1.232 +	void* iObserverDisplayedParameter;
   1.233 +	void* iObserverDisplayedXParameter;
   1.234 +	khronos_int32_t iSourceStreamUpdatedCalled;
   1.235 +	khronos_int32_t iContextUpdatedFlags;
   1.236 +public:
   1.237 +	static CTestNativeStream* iTester;
   1.238 +	};
   1.239 +
   1.240 +_LIT(KComposeThreadSemaphore, "Composer Thread Semaphore");
   1.241 +_LIT(KMainThreadSemaphore, "Main Thread Semaphore");
   1.242 +
   1.243 +#endif // TESTNATIVESTREAM_H