diff -r 29ddb8a72f0e -r 9f1c3fea0f87 graphicscomposition/openwfsupport/test/tstreamoperation/tnativestream.cpp --- a/graphicscomposition/openwfsupport/test/tstreamoperation/tnativestream.cpp Tue Jul 06 15:45:57 2010 +0300 +++ b/graphicscomposition/openwfsupport/test/tstreamoperation/tnativestream.cpp Wed Aug 18 11:05:09 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -23,9 +23,14 @@ #include #include #include +#include #include "tnativestream.h" #include "surfaceutility.h" -#include "owftestexithelper.inl" + +#ifdef EGLSYNCHELPER_INCLUDED + #include + #include "eglsynchelper.h" +#endif #define BUFFER_READ_HANDLE_BASE 0x100 #define BUFFER_WRITE_HANDLE_BASE 0x200 @@ -243,6 +248,7 @@ } RSemaphore gSemaphore; +RSemaphore gSemaphore2; TGlobalNativeStreamVar gVarInstance={0}; const TGlobalNativeStreamVar& TGlobalNativeStreamVar::Instance() @@ -462,6 +468,8 @@ ADD_TEST_STEP_PARAM_RANGE(GRAPHICS_OPENWFC_NATIVESTREAM_0140L,1,4); ADD_TEST_STEP_PARAM_RANGE(GRAPHICS_OPENWFC_NATIVESTREAM_0141L,1,4); ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0142L); + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0143L); + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0144L); END_SUITE; @@ -541,6 +549,8 @@ gVarInstance.SetSurfaceID(*checkId); gSemaphore.CreateLocal(1); gSemaphore.Wait(); + gSemaphore2.CreateLocal(1); + gSemaphore2.Wait(); CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one } @@ -550,6 +560,7 @@ CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(COpenWfcStreamMap::InstanceL().GetMainHeap()))); + gSemaphore2.Close(); gSemaphore.Close(); TSurfaceId id = gVarInstance.SurfaceID(); SymbianStreamType ns; @@ -656,8 +667,11 @@ const TSurfaceId* getId = NULL; err = SymbianStreamGetBufferId(ns,bufferHandle,&bufferIndex,&getId); ASSERT_TRUE(err == KErrNone); + TInt ChunkHandle = 100; + err = SymbianStreamGetChunkHandle(ns, &ChunkHandle); + ASSERT_TRUE(err == KErrNone); err = SymbianStreamReleaseReadBuffer(ns,bufferHandle); - ASSERT_TRUE(err == KErrNone); + ASSERT_TRUE(err == KErrNone); ASSERT_EQUALS(*getId,surface); CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one @@ -669,7 +683,7 @@ err = SymbianStreamAcquire(&surface2,&ns2); ASSERT_TRUE(err == KErrNone); ASSERT_TRUE(ns2); - ASSERT_NOT_EQUALS(ns,ns2); + ASSERT_FALSE(SymbianStreamSame(ns, ns2)); ASSERT_EQUALS((COpenWfcStreamMap::InstanceL().Count()), count + 2); err = SymbianStreamAcquireReadBuffer(ns2,&bufferHandle); ASSERT_TRUE(err == KErrNone); @@ -1343,7 +1357,8 @@ gSemaphore.Signal(2); // Thread 2 and 3 ready to run - gSemaphore.Wait(); + gSemaphore2.Wait(); + gSemaphore2.Wait(); // Wait for both threads to signal err = SymbianStreamReleaseWriteBuffer(ns,writeBuffer1); ASSERT_TRUE(err == KErrNone); SymbianStreamRemoveReference(ns); @@ -1375,7 +1390,7 @@ ASSERT_FALSE(writeBuffer1); INFO_PRINTF1(_L("Thread 2 - Write buffer already in use by Thread 1!")); - gSemaphore.Signal(); + gSemaphore2.Signal(); gSemaphore.Wait(); @@ -1418,6 +1433,8 @@ ASSERT_FALSE(writeBuffer1); INFO_PRINTF1(_L("Thread 3 - Write buffer already in use by Thread 1!")); + gSemaphore2.Signal(); + SymbianStreamRemoveReference(ns); CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one } @@ -4660,7 +4677,10 @@ err = User::LoadLogicalDevice(KDisplayChannelLdd); RDisplayChannel testChannel; - User::LeaveIfError(testChannel.Open(0)); + if (err == KErrNone || err == KErrAlreadyExists) + { + User::LeaveIfError(testChannel.Open(0)); + } TSurfaceId testId; SymbianStreamType ns; @@ -4765,3 +4785,78 @@ testChannel.Close(); CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one } + +/* +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0143 +@SYMTestCaseDesc Call eglsync helper functions +@SYMREQ +@SYMPREQ +@SYMTestType +@SYMTestPriority Low +@SYMTestPurpose Make calls of eglsync helper functions for coverage results +@SYMTestActions + Make calls of eglsync helper functions +@SYMTestExpectedResults + Test should pass without errors + */ +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0143L() + { + // This test is commented out because it won't build for Bullseye. +#ifdef EGLSYNCHELPER_INCLUDED + INFO_PRINTF1(_L("Test of egl sync helper functions")); + + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap(); + TRAPD(err, GrowCleanupStackL()); + ASSERT_TRUE(err == KErrNone); + + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap))); + + EGLDisplay eglDisplay; + eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); + ASSERT_FALSE(eglDisplay == EGL_NO_DISPLAY); + ASSERT_FALSE(eglDisplay == EGL_BAD_ALLOC); + ASSERT_EQUALS(eglGetError(),EGL_SUCCESS); + eglInitialize(eglDisplay, NULL, NULL); + ASSERT_EQUALS(eglGetError(),EGL_SUCCESS); + + EGLint attrib_list[1] = {EGL_NONE}; + EGLSyncKHR sync; + sync = eglCreateSyncKHR(eglDisplay,EGL_SYNC_REUSABLE_KHR, attrib_list); + ASSERT_NOT_EQUALS(sync,EGL_NO_SYNC_KHR); + ASSERT_EQUALS(eglGetError(),EGL_SUCCESS); + + eglSignalSyncKHR(eglDisplay, sync, EGL_SIGNALED_KHR); + eglGetSyncAttribKHR(eglDisplay, sync, NULL, NULL); + eglClientWaitSyncKHR(eglDisplay, sync, 0, 0); + + EGLBoolean eglSyncError = eglDestroySyncKHR(eglDisplay, sync); + sync = EGL_NO_SYNC_KHR; + if (eglSyncError != EGL_TRUE) + { + INFO_PRINTF2(_L("TearDown: eglSyncError line %d"),__LINE__); + } + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one +#endif + } + +/* +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0144 +@SYMTestCaseDesc Panic test +@SYMREQ +@SYMPREQ +@SYMTestType +@SYMTestPriority Low +@SYMTestPurpose Test that will cause a panic. +@SYMTestActions + Aquire a symbian stream by passing in a NULL ns +@SYMTestExpectedResults + Test should panic with the expected panic code 1000008 +*/ +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0144L() + { + INFO_PRINTF1(_L("Panic test. The expected panic code is 1000008")); + + SymbianStreamBuffer bufferHandle; + // Pass in a NULL ns will cause panic EOwfSymbianStreamBadArgument (1000008) + SymbianStreamAcquireReadBuffer(NULL, &bufferHandle); + }