sl@0: // Copyright (c) 2009-2010 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: // Implementation of Test class for OpenWfc Native Stream sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "tnativestream.h" sl@0: #include "surfaceutility.h" sl@0: sl@0: #ifdef EGLSYNCHELPER_INCLUDED sl@0: #include sl@0: #include "eglsynchelper.h" sl@0: #endif sl@0: sl@0: #define BUFFER_READ_HANDLE_BASE 0x100 sl@0: #define BUFFER_WRITE_HANDLE_BASE 0x200 sl@0: #define INDEX_TO_READ_HANDLE(x) ((SymbianStreamBuffer) ((x)+BUFFER_READ_HANDLE_BASE)) sl@0: #define INDEX_TO_WRITE_HANDLE(x) ((SymbianStreamBuffer) ((x)+BUFFER_WRITE_HANDLE_BASE)) sl@0: #define BUFFER_READ_HANDLE_TO_INDEX(x) (TInt) (x > 0 ? (x&0xFF) : (x-BUFFER_READ_HANDLE_BASE)) sl@0: #define BUFFER_WRITE_HANDLE_TO_INDEX(x) (TInt) (x > 0 ? (x&0xFF) : (x-BUFFER_WRITE_HANDLE_BASE)) sl@0: #define WFC_INVALID_HANDLE NULL sl@0: #define KGrowCleanupStack 12 sl@0: #define KCompositorVersion 0x01023456 sl@0: #define KCompositorVersionMajor 0x1 sl@0: #define KCompositorVersionMinor 0x2 sl@0: #define KCompositorVersionRevision 0x3456 sl@0: sl@0: void PopHeap(void* aHeapPtr) sl@0: { sl@0: User::SwitchHeap((RHeap*)aHeapPtr); sl@0: } sl@0: sl@0: void GrowCleanupStackL() sl@0: { sl@0: TInt n = KGrowCleanupStack; sl@0: while(n--) sl@0: { sl@0: CleanupStack::PushL((CBase*)NULL); sl@0: } sl@0: CleanupStack::Pop(KGrowCleanupStack); sl@0: } sl@0: sl@0: // Helper functions sl@0: /* supported external image formats */ sl@0: enum OWF_PIXEL_FORMAT { sl@0: OWF_IMAGE_NOT_SUPPORTED = 0, sl@0: OWF_IMAGE_ARGB8888 = 0x8888, sl@0: OWF_IMAGE_XRGB8888 = 0xf888, sl@0: OWF_IMAGE_RGB888 = 0x888, sl@0: OWF_IMAGE_RGB565 = 0x565, sl@0: OWF_IMAGE_L32 = 0xA32, sl@0: OWF_IMAGE_L16 = 0xA16, sl@0: OWF_IMAGE_L8 = 0xA8, sl@0: OWF_IMAGE_L1 = 0xA1, sl@0: OWF_IMAGE_ARGB_INTERNAL = 0x666 /* OWFpixel rep */ sl@0: } ; sl@0: sl@0: struct CTestNativeStream::OWF_IMAGE_FORMAT{ sl@0: OWF_PIXEL_FORMAT pixelFormat; sl@0: bool linear; sl@0: bool premultiplied; sl@0: int rowPadding; /* row alignment, in bytes */ sl@0: } ; sl@0: sl@0: TInt CTestNativeStream::BytesPerPixel(TUidPixelFormat aPixelFormat) sl@0: { sl@0: switch (aPixelFormat) sl@0: { sl@0: case EUidPixelFormatXRGB_8888: sl@0: case EUidPixelFormatARGB_8888: sl@0: case EUidPixelFormatBGRX_8888: sl@0: case EUidPixelFormatXBGR_8888: sl@0: case EUidPixelFormatBGRA_8888: sl@0: case EUidPixelFormatABGR_8888: sl@0: case EUidPixelFormatABGR_8888_PRE: sl@0: case EUidPixelFormatARGB_8888_PRE: sl@0: case EUidPixelFormatBGRA_8888_PRE: sl@0: case EUidPixelFormatARGB_2101010: sl@0: case EUidPixelFormatABGR_2101010: sl@0: return 4; sl@0: case EUidPixelFormatBGR_888: sl@0: case EUidPixelFormatRGB_888: sl@0: return 3; sl@0: case EUidPixelFormatXRGB_4444: sl@0: case EUidPixelFormatARGB_4444: sl@0: case EUidPixelFormatXBGR_4444: sl@0: case EUidPixelFormatRGB_565: sl@0: case EUidPixelFormatBGR_565: sl@0: case EUidPixelFormatARGB_1555: sl@0: case EUidPixelFormatXRGB_1555: sl@0: case EUidPixelFormatARGB_8332: sl@0: case EUidPixelFormatBGRX_5551: sl@0: case EUidPixelFormatBGRA_5551: sl@0: case EUidPixelFormatBGRA_4444: sl@0: case EUidPixelFormatBGRX_4444: sl@0: case EUidPixelFormatAP_88: sl@0: return 2; sl@0: case EUidPixelFormatRGB_332: sl@0: case EUidPixelFormatBGR_332: sl@0: case EUidPixelFormatA_8: sl@0: case EUidPixelFormatL_8: sl@0: return 1; sl@0: case EUidPixelFormatP_8: sl@0: return -1; sl@0: case EUidPixelFormatP_4: sl@0: case EUidPixelFormatL_4: sl@0: return -2; sl@0: case EUidPixelFormatL_2: sl@0: case EUidPixelFormatP_2: sl@0: return -4; sl@0: case EUidPixelFormatL_1 : sl@0: return -8; sl@0: default: sl@0: { sl@0: return 0; sl@0: } sl@0: } sl@0: } sl@0: sl@0: /***************************************** sl@0: * Helper Creates Surface from OWF spec sl@0: * sl@0: * sl@0: */ sl@0: TSurfaceId CTestNativeStream::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) sl@0: { sl@0: RSurfaceManager::TSurfaceCreationAttributesBuf bf; sl@0: RSurfaceManager::TSurfaceCreationAttributes& b = bf(); sl@0: sl@0: TBool premultiplied = format->premultiplied; sl@0: OWF_PIXEL_FORMAT pixelFormat = format->pixelFormat; sl@0: khronos_int32_t bytesPerPixel = 0; sl@0: sl@0: if (overridePixelFormat != EUidPixelFormatUnknown) sl@0: { sl@0: bytesPerPixel = BytesPerPixel(overridePixelFormat); sl@0: b.iAlignment = 4; sl@0: b.iPixelFormat = overridePixelFormat; sl@0: } sl@0: else sl@0: { sl@0: switch(pixelFormat) sl@0: { sl@0: case OWF_IMAGE_RGB565: sl@0: b.iPixelFormat = EUidPixelFormatRGB_565; sl@0: bytesPerPixel = 2; sl@0: b.iAlignment = 4; sl@0: break; sl@0: case OWF_IMAGE_ARGB8888: sl@0: { sl@0: if (premultiplied) sl@0: { sl@0: b.iPixelFormat = EUidPixelFormatARGB_8888_PRE; sl@0: } sl@0: else sl@0: { sl@0: b.iPixelFormat = EUidPixelFormatARGB_8888; sl@0: } sl@0: bytesPerPixel = 4; sl@0: b.iAlignment = 4; sl@0: break; sl@0: } sl@0: case OWF_IMAGE_XRGB8888 : sl@0: b.iPixelFormat = EUidPixelFormatXRGB_8888; sl@0: bytesPerPixel = 4; sl@0: b.iAlignment = 4; sl@0: break; sl@0: case OWF_IMAGE_L8 : sl@0: b.iPixelFormat = EUidPixelFormatA_8; sl@0: bytesPerPixel = 1; sl@0: b.iAlignment = 4; sl@0: break; sl@0: case OWF_IMAGE_L1 : sl@0: b.iPixelFormat = EUidPixelFormatL_1; sl@0: bytesPerPixel = -8; sl@0: b.iAlignment = 4; sl@0: break; sl@0: default: sl@0: User::Leave(KErrNotSupported); sl@0: break; sl@0: } sl@0: } sl@0: sl@0: b.iSize.iWidth = width; sl@0: b.iSize.iHeight = height; sl@0: b.iBuffers = nbufs; // number of buffers in the surface sl@0: b.iOffsetToFirstBuffer = 0; // way of reserving space before the surface pixel data sl@0: if (bytesPerPixel >= 0) sl@0: { sl@0: b.iStride = bytesPerPixel * width; // number of bytes between start of one line and start of next sl@0: } sl@0: else sl@0: { sl@0: b.iStride = (width-(bytesPerPixel+1)) / (-bytesPerPixel); sl@0: } sl@0: b.iContiguous = EFalse; sl@0: b.iMappable = ETrue; sl@0: sl@0: TSurfaceId surface = TSurfaceId::CreateNullId(); sl@0: User::LeaveIfError(iUtility->Manager().CreateSurface(bf, surface)); sl@0: sl@0: return surface; sl@0: } sl@0: sl@0: SymbianStreamType CTestNativeStream::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) sl@0: { sl@0: TSurfaceId surface; sl@0: sl@0: TRAPD(err,surface = helperCreateSurfaceL(width, height, format, nbufs, overridePixelFormat)); sl@0: if (err) sl@0: { sl@0: return WFC_INVALID_HANDLE; sl@0: } sl@0: SymbianStreamType ns; sl@0: SymbianStreamAcquire(&surface, &ns); sl@0: sl@0: iUtility->Manager().CloseSurface(surface); sl@0: sl@0: return ns; sl@0: } sl@0: sl@0: RSemaphore gSemaphore; sl@0: RSemaphore gSemaphore2; sl@0: sl@0: TGlobalNativeStreamVar gVarInstance={0}; sl@0: const TGlobalNativeStreamVar& TGlobalNativeStreamVar::Instance() sl@0: { sl@0: return gVarInstance; sl@0: } sl@0: sl@0: void TGlobalNativeStreamVar::SetSurfaceID(TSurfaceId aSurfaceID) sl@0: { sl@0: iSurfaceID = aSurfaceID; sl@0: } sl@0: sl@0: void TGlobalNativeStreamVar::SetTestComplete(TBool aTestComplete) sl@0: { sl@0: iTestComplete = aTestComplete; sl@0: } sl@0: sl@0: void TGlobalNativeStreamVar::SetBuffers(TInt aBuffers) sl@0: { sl@0: iBuffers = aBuffers; sl@0: } sl@0: sl@0: TSurfaceId TGlobalNativeStreamVar::SurfaceID() const sl@0: { sl@0: return iSurfaceID; sl@0: } sl@0: sl@0: TBool TGlobalNativeStreamVar::TestComplete() const sl@0: { sl@0: return iTestComplete; sl@0: } sl@0: sl@0: TInt TGlobalNativeStreamVar::Buffers() const sl@0: { sl@0: return iBuffers; sl@0: } sl@0: sl@0: /* sl@0: * CTestNativeStream implementation sl@0: * sl@0: * sl@0: * sl@0: * sl@0: */ sl@0: sl@0: CTestNativeStream::CTestNativeStream(): iUtility(this) sl@0: { sl@0: // No implementation required sl@0: } sl@0: sl@0: CTestNativeStream::~CTestNativeStream() sl@0: { sl@0: DeleteOwfSingletons(); sl@0: } sl@0: sl@0: void CTestNativeStream::SetupL() sl@0: { sl@0: TRAPD(err_FailedToCreateSurfaceUtility, iUtility = CSurfaceUtility::NewL( NULL )); sl@0: ASSERT_EQUALS(err_FailedToCreateSurfaceUtility,KErrNone); sl@0: DefineOwfSingletonKeys(); sl@0: } sl@0: sl@0: /** sl@0: * test Suite furniture sl@0: **/ sl@0: void CTestNativeStream::TearDownL() sl@0: { sl@0: delete iUtility(); sl@0: } sl@0: sl@0: /** sl@0: WFC context callback function invoked by native stream when the stream's content sl@0: is updated. For testing, we simply call a class member function that checks that the sl@0: correct native stream handle and events mask were supplied. sl@0: */ sl@0: void CTestNativeStream::SourceStreamUpdatedCallback( sl@0: SymbianStreamType aNs, khronos_int32_t aEvents, void* aData, void* aParam) sl@0: { sl@0: (void)aData; sl@0: if (aEvents == ESOWF_ObserverReturnDefaultEvent && aParam) sl@0: { sl@0: SYMOWF_DEFAULT_EVENT_PARAM* parameter = (SYMOWF_DEFAULT_EVENT_PARAM*) aParam; sl@0: if ((parameter->length) == sizeof(SYMOWF_DEFAULT_EVENT_PARAM)) sl@0: { sl@0: parameter->event = ESOWF_EventUpdated; sl@0: } sl@0: return; sl@0: } sl@0: sl@0: ASSERT(CTestNativeStream::iTester); sl@0: CTestNativeStream::iTester->CheckSourceStreamUpdated(aNs, aParam); sl@0: } sl@0: sl@0: void CTestNativeStream::CheckSourceStreamUpdated(SymbianStreamType aNs, void* aParam) sl@0: { sl@0: RHeap *h1 = &(User::Heap()); sl@0: if (aParam) sl@0: { sl@0: ASSERT_EQUALS(iNs, aNs); sl@0: SYMOWF_CONTENT_UPDATED_PARAM* param = (SYMOWF_CONTENT_UPDATED_PARAM*) aParam; sl@0: ASSERT_TRUE(param->id == SYM_CONTENT_UPDATE_BEGIN || sl@0: param->id == SYM_CONTENT_UPDATE_END || sl@0: param->id == SYM_CONTENT_UPDATE); sl@0: sl@0: iSourceStreamUpdatedCalled++; sl@0: iStreamUpdatedParameter = param->id; sl@0: switch(param->id) sl@0: { sl@0: case SYM_CONTENT_UPDATE_BEGIN: sl@0: param->immediateAvailable = iImmediateAvailable; sl@0: param->immediateVisibility = iImmediateVisible; sl@0: param->serialNumber = iStreamUpdatedSerialNumber; sl@0: break; sl@0: sl@0: case SYM_CONTENT_UPDATE: sl@0: case SYM_CONTENT_UPDATE_END: sl@0: ASSERT_EQUALS(iExpectedSourceStreamUpdatedEventMask, param->par); sl@0: iContextUpdatedFlags |= param->par & (~ESOWF_EventUpdated); sl@0: break; sl@0: default: sl@0: break; sl@0: } sl@0: } sl@0: else sl@0: { sl@0: iSourceStreamUpdatedCalled++; sl@0: } sl@0: sl@0: } sl@0: sl@0: /** sl@0: Remove the native stream notifications. The creator of the source is responsible sl@0: for destroying the native stream. sl@0: sl@0: Now with the new SymbianStreamRemoveObserver function we need to pass in an observer sl@0: */ sl@0: void CTestNativeStream::RemoveNsNotifications() sl@0: { sl@0: SymbianStreamRemoveObserver(iNs, &iScreenNo, ESOWF_EventAvailable); sl@0: SymbianStreamRemoveObserver(iNs, &iScreenNo, ESOWF_EventDisplayed); sl@0: SymbianStreamRemoveObserver(iNs, &iScreenNo, ESOWF_EventDisplayedX); sl@0: } sl@0: sl@0: CTestNativeStream* CTestNativeStream::iTester = NULL; sl@0: sl@0: // Create a suite of all the tests sl@0: CTestSuite* CTestNativeStream::CreateSuiteL(const TDesC& aName) sl@0: { sl@0: SymbianStreamRegisterScreenNotifications(0, 10, KCompositorVersion); sl@0: SUB_SUITE_OPT(CTestNativeStream,NULL); sl@0: sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0100L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0101L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0102L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0103L); sl@0: sl@0: // Test with 1, 2 and 3 buffers sl@0: ADD_TEST_STEP_PARAM_RANGE(GRAPHICS_OPENWFC_NATIVESTREAM_0104L,1,4); sl@0: ADD_TEST_STEP_PARAM_RANGE(GRAPHICS_OPENWFC_NATIVESTREAM_0105L,1,4); sl@0: ADD_TEST_STEP_PARAM_RANGE(GRAPHICS_OPENWFC_NATIVESTREAM_0106L,1,4); sl@0: sl@0: // Concurrent tests sl@0: ADD_TEST_STEP_PARAM_RANGE(CreateSharedNativeStreamL,1,4); sl@0: ADD_THIS_TEST_STEP(DestroySharedNativeStreamL); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0107_1L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0107_2L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0107_3L); sl@0: sl@0: // Test SUS with OpenWF pipeline sl@0: ADD_TEST_STEP_PARAM_RANGE(GRAPHICS_OPENWFC_NATIVESTREAM_0108L, 1, 4); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0109L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0110L); sl@0: sl@0: // Test various cases for Native Stream callbacks sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0111L); sl@0: // Test multithreaded cases for Native Stream callbacks sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0112_1L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0112_2L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0112_3L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0112_4L); sl@0: sl@0: // Notification tests sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0113L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0114L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0115L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0116L); sl@0: sl@0: // Notification cancel sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0117_1L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0117_2L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0117_3L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0117_4L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0118_1L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0118_2L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0118_3L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0118_4L); sl@0: sl@0: // Notification overflow sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0119_1L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0119_2L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0119_3L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0120_1L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0120_2L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0120_3L); sl@0: sl@0: // Notifications cancelled due to removal of source observer sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0122L); sl@0: sl@0: // Sym native stream add/remove observers sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0130L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0131L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0132L); sl@0: sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0133L); sl@0: sl@0: // Test with 1, 2 and 3 buffers sl@0: ADD_TEST_STEP_PARAM_RANGE(GRAPHICS_OPENWFC_NATIVESTREAM_0140L,1,4); sl@0: ADD_TEST_STEP_PARAM_RANGE(GRAPHICS_OPENWFC_NATIVESTREAM_0141L,1,4); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0142L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0143L); sl@0: ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0144L); sl@0: sl@0: END_SUITE; sl@0: sl@0: } sl@0: sl@0: // This handles any non-member uses of the extended ASSERT_XXX macros sl@0: void TefUnitFailLeaveL() sl@0: { sl@0: User::Leave(KErrTEFUnitFail); sl@0: } sl@0: sl@0: SymbianStreamType CTestNativeStream::NsCheckL(const TSurfaceId aId, TInt aCheck, TBool aFind) sl@0: { sl@0: // Acquire (create OR find) the stream sl@0: SymbianStreamType ns = NULL; sl@0: TInt err; sl@0: if (aFind) sl@0: { sl@0: err = (TInt)SymbianStreamFind(&aId, &ns); sl@0: } sl@0: else sl@0: { sl@0: err = SymbianStreamAcquire(&aId, &ns); sl@0: } sl@0: ASSERT_TRUE(err == KErrNone); sl@0: // Check the hash map count sl@0: ASSERT_EQUALS((COpenWfcStreamMap::InstanceL().Count()), aCheck); sl@0: SymbianStreamBuffer bufferHandle; sl@0: err = SymbianStreamAcquireReadBuffer(ns,&bufferHandle); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: long bufferIndex; sl@0: const TSurfaceId* checkId = NULL; sl@0: err = SymbianStreamGetBufferId(ns,bufferHandle,&bufferIndex,&checkId); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: SymbianStreamReleaseReadBuffer(ns,bufferHandle); sl@0: ASSERT_NOT_NULL(checkId); sl@0: ASSERT_EQUALS(*checkId, aId); sl@0: return ns; sl@0: } sl@0: sl@0: void CTestNativeStream::CreateSharedNativeStreamL(TInt aBuffers) sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: GrowCleanupStackL(); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: sl@0: gVarInstance.SetTestComplete(EFalse); sl@0: gVarInstance.SetBuffers(aBuffers); sl@0: sl@0: TSize surfaceSize(TSize(100,100)); sl@0: khronos_int32_t width = surfaceSize.iWidth; sl@0: khronos_int32_t height = surfaceSize.iHeight; sl@0: sl@0: OWF_IMAGE_FORMAT pixelFormat = sl@0: { sl@0: OWF_IMAGE_ARGB8888, sl@0: ETrue, sl@0: ETrue, sl@0: 4 sl@0: }; sl@0: sl@0: // Create the first stream sl@0: SymbianStreamType ns=helperCreateImageStream(width, sl@0: height, sl@0: &pixelFormat, sl@0: aBuffers); sl@0: ASSERT_TRUE(ns); sl@0: sl@0: SymbianStreamBuffer bufferHandle; sl@0: SymbianStreamAcquireReadBuffer(ns,&bufferHandle); sl@0: long bufferIndex; sl@0: const TSurfaceId* checkId = NULL; sl@0: TInt err = SymbianStreamGetBufferId(ns,bufferHandle,&bufferIndex,&checkId); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: SymbianStreamReleaseReadBuffer(ns,bufferHandle); sl@0: gVarInstance.SetSurfaceID(*checkId); sl@0: gSemaphore.CreateLocal(1); sl@0: gSemaphore.Wait(); sl@0: gSemaphore2.CreateLocal(1); sl@0: gSemaphore2.Wait(); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: void CTestNativeStream::DestroySharedNativeStreamL() sl@0: { sl@0: GrowCleanupStackL(); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(COpenWfcStreamMap::InstanceL().GetMainHeap()))); sl@0: sl@0: gSemaphore2.Close(); sl@0: gSemaphore.Close(); sl@0: TSurfaceId id = gVarInstance.SurfaceID(); sl@0: SymbianStreamType ns; sl@0: TInt err = SymbianStreamFind(&id,&ns); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(ns); sl@0: // Decrease stream's reference count by one. This removes reference added by owfNativeStreamFind() sl@0: SymbianStreamRemoveReference(ns); sl@0: // Decrease stream's reference count by one to make reference count zero, and destroy the stream sl@0: SymbianStreamRemoveReference(ns); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: // Test observers sl@0: void TestUpdateCallback(SymbianStreamType aStream, khronos_int32_t aEvent, void* aData, void* aParam) sl@0: { sl@0: (void) aStream; sl@0: switch (aEvent) sl@0: { sl@0: case ESOWF_ObserverReturnDefaultEvent: sl@0: if (aParam) sl@0: { sl@0: SYMOWF_DEFAULT_EVENT_PARAM* parameter = (SYMOWF_DEFAULT_EVENT_PARAM*) aParam; sl@0: if ((parameter->length) == sizeof(SYMOWF_DEFAULT_EVENT_PARAM)) sl@0: { sl@0: parameter->event = ESOWF_EventUpdated; sl@0: } sl@0: } sl@0: return; sl@0: sl@0: case ESOWF_EventUpdated: sl@0: { sl@0: TInt* localNumber = (TInt*)aData; sl@0: ++(*localNumber); sl@0: } sl@0: break; sl@0: default: sl@0: break; sl@0: } sl@0: } sl@0: sl@0: // Test compose target sl@0: void TestComposedCallback(SymbianStreamType aStream, khronos_int32_t aEvent, void* aData, void* aParam) sl@0: { sl@0: (void) aStream; sl@0: switch (aEvent) sl@0: { sl@0: case ESOWF_ObserverReturnDefaultEvent: sl@0: if (aParam) sl@0: { sl@0: SYMOWF_DEFAULT_EVENT_PARAM* parameter = (SYMOWF_DEFAULT_EVENT_PARAM*) aParam; sl@0: if ((parameter->length) == sizeof(SYMOWF_DEFAULT_EVENT_PARAM)) sl@0: { sl@0: parameter->event = ESOWF_EventComposed; sl@0: } sl@0: } sl@0: return; sl@0: sl@0: case ESOWF_EventComposed: sl@0: { sl@0: TInt* localNumber = (TInt*)aData; sl@0: ++(*localNumber); sl@0: } sl@0: break; sl@0: default: sl@0: break; sl@0: } sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0100 sl@0: @SYMTestCaseDesc Create a native stream using SymbianStreamAcquire() sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority sl@0: @SYMTestPurpose Verify native stream objects can be created and persist unique surface ID values sl@0: @SYMTestActions sl@0: Create two surfaces, sl@0: Create two streams from the surfaces sl@0: Read back the surface Ids from the streams sl@0: @SYMTestExpectedResults sl@0: The surface IDs should be non-null and unique sl@0: The streams should be non-null and unique sl@0: The returned surface Ids should match the constructed IDs sl@0: **/ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0100L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: TInt count = COpenWfcStreamMap::InstanceL().Count(); sl@0: TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100),EUidPixelFormatARGB_8888_PRE,400,2); sl@0: ASSERT_FALSE(surface.IsNull()); sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: SymbianStreamType ns; sl@0: err = SymbianStreamAcquire(&surface, &ns); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: SymbianStreamBuffer bufferHandle; sl@0: err = SymbianStreamAcquireReadBuffer(ns, &bufferHandle); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: long bufferIndex; sl@0: const TSurfaceId* getId = NULL; sl@0: err = SymbianStreamGetBufferId(ns,bufferHandle,&bufferIndex,&getId); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: TInt ChunkHandle = 100; sl@0: err = SymbianStreamGetChunkHandle(ns, &ChunkHandle); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamReleaseReadBuffer(ns,bufferHandle); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_EQUALS(*getId,surface); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: sl@0: TSurfaceId surface2=iUtility->CreateSurfaceL(TSize(100,100),EUidPixelFormatARGB_8888_PRE,400,2); sl@0: ASSERT_FALSE(surface2.IsNull()); sl@0: ASSERT_NOT_EQUALS(surface,surface2); sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: SymbianStreamType ns2; sl@0: err = SymbianStreamAcquire(&surface2,&ns2); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(ns2); sl@0: ASSERT_FALSE(SymbianStreamSame(ns, ns2)); sl@0: ASSERT_EQUALS((COpenWfcStreamMap::InstanceL().Count()), count + 2); sl@0: err = SymbianStreamAcquireReadBuffer(ns2,&bufferHandle); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: const TSurfaceId* getId2 = NULL; sl@0: err = SymbianStreamGetBufferId(ns2,bufferHandle,&bufferIndex,&getId2); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamReleaseReadBuffer(ns2,bufferHandle); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_NOT_NULL(getId2); sl@0: ASSERT_EQUALS(*getId2,surface2); sl@0: sl@0: SymbianStreamRemoveReference(ns); sl@0: ASSERT_EQUALS((COpenWfcStreamMap::InstanceL().Count()), count + 1); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: iUtility->DestroySurface(surface); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: SymbianStreamRemoveReference(ns2); sl@0: ASSERT_EQUALS((COpenWfcStreamMap::InstanceL().Count()), count); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: iUtility->DestroySurface(surface2); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0101 sl@0: @SYMTestCaseDesc Create a native stream using SymbianStreamCreateImageStream() sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority sl@0: @SYMTestPurpose Verify native stream objects can be created and persist unique surface ID values sl@0: @SYMTestActions sl@0: Create two streams from the parameters passed in sl@0: Read back the surface Ids from the streams sl@0: @SYMTestExpectedResults sl@0: The surface IDs should be non-null and unique sl@0: The streams should be non-null and unique sl@0: **/ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0101L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: TSize surfaceSize(TSize(100,100)); sl@0: TInt width = surfaceSize.iWidth; sl@0: TInt height = surfaceSize.iHeight; sl@0: TInt buffers = 2; sl@0: sl@0: OWF_IMAGE_FORMAT pixelFormat = sl@0: { sl@0: OWF_IMAGE_ARGB8888, sl@0: ETrue, sl@0: ETrue, sl@0: 4 sl@0: }; sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: sl@0: // Create the first stream sl@0: SymbianStreamType ns=helperCreateImageStream(width, sl@0: height, sl@0: &pixelFormat, sl@0: buffers); sl@0: ASSERT_TRUE(ns); sl@0: SymbianStreamBuffer bufferHandle; sl@0: err = SymbianStreamAcquireReadBuffer(ns,&bufferHandle); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: long bufferIndex; sl@0: const TSurfaceId* getId = NULL; sl@0: err = SymbianStreamGetBufferId(ns,bufferHandle,&bufferIndex,&getId); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamReleaseReadBuffer(ns,bufferHandle); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: // Create the second stream sl@0: SymbianStreamType ns2=helperCreateImageStream(width, sl@0: height, sl@0: &pixelFormat, sl@0: buffers); sl@0: ASSERT_TRUE(ns2); sl@0: sl@0: err = SymbianStreamAcquireReadBuffer(ns2,&bufferHandle); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: const TSurfaceId* getId2 = NULL; sl@0: err = SymbianStreamGetBufferId(ns2,bufferHandle,&bufferIndex,&getId2); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamReleaseReadBuffer(ns2,bufferHandle); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_NOT_NULL(getId2); sl@0: sl@0: ASSERT_NOT_EQUALS(ns,ns2); sl@0: ASSERT_NOT_EQUALS(getId,getId2); sl@0: sl@0: SymbianStreamRemoveReference(ns); sl@0: SymbianStreamRemoveReference(ns2); sl@0: sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0102 sl@0: @SYMTestCaseDesc Create a native stream 2 sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority sl@0: @SYMTestPurpose Verify native stream objects can be created and persist unique surface ID values sl@0: @SYMTestActions sl@0: Create two surfaces, sl@0: Create two streams from the surfaces sl@0: Read back the surface Ids from the streams sl@0: Acquire multiple time the native streams sl@0: Find native streams sl@0: @SYMTestExpectedResults sl@0: The surface IDs should be non-null and unique sl@0: The streams should be non-null and unique sl@0: The returned surface Ids should match the constructed IDs sl@0: The hash map counter should be updated accordingly when native streams are created or destroyed sl@0: **/ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0102L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: COpenWfcStreamMap& singleton = COpenWfcStreamMap::InstanceL(); sl@0: TInt check = COpenWfcStreamMap::InstanceL().Count() + 1; sl@0: // Create the first surface sl@0: TSurfaceId surfaceId1 = iUtility->CreateSurfaceL(TSize(100, 100), EUidPixelFormatARGB_8888_PRE, 400, 2); sl@0: ASSERT_FALSE(surfaceId1.IsNull()); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: SymbianStreamType ns1 = NsCheckL(surfaceId1, check, EFalse); sl@0: sl@0: TSurfaceId surfaceId2; sl@0: surfaceId2.CreateNullId(); sl@0: SymbianStreamType ns2; sl@0: err = SymbianStreamFind(&surfaceId2,&ns2); sl@0: ASSERT_TRUE(err == KErrNotFound); sl@0: ASSERT_FALSE(ns2); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: sl@0: // Create the second surface sl@0: surfaceId2 = iUtility->CreateSurfaceL(TSize(100, 100), EUidPixelFormatARGB_8888_PRE, 400, 2); sl@0: ASSERT_FALSE(surfaceId2.IsNull()); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: err = SymbianStreamFind(&surfaceId2,&ns2); sl@0: ASSERT_TRUE(err == KErrNotFound); sl@0: ASSERT_FALSE(ns2); sl@0: sl@0: ns2 = NsCheckL(surfaceId2, ++check, EFalse); sl@0: sl@0: NsCheckL(surfaceId1, check, EFalse); sl@0: sl@0: NsCheckL(surfaceId1, check, ETrue); sl@0: sl@0: NsCheckL(surfaceId2, check, ETrue); sl@0: sl@0: SymbianStreamRemoveReference(ns1); sl@0: ASSERT_EQUALS((singleton.Count()), check); sl@0: sl@0: SymbianStreamRemoveReference(ns2); sl@0: ASSERT_EQUALS((singleton.Count()), check); sl@0: sl@0: SymbianStreamRemoveReference(ns2); sl@0: ASSERT_EQUALS((singleton.Count()), --check); sl@0: sl@0: SymbianStreamRemoveReference(ns1); sl@0: ASSERT_EQUALS((singleton.Count()), check); sl@0: sl@0: SymbianStreamRemoveReference(ns1); sl@0: ASSERT_EQUALS((singleton.Count()), --check); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: sl@0: iUtility->DestroySurface(surfaceId1); sl@0: iUtility->DestroySurface(surfaceId2); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: err = SymbianStreamFind(&surfaceId2,&ns2); sl@0: ASSERT_TRUE(err == KErrNotFound); sl@0: ASSERT_FALSE(ns2); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: struct SupportedFormats sl@0: { sl@0: TUidPixelFormat symbianPixelFormat; sl@0: } supportedFormats[]= sl@0: { sl@0: EUidPixelFormatXRGB_8888, sl@0: EUidPixelFormatARGB_8888, sl@0: EUidPixelFormatBGRX_8888, sl@0: EUidPixelFormatXBGR_8888, sl@0: EUidPixelFormatBGRA_8888, sl@0: EUidPixelFormatABGR_8888, sl@0: EUidPixelFormatABGR_8888_PRE, sl@0: EUidPixelFormatARGB_8888_PRE, sl@0: EUidPixelFormatBGRA_8888_PRE, sl@0: EUidPixelFormatARGB_2101010, sl@0: EUidPixelFormatABGR_2101010, sl@0: EUidPixelFormatBGR_888, sl@0: EUidPixelFormatRGB_888, sl@0: EUidPixelFormatXRGB_4444, sl@0: EUidPixelFormatARGB_4444, sl@0: EUidPixelFormatXBGR_4444, sl@0: EUidPixelFormatRGB_565, sl@0: EUidPixelFormatBGR_565, sl@0: EUidPixelFormatARGB_1555, sl@0: EUidPixelFormatXRGB_1555, sl@0: EUidPixelFormatARGB_8332, sl@0: EUidPixelFormatBGRX_5551, sl@0: EUidPixelFormatBGRA_5551, sl@0: EUidPixelFormatBGRA_4444, sl@0: EUidPixelFormatBGRX_4444, sl@0: EUidPixelFormatAP_88, sl@0: EUidPixelFormatRGB_332, sl@0: EUidPixelFormatBGR_332, sl@0: EUidPixelFormatA_8, sl@0: EUidPixelFormatL_8, sl@0: EUidPixelFormatP_8, sl@0: EUidPixelFormatP_4, sl@0: EUidPixelFormatL_4, sl@0: EUidPixelFormatL_2, sl@0: EUidPixelFormatP_2, sl@0: EUidPixelFormatL_1 sl@0: }; sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0103 sl@0: @SYMTestCaseDesc Retrieve stream attributes using SymbianStreamGetHeader() sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority sl@0: @SYMTestPurpose Verify native stream object attributes can be retrieved. sl@0: @SYMTestActions sl@0: Create a native stream based on a supported image/pixel format sl@0: Retrieve all of the stream attributes sl@0: Retreive none of the stream attributes sl@0: @SYMTestExpectedResults sl@0: The retrieved attributes should match the parameters used to create the surface stream sl@0: Retrieving no attributes should not cause a crash sl@0: **/ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0103L() sl@0: { sl@0: // Native stream attributes sl@0: TSize surfaceSize(TSize(100,50)); sl@0: khronos_int32_t width = surfaceSize.iWidth; sl@0: khronos_int32_t height = surfaceSize.iHeight; sl@0: khronos_int32_t numBuffers = 2; sl@0: sl@0: for (TInt x=0; x 0) sl@0: { sl@0: ASSERT_EQUALS(attStreamStride, (streamPixelSize * width)); sl@0: } sl@0: else sl@0: { sl@0: ASSERT_EQUALS(attStreamStride, (width-(streamPixelSize+1)) / (-streamPixelSize)); sl@0: } sl@0: ASSERT_EQUALS(attStreamPixelSize, (TInt32)BytesPerPixel(supportedFormats[x].symbianPixelFormat)); sl@0: sl@0: SymbianStreamGetHeader(ns, NULL, NULL, NULL, NULL, NULL); sl@0: sl@0: SymbianStreamRemoveReference(ns); sl@0: } sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0104 sl@0: @SYMTestCaseDesc Acquire write/read buffers and retrieve the buffer ptr (single threaded test). sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority sl@0: @SYMTestPurpose Verify owfNativeStreamAcquireWriteBuffer(), owfNativeStreamReleaseWriteBuffer(), sl@0: owfNativeStreamAcquireReadBuffer() and owfNativeStreamReleaseReadBuffer() methods sl@0: work as expected. sl@0: sl@0: @SYMTestActions sl@0: Create a native stream sl@0: For each buffer: sl@0: - Acquire the write buffer (wB) sl@0: - Get the write buffer ptr (pWB) sl@0: - Release the write buffer sl@0: - Acquire the read buffer (rB) sl@0: - Get the read buffer ptr (pRB) sl@0: - Release the read buffer sl@0: Repeat for each buffer. Finally: sl@0: Acquire the write buffer sl@0: Release the write buffer sl@0: @SYMTestExpectedResults sl@0: For each buffer of the native stream, check: sl@0: - The read buffer (rB) should be the same as the write buffer (wB) sl@0: - The read buffer address (pRB) should be the same as the write buffer address (pWB) sl@0: If the number of buffers > 1, check: sl@0: - The write buffer number from the previous acquire write buffer call should not be the same sl@0: as the write buffer number from the next acquire write buffer call sl@0: The final acquire/release write/read calls should check: sl@0: The write buffer number should acquire the first buffer number sl@0: **/ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0104L(TInt aNumBuffers) sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: sl@0: ASSERT_TRUE(aNumBuffers > 0); sl@0: sl@0: TSize surfaceSize(TSize(100,100)); sl@0: khronos_int32_t width = surfaceSize.iWidth; sl@0: khronos_int32_t height = surfaceSize.iHeight; sl@0: sl@0: OWF_IMAGE_FORMAT pixelFormat = sl@0: { sl@0: OWF_IMAGE_ARGB8888, sl@0: ETrue, sl@0: ETrue, sl@0: aNumBuffers sl@0: }; sl@0: sl@0: SymbianStreamType ns=helperCreateImageStream(width, sl@0: height, sl@0: &pixelFormat, sl@0: aNumBuffers); sl@0: ASSERT_TRUE(ns); sl@0: sl@0: TUint8 *pWriteBuffer = NULL; sl@0: TUint8 *pReadBuffer = NULL; sl@0: TUint8 *pPrevWriteBuffer = pWriteBuffer; sl@0: khronos_int32_t writeBuffer; sl@0: khronos_int32_t readBuffer; sl@0: khronos_int32_t bufferIndexWrite; sl@0: khronos_int32_t bufferIndexRead; sl@0: khronos_int32_t bufferIndexWriteFirst; sl@0: khronos_int32_t bufferIndexWriteFinal; sl@0: khronos_int32_t finalWriteBuffer; sl@0: const TSurfaceId* getId = NULL; sl@0: sl@0: TInt bufferCount = aNumBuffers; sl@0: sl@0: // Loop through the buffers sl@0: for (TInt count=0; count(&pWriteBuffer)); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_NOT_NULL(pWriteBuffer); sl@0: sl@0: err = SymbianStreamReleaseWriteBuffer(ns,writeBuffer); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: // Acquire the read buffer sl@0: err = SymbianStreamAcquireReadBuffer(ns,&readBuffer); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamGetBufferId(ns,writeBuffer,&bufferIndexRead,&getId); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: err = SymbianStreamGetBufferPointer(ns,readBuffer,reinterpret_cast(&pReadBuffer)); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_NOT_NULL(pReadBuffer); sl@0: sl@0: err = SymbianStreamReleaseReadBuffer(ns,readBuffer); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: // Life-cycle checks sl@0: ASSERT_EQUALS(bufferIndexWrite, bufferIndexRead) sl@0: ASSERT_SAME(pWriteBuffer, pReadBuffer); sl@0: sl@0: if (count > 0) sl@0: { sl@0: ASSERT_NOT_SAME(pWriteBuffer, pPrevWriteBuffer); sl@0: } sl@0: sl@0: pPrevWriteBuffer = pWriteBuffer; sl@0: } sl@0: sl@0: // The next acquire write/reads should return the first buffer (0). sl@0: sl@0: err = SymbianStreamAcquireWriteBuffer(ns,&finalWriteBuffer); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamGetBufferId(ns,finalWriteBuffer,&bufferIndexWriteFinal,&getId); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamReleaseWriteBuffer(ns,finalWriteBuffer); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: // Final checks sl@0: ASSERT_EQUALS(bufferIndexWriteFinal, bufferIndexWriteFirst); sl@0: sl@0: SymbianStreamRemoveReference(ns); sl@0: sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0105 sl@0: @SYMTestCaseDesc Create a native stream and acquire a write buffer which is written to (single threaded test) sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority sl@0: @SYMTestPurpose Verify native stream buffers can be written to and read from. sl@0: @SYMTestActions sl@0: Create a surface and fill it Red sl@0: Create a native stream surface with the same surface properties (size, pixel format etc.) sl@0: Acquire the native stream write buffer sl@0: Fill the native stream surface Red sl@0: Release the write buffer sl@0: Acquire the native stream read buffer sl@0: Compare the pixel data of the surface to the native stream surface sl@0: Fill the Blue sl@0: Compare the pixel data of the surface to the native stream surface sl@0: @SYMTestExpectedResults sl@0: The surface pixel data is the same as the native stream surface pixel data sl@0: After the surface pixel data is changed to Blue, the native stream surface should not be the same sl@0: **/ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0105L(TInt aNumBuffers) sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: // Surface properties sl@0: TSize surfaceSize(TSize(100,100)); sl@0: sl@0: // Create the comparison surface and fill it Red sl@0: TSurfaceId surface; sl@0: TRAP(err, surface = iUtility->CreateSurfaceL(TSize(surfaceSize.iWidth,surfaceSize.iHeight), sl@0: EUidPixelFormatXRGB_8888, surfaceSize.iWidth * 4)); sl@0: sl@0: TRAP(err, iUtility->FillSurfaceL(surface, 0, KRgbRed)); sl@0: sl@0: // Native stream sl@0: khronos_int32_t width = surfaceSize.iWidth; sl@0: khronos_int32_t height = surfaceSize.iHeight; sl@0: sl@0: OWF_IMAGE_FORMAT pixelFormatXRGB888 = sl@0: { sl@0: OWF_IMAGE_XRGB8888, sl@0: ETrue, sl@0: EFalse, sl@0: 4 sl@0: }; sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: sl@0: SymbianStreamType ns1=helperCreateImageStream(width, sl@0: height, sl@0: &pixelFormatXRGB888, sl@0: aNumBuffers); sl@0: ASSERT_TRUE(ns1); sl@0: sl@0: sl@0: SymbianStreamBuffer bufferHandle; sl@0: err = SymbianStreamAcquireReadBuffer(ns1,&bufferHandle); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: long bufferIndex; sl@0: const TSurfaceId* nSurface = NULL; sl@0: err = SymbianStreamGetBufferId(ns1,bufferHandle,&bufferIndex,&nSurface); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamReleaseReadBuffer(ns1,bufferHandle); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_NOT_NULL(nSurface); sl@0: sl@0: TSurfaceId* nsSurface = const_cast(nSurface); sl@0: sl@0: // Acquire write buffer. With 3 buffers we should return buffer 1 sl@0: khronos_int32_t writeBuffer1; sl@0: err = SymbianStreamAcquireWriteBuffer(ns1,&writeBuffer1); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: TUint8 *pWriteBuffer1 = NULL; sl@0: err = SymbianStreamGetBufferPointer(ns1,writeBuffer1,reinterpret_cast(&pWriteBuffer1)); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_NOT_NULL(pWriteBuffer1); sl@0: sl@0: TRAP(err, iUtility->FillNativeStreamSurfaceL(*nsSurface, pWriteBuffer1, KRgbRed)); sl@0: sl@0: err = SymbianStreamReleaseWriteBuffer(ns1, writeBuffer1); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: // Now we should compare to see if the pixels are the same sl@0: khronos_int32_t readBuffer1; sl@0: err = SymbianStreamAcquireReadBuffer(ns1,&readBuffer1); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: TUint8 *pReadBuffer1 = NULL; sl@0: err = SymbianStreamGetBufferPointer(ns1,readBuffer1,reinterpret_cast(&pReadBuffer1)); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_NOT_NULL(pReadBuffer1); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: ASSERT_TRUE(iUtility->CompareSurfacesL(surface, 0, *nsSurface, pReadBuffer1)); sl@0: sl@0: // Finally, change the surface to blue. The pixels should now be different sl@0: TRAP(err, iUtility->FillSurfaceL(surface, 0, KRgbBlue)); sl@0: ASSERT_FALSE(iUtility->CompareSurfacesL(surface, 0, *nsSurface, pReadBuffer1)); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: err = SymbianStreamReleaseReadBuffer(ns1,readBuffer1); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: SymbianStreamRemoveReference(ns1); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0106 sl@0: @SYMTestCaseDesc Negative test - Attempt to acquire a write buffer when the write buffer has not been released (single threaded test) sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority sl@0: @SYMTestPurpose Verify an invalid handle is returned to the calling thread if the write buffer has not been released sl@0: @SYMTestActions sl@0: Create a native stream surface with 1 buffer sl@0: Acquire the native stream write buffer sl@0: Acquire the native stream write buffer again sl@0: @SYMTestExpectedResults sl@0: The 2nd acquire write buffer call should return OWF_INVALID_HANDLE if not single buffered. sl@0: **/ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0106L(TInt aNumBuffers) sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: sl@0: // Create the first stream (ARGB_8888_PRE) sl@0: TSize surfaceSize(TSize(100,100)); sl@0: khronos_int32_t width = surfaceSize.iWidth; sl@0: khronos_int32_t height = surfaceSize.iHeight; sl@0: sl@0: OWF_IMAGE_FORMAT pixelFormatARGB888Pre = sl@0: { sl@0: OWF_IMAGE_ARGB8888, sl@0: ETrue, sl@0: EFalse, sl@0: 4 sl@0: }; sl@0: sl@0: SymbianStreamType ns1=helperCreateImageStream(width, sl@0: height, sl@0: &pixelFormatARGB888Pre, sl@0: aNumBuffers); sl@0: ASSERT_TRUE(ns1); sl@0: sl@0: // Acquire write buffer. With just 1 buffer we should return buffer 0 sl@0: khronos_int32_t writeBuffer1; sl@0: err = SymbianStreamAcquireWriteBuffer(ns1,&writeBuffer1); sl@0: ASSERT_TRUE(err != KErrBadHandle); sl@0: sl@0: // Try and acquire the write buffer again before we have released it sl@0: khronos_int32_t writeBuffer2; sl@0: err = SymbianStreamAcquireWriteBuffer(ns1,&writeBuffer2); sl@0: ASSERT_TRUE(err != KErrBadHandle); sl@0: if (aNumBuffers == 1) sl@0: { sl@0: ASSERT_EQUALS(writeBuffer2, writeBuffer1); sl@0: } sl@0: else sl@0: { sl@0: ASSERT_EQUALS(writeBuffer2, (khronos_int32_t)0); sl@0: } sl@0: sl@0: err = SymbianStreamReleaseWriteBuffer(ns1,writeBuffer1); sl@0: ASSERT_TRUE(err != KErrBadHandle); sl@0: sl@0: err = SymbianStreamAcquireWriteBuffer(ns1, &writeBuffer2); sl@0: ASSERT_TRUE(err != KErrBadHandle); sl@0: TUint8 *pWriteBuffer2 = NULL; sl@0: err = SymbianStreamGetBufferPointer(ns1,writeBuffer2,reinterpret_cast(&pWriteBuffer2)); sl@0: ASSERT_TRUE(err != KErrBadHandle); sl@0: ASSERT_NOT_NULL(pWriteBuffer2); sl@0: sl@0: SymbianStreamRemoveReference(ns1); sl@0: sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0107 sl@0: @SYMTestCaseDesc Attempt to acquire a write buffer when the write buffer has not been released (multi threaded tests) sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority sl@0: @SYMTestPurpose Verify an invalid handle is returned to the calling thread if the write buffer has not been released sl@0: @SYMTestActions sl@0: Create a shared native stream surface to be used by multiple threads sl@0: Thread 1 acquires the shared native stream and acquires the write buffer sl@0: Thread 2 acquires the shared native stream and attempts to acquire the write buffer sl@0: Thread 3 acquires the shared native stream and attempts to acquire the write buffer sl@0: Thread 1 releases the write buffer sl@0: Thread 2 acquires the write buffer sl@0: Thread 2 releases the write buffer sl@0: @SYMTestExpectedResults sl@0: OWF_INVALID_HANDLE returned when Thread 2 and Thread 3 attempt to acquire the write buffer sl@0: when Thread 1 has already acquired it sl@0: **/ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0107_1L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: INFO_PRINTF2(_L("** GRAPHICS_OPENWFC_NATIVESTREAM_0107 - %i buffers **"), gVarInstance.Buffers()); sl@0: INFO_PRINTF1(_L("Thread 1 - start")); sl@0: TSurfaceId surface = gVarInstance.SurfaceID(); sl@0: SymbianStreamType ns; sl@0: err = SymbianStreamAcquire(&surface,&ns); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(ns); sl@0: sl@0: khronos_int32_t writeBuffer1; sl@0: err = SymbianStreamAcquireWriteBuffer(ns,&writeBuffer1); sl@0: ASSERT_TRUE(err != KErrBadHandle); sl@0: sl@0: khronos_int32_t bufferIndex; sl@0: const TSurfaceId* getId = NULL; sl@0: err = SymbianStreamGetBufferId(ns,writeBuffer1,&bufferIndex,&getId); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_EQUALS(*getId, surface); sl@0: ASSERT_EQUALS(bufferIndex, (khronos_int32_t)1); sl@0: INFO_PRINTF2(_L("Thread 1 - Write buffer %i acquired"), bufferIndex); sl@0: sl@0: gSemaphore.Signal(2); // Thread 2 and 3 ready to run sl@0: sl@0: gSemaphore2.Wait(); sl@0: gSemaphore2.Wait(); // Wait for both threads to signal sl@0: err = SymbianStreamReleaseWriteBuffer(ns,writeBuffer1); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: SymbianStreamRemoveReference(ns); sl@0: INFO_PRINTF2(_L("Thread 1 - Write buffer %i released"), bufferIndex); sl@0: sl@0: gSemaphore.Signal(); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0107_2L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: gSemaphore.Wait(); // Semaphore count becomes -1 sl@0: INFO_PRINTF1(_L("Thread 2 - Start")); sl@0: TSurfaceId surface = gVarInstance.SurfaceID(); sl@0: SymbianStreamType ns; sl@0: err = SymbianStreamAcquire(&surface,&ns); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(ns); sl@0: sl@0: khronos_int32_t writeBuffer1; sl@0: err = SymbianStreamAcquireWriteBuffer(ns,&writeBuffer1); sl@0: ASSERT_TRUE(err != KErrBadHandle); sl@0: INFO_PRINTF1(_L("Thread 2 - Attempt to acquire the write buffer")); sl@0: ASSERT_FALSE(writeBuffer1); sl@0: INFO_PRINTF1(_L("Thread 2 - Write buffer already in use by Thread 1!")); sl@0: sl@0: gSemaphore2.Signal(); sl@0: sl@0: gSemaphore.Wait(); sl@0: sl@0: khronos_int32_t writeBuffer2; sl@0: err = SymbianStreamAcquireWriteBuffer(ns,&writeBuffer2); sl@0: ASSERT_TRUE(err != KErrBadHandle); sl@0: khronos_int32_t bufferIndex; sl@0: const TSurfaceId* getId = NULL; sl@0: err = SymbianStreamGetBufferId(ns,writeBuffer2,&bufferIndex,&getId); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_FALSE(bufferIndex); sl@0: INFO_PRINTF2(_L("Thread 2 - Write buffer %i acquired"), bufferIndex); sl@0: sl@0: err = SymbianStreamReleaseWriteBuffer(ns,writeBuffer2); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: SymbianStreamRemoveReference(ns); sl@0: INFO_PRINTF2(_L("Thread 2 - Write buffer %i released"), bufferIndex); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0107_3L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: gSemaphore.Wait(); // Semaphore count is -2 sl@0: INFO_PRINTF1(_L("Thread 3 - start")); sl@0: TSurfaceId surface = gVarInstance.SurfaceID(); sl@0: SymbianStreamType ns; sl@0: err = SymbianStreamAcquire(&surface,&ns); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(ns); sl@0: sl@0: khronos_int32_t writeBuffer1; sl@0: err = SymbianStreamAcquireWriteBuffer(ns,&writeBuffer1); sl@0: ASSERT_TRUE(err != KErrBadHandle); sl@0: INFO_PRINTF1(_L("Thread 3 - Attempt to acquire the write buffer")); sl@0: ASSERT_FALSE(writeBuffer1); sl@0: INFO_PRINTF1(_L("Thread 3 - Write buffer already in use by Thread 1!")); sl@0: sl@0: gSemaphore2.Signal(); sl@0: sl@0: SymbianStreamRemoveReference(ns); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0108 sl@0: @SYMTestCaseDesc Content updates on valid and invalid buffers sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority sl@0: @SYMTestPurpose Verify native streams can handle content updates for valid and invalid buffer numbers sl@0: @SYMTestActions sl@0: Create a surface with 4 buffers, sl@0: Create a stream from this surface, sl@0: Add an observer to listen out for content updates to the stream, sl@0: Set valid and invalid buffer numbers to be used in content updates sl@0: @SYMTestExpectedResults sl@0: For valid buffers, the read buffers should be set correctly and observer sl@0: callback method is called. sl@0: **/ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0108L(TInt aBuffers) sl@0: { sl@0: aBuffers = 3; sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: iScreenNo = 0; sl@0: TInt localNumber = 0; sl@0: sl@0: TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, aBuffers); sl@0: ASSERT_FALSE(surface.IsNull()); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: SymbianStreamType ns; sl@0: err = SymbianStreamAcquire(&surface,&ns); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(ns); sl@0: sl@0: err = SymbianStreamAddObserver(ns, TestUpdateCallback, &localNumber); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: khronos_int32_t bufferIndex = 0; sl@0: khronos_int32_t buffersIndex = 0; sl@0: khronos_int32_t lastValidBufnum = 0; sl@0: sl@0: const TSurfaceId* getId = NULL; sl@0: CExtensionContainer* updateExtension = NULL; sl@0: err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast(&updateExtension)); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface(); sl@0: ASSERT_NOT_NULL(updateProxy); sl@0: // Valid inputs sl@0: for (TInt i = 0; i < aBuffers; ++i) sl@0: { sl@0: buffersIndex = (aBuffers + i) % aBuffers; sl@0: sl@0: sl@0: updateProxy->ContentUpdated(surface, //aSurface sl@0: buffersIndex, //aBuffer sl@0: NULL, //aRegion sl@0: NULL, //aStatusConsumed sl@0: NULL, //aStatusDisplayed sl@0: NULL, //aTimeStamp sl@0: NULL, //aStatusDispXTimes sl@0: NULL //aDisplayedXTimes sl@0: ); sl@0: sl@0: // The test can pass without a delay when running locally, but fails on ONB. Insert a delay here temporarily to see if it makes any difference sl@0: User::After(10000); //10 ms delay sl@0: khronos_int32_t readBuffer; sl@0: err = SymbianStreamAcquireReadBuffer(ns,&readBuffer); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamGetBufferId(ns,readBuffer,&bufferIndex,&getId); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamReleaseReadBuffer(ns, readBuffer); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(bufferIndex == buffersIndex); sl@0: sl@0: // The test can pass without a delay when running locally, but fails on ONB. Insert a delay here temporarily to see if it makes any difference sl@0: User::After(10000); //10 ms delay sl@0: ASSERT_EQUALS((i+1),localNumber); sl@0: } sl@0: sl@0: // Reset number for negative tests sl@0: localNumber = 0; sl@0: lastValidBufnum = buffersIndex; sl@0: sl@0: // Invalid inputs sl@0: TInt invalidBuffersIndex[] = {-1, -256, aBuffers+29, 10000, -10000, aBuffers}; sl@0: TInt size = sizeof(invalidBuffersIndex) / sizeof(invalidBuffersIndex[0]); sl@0: sl@0: for (TInt i = 0; i < size; ++i) sl@0: { sl@0: updateProxy->ContentUpdated(surface, //aSurface sl@0: invalidBuffersIndex[i], //aBuffer sl@0: NULL, //aRegion sl@0: NULL, //aStatusConsumed sl@0: NULL, //aStatusDisplayed sl@0: NULL, //aTimeStamp sl@0: NULL, //aStatusDispXTimes sl@0: NULL //aDisplayedXTimes sl@0: ); sl@0: sl@0: User::After(10000); //10 ms delay sl@0: khronos_int32_t readBuffer; sl@0: err = SymbianStreamAcquireReadBuffer(ns,&readBuffer); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamGetBufferId(ns,readBuffer,&bufferIndex,&getId); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamReleaseReadBuffer(ns, readBuffer); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(bufferIndex == lastValidBufnum); sl@0: ASSERT_EQUALS(0,localNumber); sl@0: } sl@0: SymbianStreamRemoveReference(ns); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0109 sl@0: @SYMTestCaseDesc Test multiple acquire/release read/write buffer calls sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority sl@0: @SYMTestPurpose Verify the buffer index is correctly set sl@0: @SYMTestActions sl@0: Create a surface with 4 buffers, sl@0: Call acquire/release read/write buffer functions and to Submit an update to the surface sl@0: @SYMTestExpectedResults sl@0: Verify that acquire/release read/write buffer functions honour SUS update sl@0: Verify that the update callback function is called when the native stream is updated sl@0: **/ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0109L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: iScreenNo = 0; sl@0: TInt localNumber = 0; sl@0: TInt count = 0; sl@0: khronos_int32_t bufferIndexRead; sl@0: khronos_int32_t bufferIndexWrite; sl@0: sl@0: TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4); sl@0: ASSERT_FALSE(surface.IsNull()); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: SymbianStreamType ns; sl@0: err = SymbianStreamAcquire(&surface,&ns); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(ns); sl@0: sl@0: err = SymbianStreamAddObserver(ns, TestComposedCallback, &localNumber); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamAddObserver(ns, TestUpdateCallback, &localNumber); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: khronos_int32_t readBuffer1; sl@0: err = SymbianStreamAcquireReadBuffer(ns,&readBuffer1); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: const TSurfaceId* getId = NULL; sl@0: err = SymbianStreamGetBufferId(ns,readBuffer1,&bufferIndexRead,&getId); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamReleaseReadBuffer(ns, readBuffer1); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(bufferIndexRead == 0); sl@0: sl@0: khronos_int32_t writeBuffer1; sl@0: err = SymbianStreamAcquireWriteBuffer(ns,&writeBuffer1); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: khronos_int32_t readBuffer2; sl@0: err = SymbianStreamAcquireReadBuffer(ns,&readBuffer2); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamGetBufferId(ns,readBuffer2,&bufferIndexRead,&getId); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamReleaseReadBuffer(ns, readBuffer2); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(bufferIndexRead == 0); sl@0: err = SymbianStreamReleaseWriteBuffer(ns,writeBuffer1); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: ASSERT_EQUALS((++count),localNumber); sl@0: sl@0: khronos_int32_t readBuffer3; sl@0: err = SymbianStreamAcquireReadBuffer(ns,&readBuffer3); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamGetBufferId(ns,readBuffer3,&bufferIndexRead,&getId); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamReleaseReadBuffer(ns, readBuffer3); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(bufferIndexRead == 1); sl@0: sl@0: khronos_int32_t writeBuffer2; sl@0: err = SymbianStreamAcquireWriteBuffer(ns,&writeBuffer2); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamGetBufferId(ns,writeBuffer2,&bufferIndexWrite,&getId); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE((bufferIndexRead + 1) == bufferIndexWrite); sl@0: sl@0: khronos_int32_t readBuffer4; sl@0: err = SymbianStreamAcquireReadBuffer(ns,&readBuffer4); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamGetBufferId(ns,readBuffer4,&bufferIndexRead,&getId); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamReleaseReadBuffer(ns, readBuffer4); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(bufferIndexRead == (bufferIndexWrite - 1)); sl@0: sl@0: CExtensionContainer* updateExtension = NULL; sl@0: err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast(&updateExtension)); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface(); sl@0: ASSERT_NOT_NULL(updateProxy); sl@0: sl@0: updateProxy->ContentUpdated(surface, //aSurface sl@0: 0, //aBuffer sl@0: NULL, //aRegion sl@0: NULL, //aStatusConsumed sl@0: NULL, //aStatusDisplayed sl@0: NULL, //aTimeStamp sl@0: NULL, //aStatusDispXTimes sl@0: NULL //aDisplayedXTimes sl@0: ); sl@0: sl@0: ASSERT_EQUALS((++count),localNumber); sl@0: sl@0: khronos_int32_t readBuffer5; sl@0: err = SymbianStreamAcquireReadBuffer(ns,&readBuffer5); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamGetBufferId(ns,readBuffer5,&bufferIndexRead,&getId); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamReleaseReadBuffer(ns, readBuffer5); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(bufferIndexRead == 0); sl@0: err = SymbianStreamReleaseWriteBuffer(ns,writeBuffer2); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: ASSERT_EQUALS((++count),localNumber); sl@0: sl@0: khronos_int32_t readBuffer6; sl@0: err = SymbianStreamAcquireReadBuffer(ns,&readBuffer6); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamGetBufferId(ns,readBuffer6,&bufferIndexRead,&getId); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamReleaseReadBuffer(ns, readBuffer6); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(bufferIndexRead == 0); sl@0: sl@0: khronos_int32_t writeBuffer3; sl@0: err = SymbianStreamAcquireWriteBuffer(ns,&writeBuffer3); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamGetBufferId(ns,writeBuffer3,&bufferIndexWrite,&getId); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(bufferIndexWrite == 1); sl@0: err = SymbianStreamReleaseWriteBuffer(ns,writeBuffer3); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: khronos_int32_t readBuffer7; sl@0: err = SymbianStreamAcquireReadBuffer(ns,&readBuffer7); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamGetBufferId(ns,readBuffer7,&bufferIndexRead,&getId); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamReleaseReadBuffer(ns, readBuffer7); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(bufferIndexRead == 1); sl@0: sl@0: SymbianStreamRemoveReference(ns); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0110 sl@0: @SYMTestCaseDesc Verify that the update observer callback function is called after a sl@0: acquireWriteBuffer/releaseWriteBuffer call. sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority sl@0: @SYMTestPurpose sl@0: @SYMTestActions sl@0: Create a surface with 1 buffer sl@0: Add an observer to listen out for content updates to the stream sl@0: Call acquire/release write buffer functions sl@0: @SYMTestExpectedResults sl@0: Verify that the release write buffer function notifies any observers listening and the sl@0: observer callback function is called. sl@0: **/ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0110L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: TInt localNumber = 0; sl@0: sl@0: TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 1); sl@0: ASSERT_FALSE(surface.IsNull()); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: SymbianStreamType ns; sl@0: err = SymbianStreamAcquire(&surface,&ns); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(ns); sl@0: sl@0: err = SymbianStreamAddObserver(ns, TestComposedCallback, &localNumber); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: khronos_int32_t writeBuffer1; sl@0: err = SymbianStreamAcquireWriteBuffer(ns,&writeBuffer1); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamReleaseWriteBuffer(ns,writeBuffer1); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: if (localNumber == 0) sl@0: { sl@0: User::After(1000000); sl@0: } sl@0: sl@0: ASSERT_TRUE(localNumber == 1); sl@0: SymbianStreamRemoveReference(ns); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0111 sl@0: @SYMTestCaseDesc Tests various cases including some negative cases for Native Stream callbacks sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority sl@0: @SYMTestPurpose sl@0: @SYMTestActions sl@0: Create a surface with 1 buffer sl@0: Add an observer N times sl@0: Remove the same observer M (M <= N) times sl@0: Register Null observer sl@0: Unregister something that was never registered sl@0: @SYMTestExpectedResults sl@0: Verify that the observer is called (N - M) times sl@0: Verify that error case behaviour is correct sl@0: **/ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0111L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: iScreenNo = 0; sl@0: sl@0: TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 1); sl@0: ASSERT_FALSE(surface.IsNull()); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: SymbianStreamType ns; sl@0: err = SymbianStreamAcquire(&surface,&ns); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(ns); sl@0: sl@0: TInt localNumber = 0; sl@0: err = SymbianStreamAddObserver(ns, NULL, &localNumber); sl@0: ASSERT_TRUE(err == KErrBadHandle); sl@0: err = SymbianStreamRemoveObserver(ns, &localNumber, ESOWF_EventComposed); sl@0: ASSERT_TRUE(err == KErrNotFound); sl@0: err = SymbianStreamRemoveObserver(ns, NULL, ESOWF_EventComposed); sl@0: ASSERT_TRUE(err == KErrNotFound); sl@0: err = SymbianStreamAddObserver(ns, TestUpdateCallback, &localNumber); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamRemoveObserver(ns, &localNumber, ESOWF_EventUpdated); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamRemoveObserver(ns, &localNumber, ESOWF_EventUpdated); sl@0: ASSERT_TRUE(err == KErrNotFound); sl@0: sl@0: #define N_TIMES 7 sl@0: #define M_TIMES 3 sl@0: sl@0: localNumber = 0; sl@0: TInt k = N_TIMES; sl@0: while (k--) sl@0: { sl@0: err = SymbianStreamAddObserver(ns, TestUpdateCallback, &localNumber); sl@0: ASSERT_TRUE(err != KErrBadHandle); sl@0: } sl@0: k = M_TIMES; sl@0: sl@0: CExtensionContainer* updateExtension = NULL; sl@0: err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast(&updateExtension)); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface(); sl@0: ASSERT_NOT_NULL(updateProxy); sl@0: sl@0: updateProxy->ContentUpdated(surface, //aSurface sl@0: 0, //aBuffer sl@0: NULL, //aRegion sl@0: NULL, //aStatusConsumed sl@0: NULL, //aStatusDisplayed sl@0: NULL, //aTimeStamp sl@0: NULL, //aStatusDispXTimes sl@0: NULL //aDisplayedXTimes sl@0: ); sl@0: sl@0: User::After(10000); sl@0: ASSERT_TRUE(localNumber == 1); sl@0: sl@0: while (k--) sl@0: { sl@0: err = SymbianStreamRemoveObserver(ns, &localNumber, ESOWF_EventUpdated); sl@0: ASSERT_TRUE(err != KErrBadHandle); sl@0: } sl@0: sl@0: updateProxy->ContentUpdated(surface, //aSurface sl@0: 0, //aBuffer sl@0: NULL, //aRegion sl@0: NULL, //aStatusConsumed sl@0: NULL, //aStatusDisplayed sl@0: NULL, //aTimeStamp sl@0: NULL, //aStatusDispXTimes sl@0: NULL //aDisplayedXTimes sl@0: ); sl@0: sl@0: ASSERT_TRUE(localNumber == 1); sl@0: sl@0: SymbianStreamRemoveReference(ns); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0112 sl@0: @SYMTestCaseDesc Tests multithreaded cases for Native Stream callbacks sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority sl@0: @SYMTestPurpose sl@0: @SYMTestActions sl@0: Create 3 threads and call add, remove, notify observers from sl@0: respective threads multiple times sl@0: @SYMTestExpectedResults sl@0: Verify that the observers work correctly in multithreaded environment sl@0: **/ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0112_1L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: sl@0: INFO_PRINTF1(_L("GRAPHICS_OPENWFC_NATIVESTREAM_0112_1L: Thread 1 start, Register Observer")); sl@0: TSurfaceId surface = gVarInstance.SurfaceID(); sl@0: SymbianStreamType ns; sl@0: err = SymbianStreamAcquire(&surface,&ns); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(ns); sl@0: sl@0: gVarInstance.iMultithreadCounter = 0; sl@0: sl@0: TTimeIntervalMicroSeconds32 delay(32000), zeroDelay(0); sl@0: while (delay >= zeroDelay) sl@0: { sl@0: INFO_PRINTF2(_L("Thread 1 is going to add another observer after %i microsecond"), delay.Int()); sl@0: User::AfterHighRes(delay); sl@0: SymbianStreamAddObserver(ns, TestUpdateCallback, &gVarInstance.iMultithreadCounter); sl@0: delay = delay.Int() - 43; sl@0: } sl@0: TInt count = 50; sl@0: while (count--) sl@0: { sl@0: INFO_PRINTF1(_L("Thread 1 is going to add another observer without delay")); sl@0: SymbianStreamAddObserver(ns, TestUpdateCallback, &gVarInstance.iMultithreadCounter); sl@0: } sl@0: INFO_PRINTF1(_L("GRAPHICS_OPENWFC_NATIVESTREAM_0112_1L: Thread 1 exits")); sl@0: sl@0: SymbianStreamRemoveReference(ns); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0112_2L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: sl@0: INFO_PRINTF1(_L("GRAPHICS_OPENWFC_NATIVESTREAM_0112_2L: Thread 2 start, Unregister Observer")); sl@0: TSurfaceId surface = gVarInstance.SurfaceID(); sl@0: SymbianStreamType ns; sl@0: err = SymbianStreamAcquire(&surface,&ns); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(ns); sl@0: sl@0: TTimeIntervalMicroSeconds32 delay(32000), zeroDelay(0); sl@0: while (delay > zeroDelay) sl@0: { sl@0: INFO_PRINTF2(_L("Thread 2 is going to remove one observer after %i microsecond"), delay.Int()); sl@0: User::AfterHighRes(delay); sl@0: SymbianStreamRemoveObserver(ns, &gVarInstance.iMultithreadCounter, ESOWF_EventUpdated); sl@0: delay = delay.Int() - 49; sl@0: } sl@0: TInt count = 50; sl@0: while (count--) sl@0: { sl@0: INFO_PRINTF1(_L("Thread 2 is going to remove one observer without delay")); sl@0: SymbianStreamRemoveObserver(ns, &gVarInstance.iMultithreadCounter, ESOWF_EventUpdated); sl@0: } sl@0: INFO_PRINTF1(_L("GRAPHICS_OPENWFC_NATIVESTREAM_0112_2L: Thread 2 exits")); sl@0: SymbianStreamRemoveReference(ns); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0112_3L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: sl@0: INFO_PRINTF1(_L("GRAPHICS_OPENWFC_NATIVESTREAM_0112_2L: Thread 3 start, Notify Observer")); sl@0: TSurfaceId surface = gVarInstance.SurfaceID(); sl@0: SymbianStreamType ns; sl@0: err = SymbianStreamAcquire(&surface,&ns); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(ns); sl@0: sl@0: khronos_int32_t bufferIndex; sl@0: TTimeIntervalMicroSeconds32 delay(32000), zeroDelay(0); sl@0: while (delay > zeroDelay) sl@0: { sl@0: khronos_int32_t writeBuffer; sl@0: err = SymbianStreamAcquireWriteBuffer(ns,&writeBuffer); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: const TSurfaceId* getId = NULL; sl@0: err = SymbianStreamGetBufferId(ns,writeBuffer,&bufferIndex,&getId); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: INFO_PRINTF2(_L("Thread 3 - Write buffer %i acquired"), bufferIndex); sl@0: sl@0: INFO_PRINTF2(_L("Thread 3 going to send notification after %i second"), delay.Int()); sl@0: User::AfterHighRes(delay); sl@0: delay = delay.Int() - 58; sl@0: err = SymbianStreamReleaseWriteBuffer(ns, writeBuffer); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: } sl@0: TInt count = 50; sl@0: while (count--) sl@0: { sl@0: khronos_int32_t writeBuffer; sl@0: err = SymbianStreamAcquireWriteBuffer(ns,&writeBuffer); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: const TSurfaceId* getId = NULL; sl@0: err = SymbianStreamGetBufferId(ns,writeBuffer,&bufferIndex,&getId); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: INFO_PRINTF2(_L("Thread 3 - Write buffer %i acquired"), bufferIndex); sl@0: sl@0: INFO_PRINTF1(_L("Thread 3 going to send notification without delay")); sl@0: err = SymbianStreamReleaseWriteBuffer(ns, writeBuffer); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: } sl@0: INFO_PRINTF1(_L("GRAPHICS_OPENWFC_NATIVESTREAM_0112_2L: Thread 3 exits")); sl@0: sl@0: SymbianStreamRemoveReference(ns); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: /** sl@0: Submit updates to the native stream whilst observers are being added and removed. sl@0: Do not run in parallel with 0112_3L sl@0: */ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0112_4L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: sl@0: INFO_PRINTF1(_L("GRAPHICS_OPENWFC_NATIVESTREAM_0112_2L: Thread 3 start, Notify Observer")); sl@0: sl@0: TTimeIntervalMicroSeconds32 delay(32000), zeroDelay(0); sl@0: sl@0: iScreenNo = 0; sl@0: TRequestStatus displayedStatus, availableStatus, displayedXStatus; sl@0: TUint32 timeStamp = 0; sl@0: TInt bufferNo = 0; sl@0: TInt numBuffers = 2; sl@0: TInt displayedX = 5; sl@0: sl@0: CExtensionContainer* updateExtension = NULL; sl@0: err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast(&updateExtension)); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface(); sl@0: ASSERT_NOT_NULL(updateProxy); sl@0: sl@0: while (delay > zeroDelay) sl@0: { sl@0: INFO_PRINTF2(_L("Thread 0112_4 submitting update after %i second"), delay.Int()); sl@0: User::AfterHighRes(delay); sl@0: delay = delay.Int() - 58; sl@0: sl@0: updateProxy->ContentUpdated(gVarInstance.SurfaceID(), //aSurface sl@0: bufferNo, //aBuffer sl@0: NULL, //aRegion sl@0: &availableStatus, //aStatusConsumed sl@0: &displayedStatus, //aStatusDisplayed sl@0: &timeStamp, //aTimeStamp sl@0: &displayedXStatus, //aStatusDispXTimes sl@0: &displayedX //aDisplayedXTimes sl@0: ); sl@0: sl@0: bufferNo = (bufferNo + 1) % numBuffers; sl@0: } sl@0: sl@0: TInt count = 50; sl@0: while (count--) sl@0: { sl@0: INFO_PRINTF1(_L("Thread 0112_4 Set notifications")); sl@0: INFO_PRINTF1(_L("Thread 0112_4 submitting update without delay")); sl@0: sl@0: updateProxy->ContentUpdated(gVarInstance.SurfaceID(), //aSurface sl@0: bufferNo, //aBuffer sl@0: NULL, //aRegion sl@0: &availableStatus, //aStatusConsumed sl@0: &displayedStatus, //aStatusDisplayed sl@0: &timeStamp, //aTimeStamp sl@0: &displayedXStatus, //aStatusDispXTimes sl@0: &displayedX //aDisplayedXTimes sl@0: ); sl@0: sl@0: bufferNo = (bufferNo + 1) % numBuffers; sl@0: } sl@0: INFO_PRINTF1(_L("GRAPHICS_OPENWFC_NATIVESTREAM_0112_4L: Thread exits")); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0113 sl@0: @SYMTestCaseDesc Test displayed notification sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority High sl@0: @SYMTestPurpose Tests an end to end displayed notification. sl@0: @SYMTestActions sl@0: sl@0: 1. Create a surface sl@0: 2. Create a native stream for the surface sl@0: 3. Register the test class as an observer for ESOWF_EventUpdated to act as a fake composer sl@0: 4. Register for displayed notifications sl@0: 5. Submit an update to the surface sl@0: 6. The observer function should be invoked and verifies that stream and event parameters. sl@0: 7. The tester simulates the end of a composition by firing owfNativeStreanProcessNotifications sl@0: 8. Wait on the displayed request status. sl@0: 9. Remove the source stream updated observer sl@0: 10. Destroy the native stream. sl@0: sl@0: The test is then repeated but the compositor claims the native stream is not visible. sl@0: sl@0: @SYMTestExpectedResults sl@0: No errors, displayed status completed with KErrNone. sl@0: sl@0: **/ sl@0: sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0113L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: iSourceStreamUpdatedCalled = 0; sl@0: iImmediateAvailable = EFalse; sl@0: iImmediateVisible = SYM_CONTENT_NOT_VISIBLE; sl@0: iContextUpdatedFlags = 0; sl@0: iScreenNo = 0; sl@0: sl@0: for (TInt i = 0; i < 2; ++i) sl@0: { sl@0: TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4); sl@0: ASSERT_FALSE(surface.IsNull()); sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: sl@0: CTestNativeStream::iTester = this; sl@0: TBool visible = (i == 0); sl@0: sl@0: RHeap* threadHeap3 = &User::Heap(); sl@0: err = SymbianStreamAcquire(&surface,&iNs); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(iNs); sl@0: sl@0: iExpectedSourceStreamUpdatedEventMask = 0; sl@0: err = SymbianStreamAddObserver(iNs, SourceStreamUpdatedCallback, this); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: TRequestStatus statusDisplayed; sl@0: TUint32 displayedTime; sl@0: sl@0: CExtensionContainer* updateExtension = NULL; sl@0: err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast(&updateExtension)); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface(); sl@0: ASSERT_NOT_NULL(updateProxy); sl@0: sl@0: iSourceStreamUpdatedCalled = 0; sl@0: updateProxy->ContentUpdated(surface, //aSurface sl@0: 0, //aBuffer sl@0: NULL, //aRegion sl@0: NULL, //aStatusConsumed sl@0: &statusDisplayed, //aStatusDisplayed sl@0: &displayedTime, //aTimeStamp sl@0: NULL, //aStatusDispXTimes sl@0: NULL //aDisplayedXTimes sl@0: ); sl@0: sl@0: ASSERT_TRUE(iSourceStreamUpdatedCalled == 1); sl@0: err = SymbianStreamRemoveObserver(iNs, this, ESOWF_EventUpdated); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: iExpectedSourceStreamUpdatedEventMask = ESOWF_EventDisplayed; sl@0: err = SymbianStreamAddExtendedObserver(iNs, SourceStreamUpdatedCallback, this, iScreenNo, ESOWF_EventUpdated); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: updateProxy->ContentUpdated(surface, //aSurface sl@0: 0, //aBuffer sl@0: NULL, //aRegion sl@0: NULL, //aStatusConsumed sl@0: &statusDisplayed, //aStatusDisplayed sl@0: &displayedTime, //aTimeStamp sl@0: NULL, //aStatusDispXTimes sl@0: NULL //aDisplayedXTimes sl@0: ); sl@0: sl@0: ASSERT_TRUE(iSourceStreamUpdatedCalled); sl@0: sl@0: // Pretend that a composition has occured sl@0: ++iStreamUpdatedSerialNumber; sl@0: if (visible) sl@0: { sl@0: khronos_int32_t newNotificationsMask = 0; sl@0: SymbianStreamProcessNotifications(iNs, sl@0: ESOWF_EventDisplayed, sl@0: iScreenNo, sl@0: iStreamUpdatedSerialNumber, sl@0: &newNotificationsMask); sl@0: sl@0: // No updates during composition so newNotificationMask should still be zero sl@0: ASSERT_TRUE(newNotificationsMask == 0); sl@0: } sl@0: // Simulate multiple sources sl@0: SymbianStreamCheckVisible(iNs, ESOWF_EventDisplayed, iScreenNo, iStreamUpdatedSerialNumber); sl@0: SymbianStreamCheckVisible(iNs, ESOWF_EventDisplayed, iScreenNo, iStreamUpdatedSerialNumber); sl@0: sl@0: // Make sure displayed event was completed sl@0: User::WaitForRequest(statusDisplayed); sl@0: if (visible) sl@0: { sl@0: ASSERT_EQUALS(statusDisplayed.Int(), KErrNone); sl@0: } sl@0: else sl@0: { sl@0: ASSERT_EQUALS(statusDisplayed.Int(), KErrNotVisible); sl@0: } sl@0: sl@0: err = SymbianStreamRemoveObserver(iNs, this, ESOWF_EventUpdated); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: SymbianStreamRemoveReference(iNs); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: iUtility->DestroySurface(surface); sl@0: } sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0114 sl@0: @SYMTestCaseDesc Test available notification sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority High sl@0: @SYMTestPurpose Tests an end to end available notification. sl@0: @SYMTestActions sl@0: sl@0: 1. Create a surface sl@0: 2. Create a native stream for the surface sl@0: 3. Register the test class as an observer for ESOWF_EventUpdated to act as a fake composer sl@0: 4. Register for displayed notifications sl@0: 5. Submit an update to the surface sl@0: 6. The observer function should be invoked and verifies that stream and event parameters. sl@0: 7. The tester simulates the end of a composition by firing owfNativeStreanProcessNotifications sl@0: 8. Verify that available notification has not been sent. sl@0: 9. Send another display update to change the read buffer to buffer 1 sl@0: 10. Verify that the source-stream updated callback is invoked. sl@0: 11. The tester simulates the end of a composition by firing owfNativeStreanProcessNotifications sl@0: 12. Wait for available status to be completed sl@0: 13. Remove the source stream updated observer sl@0: 14. Destroy the native stream. sl@0: sl@0: The test is then repeated but the compositor claims the native stream is not visible. sl@0: sl@0: @SYMTestExpectedResults sl@0: No errors, available status completed with KErrNone. sl@0: sl@0: **/ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0114L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: iScreenNo = 0; sl@0: iContextUpdatedFlags = 0; sl@0: iStreamUpdatedSerialNumber = 1; sl@0: iSourceStreamUpdatedCalled = 0; sl@0: // during compositio or first time after a commit sl@0: iImmediateAvailable = EFalse; sl@0: iImmediateVisible = SYM_CONTENT_VISIBLE; sl@0: sl@0: for (TInt i = 0; i < 2; ++i) sl@0: { sl@0: TBool visible = (i == 0); sl@0: TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4); sl@0: ASSERT_FALSE(surface.IsNull()); sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: sl@0: CTestNativeStream::iTester = this; sl@0: sl@0: err = SymbianStreamAcquire(&surface,&iNs); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(iNs); sl@0: sl@0: err = SymbianStreamAddExtendedObserver(iNs, SourceStreamUpdatedCallback, this, iScreenNo, ESOWF_EventUpdated); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: TRequestStatus statusAvailable; sl@0: iSourceStreamUpdatedCalled = 0; sl@0: sl@0: CExtensionContainer* updateExtension = NULL; sl@0: err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast(&updateExtension)); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface(); sl@0: ASSERT_NOT_NULL(updateProxy); sl@0: sl@0: ASSERT_TRUE(iSourceStreamUpdatedCalled == 0); sl@0: sl@0: iExpectedSourceStreamUpdatedEventMask = 0; sl@0: //we are during a composition sl@0: ++iStreamUpdatedSerialNumber; sl@0: updateProxy->ContentUpdated(surface, //aSurface sl@0: 0, //aBuffer sl@0: NULL, //aRegion sl@0: &statusAvailable, //aStatusConsumed sl@0: NULL, //aStatusDisplayed sl@0: NULL, //aTimeStamp sl@0: NULL, //aStatusDispXTimes sl@0: NULL //aDisplayedXTimes sl@0: ); sl@0: sl@0: // Verify that the context's callback is invoked when SubmitUpdate is called. sl@0: ASSERT_TRUE(iSourceStreamUpdatedCalled == 2); sl@0: sl@0: // Available should only be compled when submit update is called with a different buffer no. sl@0: // if the stream is multi-buffered. sl@0: ASSERT_EQUALS(statusAvailable.Int(), KRequestPending); sl@0: sl@0: // Pretend that a composition has occured sl@0: khronos_int32_t newNotificationsMask = 0; sl@0: if (visible) sl@0: { sl@0: SymbianStreamProcessNotifications(iNs, sl@0: 0, sl@0: iScreenNo, sl@0: iStreamUpdatedSerialNumber, sl@0: &newNotificationsMask); sl@0: sl@0: // No updates during composition so newNotificationMask should still be zero sl@0: ASSERT_TRUE(newNotificationsMask == 0); sl@0: SymbianStreamProcessNotifications(iNs, sl@0: 0, sl@0: iScreenNo, sl@0: iStreamUpdatedSerialNumber, sl@0: &newNotificationsMask); sl@0: sl@0: // No updates during composition so newNotificationMask should still be zero sl@0: ASSERT_TRUE(newNotificationsMask == 0); sl@0: } sl@0: SymbianStreamCheckVisible(iNs, ESOWF_EventAvailable, iScreenNo, iStreamUpdatedSerialNumber); sl@0: SymbianStreamCheckVisible(iNs, ESOWF_EventAvailable, iScreenNo, iStreamUpdatedSerialNumber); sl@0: sl@0: // Available for buffer zero should not be completed yet sl@0: ASSERT_EQUALS(statusAvailable.Int(), KRequestPending); sl@0: sl@0: // Update and switch to buffer 1 sl@0: iExpectedSourceStreamUpdatedEventMask = ESOWF_EventAvailable; sl@0: //we are during a composition sl@0: ++iStreamUpdatedSerialNumber; sl@0: updateProxy->ContentUpdated(surface, //aSurface sl@0: 1, //aBuffer sl@0: NULL, //aRegion sl@0: NULL, //aStatusConsumed sl@0: NULL, //aStatusDisplayed sl@0: NULL, //aTimeStamp sl@0: NULL, //aStatusDispXTimes sl@0: NULL //aDisplayedXTimes sl@0: ); sl@0: sl@0: ASSERT_TRUE(iSourceStreamUpdatedCalled == 4); sl@0: sl@0: // Consume update on buffer 1. This should make buffer 0 available sl@0: if (visible) sl@0: { sl@0: SymbianStreamProcessNotifications(iNs, sl@0: ESOWF_EventAvailable, sl@0: iScreenNo, sl@0: iStreamUpdatedSerialNumber, sl@0: &newNotificationsMask); sl@0: sl@0: ASSERT_TRUE(newNotificationsMask == 0); sl@0: sl@0: SymbianStreamProcessNotifications(iNs, sl@0: 0, sl@0: iScreenNo, sl@0: ++iStreamUpdatedSerialNumber, sl@0: &newNotificationsMask); sl@0: ASSERT_TRUE(newNotificationsMask == 0); sl@0: } sl@0: SymbianStreamCheckVisible(iNs, ESOWF_EventAvailable, iScreenNo, iStreamUpdatedSerialNumber); sl@0: SymbianStreamCheckVisible(iNs, ESOWF_EventAvailable, iScreenNo, iStreamUpdatedSerialNumber); sl@0: sl@0: // Make sure displayed event was completed sl@0: User::WaitForRequest(statusAvailable); sl@0: if (visible) sl@0: { sl@0: ASSERT_EQUALS(statusAvailable.Int(), KErrNone); sl@0: } sl@0: else sl@0: { sl@0: ASSERT_EQUALS(statusAvailable.Int(), KErrNotVisible); sl@0: } sl@0: sl@0: err = SymbianStreamRemoveObserver(iNs, this, ESOWF_EventUpdated); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: SymbianStreamRemoveReference(iNs); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: iUtility->DestroySurface(surface); sl@0: } sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0115 sl@0: @SYMTestCaseDesc Test displayed x times notification sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority High sl@0: @SYMTestPurpose Verify that the surface stream adaptation processes displayed x times sl@0: notifications correctly. sl@0: @SYMTestActions sl@0: sl@0: 1. Create a surface sl@0: 2. Create a native stream for the surface sl@0: 3. Register the test class as an observer for ESOWF_EventUpdated to act as a fake composer sl@0: 4. Register for displayed notifications sl@0: 5. Submit an update to the surface sl@0: 6. The observer function should be invoked and verifies that stream and event parameters. sl@0: 7. The tester simulates the end of a composition by firing SymbianStreamProcessNotifications sl@0: 8. If X has not been reached yet verify that displayed x status is not completed then goto 6. sl@0: Otherwise, goto step 9. sl@0: 9. Verify displayed-x-times status is completed with KErrNone sl@0: 10. Remove the observer sl@0: 11. Destroy the native stream. sl@0: sl@0: The test is then repeated but the compositor claims the native stream is not visible. sl@0: sl@0: @SYMTestExpectedResults sl@0: No errors, displayed-x-times status completed with KErrNone. sl@0: sl@0: */ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0115L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: iScreenNo = 0; sl@0: iContextUpdatedFlags = 0; sl@0: iStreamUpdatedSerialNumber = 1; sl@0: iImmediateAvailable = EFalse; sl@0: iImmediateVisible = SYM_CONTENT_VISIBLE; sl@0: sl@0: for (TInt i = 0; i < 2; ++i) sl@0: { sl@0: TBool visible = (i == 0); sl@0: iSourceStreamUpdatedCalled = 0; sl@0: TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4); sl@0: ASSERT_FALSE(surface.IsNull()); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: err = SymbianStreamAcquire(&surface, &iNs); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(iNs); sl@0: sl@0: err = SymbianStreamAddExtendedObserver(iNs, SourceStreamUpdatedCallback, this, iScreenNo, ESOWF_EventUpdated); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: TRequestStatus statusDisplayedX; sl@0: TInt X = 5; sl@0: sl@0: CExtensionContainer* updateExtension = NULL; sl@0: err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast(&updateExtension)); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface(); sl@0: ASSERT_NOT_NULL(updateProxy); sl@0: sl@0: iExpectedSourceStreamUpdatedEventMask = ESOWF_EventDisplayedX; sl@0: sl@0: updateProxy->ContentUpdated(surface, //aSurface sl@0: 0, //aBuffer sl@0: NULL, //aRegion sl@0: NULL, //aStatusConsumed sl@0: NULL, //aStatusDisplayed sl@0: NULL, //aTimeStamp sl@0: &statusDisplayedX, //aStatusDispXTimes sl@0: &X //aDisplayedXTimes sl@0: ); sl@0: sl@0: ASSERT_TRUE(iSourceStreamUpdatedCalled == 2); sl@0: sl@0: sl@0: khronos_int32_t events = ESOWF_EventDisplayedX; sl@0: for (TInt i = 0; i < X; ++i) sl@0: { sl@0: // Pretend that a composition has occured sl@0: ++iStreamUpdatedSerialNumber; sl@0: sl@0: if (visible) sl@0: { sl@0: khronos_int32_t newNotificationsMask = 0; sl@0: SymbianStreamProcessNotifications(iNs, sl@0: events, sl@0: iScreenNo, sl@0: iStreamUpdatedSerialNumber, sl@0: &newNotificationsMask); sl@0: sl@0: SymbianStreamCheckVisible(iNs, events, iScreenNo, iStreamUpdatedSerialNumber); sl@0: SymbianStreamCheckVisible(iNs, events, iScreenNo, iStreamUpdatedSerialNumber); sl@0: sl@0: if (i < X -1) sl@0: { sl@0: ASSERT_TRUE(newNotificationsMask == ESOWF_EventDisplayedX); sl@0: ASSERT_EQUALS(statusDisplayedX.Int(), KRequestPending); sl@0: } sl@0: else sl@0: { sl@0: ASSERT_TRUE(newNotificationsMask == 0); sl@0: User::WaitForRequest(statusDisplayedX); sl@0: ASSERT_EQUALS(statusDisplayedX.Int(), KErrNone); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: SymbianStreamCheckVisible(iNs, events, iScreenNo, iStreamUpdatedSerialNumber); sl@0: SymbianStreamCheckVisible(iNs, events, iScreenNo, iStreamUpdatedSerialNumber); sl@0: User::WaitForRequest(statusDisplayedX); sl@0: ASSERT_EQUALS(statusDisplayedX.Int(), KErrNotVisible); sl@0: break; sl@0: } sl@0: } sl@0: sl@0: err = SymbianStreamRemoveObserver(iNs, this, ESOWF_EventUpdated); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: SymbianStreamRemoveReference(iNs); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: sl@0: iUtility->DestroySurface(surface); sl@0: } sl@0: } sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0116 sl@0: @SYMTestCaseDesc Test all notifications together sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority High sl@0: @SYMTestPurpose Verify that the surface stream adaptation processes displayed x times sl@0: notifications correctly. sl@0: @SYMTestActions sl@0: sl@0: 1. Create a surface sl@0: 2. Create a native stream for the surface sl@0: 3. Register the test class as an observer for ESOWF_EventUpdated to act as a fake composer sl@0: 4. Register available, displayed and displayed-x-times notifications. sl@0: 5. Submit an update to the surface sl@0: 6. Wait for the displayed notification to complete. sl@0: 7. The observer function should be invoked and verifies that stream and event parameters. sl@0: 8. The tester simulates the end of a composition by firing SymbianStreamProcessNotifications sl@0: 9. If X has not been reached yet verify that displayedx and available status is not completed sl@0: then goto 5; otherwise, goto step 11. sl@0: 10. Verify displayed-x-times status is completed with KErrNone sl@0: 11. Submit an update on a different buffer number sl@0: 12. The tester simulates the end of a composition by firing SymbianStreamProcessNotifications sl@0: 13. Verify that the available status is completed with KErrNone sl@0: 14. Destroy the native stream. sl@0: sl@0: @SYMTestExpectedResults sl@0: No errors, displayed-x-times status completed with KErrNone. sl@0: sl@0: */ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0116L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: iScreenNo = 0; sl@0: iContextUpdatedFlags = 0; sl@0: iStreamUpdatedSerialNumber = 1; sl@0: iSourceStreamUpdatedCalled = 0; sl@0: iImmediateAvailable = EFalse; sl@0: iImmediateVisible = SYM_CONTENT_VISIBLE; sl@0: sl@0: TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4); sl@0: ASSERT_FALSE(surface.IsNull()); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: err = SymbianStreamAcquire(&surface, &iNs); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(iNs); sl@0: sl@0: err = SymbianStreamAddExtendedObserver(iNs, SourceStreamUpdatedCallback, this, iScreenNo, ESOWF_EventUpdated); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: TRequestStatus statusDisplayedX; sl@0: TRequestStatus statusAvailable; sl@0: TRequestStatus statusDisplayed; sl@0: sl@0: TInt X = 5; sl@0: TUint32 displayedTime = 0; sl@0: sl@0: CExtensionContainer* updateExtension = NULL; sl@0: err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast(&updateExtension)); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface(); sl@0: ASSERT_NOT_NULL(updateProxy); sl@0: sl@0: // the composition is signalled as ongoing (busy system) sl@0: iImmediateAvailable = EFalse; sl@0: // we expect, initially that the composer is asked to check only for the displayed notifications sl@0: iExpectedSourceStreamUpdatedEventMask = ESOWF_EventDisplayedX | ESOWF_EventDisplayed; sl@0: sl@0: updateProxy->ContentUpdated(surface, //aSurface sl@0: 0, //aBuffer sl@0: NULL, //aRegion sl@0: &statusAvailable, //aStatusConsumed sl@0: &statusDisplayed, //aStatusDisplayed sl@0: &displayedTime, //aTimeStamp sl@0: &statusDisplayedX, //aStatusDispXTimes sl@0: &X //aDisplayedXTimes sl@0: ); sl@0: sl@0: ASSERT_TRUE(iSourceStreamUpdatedCalled == 2); sl@0: // simulating the ongoing composition, the processing to be deferred for the following one sl@0: khronos_int32_t newNotificationsMask = 0; sl@0: SymbianStreamProcessNotifications(iNs, sl@0: iExpectedSourceStreamUpdatedEventMask, sl@0: iScreenNo, sl@0: iStreamUpdatedSerialNumber++, sl@0: &newNotificationsMask); sl@0: sl@0: ASSERT_TRUE(newNotificationsMask == iExpectedSourceStreamUpdatedEventMask); sl@0: sl@0: for (TInt i = 0; i < X; ++i) sl@0: { sl@0: // Pretend that a composition has occured sl@0: sl@0: khronos_int32_t events = newNotificationsMask; sl@0: // we process the expected notifications sl@0: newNotificationsMask = 0; sl@0: SymbianStreamProcessNotifications(iNs, sl@0: events, sl@0: iScreenNo, sl@0: iStreamUpdatedSerialNumber++, sl@0: &newNotificationsMask); sl@0: sl@0: // No updates during composition so newNotificationMask should still be zero sl@0: sl@0: if (i == 0) sl@0: { sl@0: User::WaitForRequest(statusDisplayed); sl@0: ASSERT_EQUALS(statusDisplayed.Int(), KErrNone); sl@0: } sl@0: sl@0: sl@0: if (i < X - 1) sl@0: { sl@0: ASSERT_TRUE(newNotificationsMask == ESOWF_EventDisplayedX); sl@0: // Displayed X times for buffer zero should not be completed yet sl@0: ASSERT_EQUALS(statusDisplayedX.Int(), KRequestPending); sl@0: ASSERT_EQUALS(statusAvailable.Int(), KRequestPending); sl@0: } sl@0: else sl@0: { sl@0: ASSERT_TRUE(newNotificationsMask == 0); sl@0: User::WaitForRequest(statusDisplayedX); sl@0: ASSERT_EQUALS(statusDisplayedX.Int(), KErrNone); sl@0: } sl@0: } sl@0: sl@0: // the composition is, still, signalled as ongoing (busy system) sl@0: iImmediateAvailable = EFalse; sl@0: // we expect, initially that the composer is asked to check only for the displayed notifications sl@0: iExpectedSourceStreamUpdatedEventMask = ESOWF_EventAvailable; sl@0: iUtility->SubmitUpdate(KAllScreens, surface, 1, 0); sl@0: ASSERT_TRUE(iSourceStreamUpdatedCalled == 4); sl@0: sl@0: SymbianStreamProcessNotifications(iNs, sl@0: iExpectedSourceStreamUpdatedEventMask, sl@0: iScreenNo, sl@0: iStreamUpdatedSerialNumber++, sl@0: &newNotificationsMask); sl@0: sl@0: User::WaitForRequest(statusAvailable); sl@0: ASSERT_EQUALS(statusAvailable.Int(), KErrNone); sl@0: ASSERT_TRUE(newNotificationsMask == 0); sl@0: sl@0: SymbianStreamRemoveReference(iNs); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: sl@0: iUtility->DestroySurface(surface); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0117_1 sl@0: @SYMTestCaseDesc Test displayed notification is cancelled when there are no registered SUS sl@0: notification observers sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority High sl@0: @SYMTestPurpose Verify that the surface stream adaptation cancels the displayed notification sl@0: when the native stream has not registered any observers for SUS notifications sl@0: @SYMTestActions sl@0: sl@0: 1. Create a surface sl@0: 2. Create a native stream for the surface sl@0: 3. Register the test class as an observer for ESOWF_EventUpdated to act as a fake composer sl@0: 4. Do not add any SUS notification observers to the native stream sl@0: 5. Register for displayed notification. sl@0: 6. Submit an update to the surface sl@0: 7. The observer function should be invoked and verifies that stream and event parameters. sl@0: 8. The tester simulates the end of a composition by firing SymbianStreamProcessNotifications sl@0: 9. Verify displayed status is completed with KErrCancel sl@0: 10. Destroy the native stream. sl@0: sl@0: @SYMTestExpectedResults sl@0: No errors, displayed status completed with KErrCancel. sl@0: sl@0: */ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0117_1L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: iScreenNo = 0; sl@0: iContextUpdatedFlags = 0; sl@0: iStreamUpdatedSerialNumber = 1; sl@0: iSourceStreamUpdatedCalled = 0; sl@0: iImmediateVisible = SYM_CONTENT_VISIBLE; sl@0: TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4); sl@0: ASSERT_FALSE(surface.IsNull()); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: err = SymbianStreamAcquire(&surface, &iNs); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(iNs); sl@0: sl@0: // Do not add observers for SUS notifications! sl@0: sl@0: iExpectedSourceStreamUpdatedEventMask = 0; sl@0: err = SymbianStreamAddObserver(iNs, SourceStreamUpdatedCallback, this); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: TRequestStatus statusDisplayed; sl@0: TUint32 timeStamp = 0; sl@0: sl@0: CExtensionContainer* updateExtension = NULL; sl@0: err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast(&updateExtension)); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface(); sl@0: ASSERT_NOT_NULL(updateProxy); sl@0: sl@0: updateProxy->ContentUpdated(surface, //aSurface sl@0: 0, //aBuffer sl@0: NULL, //aRegion sl@0: NULL, //aStatusConsumed sl@0: &statusDisplayed, //aStatusDisplayed sl@0: &timeStamp, //aTimeStamp sl@0: NULL, //aStatusDispXTimes sl@0: NULL //aDisplayedXTimes sl@0: ); sl@0: sl@0: // Verify that the context's callback is invoked when SubmitUpdate is called. sl@0: ASSERT_TRUE(iSourceStreamUpdatedCalled == 1); sl@0: sl@0: // Pretend that a composition has occured sl@0: khronos_int32_t notificationsMask = 0; sl@0: khronos_int32_t newNotificationsMask = 0; sl@0: sl@0: SymbianStreamProcessNotifications(iNs, sl@0: ESOWF_EventAvailable | ESOWF_EventDisplayed |ESOWF_EventDisplayedX, sl@0: iScreenNo, sl@0: ++iStreamUpdatedSerialNumber, sl@0: &newNotificationsMask); sl@0: sl@0: // No updates during composition so newNotificationMask should still be zero sl@0: ASSERT_EQUALS(newNotificationsMask, notificationsMask); sl@0: sl@0: // The displayed notification should be cancelled as we have no observers registered sl@0: ASSERT_EQUALS(statusDisplayed.Int(), KErrCancel); sl@0: ASSERT_TRUE(timeStamp == 0); sl@0: sl@0: SymbianStreamRemoveReference(iNs); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0117_2 sl@0: @SYMTestCaseDesc Test displayed x times notification is cancelled when there are no registered SUS sl@0: notification observers sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority High sl@0: @SYMTestPurpose Verify that the surface stream adaptation cancels the displayed x times notification sl@0: when the native stream has not registered any observers for SUS notifications sl@0: @SYMTestActions sl@0: sl@0: 1. Create a surface sl@0: 2. Create a native stream for the surface sl@0: 3. Register the test class as an observer for ESOWF_EventUpdated to act as a fake composer sl@0: 4. Do not add any SUS notification observers to the native stream sl@0: 5. Register for displayed x times notification. sl@0: 6. Submit an update to the surface sl@0: 7. The observer function should be invoked and verifies that stream and event parameters. sl@0: 8. The tester simulates the end of a composition by firing SymbianStreamProcessNotifications sl@0: 9. Verify displayed x time status is completed with KErrCancel sl@0: 10. Destroy the native stream. sl@0: sl@0: @SYMTestExpectedResults sl@0: No errors, displayed x times status completed with KErrCancel. sl@0: sl@0: */ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0117_2L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: iScreenNo = 0; sl@0: iContextUpdatedFlags = 0; sl@0: iStreamUpdatedSerialNumber = 1; sl@0: iSourceStreamUpdatedCalled = 0; sl@0: iImmediateVisible = SYM_CONTENT_VISIBLE; sl@0: TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4); sl@0: ASSERT_FALSE(surface.IsNull()); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: err = SymbianStreamAcquire(&surface, &iNs); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(iNs); sl@0: sl@0: // Do not add observers for SUS notifications! sl@0: sl@0: iExpectedSourceStreamUpdatedEventMask = 0; sl@0: err = SymbianStreamAddObserver(iNs, SourceStreamUpdatedCallback, this); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: TRequestStatus statusDisplayedX; sl@0: TInt X = 5; sl@0: sl@0: CExtensionContainer* updateExtension = NULL; sl@0: err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast(&updateExtension)); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface(); sl@0: ASSERT_NOT_NULL(updateProxy); sl@0: sl@0: updateProxy->ContentUpdated(surface, //aSurface sl@0: 0, //aBuffer sl@0: NULL, //aRegion sl@0: NULL, //aStatusConsumed sl@0: NULL, //aStatusDisplayed sl@0: NULL, //aTimeStamp sl@0: &statusDisplayedX, //aStatusDispXTimes sl@0: &X //aDisplayedXTimes sl@0: ); sl@0: sl@0: // Verify that the context's callback is invoked when SubmitUpdate is called. sl@0: ASSERT_TRUE(iSourceStreamUpdatedCalled == 1); sl@0: sl@0: User::WaitForRequest(statusDisplayedX); sl@0: ASSERT_EQUALS(statusDisplayedX.Int(), KErrCancel); sl@0: sl@0: for (TInt i = 0; i < X; ++i) sl@0: { sl@0: // Pretend that a composition has occured sl@0: khronos_int32_t newNotificationsMask = 0; sl@0: SymbianStreamProcessNotifications(iNs, sl@0: ESOWF_EventAvailable | ESOWF_EventDisplayed |ESOWF_EventDisplayedX, sl@0: iScreenNo, sl@0: ++iStreamUpdatedSerialNumber, sl@0: &newNotificationsMask); sl@0: sl@0: // No updates during composition so newNotificationMask should still be zero sl@0: ASSERT_TRUE(newNotificationsMask == 0); sl@0: } sl@0: sl@0: SymbianStreamRemoveReference(iNs); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0117_3 sl@0: @SYMTestCaseDesc Test available notification is cancelled when there are no registered SUS sl@0: notification observers sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority High sl@0: @SYMTestPurpose Verify that the surface stream adaptation cancels the available notification sl@0: when the native stream has not registered any observers for SUS notifications sl@0: @SYMTestActions sl@0: sl@0: 1. Create a surface sl@0: 2. Create a native stream for the surface sl@0: 3. Register the test class as an observer for ESOWF_EventUpdated to act as a fake composer sl@0: 4. Do not add any SUS notification observers to the native stream sl@0: 5. Register for available notification. sl@0: 6. Submit an update to the surface sl@0: 7. The observer function should be invoked and verifies that stream and event parameters. sl@0: 8. The tester simulates the end of a composition by firing SymbianStreamProcessNotifications sl@0: 9. Verify available status is completed with KErrCancel sl@0: 10. Destroy the native stream. sl@0: sl@0: @SYMTestExpectedResults sl@0: No errors, available status completed with KErrCancel. sl@0: sl@0: */ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0117_3L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: iScreenNo = 0; sl@0: iContextUpdatedFlags = 0; sl@0: iStreamUpdatedSerialNumber = 1; sl@0: iSourceStreamUpdatedCalled = 0; sl@0: iImmediateVisible = SYM_CONTENT_VISIBLE; sl@0: TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4); sl@0: ASSERT_FALSE(surface.IsNull()); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: err = SymbianStreamAcquire(&surface, &iNs); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(iNs); sl@0: sl@0: // Do not add observers for SUS notifications! sl@0: sl@0: iExpectedSourceStreamUpdatedEventMask = 0; sl@0: err = SymbianStreamAddObserver(iNs, SourceStreamUpdatedCallback, this); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: TRequestStatus statusAvailable; sl@0: sl@0: CExtensionContainer* updateExtension = NULL; sl@0: err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast(&updateExtension)); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface(); sl@0: ASSERT_NOT_NULL(updateProxy); sl@0: sl@0: updateProxy->ContentUpdated(surface, //aSurface sl@0: 0, //aBuffer sl@0: NULL, //aRegion sl@0: &statusAvailable, //aStatusConsumed sl@0: NULL, //aStatusDisplayed sl@0: NULL, //aTimeStamp sl@0: NULL, //aStatusDispXTimes sl@0: NULL //aDisplayedXTimes sl@0: ); sl@0: sl@0: // Verify that the context's callback is invoked when SubmitUpdate is called. sl@0: ASSERT_TRUE(iSourceStreamUpdatedCalled == 1); sl@0: sl@0: // Available should only be completed when submit update is called with a different buffer no. sl@0: // But, when there are no registered SUS observers, the notification should complete immediately sl@0: // with KErrCancel sl@0: ASSERT_EQUALS(statusAvailable.Int(), KErrCancel); sl@0: sl@0: // Pretend that a composition has occured sl@0: khronos_int32_t newNotificationsMask = 0; sl@0: SymbianStreamProcessNotifications(iNs, sl@0: ESOWF_EventAvailable | ESOWF_EventDisplayed |ESOWF_EventDisplayedX, sl@0: iScreenNo, sl@0: ++iStreamUpdatedSerialNumber, sl@0: &newNotificationsMask); sl@0: sl@0: ASSERT_TRUE(newNotificationsMask == 0); sl@0: sl@0: // Update and switch to buffer 1 sl@0: iExpectedSourceStreamUpdatedEventMask = 0; sl@0: iUtility->SubmitUpdate(KAllScreens, surface, 1, 0); sl@0: ASSERT_TRUE(iSourceStreamUpdatedCalled == 2); sl@0: sl@0: // Consume update on buffer 1. This should make buffer 0 available sl@0: SymbianStreamProcessNotifications(iNs, sl@0: ESOWF_EventAvailable | ESOWF_EventDisplayed |ESOWF_EventDisplayedX, sl@0: iScreenNo, sl@0: ++iStreamUpdatedSerialNumber, sl@0: &newNotificationsMask); sl@0: sl@0: ASSERT_TRUE(newNotificationsMask == 0); sl@0: sl@0: User::WaitForRequest(statusAvailable); sl@0: ASSERT_EQUALS(statusAvailable.Int(), KErrCancel); sl@0: sl@0: SymbianStreamRemoveReference(iNs); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0117_4 sl@0: @SYMTestCaseDesc Test all notifications are cancelled when there are no registered SUS sl@0: notification observers sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority High sl@0: @SYMTestPurpose Verify that the surface stream adaptation cancels all notifications sl@0: when the native stream has not registered any observers for SUS notifications sl@0: @SYMTestActions sl@0: sl@0: 1. Create a surface sl@0: 2. Create a native stream for the surface sl@0: 3. Register the test class as an observer for ESOWF_EventUpdated to act as a fake composer sl@0: 4. Do not add any SUS notification observers to the native stream sl@0: 5. Register for displayed, available and displayed x times notifications sl@0: 6. Submit an update to the surface sl@0: 7. The observer function should be invoked and verifies that stream and event parameters sl@0: 8. The tester simulates the end of a composition by firing SymbianStreamProcessNotifications sl@0: 9. Verify all notification statuses completed with KErrCancel sl@0: 10. Destroy the native stream. sl@0: sl@0: @SYMTestExpectedResults sl@0: No errors, all notification statuses completed with KErrCancel. sl@0: sl@0: */ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0117_4L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: iScreenNo = 0; sl@0: iContextUpdatedFlags = 0; sl@0: iStreamUpdatedSerialNumber = 1; sl@0: iSourceStreamUpdatedCalled = 0; sl@0: iImmediateVisible = SYM_CONTENT_VISIBLE; sl@0: TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4); sl@0: ASSERT_FALSE(surface.IsNull()); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: err = SymbianStreamAcquire(&surface, &iNs); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(iNs); sl@0: sl@0: // Do not add observers for SUS notifications! sl@0: sl@0: iExpectedSourceStreamUpdatedEventMask = 0; sl@0: err = SymbianStreamAddObserver(iNs, SourceStreamUpdatedCallback, this); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: TRequestStatus statusDisplayedX; sl@0: TRequestStatus statusAvailable; sl@0: TRequestStatus statusDisplayed; sl@0: TInt X = 5; sl@0: TUint32 displayedTime = 0; sl@0: sl@0: CExtensionContainer* updateExtension = NULL; sl@0: err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast(&updateExtension)); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface(); sl@0: ASSERT_NOT_NULL(updateProxy); sl@0: sl@0: updateProxy->ContentUpdated(surface, //aSurface sl@0: 0, //aBuffer sl@0: NULL, //aRegion sl@0: &statusAvailable, //aStatusConsumed sl@0: &statusDisplayed, //aStatusDisplayed sl@0: &displayedTime, //aTimeStamp sl@0: &statusDisplayedX, //aStatusDispXTimes sl@0: &X //aDisplayedXTimes sl@0: ); sl@0: sl@0: // Verify that the context's callback is invoked when SubmitUpdate is called. sl@0: ASSERT_TRUE(iSourceStreamUpdatedCalled == 1); sl@0: sl@0: for (TInt i = 0; i < X; ++i) sl@0: { sl@0: // Pretend that a composition has occured sl@0: khronos_int32_t newNotificationsMask = 0; sl@0: sl@0: SymbianStreamProcessNotifications(iNs, sl@0: ESOWF_EventAvailable | ESOWF_EventDisplayed |ESOWF_EventDisplayedX, sl@0: iScreenNo, sl@0: ++iStreamUpdatedSerialNumber, sl@0: &newNotificationsMask); sl@0: sl@0: // No updates during composition so newNotificationMask should still be zero sl@0: ASSERT_TRUE(newNotificationsMask == 0); sl@0: sl@0: if (i == 0) sl@0: { sl@0: User::WaitForRequest(statusDisplayed); sl@0: User::WaitForRequest(statusDisplayedX); sl@0: User::WaitForRequest(statusAvailable); sl@0: } sl@0: sl@0: ASSERT_EQUALS(statusAvailable.Int(), KErrCancel); sl@0: ASSERT_EQUALS(statusDisplayed.Int(), KErrCancel); sl@0: ASSERT_EQUALS(statusDisplayedX.Int(), KErrCancel); sl@0: } sl@0: sl@0: updateProxy->ContentUpdated(surface, //aSurface sl@0: 0, //aBuffer sl@0: NULL, //aRegion sl@0: NULL, //aStatusConsumed sl@0: NULL, //aStatusDisplayed sl@0: NULL, //aTimeStamp sl@0: NULL, //aStatusDispXTimes sl@0: NULL //aDisplayedXTimes sl@0: ); sl@0: sl@0: // Verify that the context's callback is invoked when SubmitUpdate is called. sl@0: ASSERT_TRUE(iSourceStreamUpdatedCalled == 2); sl@0: sl@0: khronos_int32_t newNotificationsMask = 0; sl@0: SymbianStreamProcessNotifications(iNs, sl@0: ESOWF_EventAvailable | ESOWF_EventDisplayed |ESOWF_EventDisplayedX, sl@0: iScreenNo, sl@0: ++iStreamUpdatedSerialNumber, sl@0: &newNotificationsMask); sl@0: sl@0: ASSERT_EQUALS(statusAvailable.Int(), KErrCancel); sl@0: ASSERT_TRUE(displayedTime == 0); sl@0: sl@0: SymbianStreamRemoveReference(iNs); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0118_1 sl@0: @SYMTestCaseDesc Test displayed notification is cancelled when content updated is called on sl@0: surface which is not registered with a native stream sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority High sl@0: @SYMTestPurpose Verify that the surface stream adaptation cancels the displayed notification sl@0: added to a surface which does not have a native stream associated with it sl@0: @SYMTestActions sl@0: sl@0: 1. Create a surface sl@0: 2. Register for displayed notification. sl@0: 3. Submit an update to the surface sl@0: 4. Verify displayed status is completed with KErrSurfaceNotRegistered sl@0: sl@0: @SYMTestExpectedResults sl@0: No errors, displayed status completed with KErrSurfaceNotRegistered. sl@0: sl@0: */ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0118_1L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: iScreenNo = 0; sl@0: iContextUpdatedFlags = 0; sl@0: iStreamUpdatedSerialNumber = 1; sl@0: iSourceStreamUpdatedCalled = 0; sl@0: iImmediateVisible = SYM_CONTENT_VISIBLE; sl@0: TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4); sl@0: ASSERT_FALSE(surface.IsNull()); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: TRequestStatus statusDisplayed; sl@0: TUint32 timeStamp = 0; sl@0: sl@0: CExtensionContainer* updateExtension = NULL; sl@0: err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast(&updateExtension)); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface(); sl@0: ASSERT_NOT_NULL(updateProxy); sl@0: sl@0: updateProxy->ContentUpdated(surface, //aSurface sl@0: 0, //aBuffer sl@0: NULL, //aRegion sl@0: NULL, //aStatusConsumed sl@0: &statusDisplayed, //aStatusDisplayed sl@0: &timeStamp, //aTimeStamp sl@0: NULL, //aStatusDispXTimes sl@0: NULL //aDisplayedXTimes sl@0: ); sl@0: sl@0: User::WaitForRequest(statusDisplayed); sl@0: sl@0: // The displayed notification should return with a surface registration error as there sl@0: // isn't a native stream registered with surface... sl@0: ASSERT_EQUALS(statusDisplayed.Int(), KErrSurfaceNotRegistered); sl@0: ASSERT_TRUE(timeStamp == 0); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0118_2 sl@0: @SYMTestCaseDesc Test displayed x times notification is cancelled when content updated is called on sl@0: surface which is not registered with a native stream sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority High sl@0: @SYMTestPurpose Verify that the surface stream adaptation cancels the displayed x times notification sl@0: added to a surface which does not have a native stream associated with it sl@0: @SYMTestActions sl@0: sl@0: 1. Create a surface sl@0: 2. Register for displayed x times notification. sl@0: 3. Submit an update to the surface sl@0: 4. Verify displayed x times status is completed with KErrSurfaceNotRegistered sl@0: sl@0: @SYMTestExpectedResults sl@0: No errors, displayed x times status completed with KErrSurfaceNotRegistered. sl@0: sl@0: */ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0118_2L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: iScreenNo = 0; sl@0: iContextUpdatedFlags = 0; sl@0: iStreamUpdatedSerialNumber = 1; sl@0: iSourceStreamUpdatedCalled = 0; sl@0: iImmediateVisible = SYM_CONTENT_VISIBLE; sl@0: TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4); sl@0: ASSERT_FALSE(surface.IsNull()); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: sl@0: // Do not create a native stream for surface! sl@0: sl@0: TRequestStatus statusDisplayedXTimes; sl@0: TInt X = 5; sl@0: sl@0: CExtensionContainer* updateExtension = NULL; sl@0: err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast(&updateExtension)); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface(); sl@0: ASSERT_NOT_NULL(updateProxy); sl@0: sl@0: updateProxy->ContentUpdated(surface, //aSurface sl@0: 0, //aBuffer sl@0: NULL, //aRegion sl@0: NULL, //aStatusConsumed sl@0: NULL, //aStatusDisplayed sl@0: NULL, //aTimeStamp sl@0: &statusDisplayedXTimes, //aStatusDispXTimes sl@0: &X //aDisplayedXTimes sl@0: ); sl@0: sl@0: User::WaitForRequest(statusDisplayedXTimes); sl@0: sl@0: // The displayed x times notification should return with a surface registration error as there sl@0: // isn't a native stream registered with surface... sl@0: ASSERT_EQUALS(statusDisplayedXTimes.Int(), KErrSurfaceNotRegistered); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0118_3 sl@0: @SYMTestCaseDesc Test available notification is cancelled when content updated is called on sl@0: surface which is not registered with a native stream sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority High sl@0: @SYMTestPurpose Verify that the surface stream adaptation cancels the available notification sl@0: added to a surface which does not have a native stream associated with it sl@0: @SYMTestActions sl@0: sl@0: 1. Create a surface sl@0: 2. Rregister for available notification. sl@0: 3. Submit an update to the surface sl@0: 4. Verify available status is completed with KErrSurfaceNotRegistered sl@0: sl@0: @SYMTestExpectedResults sl@0: No errors, available status completed with KErrSurfaceNotRegistered. sl@0: sl@0: */ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0118_3L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: iScreenNo = 0; sl@0: iContextUpdatedFlags = 0; sl@0: iStreamUpdatedSerialNumber = 1; sl@0: iSourceStreamUpdatedCalled = 0; sl@0: iImmediateVisible = SYM_CONTENT_VISIBLE; sl@0: TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4); sl@0: ASSERT_FALSE(surface.IsNull()); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: sl@0: // Do not create a native stream for surface! sl@0: sl@0: TRequestStatus statusAvailable; sl@0: sl@0: CExtensionContainer* updateExtension = NULL; sl@0: err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast(&updateExtension)); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface(); sl@0: ASSERT_NOT_NULL(updateProxy); sl@0: sl@0: updateProxy->ContentUpdated(surface, //aSurface sl@0: 0, //aBuffer sl@0: NULL, //aRegion sl@0: &statusAvailable, //aStatusConsumed sl@0: NULL, //aStatusDisplayed sl@0: NULL, //aTimeStamp sl@0: NULL, //aStatusDispXTimes sl@0: NULL //aDisplayedXTimes sl@0: ); sl@0: sl@0: User::WaitForRequest(statusAvailable); sl@0: sl@0: // The available notification should return with a surface registration error as there sl@0: // isn't a native stream registered with surface... sl@0: ASSERT_EQUALS(statusAvailable.Int(), KErrSurfaceNotRegistered); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0118_4 sl@0: @SYMTestCaseDesc Test all notifications are cancelled when content updated is called on sl@0: surface which is not registered with a native stream sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority High sl@0: @SYMTestPurpose Verify that the surface stream adaptation cancels all notifications sl@0: added to a surface which does not have a native stream associated with it sl@0: @SYMTestActions sl@0: sl@0: 1. Create a surface sl@0: 2. Register for displayed, available and displayed x times notifications. sl@0: 3. Submit an update to the surface sl@0: 4. Verify all notification statuses completed with KErrSurfaceNotRegistered sl@0: sl@0: @SYMTestExpectedResults sl@0: No errors, all notification statuses completed with KErrSurfaceNotRegistered. sl@0: sl@0: */ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0118_4L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: iScreenNo = 0; sl@0: iContextUpdatedFlags = 0; sl@0: iStreamUpdatedSerialNumber = 1; sl@0: iSourceStreamUpdatedCalled = 0; sl@0: iImmediateVisible = SYM_CONTENT_VISIBLE; sl@0: TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4); sl@0: ASSERT_FALSE(surface.IsNull()); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: sl@0: // Do not create a native stream for surface! sl@0: sl@0: TRequestStatus statusDisplayed, statusAvailable, statusDisplayedXTimes; sl@0: TInt X = 5; sl@0: TUint32 timeStamp = 0; sl@0: sl@0: CExtensionContainer* updateExtension = NULL; sl@0: err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast(&updateExtension)); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface(); sl@0: ASSERT_NOT_NULL(updateProxy); sl@0: sl@0: updateProxy->ContentUpdated(surface, //aSurface sl@0: 0, //aBuffer sl@0: NULL, //aRegion sl@0: &statusAvailable, //aStatusConsumed sl@0: &statusDisplayed, //aStatusDisplayed sl@0: &timeStamp, //aTimeStamp sl@0: &statusDisplayedXTimes, //aStatusDispXTimes sl@0: &X //aDisplayedXTimes sl@0: ); sl@0: sl@0: User::WaitForRequest(statusDisplayed); sl@0: User::WaitForRequest(statusAvailable); sl@0: User::WaitForRequest(statusDisplayedXTimes); sl@0: sl@0: // All notifications should return with a surface registration error as there sl@0: // isn't a native stream registered with surface... sl@0: ASSERT_EQUALS(statusDisplayed.Int(), KErrSurfaceNotRegistered); sl@0: ASSERT_EQUALS(statusAvailable.Int(), KErrSurfaceNotRegistered); sl@0: ASSERT_EQUALS(statusDisplayedXTimes.Int(), KErrSurfaceNotRegistered); sl@0: ASSERT_TRUE(timeStamp == 0); sl@0: sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0119_1 sl@0: @SYMTestCaseDesc Test overflow conditions on notifications for displayed sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority High sl@0: @SYMTestPurpose Verify that the surface stream adaptation correctly handles duplicate displayed sl@0: notifications registered by SUS for content updates on the same screen and buffer sl@0: @SYMTestActions sl@0: sl@0: 1. Create a surface sl@0: 2. Create a native stream for the surface sl@0: 3. Register the test class as an observer for ESOWF_EventUpdated to act as a fake composer sl@0: 4. Register for displayed notification (d1) sl@0: 5. Submit an update to the surface sl@0: 6. Register for displayed notification (d2) sl@0: 7. Submit an update to the surface sl@0: 8. The observer function should be invoked and verifies that stream and event parameters. sl@0: 9. The tester simulates the end of a composition by firing SymbianStreamProcessNotifications sl@0: 10. Verify d1 status is completed with KErrOverflow and d2 status is completed with KErrNone sl@0: 11. Destroy the native stream sl@0: sl@0: @SYMTestExpectedResults sl@0: No errors, d1 status completed with KErrOverflow, d2 status completed with KErrNone. sl@0: sl@0: */ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0119_1L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: iScreenNo = 0; sl@0: iContextUpdatedFlags = 0; sl@0: iStreamUpdatedSerialNumber = 1; sl@0: iSourceStreamUpdatedCalled = 0; sl@0: iImmediateVisible = SYM_CONTENT_VISIBLE; sl@0: TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4); sl@0: ASSERT_FALSE(surface.IsNull()); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: err = SymbianStreamAcquire(&surface, &iNs); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(iNs);; sl@0: sl@0: iExpectedSourceStreamUpdatedEventMask = ESOWF_EventDisplayed; sl@0: err = SymbianStreamAddExtendedObserver(iNs, SourceStreamUpdatedCallback, this, iScreenNo, ESOWF_EventUpdated); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: TRequestStatus statusDisplayed1, statusDisplayed2; sl@0: TUint32 timeStamp1 = 0; sl@0: TUint32 timeStamp2 = 0; sl@0: sl@0: CExtensionContainer* updateExtension = NULL; sl@0: err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast(&updateExtension)); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface(); sl@0: ASSERT_NOT_NULL(updateProxy); sl@0: sl@0: updateProxy->ContentUpdated(surface, //aSurface sl@0: 0, //aBuffer sl@0: NULL, //aRegion sl@0: NULL, //aStatusConsumed sl@0: &statusDisplayed1, //aStatusDisplayed sl@0: &timeStamp1, //aTimeStamp sl@0: NULL, //aStatusDispXTimes sl@0: NULL //aDisplayedXTimes sl@0: ); sl@0: sl@0: ASSERT_TRUE(iSourceStreamUpdatedCalled == 2); sl@0: sl@0: updateProxy->ContentUpdated(surface, //aSurface sl@0: 0, //aBuffer sl@0: NULL, //aRegion sl@0: NULL, //aStatusConsumed sl@0: &statusDisplayed2, //aStatusDisplayed sl@0: &timeStamp2, //aTimeStamp sl@0: NULL, //aStatusDispXTimes sl@0: NULL //aDisplayedXTimes sl@0: ); sl@0: ASSERT_TRUE(iSourceStreamUpdatedCalled == 4); sl@0: sl@0: User::WaitForRequest(statusDisplayed1); sl@0: ASSERT_EQUALS(statusDisplayed1.Int(), KErrOverflow); sl@0: ASSERT_TRUE(timeStamp1 == 0); sl@0: sl@0: // Verify that the context's callback is invoked when SubmitUpdate is called. sl@0: ASSERT_TRUE(iSourceStreamUpdatedCalled); sl@0: sl@0: // Pretend that a composition has occured sl@0: khronos_int32_t newNotificationsMask = 0; sl@0: SymbianStreamProcessNotifications(iNs, sl@0: iExpectedSourceStreamUpdatedEventMask, sl@0: iScreenNo, sl@0: ++iStreamUpdatedSerialNumber, sl@0: &newNotificationsMask); sl@0: sl@0: ASSERT_TRUE(newNotificationsMask == 0); sl@0: sl@0: // Make sure displayed event was completed sl@0: User::WaitForRequest(statusDisplayed2); sl@0: ASSERT_EQUALS(statusDisplayed2.Int(), KErrNone); sl@0: ASSERT_TRUE(timeStamp2); sl@0: sl@0: SymbianStreamRemoveReference(iNs); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0119_2 sl@0: @SYMTestCaseDesc Test overflow conditions on notifications for displayed-x-times sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority High sl@0: @SYMTestPurpose Verify that the surface stream adaptation correctly handles duplicate displayed sl@0: x times notifications registered by SUS for content updates on the same screen sl@0: and buffer sl@0: @SYMTestActions sl@0: sl@0: 1. Create a surface sl@0: 2. Create a native stream for the surface sl@0: 3. Register the test class as an observer for ESOWF_EventUpdated to act as a fake composer sl@0: 4. Register for displayed x times notification (d1) sl@0: 5. Submit an update to the surface sl@0: 6. Register for displayed x times notification (d2) sl@0: 7. Submit an update to the surface sl@0: 8. The observer function should be invoked and verifies that stream and event parameters. sl@0: 9. The tester simulates the end of a composition by firing SymbianStreamProcessNotifications sl@0: 10. Verify d1 status is completed with KErrOverflow and d2 status is completed with KErrNone sl@0: 11. Destroy the native stream sl@0: sl@0: @SYMTestExpectedResults sl@0: No errors, d1 status completed with KErrOverflow, d2 status completed with KErrNone. sl@0: sl@0: */ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0119_2L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: iScreenNo = 0; sl@0: TInt X = 5; sl@0: iContextUpdatedFlags = 0; sl@0: iStreamUpdatedSerialNumber = 1; sl@0: iSourceStreamUpdatedCalled = 0; sl@0: iImmediateVisible = SYM_CONTENT_VISIBLE; sl@0: TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4); sl@0: ASSERT_FALSE(surface.IsNull()); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: err = SymbianStreamAcquire(&surface, &iNs); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(iNs); sl@0: sl@0: iExpectedSourceStreamUpdatedEventMask = ESOWF_EventDisplayedX; sl@0: err = SymbianStreamAddExtendedObserver(iNs, SourceStreamUpdatedCallback, this, iScreenNo, ESOWF_EventUpdated); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: TRequestStatus statusDisplayedX1, statusDisplayedX2; sl@0: sl@0: CExtensionContainer* updateExtension = NULL; sl@0: err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast(&updateExtension)); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface(); sl@0: ASSERT_NOT_NULL(updateProxy); sl@0: sl@0: updateProxy->ContentUpdated(surface, //aSurface sl@0: 0, //aBuffer sl@0: NULL, //aRegion sl@0: NULL, //aStatusConsumed sl@0: NULL, //aStatusDisplayed sl@0: NULL, //aTimeStamp sl@0: &statusDisplayedX1, //aStatusDispXTimes sl@0: &X //aDisplayedXTimes sl@0: ); sl@0: sl@0: ASSERT_TRUE(iSourceStreamUpdatedCalled == 2); sl@0: sl@0: updateProxy->ContentUpdated(surface, //aSurface sl@0: 0, //aBuffer sl@0: NULL, //aRegion sl@0: NULL, //aStatusConsumed sl@0: NULL, //aStatusDisplayed sl@0: NULL, //aTimeStamp sl@0: &statusDisplayedX2, //aStatusDispXTimes sl@0: &X //aDisplayedXTimes sl@0: ); sl@0: sl@0: ASSERT_TRUE(iSourceStreamUpdatedCalled == 4); sl@0: sl@0: User::WaitForRequest(statusDisplayedX1); sl@0: ASSERT_EQUALS(statusDisplayedX1.Int(), KErrOverflow); sl@0: sl@0: for (TInt i = 0; i < X; ++i) sl@0: { sl@0: ASSERT_EQUALS(statusDisplayedX2.Int(), KRequestPending); sl@0: sl@0: // Pretend that a composition has occured sl@0: khronos_int32_t newNotificationsMask = 0; sl@0: SymbianStreamProcessNotifications(iNs, sl@0: ESOWF_EventDisplayedX, sl@0: iScreenNo, sl@0: ++iStreamUpdatedSerialNumber, sl@0: &newNotificationsMask); sl@0: sl@0: if (i < X -1) sl@0: { sl@0: ASSERT_TRUE(newNotificationsMask == ESOWF_EventDisplayedX); sl@0: } sl@0: else sl@0: { sl@0: ASSERT_TRUE(newNotificationsMask == 0); sl@0: } sl@0: } sl@0: sl@0: // Make sure displayed event was completed sl@0: User::WaitForRequest(statusDisplayedX2); sl@0: ASSERT_EQUALS(statusDisplayedX2.Int(), KErrNone); sl@0: sl@0: SymbianStreamRemoveReference(iNs); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0119_3 sl@0: @SYMTestCaseDesc Test overflow conditions on notifications for available sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority High sl@0: @SYMTestPurpose Verify that the surface stream adaptation correctly handles duplicate available sl@0: notifications registered by SUS for content updates on the same screen and buffer sl@0: @SYMTestActions sl@0: sl@0: 1. Create a surface sl@0: 2. Create a native stream for the surface sl@0: 3. Register the test class as an observer for ESOWF_EventUpdated to act as a fake composer sl@0: 4. Register for available notification (a1) sl@0: 5. Submit an update to the surface sl@0: 6. Register for available notification (a2) sl@0: 7. Submit an update to the surface sl@0: 8. The observer function should be invoked and verifies that stream and event parameters. sl@0: 9. The tester simulates the end of a composition by firing SymbianStreamProcessNotifications sl@0: 10. Verify d1 status is completed with KErrOverflow and d2 status is completed with KErrNone sl@0: 11. Destroy the native stream sl@0: sl@0: @SYMTestExpectedResults sl@0: No errors, a1 status completed with KErrOverflow, a2 status completed with KErrNone. sl@0: sl@0: */ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0119_3L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: iScreenNo = 0; sl@0: iContextUpdatedFlags = 0; sl@0: iStreamUpdatedSerialNumber = 1; sl@0: iSourceStreamUpdatedCalled = 0; sl@0: iImmediateAvailable = EFalse; sl@0: iImmediateVisible = SYM_CONTENT_VISIBLE; sl@0: TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4); sl@0: ASSERT_FALSE(surface.IsNull()); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: err = SymbianStreamAcquire(&surface, &iNs); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(iNs); sl@0: sl@0: err = SymbianStreamAddExtendedObserver(iNs, SourceStreamUpdatedCallback, this, iScreenNo, ESOWF_EventUpdated); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: TRequestStatus statusAvailable1, statusAvailable2, statusAvailable3; sl@0: sl@0: CExtensionContainer* updateExtension = NULL; sl@0: err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast(&updateExtension)); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface(); sl@0: ASSERT_NOT_NULL(updateProxy); sl@0: sl@0: iExpectedSourceStreamUpdatedEventMask = 0; sl@0: updateProxy->ContentUpdated(surface, //aSurface sl@0: 0, //aBuffer sl@0: NULL, //aRegion sl@0: &statusAvailable1, //aStatusConsumed sl@0: NULL, //aStatusDisplayed sl@0: NULL, //aTimeStamp sl@0: NULL, //aStatusDispXTimes sl@0: NULL //aDisplayedXTimes sl@0: ); sl@0: sl@0: // Verify that the context's callback is invoked when SubmitUpdate is called. sl@0: ASSERT_TRUE(iSourceStreamUpdatedCalled == 2); sl@0: sl@0: iExpectedSourceStreamUpdatedEventMask = ESOWF_EventAvailable; sl@0: updateProxy->ContentUpdated(surface, //aSurface sl@0: 0, //aBuffer sl@0: NULL, //aRegion sl@0: &statusAvailable2, //aStatusConsumed sl@0: NULL, //aStatusDisplayed sl@0: NULL, //aTimeStamp sl@0: NULL, //aStatusDispXTimes sl@0: NULL //aDisplayedXTimes sl@0: ); sl@0: sl@0: // Verify that the context's callback is invoked when SubmitUpdate is called. sl@0: ASSERT_TRUE(iSourceStreamUpdatedCalled == 4); sl@0: sl@0: iExpectedSourceStreamUpdatedEventMask = ESOWF_EventAvailable; sl@0: updateProxy->ContentUpdated(surface, //aSurface sl@0: 0, //aBuffer sl@0: NULL, //aRegion sl@0: &statusAvailable3, //aStatusConsumed sl@0: NULL, //aStatusDisplayed sl@0: NULL, //aTimeStamp sl@0: NULL, //aStatusDispXTimes sl@0: NULL //aDisplayedXTimes sl@0: ); sl@0: sl@0: // Verify that the context's callback is invoked when SubmitUpdate is called. sl@0: ASSERT_TRUE(iSourceStreamUpdatedCalled == 6); sl@0: sl@0: User::WaitForRequest(statusAvailable1); sl@0: ASSERT_EQUALS(statusAvailable1.Int(), KErrOverflow); sl@0: sl@0: // Pretend that a composition has occured sl@0: khronos_int32_t newNotificationsMask = 0; sl@0: SymbianStreamProcessNotifications(iNs, sl@0: ESOWF_EventAvailable, sl@0: iScreenNo, sl@0: iStreamUpdatedSerialNumber, sl@0: &newNotificationsMask); sl@0: sl@0: ASSERT_TRUE(newNotificationsMask == 0); sl@0: sl@0: // Make sure displayed event was completed sl@0: User::WaitForRequest(statusAvailable2); sl@0: ASSERT_EQUALS(statusAvailable2.Int(), KErrNone); sl@0: sl@0: SymbianStreamRemoveReference(iNs); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0120_1 sl@0: @SYMTestCaseDesc Test overflow conditions on notifications for displayed sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority High sl@0: @SYMTestPurpose Verify that the surface stream adaptation correctly handles duplicate notifications sl@0: registered by SUS for content updates on different buffers sl@0: @SYMTestActions sl@0: sl@0: 1. Create a surface sl@0: 2. Create a native stream for the surface sl@0: 3. Register the test class as an observer for ESOWF_EventUpdated to act as a fake composer sl@0: 4. Register for displayed notification (d1) sl@0: 5. Submit an update to the surface on buffer 0 sl@0: 6. Register for displayed notification (d2) sl@0: 7. Submit an update to the surface on buffer 1 sl@0: 8. The observer function should be invoked and verifies that stream and event parameters. sl@0: 9. The tester simulates the end of a composition by firing SymbianStreamProcessNotifications sl@0: 10. Verify d1 status is completed with KErrOverflow and d2 status is completed with KErrNone sl@0: 11. Destroy the native stream sl@0: sl@0: @SYMTestExpectedResults sl@0: No errors, d1 status completed with KErrOverflow, d2 status completed with KErrNone. sl@0: sl@0: */ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0120_1L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: iScreenNo = 0; sl@0: iContextUpdatedFlags = 0; sl@0: iStreamUpdatedSerialNumber = 1; sl@0: iSourceStreamUpdatedCalled = 0; sl@0: iImmediateVisible = SYM_CONTENT_VISIBLE; sl@0: TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4); sl@0: ASSERT_FALSE(surface.IsNull()); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: err = SymbianStreamAcquire(&surface, &iNs); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(iNs); sl@0: sl@0: err = SymbianStreamAddExtendedObserver(iNs, SourceStreamUpdatedCallback, this, iScreenNo, ESOWF_EventUpdated); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: iExpectedSourceStreamUpdatedEventMask = ESOWF_EventDisplayed; sl@0: sl@0: TRequestStatus statusDisplayed1, statusDisplayed2; sl@0: TUint32 timeStamp1 = 0; sl@0: TUint32 timeStamp2 = 0; sl@0: sl@0: CExtensionContainer* updateExtension = NULL; sl@0: err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast(&updateExtension)); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface(); sl@0: ASSERT_NOT_NULL(updateProxy); sl@0: sl@0: updateProxy->ContentUpdated(surface, //aSurface sl@0: 0, //aBuffer sl@0: NULL, //aRegion sl@0: NULL, //aStatusConsumed sl@0: &statusDisplayed1, //aStatusDisplayed sl@0: &timeStamp1, //aTimeStamp sl@0: NULL, //aStatusDispXTimes sl@0: NULL //aDisplayedXTimes sl@0: ); sl@0: sl@0: // Verify that the context's callback is invoked when SubmitUpdate is called. sl@0: ASSERT_TRUE(iSourceStreamUpdatedCalled == 2); sl@0: sl@0: updateProxy->ContentUpdated(surface, //aSurface sl@0: 1, //aBuffer sl@0: NULL, //aRegion sl@0: NULL, //aStatusConsumed sl@0: &statusDisplayed2, //aStatusDisplayed sl@0: &timeStamp2, //aTimeStamp sl@0: NULL, //aStatusDispXTimes sl@0: NULL //aDisplayedXTimes sl@0: ); sl@0: sl@0: ASSERT_TRUE(iSourceStreamUpdatedCalled == 4); sl@0: sl@0: User::WaitForRequest(statusDisplayed1); sl@0: ASSERT_EQUALS(statusDisplayed1.Int(), KErrOverflow); sl@0: sl@0: // Pretend that a composition has occured sl@0: khronos_int32_t newNotificationsMask = 0; sl@0: SymbianStreamProcessNotifications(iNs, sl@0: iExpectedSourceStreamUpdatedEventMask, sl@0: iScreenNo, sl@0: ++iStreamUpdatedSerialNumber, sl@0: &newNotificationsMask); sl@0: sl@0: ASSERT_TRUE(newNotificationsMask == 0); sl@0: sl@0: // Make sure displayed event was completed sl@0: User::WaitForRequest(statusDisplayed2); sl@0: ASSERT_EQUALS(statusDisplayed2.Int(), KErrNone); sl@0: sl@0: SymbianStreamRemoveReference(iNs); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0120_2 sl@0: @SYMTestCaseDesc Test overflow conditions on notifications for displayed-x-times sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority High sl@0: @SYMTestPurpose Verify that the surface stream adaptation correctly handles duplicate notifications sl@0: registered by SUS for content updates on different buffers sl@0: @SYMTestActions sl@0: sl@0: 1. Create a surface sl@0: 2. Create a native stream for the surface sl@0: 3. Register the test class as an observer for ESOWF_EventUpdated to act as a fake composer sl@0: 4. Register for displayed-x-times notification (d1) sl@0: 5. Submit an update to the surface on buffer 0 sl@0: 6. Register for displayed-x-times notification (d2) sl@0: 7. Submit an update to the surface on buffer 1 sl@0: 8. The observer function should be invoked and verifies that stream and event parameters. sl@0: 9. Verify d1 status is completed with KErrOverflow sl@0: 10. The tester simulates the end of a composition by firing SymbianStreamProcessNotifications sl@0: 11. Step 11. is repeated 5 times to simulate 5 compositions. sl@0: 12. Verify that d2 status is completed with KErrNone sl@0: 13. Destroy the native stream sl@0: sl@0: @SYMTestExpectedResults sl@0: No errors, d1 status completed with KErrOverflow, d2 status completed with KErrNone. sl@0: sl@0: */ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0120_2L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: iScreenNo = 0; sl@0: iContextUpdatedFlags = 0; sl@0: iStreamUpdatedSerialNumber = 1; sl@0: iSourceStreamUpdatedCalled = 0; sl@0: TInt X = 5; sl@0: TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4); sl@0: ASSERT_FALSE(surface.IsNull()); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: err = SymbianStreamAcquire(&surface, &iNs); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(iNs); sl@0: sl@0: err = SymbianStreamAddExtendedObserver(iNs, SourceStreamUpdatedCallback, this, iScreenNo, ESOWF_EventUpdated); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: iExpectedSourceStreamUpdatedEventMask = ESOWF_EventDisplayedX; sl@0: sl@0: TRequestStatus statusDisplayedX1, statusDisplayedX2; sl@0: sl@0: CExtensionContainer* updateExtension = NULL; sl@0: err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast(&updateExtension)); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface(); sl@0: ASSERT_NOT_NULL(updateProxy); sl@0: sl@0: updateProxy->ContentUpdated(surface, //aSurface sl@0: 0, //aBuffer sl@0: NULL, //aRegion sl@0: NULL, //aStatusConsumed sl@0: NULL, //aStatusDisplayed sl@0: NULL, //aTimeStamp sl@0: &statusDisplayedX1, //aStatusDispXTimes sl@0: &X //aDisplayedXTimes sl@0: ); sl@0: sl@0: // Verify that the context's callback is invoked when SubmitUpdate is called. sl@0: ASSERT_TRUE(iSourceStreamUpdatedCalled == 2); sl@0: sl@0: updateProxy->ContentUpdated(surface, //aSurface sl@0: 1, //aBuffer sl@0: NULL, //aRegion sl@0: NULL, //aStatusConsumed sl@0: NULL, //aStatusDisplayed sl@0: NULL, //aTimeStamp sl@0: &statusDisplayedX2, //aStatusDispXTimes sl@0: &X //aDisplayedXTimes sl@0: ); sl@0: sl@0: // Verify that the context's callback is invoked when SubmitUpdate is called. sl@0: ASSERT_TRUE(iSourceStreamUpdatedCalled == 4); sl@0: sl@0: User::WaitForRequest(statusDisplayedX1); sl@0: ASSERT_EQUALS(statusDisplayedX1.Int(), KErrOverflow); sl@0: sl@0: for (TInt i = 0; i < X; ++i) sl@0: { sl@0: ASSERT_EQUALS(statusDisplayedX2.Int(), KRequestPending); sl@0: sl@0: // Pretend that a composition has occured sl@0: khronos_int32_t newNotificationsMask = 0; sl@0: SymbianStreamProcessNotifications(iNs, sl@0: iExpectedSourceStreamUpdatedEventMask, sl@0: iScreenNo, sl@0: ++iStreamUpdatedSerialNumber, sl@0: &newNotificationsMask); sl@0: if (i < X -1) sl@0: { sl@0: ASSERT_TRUE(newNotificationsMask == ESOWF_EventDisplayedX); sl@0: } sl@0: else sl@0: { sl@0: ASSERT_TRUE(newNotificationsMask == 0); sl@0: } sl@0: } sl@0: sl@0: // Make sure displayed event was completed sl@0: User::WaitForRequest(statusDisplayedX2); sl@0: ASSERT_EQUALS(statusDisplayedX2.Int(), KErrNone); sl@0: sl@0: SymbianStreamRemoveReference(iNs); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0120_3 sl@0: @SYMTestCaseDesc Test overflow conditions on notifications for available sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority High sl@0: @SYMTestPurpose Verify that the surface stream adaptation correctly handles duplicate notifications sl@0: registered by SUS for content updates on different buffers sl@0: @SYMTestActions sl@0: sl@0: 1. Create a surface sl@0: 2. Create a native stream for the surface sl@0: 3. Register the test class as an observer for ESOWF_EventUpdated to act as a fake composer sl@0: 4. Register for available notification (d1) sl@0: 5. Submit an update to the surface on buffer 0 sl@0: 6. Register for available notification (d2) sl@0: 7. Submit an update to the surface on buffer 1 sl@0: 8. The observer function should be invoked and verifies that stream and event parameters. sl@0: 9. The tester simulates the end of a composition by firing SymbianStreamProcessNotifications sl@0: 10. Verify d1 status is completed with KErrOverflow and d2 status is completed with KErrNone sl@0: 11. Destroy the native stream sl@0: sl@0: @SYMTestExpectedResults sl@0: No errors, d1 status completed with KErrOverflow, d2 status completed with KErrNone. sl@0: sl@0: */ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0120_3L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: iScreenNo = 0; sl@0: iContextUpdatedFlags = 0; sl@0: iStreamUpdatedSerialNumber = 1; sl@0: iSourceStreamUpdatedCalled = 0; sl@0: //force composition, otherwise we may never be able to experience the overflow sl@0: iImmediateAvailable = EFalse; sl@0: iImmediateVisible = SYM_CONTENT_VISIBLE; sl@0: TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4); sl@0: ASSERT_FALSE(surface.IsNull()); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: err = SymbianStreamAcquire(&surface, &iNs); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(iNs); sl@0: sl@0: err = SymbianStreamAddExtendedObserver(iNs, SourceStreamUpdatedCallback, this, iScreenNo, ESOWF_EventUpdated); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: TRequestStatus statusAvailable1, statusAvailable2, statusAvailable3; sl@0: sl@0: CExtensionContainer* updateExtension = NULL; sl@0: err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast(&updateExtension)); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface(); sl@0: ASSERT_NOT_NULL(updateProxy); sl@0: sl@0: iExpectedSourceStreamUpdatedEventMask = 0; sl@0: sl@0: updateProxy->ContentUpdated(surface, //aSurface sl@0: 0, //aBuffer sl@0: NULL, //aRegion sl@0: &statusAvailable1, //aStatusConsumed sl@0: NULL, //aStatusDisplayed sl@0: NULL, //aTimeStamp sl@0: NULL, //aStatusDispXTimes sl@0: NULL //aDisplayedXTimes sl@0: ); sl@0: sl@0: // Verify that the context's callback is invoked when SubmitUpdate is called. sl@0: ASSERT_TRUE(iSourceStreamUpdatedCalled == 2); sl@0: sl@0: iExpectedSourceStreamUpdatedEventMask = ESOWF_EventAvailable; sl@0: sl@0: updateProxy->ContentUpdated(surface, //aSurface sl@0: 1, //aBuffer sl@0: NULL, //aRegion sl@0: &statusAvailable2, //aStatusConsumed sl@0: NULL, //aStatusDisplayed sl@0: NULL, //aTimeStamp sl@0: NULL, //aStatusDispXTimes sl@0: NULL //aDisplayedXTimes sl@0: ); sl@0: sl@0: // Verify that the context's callback is invoked when SubmitUpdate is called. sl@0: ASSERT_TRUE(iSourceStreamUpdatedCalled == 4); sl@0: sl@0: iExpectedSourceStreamUpdatedEventMask = ESOWF_EventAvailable; sl@0: sl@0: updateProxy->ContentUpdated(surface, //aSurface sl@0: 2, //aBuffer sl@0: NULL, //aRegion sl@0: &statusAvailable3, //aStatusConsumed sl@0: NULL, //aStatusDisplayed sl@0: NULL, //aTimeStamp sl@0: NULL, //aStatusDispXTimes sl@0: NULL //aDisplayedXTimes sl@0: ); sl@0: sl@0: // Verify that the context's callback is invoked when SubmitUpdate is called. sl@0: ASSERT_TRUE(iSourceStreamUpdatedCalled == 6); sl@0: sl@0: // Theoretically KErrNone could be returned because buffer 0 is actually available. sl@0: // However, this would be a change in behaviour. sl@0: User::WaitForRequest(statusAvailable1); sl@0: ASSERT_EQUALS(statusAvailable1.Int(), KErrOverflow); sl@0: sl@0: // Pretend that a composition has occured sl@0: khronos_int32_t newNotificationsMask = 0; sl@0: SymbianStreamProcessNotifications(iNs, sl@0: iExpectedSourceStreamUpdatedEventMask, sl@0: iScreenNo, sl@0: iStreamUpdatedSerialNumber, sl@0: &newNotificationsMask); sl@0: sl@0: ASSERT_TRUE(newNotificationsMask == 0); sl@0: sl@0: // Make sure displayed event was completed sl@0: User::WaitForRequest(statusAvailable2); sl@0: ASSERT_EQUALS(statusAvailable2.Int(), KErrNone); sl@0: sl@0: SymbianStreamRemoveReference(iNs); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0122 sl@0: @SYMTestCaseDesc sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority High sl@0: @SYMTestPurpose Tests an end to end displayed notification. sl@0: @SYMTestActions sl@0: sl@0: 1. Create a surface. sl@0: 2. Create a native stream for the surface. sl@0: 3. Register an observer for content-update events. sl@0: 4. Register notifications for displayed, available and displayed-x-times. sl@0: 5. Submit an update to the surface sl@0: 6. Remove the content-updated observer. sl@0: 7. Wait for the request status objects to be completed. sl@0: sl@0: @SYMTestExpectedResults sl@0: The notification status objects are completed with KErrCancel. sl@0: sl@0: **/ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0122L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: iScreenNo = 0; sl@0: iContextUpdatedFlags = 0; sl@0: iStreamUpdatedSerialNumber = 1; sl@0: iSourceStreamUpdatedCalled = 0; sl@0: CTestNativeStream::iTester = this; sl@0: iImmediateVisible = SYM_CONTENT_VISIBLE; sl@0: TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4); sl@0: ASSERT_FALSE(surface.IsNull()); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: err = SymbianStreamAcquire(&surface, &iNs); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(iNs); sl@0: sl@0: err = SymbianStreamAddExtendedObserver(iNs, SourceStreamUpdatedCallback, this, iScreenNo, ESOWF_EventUpdated); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: TRequestStatus statusDisplayed, statusAvailable, statusDisplayedX; sl@0: TUint32 displayedTime = 0; sl@0: TInt X = 42; sl@0: sl@0: CExtensionContainer* updateExtension = NULL; sl@0: err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast(&updateExtension)); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface(); sl@0: ASSERT_NOT_NULL(updateProxy); sl@0: sl@0: iExpectedSourceStreamUpdatedEventMask = ESOWF_EventDisplayed | ESOWF_EventDisplayedX; sl@0: sl@0: updateProxy->ContentUpdated(surface, //aSurface sl@0: 0, //aBuffer sl@0: NULL, //aRegion sl@0: &statusAvailable, //aStatusConsumed sl@0: &statusDisplayed, //aStatusDisplayed sl@0: &displayedTime, //aTimeStamp sl@0: &statusDisplayedX, //aStatusDispXTimes sl@0: &X //aDisplayedXTimes sl@0: ); sl@0: sl@0: ASSERT_TRUE(iSourceStreamUpdatedCalled == 2); sl@0: err = SymbianStreamRemoveObserver(iNs, this, ESOWF_EventUpdated); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: User::WaitForRequest(statusDisplayed); sl@0: ASSERT_EQUALS(statusDisplayed.Int(), KErrCancel); sl@0: User::WaitForRequest(statusAvailable); sl@0: ASSERT_EQUALS(statusAvailable.Int(), KErrCancel); sl@0: User::WaitForRequest(statusDisplayedX); sl@0: ASSERT_EQUALS(statusDisplayedX.Int(), KErrCancel); sl@0: sl@0: SymbianStreamRemoveReference(iNs); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: sl@0: iUtility->DestroySurface(surface); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0130 sl@0: @SYMTestCaseDesc Add/remove Sym observers - positive test cases sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority sl@0: @SYMTestPurpose Verify that Sym observers can be added, removed and re-added sl@0: @SYMTestActions sl@0: Create a surface with 1 buffer sl@0: Add a Sym observer (displayed notification) sl@0: Remove the Sym observer sl@0: Add the Sym observer sl@0: @SYMTestExpectedResults sl@0: KErrNone is returned when the Sym observer is added sl@0: KErrNone is returned when the Sym observer is removed sl@0: KErrNone is returned when the Sym observer is re-added sl@0: **/ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0130L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 1); sl@0: ASSERT_FALSE(surface.IsNull()); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: SymbianStreamType ns; sl@0: err = SymbianStreamAcquire(&surface,&ns); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(ns); sl@0: sl@0: TInt32 screenNumber = 0; sl@0: TInt localnumber = 0; sl@0: err = SymbianStreamAddExtendedObserver(ns, TestUpdateCallback, &localnumber, screenNumber, ESOWF_EventDisplayed); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamRemoveObserver(ns, &localnumber, ESOWF_EventDisplayed); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamAddExtendedObserver(ns, TestUpdateCallback, &localnumber, screenNumber, ESOWF_EventDisplayed); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0131 sl@0: @SYMTestCaseDesc Add/remove Sym observers - negative test cases sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority sl@0: @SYMTestPurpose Verify that Sym observers reject invalid parameters sl@0: @SYMTestActions sl@0: Create a surface with 1 buffer sl@0: Add an invalid Sym observer (invalid event flag) sl@0: Remove a non-existent Sym observer sl@0: Add a valid Sym observer sl@0: Add the same Sym observer sl@0: Remove the valid Sym observer sl@0: Remove the same Sym observer sl@0: @SYMTestExpectedResults sl@0: KErrArgument is returned and the observer list is un-changed sl@0: KErrNotFound is returned and the observer list is un-changed sl@0: KErrOverflow is returned when the Sym observer is added again and the observer list is un-changed sl@0: KErrNotFound is returned when the Sym observer is removed again the observer list is un-changed sl@0: **/ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0131L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 1); sl@0: ASSERT_FALSE(surface.IsNull()); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: SymbianStreamType ns; sl@0: err = SymbianStreamAcquire(&surface, &ns); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(ns); sl@0: sl@0: TInt32 screenNumber = 0; sl@0: err = SymbianStreamAddExtendedObserver(ns, NULL, NULL, screenNumber, ESOWF_NoEvent); sl@0: ASSERT_TRUE(err == KErrArgument); sl@0: err = SymbianStreamRemoveObserver(ns, &screenNumber, ESOWF_EventDisplayed); sl@0: ASSERT_TRUE(err == KErrNotFound); sl@0: sl@0: // add the same observer twice sl@0: err = SymbianStreamAddExtendedObserver(ns, NULL, NULL, screenNumber, ESOWF_EventDisplayed); sl@0: ASSERT_TRUE(err == KErrArgument); sl@0: err = SymbianStreamAddExtendedObserver(ns, NULL, NULL, screenNumber, ESOWF_EventDisplayed); sl@0: ASSERT_TRUE(err == KErrArgument); sl@0: sl@0: // remove the same observer sl@0: err = SymbianStreamRemoveObserver(ns, &screenNumber, ESOWF_EventDisplayed); sl@0: ASSERT_TRUE(err == KErrNotFound); sl@0: err = SymbianStreamRemoveObserver(ns, &screenNumber, ESOWF_EventDisplayed); sl@0: ASSERT_TRUE(err == KErrNotFound); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0132 sl@0: @SYMTestCaseDesc Destroy a native stream when a Sym observer is registered sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority sl@0: @SYMTestPurpose Verify that Sym observers are safely removed before native stream destruction sl@0: @SYMTestActions sl@0: Create a surface with 1 buffer sl@0: Add a Sym observer (displayed notification) sl@0: Destroy the native stream sl@0: Create another native stream using the surface created previously sl@0: Remove the same Sym observer added in step 2 sl@0: @SYMTestExpectedResults sl@0: KErrNone is returned when the Sym observer is added sl@0: KErrNotFound is returned when the Sym observer is attempting to be removed sl@0: **/ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0132L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 1); sl@0: ASSERT_FALSE(surface.IsNull()); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: SymbianStreamType ns; sl@0: err = SymbianStreamAcquire(&surface, &ns); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(ns); sl@0: sl@0: TInt screenNumber = 0; sl@0: err = SymbianStreamAddExtendedObserver(ns, NULL, NULL, screenNumber, ESOWF_EventDisplayed); sl@0: ASSERT_TRUE(err == KErrArgument); sl@0: sl@0: SymbianStreamRemoveReference(ns); sl@0: sl@0: SymbianStreamType ns2; sl@0: err = SymbianStreamAcquire(&surface, &ns2); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(ns2); sl@0: sl@0: err = SymbianStreamRemoveObserver(ns2, &screenNumber, ESOWF_EventDisplayed); sl@0: ASSERT_TRUE(err == KErrNotFound); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0133 sl@0: @SYMTestCaseDesc Test the construction/destruction of a CContentUpdateProxy sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority sl@0: @SYMTestPurpose Verify that additional screens can be created and destroyed sl@0: @SYMTestActions sl@0: sl@0: 1. Create a new CContentUpdateProxy (screen 1) sl@0: 2. Verify API version and Internal version are correct sl@0: 3. Create a surface sl@0: 4. Create a native stream for the surface sl@0: 5. Register the test class as an observer for ESOWF_EventUpdated to act as a fake composer sl@0: 6. Submit an update to the surface sl@0: 7. The observer function should be invoked and verifies that stream and event parameters. sl@0: 8. Verify that the source-stream updated callback is invoked. sl@0: 9. Destroy the native stream. sl@0: 10. Destroy the CContentUpdateProxy (screen 1) sl@0: sl@0: @SYMTestExpectedResults sl@0: KErrNone is returned when screen 1 is created sl@0: API version and Internal version match expected results sl@0: KErrNone is returned when screen 1 is destroyed sl@0: **/ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0133L() sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: // Register a new screen sl@0: iScreenNo = 0; sl@0: iContextUpdatedFlags = 0; sl@0: iStreamUpdatedSerialNumber = 1; sl@0: iSourceStreamUpdatedCalled = 0; sl@0: iImmediateVisible = SYM_CONTENT_VISIBLE; sl@0: sl@0: TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4); sl@0: ASSERT_FALSE(surface.IsNull()); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: err = SymbianStreamRegisterScreenNotifications(1, 0, KCompositorVersion); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: sl@0: CExtensionContainer* updateExtension = NULL; sl@0: err = SymbianStreamHasRegisteredScreenNotifications(1,reinterpret_cast(&updateExtension)); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: MCompositionSurfaceUpdate* screen1=updateExtension->GetInterface(); sl@0: ASSERT_NOT_NULL(screen1); sl@0: sl@0: TVersion expectedVersion(KCompositorVersionMajor,KCompositorVersionMinor,KCompositorVersionRevision); sl@0: sl@0: ASSERT_EQUALS(screen1->ApiVersion(), 3); sl@0: ASSERT_TRUE(screen1->InternalVersion().iBuild == expectedVersion.iBuild && sl@0: screen1->InternalVersion().iMajor == expectedVersion.iMajor && sl@0: screen1->InternalVersion().iMinor == expectedVersion.iMinor); sl@0: sl@0: err = SymbianStreamAcquire(&surface, &iNs); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(iNs); sl@0: sl@0: iExpectedSourceStreamUpdatedEventMask = 0; sl@0: err = SymbianStreamAddObserver(iNs, SourceStreamUpdatedCallback, this); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: iSourceStreamUpdatedCalled = EFalse; sl@0: screen1->ContentUpdated(surface,0,NULL,NULL,NULL,NULL,NULL,NULL); sl@0: sl@0: // Verify that the context's callback (screen 1) is invoked when SubmitUpdate is called. sl@0: ASSERT_TRUE(iSourceStreamUpdatedCalled == 1); sl@0: sl@0: SymbianStreamRemoveReference(iNs); sl@0: sl@0: // Destroy the context (screen 1) sl@0: err = SymbianStreamUnregisterScreenNotifications(1); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0140 sl@0: @SYMTestCaseDesc Negative test - Acquire write/read buffers and retrieve the buffer ptr (single threaded test). sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType CT sl@0: @SYMTestPriority sl@0: @SYMTestPurpose Verify SymbianStreamAcquireWriteBuffer(), SymbianStreamReleaseWriteBuffer(), sl@0: SymbianStreamAcquireReadBuffer() and SymbianStreamReleaseReadBuffer() methods sl@0: work as expected. sl@0: sl@0: @SYMTestActions sl@0: Create a native stream sl@0: For each buffer: sl@0: - Acquire the read buffer sl@0: - Acquire the write buffer sl@0: - Release the write buffer sl@0: - Acquire the read buffer sl@0: sl@0: Repeat for each buffer. Finally: sl@0: Acquire the write buffer sl@0: Release the write buffer sl@0: @SYMTestExpectedResults sl@0: For each buffer of the native stream, check: sl@0: - The read buffer should be aquired successfully sl@0: If the number of buffers = 1, check: sl@0: - The write buffer should be aquired successfully sl@0: If the number of buffers > 1, check: sl@0: - The write buffer before the final one should be aquired successfully sl@0: - The final acquire write buffer call should return OWF_INVALID_HANDLE if not single buffered sl@0: **/ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0140L(TInt aNumBuffers) sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: sl@0: ASSERT_TRUE(aNumBuffers > 0); sl@0: sl@0: TSize surfaceSize(TSize(100,100)); sl@0: khronos_int32_t width = surfaceSize.iWidth; sl@0: khronos_int32_t height = surfaceSize.iHeight; sl@0: sl@0: OWF_IMAGE_FORMAT pixelFormat = sl@0: { sl@0: OWF_IMAGE_ARGB8888, sl@0: ETrue, sl@0: ETrue, sl@0: aNumBuffers sl@0: }; sl@0: sl@0: SymbianStreamType ns=helperCreateImageStream(width, sl@0: height, sl@0: &pixelFormat, sl@0: aNumBuffers); sl@0: ASSERT_TRUE(ns); sl@0: sl@0: khronos_int32_t writeBuffer = 0; sl@0: khronos_int32_t readBuffer = 0; sl@0: TInt bufferCount; sl@0: sl@0: if (aNumBuffers == 1) sl@0: { sl@0: bufferCount = aNumBuffers; sl@0: } sl@0: else sl@0: { sl@0: bufferCount = aNumBuffers - 1; sl@0: } sl@0: sl@0: RArray bufferHandleArray; sl@0: sl@0: // Loop through the buffers sl@0: for (TInt count=0; count 1, check: sl@0: - The buffer index increments after release write buffer is called sl@0: **/ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0141L(TInt aNumBuffers) sl@0: { sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: sl@0: ASSERT_TRUE(aNumBuffers > 0); sl@0: sl@0: TSize surfaceSize(TSize(100,100)); sl@0: khronos_int32_t width = surfaceSize.iWidth; sl@0: khronos_int32_t height = surfaceSize.iHeight; sl@0: sl@0: OWF_IMAGE_FORMAT pixelFormat = sl@0: { sl@0: OWF_IMAGE_ARGB8888, sl@0: ETrue, sl@0: ETrue, sl@0: aNumBuffers sl@0: }; sl@0: sl@0: SymbianStreamType ns=helperCreateImageStream(width, sl@0: height, sl@0: &pixelFormat, sl@0: aNumBuffers); sl@0: ASSERT_TRUE(ns); sl@0: sl@0: khronos_int32_t writeBuffer = 0; sl@0: khronos_int32_t readBuffer = 0; sl@0: khronos_int32_t bufferIndexRead1, bufferIndexRead2, bufferIndexRead3, bufferIndexRead4; sl@0: khronos_int32_t bufferIndexWrite; sl@0: sl@0: err = SymbianStreamAcquireReadBuffer(ns, &readBuffer); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(readBuffer); sl@0: const TSurfaceId* getId = NULL; sl@0: err = SymbianStreamGetBufferId(ns,readBuffer,&bufferIndexRead1,&getId); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamReleaseReadBuffer(ns,readBuffer); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: err = SymbianStreamAcquireReadBuffer(ns, &readBuffer); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(readBuffer); sl@0: err = SymbianStreamGetBufferId(ns,readBuffer,&bufferIndexRead2,&getId); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: SymbianStreamReleaseReadBuffer(ns,readBuffer); sl@0: ASSERT_EQUALS(bufferIndexRead1, bufferIndexRead2); sl@0: sl@0: err = SymbianStreamAcquireWriteBuffer(ns,&writeBuffer); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(writeBuffer); sl@0: err = SymbianStreamGetBufferId(ns,writeBuffer,&bufferIndexWrite,&getId); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: if (aNumBuffers == 1) sl@0: { sl@0: ASSERT_EQUALS(bufferIndexRead2, bufferIndexWrite); sl@0: } sl@0: else sl@0: { sl@0: ASSERT_NOT_EQUALS((bufferIndexRead2), bufferIndexWrite); sl@0: } sl@0: sl@0: err = SymbianStreamAcquireReadBuffer(ns,&readBuffer); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(readBuffer); sl@0: err = SymbianStreamGetBufferId(ns,readBuffer,&bufferIndexRead3,&getId); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamReleaseReadBuffer(ns,readBuffer); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_EQUALS(bufferIndexRead3, bufferIndexRead2); sl@0: sl@0: err = SymbianStreamReleaseWriteBuffer(ns,writeBuffer); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: err = SymbianStreamAcquireReadBuffer(ns,&readBuffer); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(readBuffer); sl@0: err = SymbianStreamGetBufferId(ns,readBuffer,&bufferIndexRead4,&getId); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: err = SymbianStreamReleaseReadBuffer(ns,readBuffer); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: if (aNumBuffers == 1) sl@0: { sl@0: ASSERT_EQUALS(bufferIndexRead3, bufferIndexRead4); sl@0: } sl@0: else sl@0: { sl@0: ASSERT_NOT_EQUALS((bufferIndexRead3), bufferIndexRead4); sl@0: } sl@0: sl@0: SymbianStreamRemoveReference(ns); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0142 sl@0: @SYMTestCaseDesc Special surface ID unit tests sl@0: @SYMREQ sl@0: @SYMPREQ PREQ2400 sl@0: @SYMTestType sl@0: @SYMTestPriority sl@0: @SYMTestPurpose Exercise special surface creation and flip operations sl@0: sl@0: @SYMTestActions sl@0: Generate a special surface ID with pixel formats of type sl@0: EUidPixelFormatARGB_8888_PRE, EUidPixelFormatRGB_888, sl@0: EUidPixelFormatRGB_565, and EUidPixelFormatRGB_332. Then sl@0: - Acquire the read buffer sl@0: - Acquire the write buffer sl@0: - Check that they are the same sl@0: - Add a value to the read buffer sl@0: - Check that the write buffer has the same value sl@0: - Release the write buffer sl@0: - Release the read buffer sl@0: Then reset the special surface ID, acquire a stream, and read header data. sl@0: Set the flip flag to true and re-acquire the stream. sl@0: Compare header data of pre-flip and post-flip cases. sl@0: sl@0: @SYMTestExpectedResults sl@0: Read/write buffer pairs are always identical. sl@0: Flipped stream has width and height switched and stride is different sl@0: **/ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0142L() sl@0: { sl@0: _LIT(KDisplayChannelLdd, "display0.ldd"); sl@0: sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: sl@0: err = User::LoadLogicalDevice(KDisplayChannelLdd); sl@0: RDisplayChannel testChannel; sl@0: if (err == KErrNone || err == KErrAlreadyExists) sl@0: { sl@0: User::LeaveIfError(testChannel.Open(0)); sl@0: } sl@0: sl@0: TSurfaceId testId; sl@0: SymbianStreamType ns; sl@0: TUidPixelFormat testGuids[] = {EUidPixelFormatARGB_8888_PRE, EUidPixelFormatRGB_888, EUidPixelFormatRGB_565, EUidPixelFormatRGB_332}; sl@0: TInt size = sizeof(testGuids) / sizeof(testGuids[0]); sl@0: TUint8 *pWriteBuffer = NULL; sl@0: khronos_int32_t writeBuffer; sl@0: TUint8 *pReadBuffer = NULL; sl@0: khronos_int32_t readBuffer; sl@0: sl@0: TInt halStride = 0; sl@0: TInt halMode = 0; sl@0: sl@0: // For header variables before flipping sl@0: TInt32 preFlipWidth = 0; sl@0: TInt32 preFlipHeight = 0; sl@0: TInt32 preFlipStreamStride = 0; sl@0: TInt32 preFlipStreamFormat = EUidPixelFormatUnknown; sl@0: TInt32 preFlipStreamPixelSize = 0; sl@0: sl@0: // For header variables after flipping sl@0: TInt32 width = 0; sl@0: TInt32 height = 0; sl@0: TInt32 streamStride = 0; sl@0: TInt32 streamFormat = EUidPixelFormatUnknown; sl@0: TInt32 streamPixelSize = 0; sl@0: sl@0: for (TInt ii = 0; ii < size; ii++) sl@0: { sl@0: HAL::Get(0, HALData::EDisplayMode, halMode); sl@0: sl@0: testId.iInternal[TSurfaceId::TScreenSurfaceUsage::EScreenField] = 0; // Screen number sl@0: testId.iInternal[TSurfaceId::TScreenSurfaceUsage::EHalField] = halMode; // Rotation and hal mode index sl@0: testId.iInternal[TSurfaceId::TScreenSurfaceUsage::ETypeGuidField] = testGuids[ii]; //May be zero for non-GCE modes sl@0: testId.iInternal[TSurfaceId::TScreenSurfaceUsage::ETypeClassField] = ((TUint32)(TSurfaceId::EScreenSurface) << TSurfaceId::TScreenSurfaceUsage::ETypeClassShift); // Type sl@0: sl@0: err = SymbianStreamAcquire(&testId, &ns); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(ns); sl@0: sl@0: err = SymbianStreamAcquireWriteBuffer(ns,&writeBuffer); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: err = SymbianStreamGetBufferPointer(ns,writeBuffer,reinterpret_cast(&pWriteBuffer)); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_NOT_NULL(pWriteBuffer); sl@0: sl@0: err = SymbianStreamReleaseWriteBuffer(ns,writeBuffer); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: err = SymbianStreamAcquireReadBuffer(ns,&readBuffer); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: err = SymbianStreamGetBufferPointer(ns,readBuffer,reinterpret_cast(&pReadBuffer)); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_NOT_NULL(pReadBuffer); sl@0: sl@0: err = SymbianStreamReleaseReadBuffer(ns,readBuffer); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: ASSERT_SAME(pWriteBuffer, pReadBuffer); sl@0: sl@0: *pWriteBuffer = 0xFF; sl@0: ASSERT_TRUE(*pReadBuffer == 0xFF); sl@0: sl@0: halStride = halMode; sl@0: HAL::Get(0, HALData::EDisplayOffsetBetweenLines, halStride); sl@0: sl@0: SymbianStreamGetHeader(ns, &preFlipWidth, &preFlipHeight, &preFlipStreamStride, &preFlipStreamFormat, &preFlipStreamPixelSize); sl@0: ASSERT_TRUE(preFlipStreamStride == halStride); sl@0: sl@0: // Now the flipping test sl@0: halMode = halMode^TSurfaceId::TScreenSurfaceUsage::EHalFlippedFlag; sl@0: testId.iInternal[TSurfaceId::TScreenSurfaceUsage::EHalField] = halMode; sl@0: sl@0: err = SymbianStreamAcquire(&testId, &ns); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: ASSERT_TRUE(ns); sl@0: sl@0: halStride = halMode; sl@0: HAL::Get(0, HALData::EDisplayOffsetBetweenLines, halStride); sl@0: SymbianStreamGetHeader(ns, &width, &height, &streamStride, &streamFormat, &streamPixelSize); sl@0: sl@0: ASSERT_EQUALS(preFlipWidth, height); sl@0: ASSERT_EQUALS(preFlipHeight, width); sl@0: ASSERT_EQUALS((TInt32)preFlipStreamFormat,(TInt32)streamFormat); sl@0: ASSERT_TRUE(streamStride == halStride); sl@0: ASSERT_EQUALS(preFlipStreamPixelSize, streamPixelSize); sl@0: sl@0: SymbianStreamGetHeader(ns, NULL, NULL, NULL, NULL, NULL); sl@0: // Clearing the flip flag sl@0: halMode = halMode&~TSurfaceId::TScreenSurfaceUsage::EHalFlippedFlag; sl@0: sl@0: SymbianStreamRemoveReference(ns); sl@0: sl@0: *pWriteBuffer = NULL; sl@0: pWriteBuffer = NULL; sl@0: *pReadBuffer = NULL; sl@0: pReadBuffer = NULL; sl@0: } sl@0: sl@0: testChannel.Close(); sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: } sl@0: sl@0: /* sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0143 sl@0: @SYMTestCaseDesc Call eglsync helper functions sl@0: @SYMREQ sl@0: @SYMPREQ sl@0: @SYMTestType sl@0: @SYMTestPriority Low sl@0: @SYMTestPurpose Make calls of eglsync helper functions for coverage results sl@0: @SYMTestActions sl@0: Make calls of eglsync helper functions sl@0: @SYMTestExpectedResults sl@0: Test should pass without errors sl@0: */ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0143L() sl@0: { sl@0: // This test is commented out because it won't build for Bullseye. sl@0: #ifdef EGLSYNCHELPER_INCLUDED sl@0: INFO_PRINTF1(_L("Test of egl sync helper functions")); sl@0: sl@0: RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); sl@0: TRAPD(err, GrowCleanupStackL()); sl@0: ASSERT_TRUE(err == KErrNone); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); sl@0: sl@0: EGLDisplay eglDisplay; sl@0: eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); sl@0: ASSERT_FALSE(eglDisplay == EGL_NO_DISPLAY); sl@0: ASSERT_FALSE(eglDisplay == EGL_BAD_ALLOC); sl@0: ASSERT_EQUALS(eglGetError(),EGL_SUCCESS); sl@0: eglInitialize(eglDisplay, NULL, NULL); sl@0: ASSERT_EQUALS(eglGetError(),EGL_SUCCESS); sl@0: sl@0: EGLint attrib_list[1] = {EGL_NONE}; sl@0: EGLSyncKHR sync; sl@0: sync = eglCreateSyncKHR(eglDisplay,EGL_SYNC_REUSABLE_KHR, attrib_list); sl@0: ASSERT_NOT_EQUALS(sync,EGL_NO_SYNC_KHR); sl@0: ASSERT_EQUALS(eglGetError(),EGL_SUCCESS); sl@0: sl@0: eglSignalSyncKHR(eglDisplay, sync, EGL_SIGNALED_KHR); sl@0: eglGetSyncAttribKHR(eglDisplay, sync, NULL, NULL); sl@0: eglClientWaitSyncKHR(eglDisplay, sync, 0, 0); sl@0: sl@0: EGLBoolean eglSyncError = eglDestroySyncKHR(eglDisplay, sync); sl@0: sync = EGL_NO_SYNC_KHR; sl@0: if (eglSyncError != EGL_TRUE) sl@0: { sl@0: INFO_PRINTF2(_L("TearDown: eglSyncError line %d"),__LINE__); sl@0: } sl@0: CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one sl@0: #endif sl@0: } sl@0: sl@0: /* sl@0: @SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0144 sl@0: @SYMTestCaseDesc Panic test sl@0: @SYMREQ sl@0: @SYMPREQ sl@0: @SYMTestType sl@0: @SYMTestPriority Low sl@0: @SYMTestPurpose Test that will cause a panic. sl@0: @SYMTestActions sl@0: Aquire a symbian stream by passing in a NULL ns sl@0: @SYMTestExpectedResults sl@0: Test should panic with the expected panic code 1000008 sl@0: */ sl@0: void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0144L() sl@0: { sl@0: INFO_PRINTF1(_L("Panic test. The expected panic code is 1000008")); sl@0: sl@0: SymbianStreamBuffer bufferHandle; sl@0: // Pass in a NULL ns will cause panic EOwfSymbianStreamBadArgument (1000008) sl@0: SymbianStreamAcquireReadBuffer(NULL, &bufferHandle); sl@0: }