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