sl@0: // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Test class for interop implementation of NativeStream sl@0: // sl@0: // sl@0: sl@0: #ifndef TESTNATIVESTREAM_H sl@0: #define TESTNATIVESTREAM_H sl@0: sl@0: // INCLUDES sl@0: #include sl@0: #include sl@0: #include sl@0: #include "surfaceutility.h" sl@0: sl@0: #include sl@0: class CTestExecuteLogger; sl@0: class CSurfaceStream; sl@0: sl@0: template sl@0: class SafePointer sl@0: { sl@0: public: sl@0: SafePointer(LoggerOwner* aOwner,Referee* aReferee=NULL): sl@0: iOwner(aOwner), iReferee(aReferee) sl@0: {} sl@0: Referee* operator=(Referee* aReferee) sl@0: { sl@0: return iReferee=aReferee; sl@0: } sl@0: Referee*& operator()() sl@0: { sl@0: return iReferee; sl@0: } sl@0: Referee* operator->() sl@0: { sl@0: if (iReferee==NULL) sl@0: { sl@0: iOwner -> INFO_PRINTF1(_L("Tried to dereference a pointer that is null!")); sl@0: User::Panic(_L("null pointer"),__LINE__); sl@0: } sl@0: return iReferee; sl@0: } sl@0: private: sl@0: LoggerOwner* iOwner; sl@0: Referee* iReferee; sl@0: }; sl@0: sl@0: sl@0: // MAIN CLASS DECLARATION sl@0: sl@0: class TGlobalNativeStreamVar sl@0: { sl@0: public: sl@0: static const TGlobalNativeStreamVar& Instance(); sl@0: sl@0: void SetSurfaceID(TSurfaceId aSurfaceID); sl@0: void SetTestComplete (TBool aTestComplete); sl@0: void SetBuffers (TInt aBuffers); sl@0: sl@0: TSurfaceId SurfaceID() const; sl@0: TBool TestComplete() const; sl@0: TInt Buffers() const; sl@0: sl@0: public: sl@0: TSurfaceId iSurfaceID; sl@0: TBool iTestComplete; sl@0: TInt iBuffers; sl@0: TInt iMultithreadCounter; sl@0: }; sl@0: sl@0: struct TCallbackData sl@0: { sl@0: SymbianStreamType iStream; sl@0: TInt32 iEvent; sl@0: TAny* iData; sl@0: }; sl@0: sl@0: /** sl@0: * CTestNativeStream sl@0: * sl@0: */ sl@0: class CTestNativeStream : public CTestFixture sl@0: { sl@0: public: sl@0: // Constructors and destructor sl@0: sl@0: /** sl@0: * Constructor for performing 1st stage construction sl@0: */ sl@0: CTestNativeStream(); sl@0: sl@0: /** sl@0: * Destructor. sl@0: */ sl@0: ~CTestNativeStream(); sl@0: sl@0: /** sl@0: * test Suite furniture sl@0: **/ sl@0: virtual void SetupL(); sl@0: sl@0: /** sl@0: * test Suite furniture sl@0: **/ sl@0: virtual void TearDownL(); sl@0: sl@0: sl@0: /** sl@0: * test Suite furniture sl@0: **/ sl@0: static CTestSuite* CreateSuiteL(const TDesC& aName); sl@0: sl@0: /** sl@0: * Checks acquire or find native streams operations sl@0: **/ sl@0: SymbianStreamType NsCheckL(const TSurfaceId aId, TInt aCheck, TBool aFind); sl@0: sl@0: /** sl@0: * For concurrent tests, create a shared stream for all threads to access. sl@0: */ sl@0: void CreateSharedNativeStreamL(TInt aBuffers); sl@0: sl@0: /** sl@0: * For concurrent tests, destroy the shared stream. sl@0: */ sl@0: void DestroySharedNativeStreamL(); sl@0: sl@0: static void SourceStreamUpdatedCallback(SymbianStreamType aNs, sl@0: khronos_int32_t aEvents, void* aData, void* aParam); sl@0: sl@0: void CheckSourceStreamUpdated(SymbianStreamType aNs, void* aParam); sl@0: void RemoveNsNotifications(); sl@0: sl@0: /** sl@0: * A helper function that returns the bytes per pixel for a given pixel format UID sl@0: * @param aPixelFormat Pixel format UID to convert sl@0: * @return Positive: bytes per pixel; negative is pixels per byte; 0 is error sl@0: */ sl@0: sl@0: TInt BytesPerPixel(TUidPixelFormat aPixelFormat); sl@0: sl@0: private: sl@0: // Private tests sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0100L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0101L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0102L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0103L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0104L(TInt aNumBuffers); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0105L(TInt aNumBuffers); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0106L(TInt aNumBuffers); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0107_1L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0107_2L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0107_3L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0108L(TInt aNumBuffers); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0109L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0110L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0111L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0112_1L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0112_2L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0112_3L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0112_4L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0113L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0114L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0115L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0116L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0117_1L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0117_2L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0117_3L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0117_4L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0118_1L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0118_2L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0118_3L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0118_4L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0119_1L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0119_2L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0119_3L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0120_1L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0120_2L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0120_3L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0122L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0130L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0131L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0132L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0133L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0140L(TInt aNumBuffers); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0141L(TInt aNumBuffers); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0142L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0143L(); sl@0: void GRAPHICS_OPENWFC_NATIVESTREAM_0144L(); sl@0: sl@0: private: sl@0: sl@0: struct OWF_IMAGE_FORMAT; sl@0: TSurfaceId helperCreateSurfaceL(khronos_int32_t width, sl@0: khronos_int32_t height, sl@0: const OWF_IMAGE_FORMAT* format, sl@0: khronos_int32_t nbufs, sl@0: TUidPixelFormat overridePixelFormat = EUidPixelFormatUnknown); sl@0: sl@0: SymbianStreamType helperCreateImageStream(khronos_int32_t width, sl@0: khronos_int32_t height, sl@0: const OWF_IMAGE_FORMAT* format, sl@0: khronos_int32_t nbufs, sl@0: TUidPixelFormat overridePixelFormat = EUidPixelFormatUnknown); sl@0: sl@0: private: sl@0: //data sl@0: SafePointer iUtility; sl@0: khronos_int32_t iExpectedSourceStreamUpdatedEventMask; sl@0: khronos_int32_t iImmediateAvailable; sl@0: khronos_int32_t iImmediateVisible; sl@0: khronos_int32_t iStreamUpdatedParameter; sl@0: khronos_int32_t iStreamUpdatedSerialNumber; sl@0: SymbianStreamType iNs; sl@0: TInt32 iScreenNo; sl@0: void* iObserverAvailableParameter; sl@0: void* iObserverDisplayedParameter; sl@0: void* iObserverDisplayedXParameter; sl@0: khronos_int32_t iSourceStreamUpdatedCalled; sl@0: khronos_int32_t iContextUpdatedFlags; sl@0: public: sl@0: static CTestNativeStream* iTester; sl@0: }; sl@0: sl@0: _LIT(KComposeThreadSemaphore, "Composer Thread Semaphore"); sl@0: _LIT(KMainThreadSemaphore, "Main Thread Semaphore"); sl@0: sl@0: #endif // TESTNATIVESTREAM_H