os/graphics/graphicscomposition/openwfsupport/test/tstreamoperation/tnativestream.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/graphicscomposition/openwfsupport/test/tstreamoperation/tnativestream.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,4862 @@
1.4 +// Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Implementation of Test class for OpenWfc Native Stream
1.18 +//
1.19 +//
1.20 +
1.21 +#include <graphics/symbianstream.h>
1.22 +#include <graphics/streammap.h>
1.23 +#include <graphics/compositionsurfaceupdate.h>
1.24 +#include <graphics/extensioncontainer.h>
1.25 +#include <graphics/suerror.h>
1.26 +#include <test/extendtef.h>
1.27 +#include <dispchannel.h>
1.28 +#include <hal.h>
1.29 +#include <test/singletontestexithelper.inl>
1.30 +#include "tnativestream.h"
1.31 +#include "surfaceutility.h"
1.32 +
1.33 +#ifdef EGLSYNCHELPER_INCLUDED
1.34 + #include <EGL/egl.h>
1.35 + #include "eglsynchelper.h"
1.36 +#endif
1.37 +
1.38 +#define BUFFER_READ_HANDLE_BASE 0x100
1.39 +#define BUFFER_WRITE_HANDLE_BASE 0x200
1.40 +#define INDEX_TO_READ_HANDLE(x) ((SymbianStreamBuffer) ((x)+BUFFER_READ_HANDLE_BASE))
1.41 +#define INDEX_TO_WRITE_HANDLE(x) ((SymbianStreamBuffer) ((x)+BUFFER_WRITE_HANDLE_BASE))
1.42 +#define BUFFER_READ_HANDLE_TO_INDEX(x) (TInt) (x > 0 ? (x&0xFF) : (x-BUFFER_READ_HANDLE_BASE))
1.43 +#define BUFFER_WRITE_HANDLE_TO_INDEX(x) (TInt) (x > 0 ? (x&0xFF) : (x-BUFFER_WRITE_HANDLE_BASE))
1.44 +#define WFC_INVALID_HANDLE NULL
1.45 +#define KGrowCleanupStack 12
1.46 +#define KCompositorVersion 0x01023456
1.47 +#define KCompositorVersionMajor 0x1
1.48 +#define KCompositorVersionMinor 0x2
1.49 +#define KCompositorVersionRevision 0x3456
1.50 +
1.51 +void PopHeap(void* aHeapPtr)
1.52 + {
1.53 + User::SwitchHeap((RHeap*)aHeapPtr);
1.54 + }
1.55 +
1.56 +void GrowCleanupStackL()
1.57 + {
1.58 + TInt n = KGrowCleanupStack;
1.59 + while(n--)
1.60 + {
1.61 + CleanupStack::PushL((CBase*)NULL);
1.62 + }
1.63 + CleanupStack::Pop(KGrowCleanupStack);
1.64 + }
1.65 +
1.66 +// Helper functions
1.67 +/* supported external image formats */
1.68 +enum OWF_PIXEL_FORMAT {
1.69 + OWF_IMAGE_NOT_SUPPORTED = 0,
1.70 + OWF_IMAGE_ARGB8888 = 0x8888,
1.71 + OWF_IMAGE_XRGB8888 = 0xf888,
1.72 + OWF_IMAGE_RGB888 = 0x888,
1.73 + OWF_IMAGE_RGB565 = 0x565,
1.74 + OWF_IMAGE_L32 = 0xA32,
1.75 + OWF_IMAGE_L16 = 0xA16,
1.76 + OWF_IMAGE_L8 = 0xA8,
1.77 + OWF_IMAGE_L1 = 0xA1,
1.78 + OWF_IMAGE_ARGB_INTERNAL = 0x666 /* OWFpixel rep */
1.79 +} ;
1.80 +
1.81 +struct CTestNativeStream::OWF_IMAGE_FORMAT{
1.82 + OWF_PIXEL_FORMAT pixelFormat;
1.83 + bool linear;
1.84 + bool premultiplied;
1.85 + int rowPadding; /* row alignment, in bytes */
1.86 +} ;
1.87 +
1.88 +TInt CTestNativeStream::BytesPerPixel(TUidPixelFormat aPixelFormat)
1.89 + {
1.90 + switch (aPixelFormat)
1.91 + {
1.92 + case EUidPixelFormatXRGB_8888:
1.93 + case EUidPixelFormatARGB_8888:
1.94 + case EUidPixelFormatBGRX_8888:
1.95 + case EUidPixelFormatXBGR_8888:
1.96 + case EUidPixelFormatBGRA_8888:
1.97 + case EUidPixelFormatABGR_8888:
1.98 + case EUidPixelFormatABGR_8888_PRE:
1.99 + case EUidPixelFormatARGB_8888_PRE:
1.100 + case EUidPixelFormatBGRA_8888_PRE:
1.101 + case EUidPixelFormatARGB_2101010:
1.102 + case EUidPixelFormatABGR_2101010:
1.103 + return 4;
1.104 + case EUidPixelFormatBGR_888:
1.105 + case EUidPixelFormatRGB_888:
1.106 + return 3;
1.107 + case EUidPixelFormatXRGB_4444:
1.108 + case EUidPixelFormatARGB_4444:
1.109 + case EUidPixelFormatXBGR_4444:
1.110 + case EUidPixelFormatRGB_565:
1.111 + case EUidPixelFormatBGR_565:
1.112 + case EUidPixelFormatARGB_1555:
1.113 + case EUidPixelFormatXRGB_1555:
1.114 + case EUidPixelFormatARGB_8332:
1.115 + case EUidPixelFormatBGRX_5551:
1.116 + case EUidPixelFormatBGRA_5551:
1.117 + case EUidPixelFormatBGRA_4444:
1.118 + case EUidPixelFormatBGRX_4444:
1.119 + case EUidPixelFormatAP_88:
1.120 + return 2;
1.121 + case EUidPixelFormatRGB_332:
1.122 + case EUidPixelFormatBGR_332:
1.123 + case EUidPixelFormatA_8:
1.124 + case EUidPixelFormatL_8:
1.125 + return 1;
1.126 + case EUidPixelFormatP_8:
1.127 + return -1;
1.128 + case EUidPixelFormatP_4:
1.129 + case EUidPixelFormatL_4:
1.130 + return -2;
1.131 + case EUidPixelFormatL_2:
1.132 + case EUidPixelFormatP_2:
1.133 + return -4;
1.134 + case EUidPixelFormatL_1 :
1.135 + return -8;
1.136 + default:
1.137 + {
1.138 + return 0;
1.139 + }
1.140 + }
1.141 + }
1.142 +
1.143 +/*****************************************
1.144 + * Helper Creates Surface from OWF spec
1.145 + *
1.146 + *
1.147 + */
1.148 +TSurfaceId CTestNativeStream::helperCreateSurfaceL(khronos_int32_t width,
1.149 + khronos_int32_t height,
1.150 + const OWF_IMAGE_FORMAT* format,
1.151 + khronos_int32_t nbufs,
1.152 + TUidPixelFormat overridePixelFormat)
1.153 + {
1.154 + RSurfaceManager::TSurfaceCreationAttributesBuf bf;
1.155 + RSurfaceManager::TSurfaceCreationAttributes& b = bf();
1.156 +
1.157 + TBool premultiplied = format->premultiplied;
1.158 + OWF_PIXEL_FORMAT pixelFormat = format->pixelFormat;
1.159 + khronos_int32_t bytesPerPixel = 0;
1.160 +
1.161 + if (overridePixelFormat != EUidPixelFormatUnknown)
1.162 + {
1.163 + bytesPerPixel = BytesPerPixel(overridePixelFormat);
1.164 + b.iAlignment = 4;
1.165 + b.iPixelFormat = overridePixelFormat;
1.166 + }
1.167 + else
1.168 + {
1.169 + switch(pixelFormat)
1.170 + {
1.171 + case OWF_IMAGE_RGB565:
1.172 + b.iPixelFormat = EUidPixelFormatRGB_565;
1.173 + bytesPerPixel = 2;
1.174 + b.iAlignment = 4;
1.175 + break;
1.176 + case OWF_IMAGE_ARGB8888:
1.177 + {
1.178 + if (premultiplied)
1.179 + {
1.180 + b.iPixelFormat = EUidPixelFormatARGB_8888_PRE;
1.181 + }
1.182 + else
1.183 + {
1.184 + b.iPixelFormat = EUidPixelFormatARGB_8888;
1.185 + }
1.186 + bytesPerPixel = 4;
1.187 + b.iAlignment = 4;
1.188 + break;
1.189 + }
1.190 + case OWF_IMAGE_XRGB8888 :
1.191 + b.iPixelFormat = EUidPixelFormatXRGB_8888;
1.192 + bytesPerPixel = 4;
1.193 + b.iAlignment = 4;
1.194 + break;
1.195 + case OWF_IMAGE_L8 :
1.196 + b.iPixelFormat = EUidPixelFormatA_8;
1.197 + bytesPerPixel = 1;
1.198 + b.iAlignment = 4;
1.199 + break;
1.200 + case OWF_IMAGE_L1 :
1.201 + b.iPixelFormat = EUidPixelFormatL_1;
1.202 + bytesPerPixel = -8;
1.203 + b.iAlignment = 4;
1.204 + break;
1.205 + default:
1.206 + User::Leave(KErrNotSupported);
1.207 + break;
1.208 + }
1.209 + }
1.210 +
1.211 + b.iSize.iWidth = width;
1.212 + b.iSize.iHeight = height;
1.213 + b.iBuffers = nbufs; // number of buffers in the surface
1.214 + b.iOffsetToFirstBuffer = 0; // way of reserving space before the surface pixel data
1.215 + if (bytesPerPixel >= 0)
1.216 + {
1.217 + b.iStride = bytesPerPixel * width; // number of bytes between start of one line and start of next
1.218 + }
1.219 + else
1.220 + {
1.221 + b.iStride = (width-(bytesPerPixel+1)) / (-bytesPerPixel);
1.222 + }
1.223 + b.iContiguous = EFalse;
1.224 + b.iMappable = ETrue;
1.225 +
1.226 + TSurfaceId surface = TSurfaceId::CreateNullId();
1.227 + User::LeaveIfError(iUtility->Manager().CreateSurface(bf, surface));
1.228 +
1.229 + return surface;
1.230 + }
1.231 +
1.232 +SymbianStreamType CTestNativeStream::helperCreateImageStream(khronos_int32_t width,
1.233 + khronos_int32_t height,
1.234 + const OWF_IMAGE_FORMAT* format,
1.235 + khronos_int32_t nbufs,
1.236 + TUidPixelFormat overridePixelFormat)
1.237 + {
1.238 + TSurfaceId surface;
1.239 +
1.240 + TRAPD(err,surface = helperCreateSurfaceL(width, height, format, nbufs, overridePixelFormat));
1.241 + if (err)
1.242 + {
1.243 + return WFC_INVALID_HANDLE;
1.244 + }
1.245 + SymbianStreamType ns;
1.246 + SymbianStreamAcquire(&surface, &ns);
1.247 +
1.248 + iUtility->Manager().CloseSurface(surface);
1.249 +
1.250 + return ns;
1.251 + }
1.252 +
1.253 +RSemaphore gSemaphore;
1.254 +RSemaphore gSemaphore2;
1.255 +
1.256 +TGlobalNativeStreamVar gVarInstance={0};
1.257 +const TGlobalNativeStreamVar& TGlobalNativeStreamVar::Instance()
1.258 + {
1.259 + return gVarInstance;
1.260 + }
1.261 +
1.262 +void TGlobalNativeStreamVar::SetSurfaceID(TSurfaceId aSurfaceID)
1.263 + {
1.264 + iSurfaceID = aSurfaceID;
1.265 + }
1.266 +
1.267 +void TGlobalNativeStreamVar::SetTestComplete(TBool aTestComplete)
1.268 + {
1.269 + iTestComplete = aTestComplete;
1.270 + }
1.271 +
1.272 +void TGlobalNativeStreamVar::SetBuffers(TInt aBuffers)
1.273 + {
1.274 + iBuffers = aBuffers;
1.275 + }
1.276 +
1.277 +TSurfaceId TGlobalNativeStreamVar::SurfaceID() const
1.278 + {
1.279 + return iSurfaceID;
1.280 + }
1.281 +
1.282 +TBool TGlobalNativeStreamVar::TestComplete() const
1.283 + {
1.284 + return iTestComplete;
1.285 + }
1.286 +
1.287 +TInt TGlobalNativeStreamVar::Buffers() const
1.288 + {
1.289 + return iBuffers;
1.290 + }
1.291 +
1.292 +/*
1.293 + * CTestNativeStream implementation
1.294 + *
1.295 + *
1.296 + *
1.297 + *
1.298 + */
1.299 +
1.300 +CTestNativeStream::CTestNativeStream(): iUtility(this)
1.301 + {
1.302 + // No implementation required
1.303 + }
1.304 +
1.305 +CTestNativeStream::~CTestNativeStream()
1.306 + {
1.307 + DeleteOwfSingletons();
1.308 + }
1.309 +
1.310 +void CTestNativeStream::SetupL()
1.311 + {
1.312 + TRAPD(err_FailedToCreateSurfaceUtility, iUtility = CSurfaceUtility::NewL( NULL ));
1.313 + ASSERT_EQUALS(err_FailedToCreateSurfaceUtility,KErrNone);
1.314 + DefineOwfSingletonKeys();
1.315 + }
1.316 +
1.317 +/**
1.318 + * test Suite furniture
1.319 + **/
1.320 +void CTestNativeStream::TearDownL()
1.321 + {
1.322 + delete iUtility();
1.323 + }
1.324 +
1.325 +/**
1.326 +WFC context callback function invoked by native stream when the stream's content
1.327 +is updated. For testing, we simply call a class member function that checks that the
1.328 +correct native stream handle and events mask were supplied.
1.329 +*/
1.330 +void CTestNativeStream::SourceStreamUpdatedCallback(
1.331 + SymbianStreamType aNs, khronos_int32_t aEvents, void* aData, void* aParam)
1.332 + {
1.333 + (void)aData;
1.334 + if (aEvents == ESOWF_ObserverReturnDefaultEvent && aParam)
1.335 + {
1.336 + SYMOWF_DEFAULT_EVENT_PARAM* parameter = (SYMOWF_DEFAULT_EVENT_PARAM*) aParam;
1.337 + if ((parameter->length) == sizeof(SYMOWF_DEFAULT_EVENT_PARAM))
1.338 + {
1.339 + parameter->event = ESOWF_EventUpdated;
1.340 + }
1.341 + return;
1.342 + }
1.343 +
1.344 + ASSERT(CTestNativeStream::iTester);
1.345 + CTestNativeStream::iTester->CheckSourceStreamUpdated(aNs, aParam);
1.346 + }
1.347 +
1.348 +void CTestNativeStream::CheckSourceStreamUpdated(SymbianStreamType aNs, void* aParam)
1.349 + {
1.350 + RHeap *h1 = &(User::Heap());
1.351 + if (aParam)
1.352 + {
1.353 + ASSERT_EQUALS(iNs, aNs);
1.354 + SYMOWF_CONTENT_UPDATED_PARAM* param = (SYMOWF_CONTENT_UPDATED_PARAM*) aParam;
1.355 + ASSERT_TRUE(param->id == SYM_CONTENT_UPDATE_BEGIN ||
1.356 + param->id == SYM_CONTENT_UPDATE_END ||
1.357 + param->id == SYM_CONTENT_UPDATE);
1.358 +
1.359 + iSourceStreamUpdatedCalled++;
1.360 + iStreamUpdatedParameter = param->id;
1.361 + switch(param->id)
1.362 + {
1.363 + case SYM_CONTENT_UPDATE_BEGIN:
1.364 + param->immediateAvailable = iImmediateAvailable;
1.365 + param->immediateVisibility = iImmediateVisible;
1.366 + param->serialNumber = iStreamUpdatedSerialNumber;
1.367 + break;
1.368 +
1.369 + case SYM_CONTENT_UPDATE:
1.370 + case SYM_CONTENT_UPDATE_END:
1.371 + ASSERT_EQUALS(iExpectedSourceStreamUpdatedEventMask, param->par);
1.372 + iContextUpdatedFlags |= param->par & (~ESOWF_EventUpdated);
1.373 + break;
1.374 + default:
1.375 + break;
1.376 + }
1.377 + }
1.378 + else
1.379 + {
1.380 + iSourceStreamUpdatedCalled++;
1.381 + }
1.382 +
1.383 + }
1.384 +
1.385 +/**
1.386 +Remove the native stream notifications. The creator of the source is responsible
1.387 +for destroying the native stream.
1.388 +
1.389 +Now with the new SymbianStreamRemoveObserver function we need to pass in an observer
1.390 +*/
1.391 +void CTestNativeStream::RemoveNsNotifications()
1.392 + {
1.393 + SymbianStreamRemoveObserver(iNs, &iScreenNo, ESOWF_EventAvailable);
1.394 + SymbianStreamRemoveObserver(iNs, &iScreenNo, ESOWF_EventDisplayed);
1.395 + SymbianStreamRemoveObserver(iNs, &iScreenNo, ESOWF_EventDisplayedX);
1.396 + }
1.397 +
1.398 +CTestNativeStream* CTestNativeStream::iTester = NULL;
1.399 +
1.400 +// Create a suite of all the tests
1.401 +CTestSuite* CTestNativeStream::CreateSuiteL(const TDesC& aName)
1.402 + {
1.403 + SymbianStreamRegisterScreenNotifications(0, 10, KCompositorVersion);
1.404 + SUB_SUITE_OPT(CTestNativeStream,NULL);
1.405 +
1.406 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0100L);
1.407 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0101L);
1.408 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0102L);
1.409 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0103L);
1.410 +
1.411 + // Test with 1, 2 and 3 buffers
1.412 + ADD_TEST_STEP_PARAM_RANGE(GRAPHICS_OPENWFC_NATIVESTREAM_0104L,1,4);
1.413 + ADD_TEST_STEP_PARAM_RANGE(GRAPHICS_OPENWFC_NATIVESTREAM_0105L,1,4);
1.414 + ADD_TEST_STEP_PARAM_RANGE(GRAPHICS_OPENWFC_NATIVESTREAM_0106L,1,4);
1.415 +
1.416 + // Concurrent tests
1.417 + ADD_TEST_STEP_PARAM_RANGE(CreateSharedNativeStreamL,1,4);
1.418 + ADD_THIS_TEST_STEP(DestroySharedNativeStreamL);
1.419 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0107_1L);
1.420 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0107_2L);
1.421 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0107_3L);
1.422 +
1.423 + // Test SUS with OpenWF pipeline
1.424 + ADD_TEST_STEP_PARAM_RANGE(GRAPHICS_OPENWFC_NATIVESTREAM_0108L, 1, 4);
1.425 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0109L);
1.426 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0110L);
1.427 +
1.428 + // Test various cases for Native Stream callbacks
1.429 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0111L);
1.430 + // Test multithreaded cases for Native Stream callbacks
1.431 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0112_1L);
1.432 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0112_2L);
1.433 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0112_3L);
1.434 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0112_4L);
1.435 +
1.436 + // Notification tests
1.437 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0113L);
1.438 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0114L);
1.439 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0115L);
1.440 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0116L);
1.441 +
1.442 + // Notification cancel
1.443 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0117_1L);
1.444 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0117_2L);
1.445 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0117_3L);
1.446 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0117_4L);
1.447 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0118_1L);
1.448 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0118_2L);
1.449 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0118_3L);
1.450 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0118_4L);
1.451 +
1.452 + // Notification overflow
1.453 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0119_1L);
1.454 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0119_2L);
1.455 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0119_3L);
1.456 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0120_1L);
1.457 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0120_2L);
1.458 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0120_3L);
1.459 +
1.460 + // Notifications cancelled due to removal of source observer
1.461 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0122L);
1.462 +
1.463 + // Sym native stream add/remove observers
1.464 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0130L);
1.465 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0131L);
1.466 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0132L);
1.467 +
1.468 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0133L);
1.469 +
1.470 + // Test with 1, 2 and 3 buffers
1.471 + ADD_TEST_STEP_PARAM_RANGE(GRAPHICS_OPENWFC_NATIVESTREAM_0140L,1,4);
1.472 + ADD_TEST_STEP_PARAM_RANGE(GRAPHICS_OPENWFC_NATIVESTREAM_0141L,1,4);
1.473 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0142L);
1.474 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0143L);
1.475 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_NATIVESTREAM_0144L);
1.476 +
1.477 + END_SUITE;
1.478 +
1.479 + }
1.480 +
1.481 +// This handles any non-member uses of the extended ASSERT_XXX macros
1.482 +void TefUnitFailLeaveL()
1.483 + {
1.484 + User::Leave(KErrTEFUnitFail);
1.485 + }
1.486 +
1.487 +SymbianStreamType CTestNativeStream::NsCheckL(const TSurfaceId aId, TInt aCheck, TBool aFind)
1.488 + {
1.489 + // Acquire (create OR find) the stream
1.490 + SymbianStreamType ns = NULL;
1.491 + TInt err;
1.492 + if (aFind)
1.493 + {
1.494 + err = (TInt)SymbianStreamFind(&aId, &ns);
1.495 + }
1.496 + else
1.497 + {
1.498 + err = SymbianStreamAcquire(&aId, &ns);
1.499 + }
1.500 + ASSERT_TRUE(err == KErrNone);
1.501 + // Check the hash map count
1.502 + ASSERT_EQUALS((COpenWfcStreamMap::InstanceL().Count()), aCheck);
1.503 + SymbianStreamBuffer bufferHandle;
1.504 + err = SymbianStreamAcquireReadBuffer(ns,&bufferHandle);
1.505 + ASSERT_TRUE(err == KErrNone);
1.506 + long bufferIndex;
1.507 + const TSurfaceId* checkId = NULL;
1.508 + err = SymbianStreamGetBufferId(ns,bufferHandle,&bufferIndex,&checkId);
1.509 + ASSERT_TRUE(err == KErrNone);
1.510 + SymbianStreamReleaseReadBuffer(ns,bufferHandle);
1.511 + ASSERT_NOT_NULL(checkId);
1.512 + ASSERT_EQUALS(*checkId, aId);
1.513 + return ns;
1.514 + }
1.515 +
1.516 +void CTestNativeStream::CreateSharedNativeStreamL(TInt aBuffers)
1.517 + {
1.518 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.519 + GrowCleanupStackL();
1.520 +
1.521 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.522 +
1.523 + gVarInstance.SetTestComplete(EFalse);
1.524 + gVarInstance.SetBuffers(aBuffers);
1.525 +
1.526 + TSize surfaceSize(TSize(100,100));
1.527 + khronos_int32_t width = surfaceSize.iWidth;
1.528 + khronos_int32_t height = surfaceSize.iHeight;
1.529 +
1.530 + OWF_IMAGE_FORMAT pixelFormat =
1.531 + {
1.532 + OWF_IMAGE_ARGB8888,
1.533 + ETrue,
1.534 + ETrue,
1.535 + 4
1.536 + };
1.537 +
1.538 + // Create the first stream
1.539 + SymbianStreamType ns=helperCreateImageStream(width,
1.540 + height,
1.541 + &pixelFormat,
1.542 + aBuffers);
1.543 + ASSERT_TRUE(ns);
1.544 +
1.545 + SymbianStreamBuffer bufferHandle;
1.546 + SymbianStreamAcquireReadBuffer(ns,&bufferHandle);
1.547 + long bufferIndex;
1.548 + const TSurfaceId* checkId = NULL;
1.549 + TInt err = SymbianStreamGetBufferId(ns,bufferHandle,&bufferIndex,&checkId);
1.550 + ASSERT_TRUE(err == KErrNone);
1.551 + SymbianStreamReleaseReadBuffer(ns,bufferHandle);
1.552 + gVarInstance.SetSurfaceID(*checkId);
1.553 + gSemaphore.CreateLocal(1);
1.554 + gSemaphore.Wait();
1.555 + gSemaphore2.CreateLocal(1);
1.556 + gSemaphore2.Wait();
1.557 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.558 + }
1.559 +
1.560 +void CTestNativeStream::DestroySharedNativeStreamL()
1.561 + {
1.562 + GrowCleanupStackL();
1.563 +
1.564 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(COpenWfcStreamMap::InstanceL().GetMainHeap())));
1.565 +
1.566 + gSemaphore2.Close();
1.567 + gSemaphore.Close();
1.568 + TSurfaceId id = gVarInstance.SurfaceID();
1.569 + SymbianStreamType ns;
1.570 + TInt err = SymbianStreamFind(&id,&ns);
1.571 + ASSERT_TRUE(err == KErrNone);
1.572 + ASSERT_TRUE(ns);
1.573 + // Decrease stream's reference count by one. This removes reference added by owfNativeStreamFind()
1.574 + SymbianStreamRemoveReference(ns);
1.575 + // Decrease stream's reference count by one to make reference count zero, and destroy the stream
1.576 + SymbianStreamRemoveReference(ns);
1.577 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.578 + }
1.579 +
1.580 +// Test observers
1.581 +void TestUpdateCallback(SymbianStreamType aStream, khronos_int32_t aEvent, void* aData, void* aParam)
1.582 + {
1.583 + (void) aStream;
1.584 + switch (aEvent)
1.585 + {
1.586 + case ESOWF_ObserverReturnDefaultEvent:
1.587 + if (aParam)
1.588 + {
1.589 + SYMOWF_DEFAULT_EVENT_PARAM* parameter = (SYMOWF_DEFAULT_EVENT_PARAM*) aParam;
1.590 + if ((parameter->length) == sizeof(SYMOWF_DEFAULT_EVENT_PARAM))
1.591 + {
1.592 + parameter->event = ESOWF_EventUpdated;
1.593 + }
1.594 + }
1.595 + return;
1.596 +
1.597 + case ESOWF_EventUpdated:
1.598 + {
1.599 + TInt* localNumber = (TInt*)aData;
1.600 + ++(*localNumber);
1.601 + }
1.602 + break;
1.603 + default:
1.604 + break;
1.605 + }
1.606 + }
1.607 +
1.608 +// Test compose target
1.609 +void TestComposedCallback(SymbianStreamType aStream, khronos_int32_t aEvent, void* aData, void* aParam)
1.610 + {
1.611 + (void) aStream;
1.612 + switch (aEvent)
1.613 + {
1.614 + case ESOWF_ObserverReturnDefaultEvent:
1.615 + if (aParam)
1.616 + {
1.617 + SYMOWF_DEFAULT_EVENT_PARAM* parameter = (SYMOWF_DEFAULT_EVENT_PARAM*) aParam;
1.618 + if ((parameter->length) == sizeof(SYMOWF_DEFAULT_EVENT_PARAM))
1.619 + {
1.620 + parameter->event = ESOWF_EventComposed;
1.621 + }
1.622 + }
1.623 + return;
1.624 +
1.625 + case ESOWF_EventComposed:
1.626 + {
1.627 + TInt* localNumber = (TInt*)aData;
1.628 + ++(*localNumber);
1.629 + }
1.630 + break;
1.631 + default:
1.632 + break;
1.633 + }
1.634 + }
1.635 +
1.636 +/**
1.637 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0100
1.638 +@SYMTestCaseDesc Create a native stream using SymbianStreamAcquire()
1.639 +@SYMREQ
1.640 +@SYMPREQ PREQ2400
1.641 +@SYMTestType CT
1.642 +@SYMTestPriority
1.643 +@SYMTestPurpose Verify native stream objects can be created and persist unique surface ID values
1.644 +@SYMTestActions
1.645 + Create two surfaces,
1.646 + Create two streams from the surfaces
1.647 + Read back the surface Ids from the streams
1.648 +@SYMTestExpectedResults
1.649 + The surface IDs should be non-null and unique
1.650 + The streams should be non-null and unique
1.651 + The returned surface Ids should match the constructed IDs
1.652 + **/
1.653 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0100L()
1.654 + {
1.655 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.656 + TRAPD(err, GrowCleanupStackL());
1.657 + ASSERT_TRUE(err == KErrNone);
1.658 +
1.659 + TInt count = COpenWfcStreamMap::InstanceL().Count();
1.660 + TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100),EUidPixelFormatARGB_8888_PRE,400,2);
1.661 + ASSERT_FALSE(surface.IsNull());
1.662 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.663 + SymbianStreamType ns;
1.664 + err = SymbianStreamAcquire(&surface, &ns);
1.665 + ASSERT_TRUE(err == KErrNone);
1.666 + SymbianStreamBuffer bufferHandle;
1.667 + err = SymbianStreamAcquireReadBuffer(ns, &bufferHandle);
1.668 + ASSERT_TRUE(err == KErrNone);
1.669 + long bufferIndex;
1.670 + const TSurfaceId* getId = NULL;
1.671 + err = SymbianStreamGetBufferId(ns,bufferHandle,&bufferIndex,&getId);
1.672 + ASSERT_TRUE(err == KErrNone);
1.673 + TInt ChunkHandle = 100;
1.674 + err = SymbianStreamGetChunkHandle(ns, &ChunkHandle);
1.675 + ASSERT_TRUE(err == KErrNone);
1.676 + err = SymbianStreamReleaseReadBuffer(ns,bufferHandle);
1.677 + ASSERT_TRUE(err == KErrNone);
1.678 + ASSERT_EQUALS(*getId,surface);
1.679 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.680 +
1.681 + TSurfaceId surface2=iUtility->CreateSurfaceL(TSize(100,100),EUidPixelFormatARGB_8888_PRE,400,2);
1.682 + ASSERT_FALSE(surface2.IsNull());
1.683 + ASSERT_NOT_EQUALS(surface,surface2);
1.684 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.685 + SymbianStreamType ns2;
1.686 + err = SymbianStreamAcquire(&surface2,&ns2);
1.687 + ASSERT_TRUE(err == KErrNone);
1.688 + ASSERT_TRUE(ns2);
1.689 + ASSERT_FALSE(SymbianStreamSame(ns, ns2));
1.690 + ASSERT_EQUALS((COpenWfcStreamMap::InstanceL().Count()), count + 2);
1.691 + err = SymbianStreamAcquireReadBuffer(ns2,&bufferHandle);
1.692 + ASSERT_TRUE(err == KErrNone);
1.693 + const TSurfaceId* getId2 = NULL;
1.694 + err = SymbianStreamGetBufferId(ns2,bufferHandle,&bufferIndex,&getId2);
1.695 + ASSERT_TRUE(err == KErrNone);
1.696 + err = SymbianStreamReleaseReadBuffer(ns2,bufferHandle);
1.697 + ASSERT_TRUE(err == KErrNone);
1.698 + ASSERT_NOT_NULL(getId2);
1.699 + ASSERT_EQUALS(*getId2,surface2);
1.700 +
1.701 + SymbianStreamRemoveReference(ns);
1.702 + ASSERT_EQUALS((COpenWfcStreamMap::InstanceL().Count()), count + 1);
1.703 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.704 + iUtility->DestroySurface(surface);
1.705 +
1.706 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.707 + SymbianStreamRemoveReference(ns2);
1.708 + ASSERT_EQUALS((COpenWfcStreamMap::InstanceL().Count()), count);
1.709 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.710 + iUtility->DestroySurface(surface2);
1.711 + }
1.712 +
1.713 +/**
1.714 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0101
1.715 +@SYMTestCaseDesc Create a native stream using SymbianStreamCreateImageStream()
1.716 +@SYMREQ
1.717 +@SYMPREQ PREQ2400
1.718 +@SYMTestType CT
1.719 +@SYMTestPriority
1.720 +@SYMTestPurpose Verify native stream objects can be created and persist unique surface ID values
1.721 +@SYMTestActions
1.722 + Create two streams from the parameters passed in
1.723 + Read back the surface Ids from the streams
1.724 +@SYMTestExpectedResults
1.725 + The surface IDs should be non-null and unique
1.726 + The streams should be non-null and unique
1.727 + **/
1.728 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0101L()
1.729 + {
1.730 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.731 + TRAPD(err, GrowCleanupStackL());
1.732 + ASSERT_TRUE(err == KErrNone);
1.733 +
1.734 + TSize surfaceSize(TSize(100,100));
1.735 + TInt width = surfaceSize.iWidth;
1.736 + TInt height = surfaceSize.iHeight;
1.737 + TInt buffers = 2;
1.738 +
1.739 + OWF_IMAGE_FORMAT pixelFormat =
1.740 + {
1.741 + OWF_IMAGE_ARGB8888,
1.742 + ETrue,
1.743 + ETrue,
1.744 + 4
1.745 + };
1.746 +
1.747 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.748 +
1.749 + // Create the first stream
1.750 + SymbianStreamType ns=helperCreateImageStream(width,
1.751 + height,
1.752 + &pixelFormat,
1.753 + buffers);
1.754 + ASSERT_TRUE(ns);
1.755 + SymbianStreamBuffer bufferHandle;
1.756 + err = SymbianStreamAcquireReadBuffer(ns,&bufferHandle);
1.757 + ASSERT_TRUE(err == KErrNone);
1.758 + long bufferIndex;
1.759 + const TSurfaceId* getId = NULL;
1.760 + err = SymbianStreamGetBufferId(ns,bufferHandle,&bufferIndex,&getId);
1.761 + ASSERT_TRUE(err == KErrNone);
1.762 + err = SymbianStreamReleaseReadBuffer(ns,bufferHandle);
1.763 + ASSERT_TRUE(err == KErrNone);
1.764 +
1.765 + // Create the second stream
1.766 + SymbianStreamType ns2=helperCreateImageStream(width,
1.767 + height,
1.768 + &pixelFormat,
1.769 + buffers);
1.770 + ASSERT_TRUE(ns2);
1.771 +
1.772 + err = SymbianStreamAcquireReadBuffer(ns2,&bufferHandle);
1.773 + ASSERT_TRUE(err == KErrNone);
1.774 + const TSurfaceId* getId2 = NULL;
1.775 + err = SymbianStreamGetBufferId(ns2,bufferHandle,&bufferIndex,&getId2);
1.776 + ASSERT_TRUE(err == KErrNone);
1.777 + err = SymbianStreamReleaseReadBuffer(ns2,bufferHandle);
1.778 + ASSERT_TRUE(err == KErrNone);
1.779 + ASSERT_NOT_NULL(getId2);
1.780 +
1.781 + ASSERT_NOT_EQUALS(ns,ns2);
1.782 + ASSERT_NOT_EQUALS(getId,getId2);
1.783 +
1.784 + SymbianStreamRemoveReference(ns);
1.785 + SymbianStreamRemoveReference(ns2);
1.786 +
1.787 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.788 + }
1.789 +
1.790 +/**
1.791 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0102
1.792 +@SYMTestCaseDesc Create a native stream 2
1.793 +@SYMREQ
1.794 +@SYMPREQ PREQ2400
1.795 +@SYMTestType CT
1.796 +@SYMTestPriority
1.797 +@SYMTestPurpose Verify native stream objects can be created and persist unique surface ID values
1.798 +@SYMTestActions
1.799 + Create two surfaces,
1.800 + Create two streams from the surfaces
1.801 + Read back the surface Ids from the streams
1.802 + Acquire multiple time the native streams
1.803 + Find native streams
1.804 +@SYMTestExpectedResults
1.805 + The surface IDs should be non-null and unique
1.806 + The streams should be non-null and unique
1.807 + The returned surface Ids should match the constructed IDs
1.808 + The hash map counter should be updated accordingly when native streams are created or destroyed
1.809 + **/
1.810 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0102L()
1.811 + {
1.812 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.813 + TRAPD(err, GrowCleanupStackL());
1.814 + ASSERT_TRUE(err == KErrNone);
1.815 +
1.816 + COpenWfcStreamMap& singleton = COpenWfcStreamMap::InstanceL();
1.817 + TInt check = COpenWfcStreamMap::InstanceL().Count() + 1;
1.818 + // Create the first surface
1.819 + TSurfaceId surfaceId1 = iUtility->CreateSurfaceL(TSize(100, 100), EUidPixelFormatARGB_8888_PRE, 400, 2);
1.820 + ASSERT_FALSE(surfaceId1.IsNull());
1.821 +
1.822 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.823 + SymbianStreamType ns1 = NsCheckL(surfaceId1, check, EFalse);
1.824 +
1.825 + TSurfaceId surfaceId2;
1.826 + surfaceId2.CreateNullId();
1.827 + SymbianStreamType ns2;
1.828 + err = SymbianStreamFind(&surfaceId2,&ns2);
1.829 + ASSERT_TRUE(err == KErrNotFound);
1.830 + ASSERT_FALSE(ns2);
1.831 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.832 +
1.833 + // Create the second surface
1.834 + surfaceId2 = iUtility->CreateSurfaceL(TSize(100, 100), EUidPixelFormatARGB_8888_PRE, 400, 2);
1.835 + ASSERT_FALSE(surfaceId2.IsNull());
1.836 +
1.837 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.838 + err = SymbianStreamFind(&surfaceId2,&ns2);
1.839 + ASSERT_TRUE(err == KErrNotFound);
1.840 + ASSERT_FALSE(ns2);
1.841 +
1.842 + ns2 = NsCheckL(surfaceId2, ++check, EFalse);
1.843 +
1.844 + NsCheckL(surfaceId1, check, EFalse);
1.845 +
1.846 + NsCheckL(surfaceId1, check, ETrue);
1.847 +
1.848 + NsCheckL(surfaceId2, check, ETrue);
1.849 +
1.850 + SymbianStreamRemoveReference(ns1);
1.851 + ASSERT_EQUALS((singleton.Count()), check);
1.852 +
1.853 + SymbianStreamRemoveReference(ns2);
1.854 + ASSERT_EQUALS((singleton.Count()), check);
1.855 +
1.856 + SymbianStreamRemoveReference(ns2);
1.857 + ASSERT_EQUALS((singleton.Count()), --check);
1.858 +
1.859 + SymbianStreamRemoveReference(ns1);
1.860 + ASSERT_EQUALS((singleton.Count()), check);
1.861 +
1.862 + SymbianStreamRemoveReference(ns1);
1.863 + ASSERT_EQUALS((singleton.Count()), --check);
1.864 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.865 +
1.866 + iUtility->DestroySurface(surfaceId1);
1.867 + iUtility->DestroySurface(surfaceId2);
1.868 +
1.869 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.870 + err = SymbianStreamFind(&surfaceId2,&ns2);
1.871 + ASSERT_TRUE(err == KErrNotFound);
1.872 + ASSERT_FALSE(ns2);
1.873 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.874 + }
1.875 +
1.876 +struct SupportedFormats
1.877 + {
1.878 + TUidPixelFormat symbianPixelFormat;
1.879 + } supportedFormats[]=
1.880 + {
1.881 + EUidPixelFormatXRGB_8888,
1.882 + EUidPixelFormatARGB_8888,
1.883 + EUidPixelFormatBGRX_8888,
1.884 + EUidPixelFormatXBGR_8888,
1.885 + EUidPixelFormatBGRA_8888,
1.886 + EUidPixelFormatABGR_8888,
1.887 + EUidPixelFormatABGR_8888_PRE,
1.888 + EUidPixelFormatARGB_8888_PRE,
1.889 + EUidPixelFormatBGRA_8888_PRE,
1.890 + EUidPixelFormatARGB_2101010,
1.891 + EUidPixelFormatABGR_2101010,
1.892 + EUidPixelFormatBGR_888,
1.893 + EUidPixelFormatRGB_888,
1.894 + EUidPixelFormatXRGB_4444,
1.895 + EUidPixelFormatARGB_4444,
1.896 + EUidPixelFormatXBGR_4444,
1.897 + EUidPixelFormatRGB_565,
1.898 + EUidPixelFormatBGR_565,
1.899 + EUidPixelFormatARGB_1555,
1.900 + EUidPixelFormatXRGB_1555,
1.901 + EUidPixelFormatARGB_8332,
1.902 + EUidPixelFormatBGRX_5551,
1.903 + EUidPixelFormatBGRA_5551,
1.904 + EUidPixelFormatBGRA_4444,
1.905 + EUidPixelFormatBGRX_4444,
1.906 + EUidPixelFormatAP_88,
1.907 + EUidPixelFormatRGB_332,
1.908 + EUidPixelFormatBGR_332,
1.909 + EUidPixelFormatA_8,
1.910 + EUidPixelFormatL_8,
1.911 + EUidPixelFormatP_8,
1.912 + EUidPixelFormatP_4,
1.913 + EUidPixelFormatL_4,
1.914 + EUidPixelFormatL_2,
1.915 + EUidPixelFormatP_2,
1.916 + EUidPixelFormatL_1
1.917 + };
1.918 +
1.919 +/**
1.920 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0103
1.921 +@SYMTestCaseDesc Retrieve stream attributes using SymbianStreamGetHeader()
1.922 +@SYMREQ
1.923 +@SYMPREQ PREQ2400
1.924 +@SYMTestType CT
1.925 +@SYMTestPriority
1.926 +@SYMTestPurpose Verify native stream object attributes can be retrieved.
1.927 +@SYMTestActions
1.928 + Create a native stream based on a supported image/pixel format
1.929 + Retrieve all of the stream attributes
1.930 + Retreive none of the stream attributes
1.931 +@SYMTestExpectedResults
1.932 + The retrieved attributes should match the parameters used to create the surface stream
1.933 + Retrieving no attributes should not cause a crash
1.934 + **/
1.935 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0103L()
1.936 + {
1.937 + // Native stream attributes
1.938 + TSize surfaceSize(TSize(100,50));
1.939 + khronos_int32_t width = surfaceSize.iWidth;
1.940 + khronos_int32_t height = surfaceSize.iHeight;
1.941 + khronos_int32_t numBuffers = 2;
1.942 +
1.943 + for (TInt x=0; x<sizeof(supportedFormats)/sizeof(supportedFormats[0]); x++)
1.944 + {
1.945 + INFO_PRINTF2(_L("Pixel format %x"),supportedFormats[x]);
1.946 + khronos_int32_t streamPixelSize = BytesPerPixel(supportedFormats[x].symbianPixelFormat);
1.947 +
1.948 + OWF_IMAGE_FORMAT pixelFormat =
1.949 + {
1.950 + OWF_IMAGE_NOT_SUPPORTED,
1.951 + EFalse,
1.952 + EFalse,
1.953 + 2
1.954 + };
1.955 +
1.956 + SymbianStreamType ns=helperCreateImageStream(width,
1.957 + height,
1.958 + &pixelFormat,
1.959 + numBuffers,
1.960 + supportedFormats[x].symbianPixelFormat); //will ignore pixelFormat
1.961 + ASSERT_TRUE(ns);
1.962 +
1.963 + // Store the retrieved attributes
1.964 + TInt32 attWidth = 0;
1.965 + TInt32 attHeight = 0;
1.966 + TInt32 attStreamStride = 0;
1.967 + TInt32 attStreamFormat = EUidPixelFormatUnknown;
1.968 + TInt32 attStreamPixelSize = 0;
1.969 +
1.970 + SymbianStreamGetHeader(ns, &attWidth, &attHeight, &attStreamStride, &attStreamFormat, &attStreamPixelSize);
1.971 +
1.972 + ASSERT_EQUALS(attWidth, width);
1.973 + ASSERT_EQUALS(attHeight, height);
1.974 + ASSERT_EQUALS((TInt32)attStreamFormat, (TInt32)supportedFormats[x].symbianPixelFormat);
1.975 + if (BytesPerPixel(supportedFormats[x].symbianPixelFormat) > 0)
1.976 + {
1.977 + ASSERT_EQUALS(attStreamStride, (streamPixelSize * width));
1.978 + }
1.979 + else
1.980 + {
1.981 + ASSERT_EQUALS(attStreamStride, (width-(streamPixelSize+1)) / (-streamPixelSize));
1.982 + }
1.983 + ASSERT_EQUALS(attStreamPixelSize, (TInt32)BytesPerPixel(supportedFormats[x].symbianPixelFormat));
1.984 +
1.985 + SymbianStreamGetHeader(ns, NULL, NULL, NULL, NULL, NULL);
1.986 +
1.987 + SymbianStreamRemoveReference(ns);
1.988 + }
1.989 + }
1.990 +
1.991 +/**
1.992 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0104
1.993 +@SYMTestCaseDesc Acquire write/read buffers and retrieve the buffer ptr (single threaded test).
1.994 +@SYMREQ
1.995 +@SYMPREQ PREQ2400
1.996 +@SYMTestType CT
1.997 +@SYMTestPriority
1.998 +@SYMTestPurpose Verify owfNativeStreamAcquireWriteBuffer(), owfNativeStreamReleaseWriteBuffer(),
1.999 + owfNativeStreamAcquireReadBuffer() and owfNativeStreamReleaseReadBuffer() methods
1.1000 + work as expected.
1.1001 +
1.1002 +@SYMTestActions
1.1003 + Create a native stream
1.1004 + For each buffer:
1.1005 + - Acquire the write buffer (wB)
1.1006 + - Get the write buffer ptr (pWB)
1.1007 + - Release the write buffer
1.1008 + - Acquire the read buffer (rB)
1.1009 + - Get the read buffer ptr (pRB)
1.1010 + - Release the read buffer
1.1011 + Repeat for each buffer. Finally:
1.1012 + Acquire the write buffer
1.1013 + Release the write buffer
1.1014 +@SYMTestExpectedResults
1.1015 + For each buffer of the native stream, check:
1.1016 + - The read buffer (rB) should be the same as the write buffer (wB)
1.1017 + - The read buffer address (pRB) should be the same as the write buffer address (pWB)
1.1018 + If the number of buffers > 1, check:
1.1019 + - The write buffer number from the previous acquire write buffer call should not be the same
1.1020 + as the write buffer number from the next acquire write buffer call
1.1021 + The final acquire/release write/read calls should check:
1.1022 + The write buffer number should acquire the first buffer number
1.1023 + **/
1.1024 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0104L(TInt aNumBuffers)
1.1025 + {
1.1026 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.1027 + TRAPD(err, GrowCleanupStackL());
1.1028 + ASSERT_TRUE(err == KErrNone);
1.1029 +
1.1030 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.1031 +
1.1032 + ASSERT_TRUE(aNumBuffers > 0);
1.1033 +
1.1034 + TSize surfaceSize(TSize(100,100));
1.1035 + khronos_int32_t width = surfaceSize.iWidth;
1.1036 + khronos_int32_t height = surfaceSize.iHeight;
1.1037 +
1.1038 + OWF_IMAGE_FORMAT pixelFormat =
1.1039 + {
1.1040 + OWF_IMAGE_ARGB8888,
1.1041 + ETrue,
1.1042 + ETrue,
1.1043 + aNumBuffers
1.1044 + };
1.1045 +
1.1046 + SymbianStreamType ns=helperCreateImageStream(width,
1.1047 + height,
1.1048 + &pixelFormat,
1.1049 + aNumBuffers);
1.1050 + ASSERT_TRUE(ns);
1.1051 +
1.1052 + TUint8 *pWriteBuffer = NULL;
1.1053 + TUint8 *pReadBuffer = NULL;
1.1054 + TUint8 *pPrevWriteBuffer = pWriteBuffer;
1.1055 + khronos_int32_t writeBuffer;
1.1056 + khronos_int32_t readBuffer;
1.1057 + khronos_int32_t bufferIndexWrite;
1.1058 + khronos_int32_t bufferIndexRead;
1.1059 + khronos_int32_t bufferIndexWriteFirst;
1.1060 + khronos_int32_t bufferIndexWriteFinal;
1.1061 + khronos_int32_t finalWriteBuffer;
1.1062 + const TSurfaceId* getId = NULL;
1.1063 +
1.1064 + TInt bufferCount = aNumBuffers;
1.1065 +
1.1066 + // Loop through the buffers
1.1067 + for (TInt count=0; count<bufferCount; count++)
1.1068 + {
1.1069 + // Acquire the write buffer
1.1070 + err = SymbianStreamAcquireWriteBuffer(ns,&writeBuffer);
1.1071 + ASSERT_TRUE(err == KErrNone);
1.1072 + err = SymbianStreamGetBufferId(ns,writeBuffer,&bufferIndexWrite,&getId);
1.1073 + ASSERT_TRUE(err == KErrNone);
1.1074 +
1.1075 + if (count == 0)
1.1076 + {
1.1077 + bufferIndexWriteFirst = bufferIndexWrite;
1.1078 + }
1.1079 +
1.1080 + err = SymbianStreamGetBufferPointer(ns,writeBuffer,reinterpret_cast<void**>(&pWriteBuffer));
1.1081 + ASSERT_TRUE(err == KErrNone);
1.1082 + ASSERT_NOT_NULL(pWriteBuffer);
1.1083 +
1.1084 + err = SymbianStreamReleaseWriteBuffer(ns,writeBuffer);
1.1085 + ASSERT_TRUE(err == KErrNone);
1.1086 +
1.1087 + // Acquire the read buffer
1.1088 + err = SymbianStreamAcquireReadBuffer(ns,&readBuffer);
1.1089 + ASSERT_TRUE(err == KErrNone);
1.1090 + err = SymbianStreamGetBufferId(ns,writeBuffer,&bufferIndexRead,&getId);
1.1091 + ASSERT_TRUE(err == KErrNone);
1.1092 +
1.1093 + err = SymbianStreamGetBufferPointer(ns,readBuffer,reinterpret_cast<void**>(&pReadBuffer));
1.1094 + ASSERT_TRUE(err == KErrNone);
1.1095 + ASSERT_NOT_NULL(pReadBuffer);
1.1096 +
1.1097 + err = SymbianStreamReleaseReadBuffer(ns,readBuffer);
1.1098 + ASSERT_TRUE(err == KErrNone);
1.1099 +
1.1100 + // Life-cycle checks
1.1101 + ASSERT_EQUALS(bufferIndexWrite, bufferIndexRead)
1.1102 + ASSERT_SAME(pWriteBuffer, pReadBuffer);
1.1103 +
1.1104 + if (count > 0)
1.1105 + {
1.1106 + ASSERT_NOT_SAME(pWriteBuffer, pPrevWriteBuffer);
1.1107 + }
1.1108 +
1.1109 + pPrevWriteBuffer = pWriteBuffer;
1.1110 + }
1.1111 +
1.1112 + // The next acquire write/reads should return the first buffer (0).
1.1113 +
1.1114 + err = SymbianStreamAcquireWriteBuffer(ns,&finalWriteBuffer);
1.1115 + ASSERT_TRUE(err == KErrNone);
1.1116 + err = SymbianStreamGetBufferId(ns,finalWriteBuffer,&bufferIndexWriteFinal,&getId);
1.1117 + ASSERT_TRUE(err == KErrNone);
1.1118 + err = SymbianStreamReleaseWriteBuffer(ns,finalWriteBuffer);
1.1119 + ASSERT_TRUE(err == KErrNone);
1.1120 +
1.1121 + // Final checks
1.1122 + ASSERT_EQUALS(bufferIndexWriteFinal, bufferIndexWriteFirst);
1.1123 +
1.1124 + SymbianStreamRemoveReference(ns);
1.1125 +
1.1126 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.1127 + }
1.1128 +
1.1129 +/**
1.1130 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0105
1.1131 +@SYMTestCaseDesc Create a native stream and acquire a write buffer which is written to (single threaded test)
1.1132 +@SYMREQ
1.1133 +@SYMPREQ PREQ2400
1.1134 +@SYMTestType CT
1.1135 +@SYMTestPriority
1.1136 +@SYMTestPurpose Verify native stream buffers can be written to and read from.
1.1137 +@SYMTestActions
1.1138 + Create a surface and fill it Red
1.1139 + Create a native stream surface with the same surface properties (size, pixel format etc.)
1.1140 + Acquire the native stream write buffer
1.1141 + Fill the native stream surface Red
1.1142 + Release the write buffer
1.1143 + Acquire the native stream read buffer
1.1144 + Compare the pixel data of the surface to the native stream surface
1.1145 + Fill the Blue
1.1146 + Compare the pixel data of the surface to the native stream surface
1.1147 +@SYMTestExpectedResults
1.1148 + The surface pixel data is the same as the native stream surface pixel data
1.1149 + After the surface pixel data is changed to Blue, the native stream surface should not be the same
1.1150 + **/
1.1151 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0105L(TInt aNumBuffers)
1.1152 + {
1.1153 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.1154 + TRAPD(err, GrowCleanupStackL());
1.1155 + ASSERT_TRUE(err == KErrNone);
1.1156 +
1.1157 + // Surface properties
1.1158 + TSize surfaceSize(TSize(100,100));
1.1159 +
1.1160 + // Create the comparison surface and fill it Red
1.1161 + TSurfaceId surface;
1.1162 + TRAP(err, surface = iUtility->CreateSurfaceL(TSize(surfaceSize.iWidth,surfaceSize.iHeight),
1.1163 + EUidPixelFormatXRGB_8888, surfaceSize.iWidth * 4));
1.1164 +
1.1165 + TRAP(err, iUtility->FillSurfaceL(surface, 0, KRgbRed));
1.1166 +
1.1167 + // Native stream
1.1168 + khronos_int32_t width = surfaceSize.iWidth;
1.1169 + khronos_int32_t height = surfaceSize.iHeight;
1.1170 +
1.1171 + OWF_IMAGE_FORMAT pixelFormatXRGB888 =
1.1172 + {
1.1173 + OWF_IMAGE_XRGB8888,
1.1174 + ETrue,
1.1175 + EFalse,
1.1176 + 4
1.1177 + };
1.1178 +
1.1179 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.1180 +
1.1181 + SymbianStreamType ns1=helperCreateImageStream(width,
1.1182 + height,
1.1183 + &pixelFormatXRGB888,
1.1184 + aNumBuffers);
1.1185 + ASSERT_TRUE(ns1);
1.1186 +
1.1187 +
1.1188 + SymbianStreamBuffer bufferHandle;
1.1189 + err = SymbianStreamAcquireReadBuffer(ns1,&bufferHandle);
1.1190 + ASSERT_TRUE(err == KErrNone);
1.1191 + long bufferIndex;
1.1192 + const TSurfaceId* nSurface = NULL;
1.1193 + err = SymbianStreamGetBufferId(ns1,bufferHandle,&bufferIndex,&nSurface);
1.1194 + ASSERT_TRUE(err == KErrNone);
1.1195 + err = SymbianStreamReleaseReadBuffer(ns1,bufferHandle);
1.1196 + ASSERT_TRUE(err == KErrNone);
1.1197 + ASSERT_NOT_NULL(nSurface);
1.1198 +
1.1199 + TSurfaceId* nsSurface = const_cast<TSurfaceId*>(nSurface);
1.1200 +
1.1201 + // Acquire write buffer. With 3 buffers we should return buffer 1
1.1202 + khronos_int32_t writeBuffer1;
1.1203 + err = SymbianStreamAcquireWriteBuffer(ns1,&writeBuffer1);
1.1204 + ASSERT_TRUE(err == KErrNone);
1.1205 +
1.1206 + TUint8 *pWriteBuffer1 = NULL;
1.1207 + err = SymbianStreamGetBufferPointer(ns1,writeBuffer1,reinterpret_cast<void**>(&pWriteBuffer1));
1.1208 + ASSERT_TRUE(err == KErrNone);
1.1209 + ASSERT_NOT_NULL(pWriteBuffer1);
1.1210 +
1.1211 + TRAP(err, iUtility->FillNativeStreamSurfaceL(*nsSurface, pWriteBuffer1, KRgbRed));
1.1212 +
1.1213 + err = SymbianStreamReleaseWriteBuffer(ns1, writeBuffer1);
1.1214 + ASSERT_TRUE(err == KErrNone);
1.1215 +
1.1216 + // Now we should compare to see if the pixels are the same
1.1217 + khronos_int32_t readBuffer1;
1.1218 + err = SymbianStreamAcquireReadBuffer(ns1,&readBuffer1);
1.1219 + ASSERT_TRUE(err == KErrNone);
1.1220 +
1.1221 + TUint8 *pReadBuffer1 = NULL;
1.1222 + err = SymbianStreamGetBufferPointer(ns1,readBuffer1,reinterpret_cast<void**>(&pReadBuffer1));
1.1223 + ASSERT_TRUE(err == KErrNone);
1.1224 + ASSERT_NOT_NULL(pReadBuffer1);
1.1225 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.1226 + ASSERT_TRUE(iUtility->CompareSurfacesL(surface, 0, *nsSurface, pReadBuffer1));
1.1227 +
1.1228 + // Finally, change the surface to blue. The pixels should now be different
1.1229 + TRAP(err, iUtility->FillSurfaceL(surface, 0, KRgbBlue));
1.1230 + ASSERT_FALSE(iUtility->CompareSurfacesL(surface, 0, *nsSurface, pReadBuffer1));
1.1231 +
1.1232 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.1233 + err = SymbianStreamReleaseReadBuffer(ns1,readBuffer1);
1.1234 + ASSERT_TRUE(err == KErrNone);
1.1235 + SymbianStreamRemoveReference(ns1);
1.1236 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.1237 + }
1.1238 +
1.1239 +/**
1.1240 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0106
1.1241 +@SYMTestCaseDesc Negative test - Attempt to acquire a write buffer when the write buffer has not been released (single threaded test)
1.1242 +@SYMREQ
1.1243 +@SYMPREQ PREQ2400
1.1244 +@SYMTestType CT
1.1245 +@SYMTestPriority
1.1246 +@SYMTestPurpose Verify an invalid handle is returned to the calling thread if the write buffer has not been released
1.1247 +@SYMTestActions
1.1248 + Create a native stream surface with 1 buffer
1.1249 + Acquire the native stream write buffer
1.1250 + Acquire the native stream write buffer again
1.1251 +@SYMTestExpectedResults
1.1252 + The 2nd acquire write buffer call should return OWF_INVALID_HANDLE if not single buffered.
1.1253 + **/
1.1254 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0106L(TInt aNumBuffers)
1.1255 + {
1.1256 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.1257 + TRAPD(err, GrowCleanupStackL());
1.1258 + ASSERT_TRUE(err == KErrNone);
1.1259 +
1.1260 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.1261 +
1.1262 + // Create the first stream (ARGB_8888_PRE)
1.1263 + TSize surfaceSize(TSize(100,100));
1.1264 + khronos_int32_t width = surfaceSize.iWidth;
1.1265 + khronos_int32_t height = surfaceSize.iHeight;
1.1266 +
1.1267 + OWF_IMAGE_FORMAT pixelFormatARGB888Pre =
1.1268 + {
1.1269 + OWF_IMAGE_ARGB8888,
1.1270 + ETrue,
1.1271 + EFalse,
1.1272 + 4
1.1273 + };
1.1274 +
1.1275 + SymbianStreamType ns1=helperCreateImageStream(width,
1.1276 + height,
1.1277 + &pixelFormatARGB888Pre,
1.1278 + aNumBuffers);
1.1279 + ASSERT_TRUE(ns1);
1.1280 +
1.1281 + // Acquire write buffer. With just 1 buffer we should return buffer 0
1.1282 + khronos_int32_t writeBuffer1;
1.1283 + err = SymbianStreamAcquireWriteBuffer(ns1,&writeBuffer1);
1.1284 + ASSERT_TRUE(err != KErrBadHandle);
1.1285 +
1.1286 + // Try and acquire the write buffer again before we have released it
1.1287 + khronos_int32_t writeBuffer2;
1.1288 + err = SymbianStreamAcquireWriteBuffer(ns1,&writeBuffer2);
1.1289 + ASSERT_TRUE(err != KErrBadHandle);
1.1290 + if (aNumBuffers == 1)
1.1291 + {
1.1292 + ASSERT_EQUALS(writeBuffer2, writeBuffer1);
1.1293 + }
1.1294 + else
1.1295 + {
1.1296 + ASSERT_EQUALS(writeBuffer2, (khronos_int32_t)0);
1.1297 + }
1.1298 +
1.1299 + err = SymbianStreamReleaseWriteBuffer(ns1,writeBuffer1);
1.1300 + ASSERT_TRUE(err != KErrBadHandle);
1.1301 +
1.1302 + err = SymbianStreamAcquireWriteBuffer(ns1, &writeBuffer2);
1.1303 + ASSERT_TRUE(err != KErrBadHandle);
1.1304 + TUint8 *pWriteBuffer2 = NULL;
1.1305 + err = SymbianStreamGetBufferPointer(ns1,writeBuffer2,reinterpret_cast<void**>(&pWriteBuffer2));
1.1306 + ASSERT_TRUE(err != KErrBadHandle);
1.1307 + ASSERT_NOT_NULL(pWriteBuffer2);
1.1308 +
1.1309 + SymbianStreamRemoveReference(ns1);
1.1310 +
1.1311 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.1312 + }
1.1313 +
1.1314 +/**
1.1315 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0107
1.1316 +@SYMTestCaseDesc Attempt to acquire a write buffer when the write buffer has not been released (multi threaded tests)
1.1317 +@SYMREQ
1.1318 +@SYMPREQ PREQ2400
1.1319 +@SYMTestType CT
1.1320 +@SYMTestPriority
1.1321 +@SYMTestPurpose Verify an invalid handle is returned to the calling thread if the write buffer has not been released
1.1322 +@SYMTestActions
1.1323 + Create a shared native stream surface to be used by multiple threads
1.1324 + Thread 1 acquires the shared native stream and acquires the write buffer
1.1325 + Thread 2 acquires the shared native stream and attempts to acquire the write buffer
1.1326 + Thread 3 acquires the shared native stream and attempts to acquire the write buffer
1.1327 + Thread 1 releases the write buffer
1.1328 + Thread 2 acquires the write buffer
1.1329 + Thread 2 releases the write buffer
1.1330 +@SYMTestExpectedResults
1.1331 + OWF_INVALID_HANDLE returned when Thread 2 and Thread 3 attempt to acquire the write buffer
1.1332 + when Thread 1 has already acquired it
1.1333 + **/
1.1334 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0107_1L()
1.1335 + {
1.1336 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.1337 + TRAPD(err, GrowCleanupStackL());
1.1338 + ASSERT_TRUE(err == KErrNone);
1.1339 +
1.1340 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.1341 + INFO_PRINTF2(_L("** GRAPHICS_OPENWFC_NATIVESTREAM_0107 - %i buffers **"), gVarInstance.Buffers());
1.1342 + INFO_PRINTF1(_L("Thread 1 - start"));
1.1343 + TSurfaceId surface = gVarInstance.SurfaceID();
1.1344 + SymbianStreamType ns;
1.1345 + err = SymbianStreamAcquire(&surface,&ns);
1.1346 + ASSERT_TRUE(err == KErrNone);
1.1347 + ASSERT_TRUE(ns);
1.1348 +
1.1349 + khronos_int32_t writeBuffer1;
1.1350 + err = SymbianStreamAcquireWriteBuffer(ns,&writeBuffer1);
1.1351 + ASSERT_TRUE(err != KErrBadHandle);
1.1352 +
1.1353 + khronos_int32_t bufferIndex;
1.1354 + const TSurfaceId* getId = NULL;
1.1355 + err = SymbianStreamGetBufferId(ns,writeBuffer1,&bufferIndex,&getId);
1.1356 + ASSERT_TRUE(err == KErrNone);
1.1357 + ASSERT_EQUALS(*getId, surface);
1.1358 + ASSERT_EQUALS(bufferIndex, (khronos_int32_t)1);
1.1359 + INFO_PRINTF2(_L("Thread 1 - Write buffer %i acquired"), bufferIndex);
1.1360 +
1.1361 + gSemaphore.Signal(2); // Thread 2 and 3 ready to run
1.1362 +
1.1363 + gSemaphore2.Wait();
1.1364 + gSemaphore2.Wait(); // Wait for both threads to signal
1.1365 + err = SymbianStreamReleaseWriteBuffer(ns,writeBuffer1);
1.1366 + ASSERT_TRUE(err == KErrNone);
1.1367 + SymbianStreamRemoveReference(ns);
1.1368 + INFO_PRINTF2(_L("Thread 1 - Write buffer %i released"), bufferIndex);
1.1369 +
1.1370 + gSemaphore.Signal();
1.1371 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.1372 + }
1.1373 +
1.1374 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0107_2L()
1.1375 + {
1.1376 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.1377 + TRAPD(err, GrowCleanupStackL());
1.1378 + ASSERT_TRUE(err == KErrNone);
1.1379 +
1.1380 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.1381 + gSemaphore.Wait(); // Semaphore count becomes -1
1.1382 + INFO_PRINTF1(_L("Thread 2 - Start"));
1.1383 + TSurfaceId surface = gVarInstance.SurfaceID();
1.1384 + SymbianStreamType ns;
1.1385 + err = SymbianStreamAcquire(&surface,&ns);
1.1386 + ASSERT_TRUE(err == KErrNone);
1.1387 + ASSERT_TRUE(ns);
1.1388 +
1.1389 + khronos_int32_t writeBuffer1;
1.1390 + err = SymbianStreamAcquireWriteBuffer(ns,&writeBuffer1);
1.1391 + ASSERT_TRUE(err != KErrBadHandle);
1.1392 + INFO_PRINTF1(_L("Thread 2 - Attempt to acquire the write buffer"));
1.1393 + ASSERT_FALSE(writeBuffer1);
1.1394 + INFO_PRINTF1(_L("Thread 2 - Write buffer already in use by Thread 1!"));
1.1395 +
1.1396 + gSemaphore2.Signal();
1.1397 +
1.1398 + gSemaphore.Wait();
1.1399 +
1.1400 + khronos_int32_t writeBuffer2;
1.1401 + err = SymbianStreamAcquireWriteBuffer(ns,&writeBuffer2);
1.1402 + ASSERT_TRUE(err != KErrBadHandle);
1.1403 + khronos_int32_t bufferIndex;
1.1404 + const TSurfaceId* getId = NULL;
1.1405 + err = SymbianStreamGetBufferId(ns,writeBuffer2,&bufferIndex,&getId);
1.1406 + ASSERT_TRUE(err == KErrNone);
1.1407 + ASSERT_FALSE(bufferIndex);
1.1408 + INFO_PRINTF2(_L("Thread 2 - Write buffer %i acquired"), bufferIndex);
1.1409 +
1.1410 + err = SymbianStreamReleaseWriteBuffer(ns,writeBuffer2);
1.1411 + ASSERT_TRUE(err == KErrNone);
1.1412 + SymbianStreamRemoveReference(ns);
1.1413 + INFO_PRINTF2(_L("Thread 2 - Write buffer %i released"), bufferIndex);
1.1414 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.1415 + }
1.1416 +
1.1417 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0107_3L()
1.1418 + {
1.1419 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.1420 + TRAPD(err, GrowCleanupStackL());
1.1421 + ASSERT_TRUE(err == KErrNone);
1.1422 +
1.1423 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.1424 + gSemaphore.Wait(); // Semaphore count is -2
1.1425 + INFO_PRINTF1(_L("Thread 3 - start"));
1.1426 + TSurfaceId surface = gVarInstance.SurfaceID();
1.1427 + SymbianStreamType ns;
1.1428 + err = SymbianStreamAcquire(&surface,&ns);
1.1429 + ASSERT_TRUE(err == KErrNone);
1.1430 + ASSERT_TRUE(ns);
1.1431 +
1.1432 + khronos_int32_t writeBuffer1;
1.1433 + err = SymbianStreamAcquireWriteBuffer(ns,&writeBuffer1);
1.1434 + ASSERT_TRUE(err != KErrBadHandle);
1.1435 + INFO_PRINTF1(_L("Thread 3 - Attempt to acquire the write buffer"));
1.1436 + ASSERT_FALSE(writeBuffer1);
1.1437 + INFO_PRINTF1(_L("Thread 3 - Write buffer already in use by Thread 1!"));
1.1438 +
1.1439 + gSemaphore2.Signal();
1.1440 +
1.1441 + SymbianStreamRemoveReference(ns);
1.1442 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.1443 + }
1.1444 +
1.1445 +
1.1446 +/**
1.1447 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0108
1.1448 +@SYMTestCaseDesc Content updates on valid and invalid buffers
1.1449 +@SYMREQ
1.1450 +@SYMPREQ PREQ2400
1.1451 +@SYMTestType CT
1.1452 +@SYMTestPriority
1.1453 +@SYMTestPurpose Verify native streams can handle content updates for valid and invalid buffer numbers
1.1454 +@SYMTestActions
1.1455 + Create a surface with 4 buffers,
1.1456 + Create a stream from this surface,
1.1457 + Add an observer to listen out for content updates to the stream,
1.1458 + Set valid and invalid buffer numbers to be used in content updates
1.1459 +@SYMTestExpectedResults
1.1460 + For valid buffers, the read buffers should be set correctly and observer
1.1461 + callback method is called.
1.1462 + **/
1.1463 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0108L(TInt aBuffers)
1.1464 + {
1.1465 + aBuffers = 3;
1.1466 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.1467 + TRAPD(err, GrowCleanupStackL());
1.1468 + ASSERT_TRUE(err == KErrNone);
1.1469 +
1.1470 + iScreenNo = 0;
1.1471 + TInt localNumber = 0;
1.1472 +
1.1473 + TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, aBuffers);
1.1474 + ASSERT_FALSE(surface.IsNull());
1.1475 +
1.1476 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.1477 + SymbianStreamType ns;
1.1478 + err = SymbianStreamAcquire(&surface,&ns);
1.1479 + ASSERT_TRUE(err == KErrNone);
1.1480 + ASSERT_TRUE(ns);
1.1481 +
1.1482 + err = SymbianStreamAddObserver(ns, TestUpdateCallback, &localNumber);
1.1483 + ASSERT_TRUE(err == KErrNone);
1.1484 + khronos_int32_t bufferIndex = 0;
1.1485 + khronos_int32_t buffersIndex = 0;
1.1486 + khronos_int32_t lastValidBufnum = 0;
1.1487 +
1.1488 + const TSurfaceId* getId = NULL;
1.1489 + CExtensionContainer* updateExtension = NULL;
1.1490 + err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast<void**>(&updateExtension));
1.1491 + ASSERT_TRUE(err == KErrNone);
1.1492 + MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface<MCompositionSurfaceUpdate>();
1.1493 + ASSERT_NOT_NULL(updateProxy);
1.1494 + // Valid inputs
1.1495 + for (TInt i = 0; i < aBuffers; ++i)
1.1496 + {
1.1497 + buffersIndex = (aBuffers + i) % aBuffers;
1.1498 +
1.1499 +
1.1500 + updateProxy->ContentUpdated(surface, //aSurface
1.1501 + buffersIndex, //aBuffer
1.1502 + NULL, //aRegion
1.1503 + NULL, //aStatusConsumed
1.1504 + NULL, //aStatusDisplayed
1.1505 + NULL, //aTimeStamp
1.1506 + NULL, //aStatusDispXTimes
1.1507 + NULL //aDisplayedXTimes
1.1508 + );
1.1509 +
1.1510 + // 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
1.1511 + User::After(10000); //10 ms delay
1.1512 + khronos_int32_t readBuffer;
1.1513 + err = SymbianStreamAcquireReadBuffer(ns,&readBuffer);
1.1514 + ASSERT_TRUE(err == KErrNone);
1.1515 + err = SymbianStreamGetBufferId(ns,readBuffer,&bufferIndex,&getId);
1.1516 + ASSERT_TRUE(err == KErrNone);
1.1517 + err = SymbianStreamReleaseReadBuffer(ns, readBuffer);
1.1518 + ASSERT_TRUE(err == KErrNone);
1.1519 + ASSERT_TRUE(bufferIndex == buffersIndex);
1.1520 +
1.1521 + // 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
1.1522 + User::After(10000); //10 ms delay
1.1523 + ASSERT_EQUALS((i+1),localNumber);
1.1524 + }
1.1525 +
1.1526 + // Reset number for negative tests
1.1527 + localNumber = 0;
1.1528 + lastValidBufnum = buffersIndex;
1.1529 +
1.1530 + // Invalid inputs
1.1531 + TInt invalidBuffersIndex[] = {-1, -256, aBuffers+29, 10000, -10000, aBuffers};
1.1532 + TInt size = sizeof(invalidBuffersIndex) / sizeof(invalidBuffersIndex[0]);
1.1533 +
1.1534 + for (TInt i = 0; i < size; ++i)
1.1535 + {
1.1536 + updateProxy->ContentUpdated(surface, //aSurface
1.1537 + invalidBuffersIndex[i], //aBuffer
1.1538 + NULL, //aRegion
1.1539 + NULL, //aStatusConsumed
1.1540 + NULL, //aStatusDisplayed
1.1541 + NULL, //aTimeStamp
1.1542 + NULL, //aStatusDispXTimes
1.1543 + NULL //aDisplayedXTimes
1.1544 + );
1.1545 +
1.1546 + User::After(10000); //10 ms delay
1.1547 + khronos_int32_t readBuffer;
1.1548 + err = SymbianStreamAcquireReadBuffer(ns,&readBuffer);
1.1549 + ASSERT_TRUE(err == KErrNone);
1.1550 + err = SymbianStreamGetBufferId(ns,readBuffer,&bufferIndex,&getId);
1.1551 + ASSERT_TRUE(err == KErrNone);
1.1552 + err = SymbianStreamReleaseReadBuffer(ns, readBuffer);
1.1553 + ASSERT_TRUE(err == KErrNone);
1.1554 + ASSERT_TRUE(bufferIndex == lastValidBufnum);
1.1555 + ASSERT_EQUALS(0,localNumber);
1.1556 + }
1.1557 + SymbianStreamRemoveReference(ns);
1.1558 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.1559 + }
1.1560 +
1.1561 +/**
1.1562 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0109
1.1563 +@SYMTestCaseDesc Test multiple acquire/release read/write buffer calls
1.1564 +@SYMREQ
1.1565 +@SYMPREQ PREQ2400
1.1566 +@SYMTestType CT
1.1567 +@SYMTestPriority
1.1568 +@SYMTestPurpose Verify the buffer index is correctly set
1.1569 +@SYMTestActions
1.1570 + Create a surface with 4 buffers,
1.1571 + Call acquire/release read/write buffer functions and to Submit an update to the surface
1.1572 +@SYMTestExpectedResults
1.1573 + Verify that acquire/release read/write buffer functions honour SUS update
1.1574 + Verify that the update callback function is called when the native stream is updated
1.1575 + **/
1.1576 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0109L()
1.1577 + {
1.1578 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.1579 + TRAPD(err, GrowCleanupStackL());
1.1580 + ASSERT_TRUE(err == KErrNone);
1.1581 +
1.1582 + iScreenNo = 0;
1.1583 + TInt localNumber = 0;
1.1584 + TInt count = 0;
1.1585 + khronos_int32_t bufferIndexRead;
1.1586 + khronos_int32_t bufferIndexWrite;
1.1587 +
1.1588 + TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4);
1.1589 + ASSERT_FALSE(surface.IsNull());
1.1590 +
1.1591 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.1592 + SymbianStreamType ns;
1.1593 + err = SymbianStreamAcquire(&surface,&ns);
1.1594 + ASSERT_TRUE(err == KErrNone);
1.1595 + ASSERT_TRUE(ns);
1.1596 +
1.1597 + err = SymbianStreamAddObserver(ns, TestComposedCallback, &localNumber);
1.1598 + ASSERT_TRUE(err == KErrNone);
1.1599 + err = SymbianStreamAddObserver(ns, TestUpdateCallback, &localNumber);
1.1600 + ASSERT_TRUE(err == KErrNone);
1.1601 +
1.1602 + khronos_int32_t readBuffer1;
1.1603 + err = SymbianStreamAcquireReadBuffer(ns,&readBuffer1);
1.1604 + ASSERT_TRUE(err == KErrNone);
1.1605 + const TSurfaceId* getId = NULL;
1.1606 + err = SymbianStreamGetBufferId(ns,readBuffer1,&bufferIndexRead,&getId);
1.1607 + ASSERT_TRUE(err == KErrNone);
1.1608 + err = SymbianStreamReleaseReadBuffer(ns, readBuffer1);
1.1609 + ASSERT_TRUE(err == KErrNone);
1.1610 + ASSERT_TRUE(bufferIndexRead == 0);
1.1611 +
1.1612 + khronos_int32_t writeBuffer1;
1.1613 + err = SymbianStreamAcquireWriteBuffer(ns,&writeBuffer1);
1.1614 + ASSERT_TRUE(err == KErrNone);
1.1615 +
1.1616 + khronos_int32_t readBuffer2;
1.1617 + err = SymbianStreamAcquireReadBuffer(ns,&readBuffer2);
1.1618 + ASSERT_TRUE(err == KErrNone);
1.1619 + err = SymbianStreamGetBufferId(ns,readBuffer2,&bufferIndexRead,&getId);
1.1620 + ASSERT_TRUE(err == KErrNone);
1.1621 + err = SymbianStreamReleaseReadBuffer(ns, readBuffer2);
1.1622 + ASSERT_TRUE(err == KErrNone);
1.1623 + ASSERT_TRUE(bufferIndexRead == 0);
1.1624 + err = SymbianStreamReleaseWriteBuffer(ns,writeBuffer1);
1.1625 + ASSERT_TRUE(err == KErrNone);
1.1626 +
1.1627 + ASSERT_EQUALS((++count),localNumber);
1.1628 +
1.1629 + khronos_int32_t readBuffer3;
1.1630 + err = SymbianStreamAcquireReadBuffer(ns,&readBuffer3);
1.1631 + ASSERT_TRUE(err == KErrNone);
1.1632 + err = SymbianStreamGetBufferId(ns,readBuffer3,&bufferIndexRead,&getId);
1.1633 + ASSERT_TRUE(err == KErrNone);
1.1634 + err = SymbianStreamReleaseReadBuffer(ns, readBuffer3);
1.1635 + ASSERT_TRUE(err == KErrNone);
1.1636 + ASSERT_TRUE(bufferIndexRead == 1);
1.1637 +
1.1638 + khronos_int32_t writeBuffer2;
1.1639 + err = SymbianStreamAcquireWriteBuffer(ns,&writeBuffer2);
1.1640 + ASSERT_TRUE(err == KErrNone);
1.1641 + err = SymbianStreamGetBufferId(ns,writeBuffer2,&bufferIndexWrite,&getId);
1.1642 + ASSERT_TRUE(err == KErrNone);
1.1643 + ASSERT_TRUE((bufferIndexRead + 1) == bufferIndexWrite);
1.1644 +
1.1645 + khronos_int32_t readBuffer4;
1.1646 + err = SymbianStreamAcquireReadBuffer(ns,&readBuffer4);
1.1647 + ASSERT_TRUE(err == KErrNone);
1.1648 + err = SymbianStreamGetBufferId(ns,readBuffer4,&bufferIndexRead,&getId);
1.1649 + ASSERT_TRUE(err == KErrNone);
1.1650 + err = SymbianStreamReleaseReadBuffer(ns, readBuffer4);
1.1651 + ASSERT_TRUE(err == KErrNone);
1.1652 + ASSERT_TRUE(bufferIndexRead == (bufferIndexWrite - 1));
1.1653 +
1.1654 + CExtensionContainer* updateExtension = NULL;
1.1655 + err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast<void**>(&updateExtension));
1.1656 + ASSERT_TRUE(err == KErrNone);
1.1657 + MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface<MCompositionSurfaceUpdate>();
1.1658 + ASSERT_NOT_NULL(updateProxy);
1.1659 +
1.1660 + updateProxy->ContentUpdated(surface, //aSurface
1.1661 + 0, //aBuffer
1.1662 + NULL, //aRegion
1.1663 + NULL, //aStatusConsumed
1.1664 + NULL, //aStatusDisplayed
1.1665 + NULL, //aTimeStamp
1.1666 + NULL, //aStatusDispXTimes
1.1667 + NULL //aDisplayedXTimes
1.1668 + );
1.1669 +
1.1670 + ASSERT_EQUALS((++count),localNumber);
1.1671 +
1.1672 + khronos_int32_t readBuffer5;
1.1673 + err = SymbianStreamAcquireReadBuffer(ns,&readBuffer5);
1.1674 + ASSERT_TRUE(err == KErrNone);
1.1675 + err = SymbianStreamGetBufferId(ns,readBuffer5,&bufferIndexRead,&getId);
1.1676 + ASSERT_TRUE(err == KErrNone);
1.1677 + err = SymbianStreamReleaseReadBuffer(ns, readBuffer5);
1.1678 + ASSERT_TRUE(err == KErrNone);
1.1679 + ASSERT_TRUE(bufferIndexRead == 0);
1.1680 + err = SymbianStreamReleaseWriteBuffer(ns,writeBuffer2);
1.1681 + ASSERT_TRUE(err == KErrNone);
1.1682 +
1.1683 + ASSERT_EQUALS((++count),localNumber);
1.1684 +
1.1685 + khronos_int32_t readBuffer6;
1.1686 + err = SymbianStreamAcquireReadBuffer(ns,&readBuffer6);
1.1687 + ASSERT_TRUE(err == KErrNone);
1.1688 + err = SymbianStreamGetBufferId(ns,readBuffer6,&bufferIndexRead,&getId);
1.1689 + ASSERT_TRUE(err == KErrNone);
1.1690 + err = SymbianStreamReleaseReadBuffer(ns, readBuffer6);
1.1691 + ASSERT_TRUE(err == KErrNone);
1.1692 + ASSERT_TRUE(bufferIndexRead == 0);
1.1693 +
1.1694 + khronos_int32_t writeBuffer3;
1.1695 + err = SymbianStreamAcquireWriteBuffer(ns,&writeBuffer3);
1.1696 + ASSERT_TRUE(err == KErrNone);
1.1697 + err = SymbianStreamGetBufferId(ns,writeBuffer3,&bufferIndexWrite,&getId);
1.1698 + ASSERT_TRUE(err == KErrNone);
1.1699 + ASSERT_TRUE(bufferIndexWrite == 1);
1.1700 + err = SymbianStreamReleaseWriteBuffer(ns,writeBuffer3);
1.1701 + ASSERT_TRUE(err == KErrNone);
1.1702 +
1.1703 + khronos_int32_t readBuffer7;
1.1704 + err = SymbianStreamAcquireReadBuffer(ns,&readBuffer7);
1.1705 + ASSERT_TRUE(err == KErrNone);
1.1706 + err = SymbianStreamGetBufferId(ns,readBuffer7,&bufferIndexRead,&getId);
1.1707 + ASSERT_TRUE(err == KErrNone);
1.1708 + err = SymbianStreamReleaseReadBuffer(ns, readBuffer7);
1.1709 + ASSERT_TRUE(err == KErrNone);
1.1710 + ASSERT_TRUE(bufferIndexRead == 1);
1.1711 +
1.1712 + SymbianStreamRemoveReference(ns);
1.1713 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.1714 + }
1.1715 +
1.1716 +/**
1.1717 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0110
1.1718 +@SYMTestCaseDesc Verify that the update observer callback function is called after a
1.1719 + acquireWriteBuffer/releaseWriteBuffer call.
1.1720 +@SYMREQ
1.1721 +@SYMPREQ PREQ2400
1.1722 +@SYMTestType CT
1.1723 +@SYMTestPriority
1.1724 +@SYMTestPurpose
1.1725 +@SYMTestActions
1.1726 + Create a surface with 1 buffer
1.1727 + Add an observer to listen out for content updates to the stream
1.1728 + Call acquire/release write buffer functions
1.1729 +@SYMTestExpectedResults
1.1730 + Verify that the release write buffer function notifies any observers listening and the
1.1731 + observer callback function is called.
1.1732 + **/
1.1733 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0110L()
1.1734 + {
1.1735 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.1736 + TRAPD(err, GrowCleanupStackL());
1.1737 + ASSERT_TRUE(err == KErrNone);
1.1738 +
1.1739 + TInt localNumber = 0;
1.1740 +
1.1741 + TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 1);
1.1742 + ASSERT_FALSE(surface.IsNull());
1.1743 +
1.1744 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.1745 + SymbianStreamType ns;
1.1746 + err = SymbianStreamAcquire(&surface,&ns);
1.1747 + ASSERT_TRUE(err == KErrNone);
1.1748 + ASSERT_TRUE(ns);
1.1749 +
1.1750 + err = SymbianStreamAddObserver(ns, TestComposedCallback, &localNumber);
1.1751 + ASSERT_TRUE(err == KErrNone);
1.1752 +
1.1753 + khronos_int32_t writeBuffer1;
1.1754 + err = SymbianStreamAcquireWriteBuffer(ns,&writeBuffer1);
1.1755 + ASSERT_TRUE(err == KErrNone);
1.1756 + err = SymbianStreamReleaseWriteBuffer(ns,writeBuffer1);
1.1757 + ASSERT_TRUE(err == KErrNone);
1.1758 +
1.1759 + if (localNumber == 0)
1.1760 + {
1.1761 + User::After(1000000);
1.1762 + }
1.1763 +
1.1764 + ASSERT_TRUE(localNumber == 1);
1.1765 + SymbianStreamRemoveReference(ns);
1.1766 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.1767 + }
1.1768 +
1.1769 +/**
1.1770 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0111
1.1771 +@SYMTestCaseDesc Tests various cases including some negative cases for Native Stream callbacks
1.1772 +@SYMREQ
1.1773 +@SYMPREQ PREQ2400
1.1774 +@SYMTestType CT
1.1775 +@SYMTestPriority
1.1776 +@SYMTestPurpose
1.1777 +@SYMTestActions
1.1778 + Create a surface with 1 buffer
1.1779 + Add an observer N times
1.1780 + Remove the same observer M (M <= N) times
1.1781 + Register Null observer
1.1782 + Unregister something that was never registered
1.1783 +@SYMTestExpectedResults
1.1784 + Verify that the observer is called (N - M) times
1.1785 + Verify that error case behaviour is correct
1.1786 + **/
1.1787 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0111L()
1.1788 + {
1.1789 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.1790 + TRAPD(err, GrowCleanupStackL());
1.1791 + ASSERT_TRUE(err == KErrNone);
1.1792 +
1.1793 + iScreenNo = 0;
1.1794 +
1.1795 + TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 1);
1.1796 + ASSERT_FALSE(surface.IsNull());
1.1797 +
1.1798 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.1799 + SymbianStreamType ns;
1.1800 + err = SymbianStreamAcquire(&surface,&ns);
1.1801 + ASSERT_TRUE(err == KErrNone);
1.1802 + ASSERT_TRUE(ns);
1.1803 +
1.1804 + TInt localNumber = 0;
1.1805 + err = SymbianStreamAddObserver(ns, NULL, &localNumber);
1.1806 + ASSERT_TRUE(err == KErrBadHandle);
1.1807 + err = SymbianStreamRemoveObserver(ns, &localNumber, ESOWF_EventComposed);
1.1808 + ASSERT_TRUE(err == KErrNotFound);
1.1809 + err = SymbianStreamRemoveObserver(ns, NULL, ESOWF_EventComposed);
1.1810 + ASSERT_TRUE(err == KErrNotFound);
1.1811 + err = SymbianStreamAddObserver(ns, TestUpdateCallback, &localNumber);
1.1812 + ASSERT_TRUE(err == KErrNone);
1.1813 + err = SymbianStreamRemoveObserver(ns, &localNumber, ESOWF_EventUpdated);
1.1814 + ASSERT_TRUE(err == KErrNone);
1.1815 + err = SymbianStreamRemoveObserver(ns, &localNumber, ESOWF_EventUpdated);
1.1816 + ASSERT_TRUE(err == KErrNotFound);
1.1817 +
1.1818 +#define N_TIMES 7
1.1819 +#define M_TIMES 3
1.1820 +
1.1821 + localNumber = 0;
1.1822 + TInt k = N_TIMES;
1.1823 + while (k--)
1.1824 + {
1.1825 + err = SymbianStreamAddObserver(ns, TestUpdateCallback, &localNumber);
1.1826 + ASSERT_TRUE(err != KErrBadHandle);
1.1827 + }
1.1828 + k = M_TIMES;
1.1829 +
1.1830 + CExtensionContainer* updateExtension = NULL;
1.1831 + err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast<void**>(&updateExtension));
1.1832 + ASSERT_TRUE(err == KErrNone);
1.1833 + MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface<MCompositionSurfaceUpdate>();
1.1834 + ASSERT_NOT_NULL(updateProxy);
1.1835 +
1.1836 + updateProxy->ContentUpdated(surface, //aSurface
1.1837 + 0, //aBuffer
1.1838 + NULL, //aRegion
1.1839 + NULL, //aStatusConsumed
1.1840 + NULL, //aStatusDisplayed
1.1841 + NULL, //aTimeStamp
1.1842 + NULL, //aStatusDispXTimes
1.1843 + NULL //aDisplayedXTimes
1.1844 + );
1.1845 +
1.1846 + User::After(10000);
1.1847 + ASSERT_TRUE(localNumber == 1);
1.1848 +
1.1849 + while (k--)
1.1850 + {
1.1851 + err = SymbianStreamRemoveObserver(ns, &localNumber, ESOWF_EventUpdated);
1.1852 + ASSERT_TRUE(err != KErrBadHandle);
1.1853 + }
1.1854 +
1.1855 + updateProxy->ContentUpdated(surface, //aSurface
1.1856 + 0, //aBuffer
1.1857 + NULL, //aRegion
1.1858 + NULL, //aStatusConsumed
1.1859 + NULL, //aStatusDisplayed
1.1860 + NULL, //aTimeStamp
1.1861 + NULL, //aStatusDispXTimes
1.1862 + NULL //aDisplayedXTimes
1.1863 + );
1.1864 +
1.1865 + ASSERT_TRUE(localNumber == 1);
1.1866 +
1.1867 + SymbianStreamRemoveReference(ns);
1.1868 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.1869 + }
1.1870 +
1.1871 +/**
1.1872 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0112
1.1873 +@SYMTestCaseDesc Tests multithreaded cases for Native Stream callbacks
1.1874 +@SYMREQ
1.1875 +@SYMPREQ PREQ2400
1.1876 +@SYMTestType CT
1.1877 +@SYMTestPriority
1.1878 +@SYMTestPurpose
1.1879 +@SYMTestActions
1.1880 + Create 3 threads and call add, remove, notify observers from
1.1881 + respective threads multiple times
1.1882 +@SYMTestExpectedResults
1.1883 + Verify that the observers work correctly in multithreaded environment
1.1884 + **/
1.1885 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0112_1L()
1.1886 + {
1.1887 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.1888 + TRAPD(err, GrowCleanupStackL());
1.1889 + ASSERT_TRUE(err == KErrNone);
1.1890 +
1.1891 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.1892 +
1.1893 + INFO_PRINTF1(_L("GRAPHICS_OPENWFC_NATIVESTREAM_0112_1L: Thread 1 start, Register Observer"));
1.1894 + TSurfaceId surface = gVarInstance.SurfaceID();
1.1895 + SymbianStreamType ns;
1.1896 + err = SymbianStreamAcquire(&surface,&ns);
1.1897 + ASSERT_TRUE(err == KErrNone);
1.1898 + ASSERT_TRUE(ns);
1.1899 +
1.1900 + gVarInstance.iMultithreadCounter = 0;
1.1901 +
1.1902 + TTimeIntervalMicroSeconds32 delay(32000), zeroDelay(0);
1.1903 + while (delay >= zeroDelay)
1.1904 + {
1.1905 + INFO_PRINTF2(_L("Thread 1 is going to add another observer after %i microsecond"), delay.Int());
1.1906 + User::AfterHighRes(delay);
1.1907 + SymbianStreamAddObserver(ns, TestUpdateCallback, &gVarInstance.iMultithreadCounter);
1.1908 + delay = delay.Int() - 43;
1.1909 + }
1.1910 + TInt count = 50;
1.1911 + while (count--)
1.1912 + {
1.1913 + INFO_PRINTF1(_L("Thread 1 is going to add another observer without delay"));
1.1914 + SymbianStreamAddObserver(ns, TestUpdateCallback, &gVarInstance.iMultithreadCounter);
1.1915 + }
1.1916 + INFO_PRINTF1(_L("GRAPHICS_OPENWFC_NATIVESTREAM_0112_1L: Thread 1 exits"));
1.1917 +
1.1918 + SymbianStreamRemoveReference(ns);
1.1919 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.1920 + }
1.1921 +
1.1922 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0112_2L()
1.1923 + {
1.1924 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.1925 + TRAPD(err, GrowCleanupStackL());
1.1926 + ASSERT_TRUE(err == KErrNone);
1.1927 +
1.1928 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.1929 +
1.1930 + INFO_PRINTF1(_L("GRAPHICS_OPENWFC_NATIVESTREAM_0112_2L: Thread 2 start, Unregister Observer"));
1.1931 + TSurfaceId surface = gVarInstance.SurfaceID();
1.1932 + SymbianStreamType ns;
1.1933 + err = SymbianStreamAcquire(&surface,&ns);
1.1934 + ASSERT_TRUE(err == KErrNone);
1.1935 + ASSERT_TRUE(ns);
1.1936 +
1.1937 + TTimeIntervalMicroSeconds32 delay(32000), zeroDelay(0);
1.1938 + while (delay > zeroDelay)
1.1939 + {
1.1940 + INFO_PRINTF2(_L("Thread 2 is going to remove one observer after %i microsecond"), delay.Int());
1.1941 + User::AfterHighRes(delay);
1.1942 + SymbianStreamRemoveObserver(ns, &gVarInstance.iMultithreadCounter, ESOWF_EventUpdated);
1.1943 + delay = delay.Int() - 49;
1.1944 + }
1.1945 + TInt count = 50;
1.1946 + while (count--)
1.1947 + {
1.1948 + INFO_PRINTF1(_L("Thread 2 is going to remove one observer without delay"));
1.1949 + SymbianStreamRemoveObserver(ns, &gVarInstance.iMultithreadCounter, ESOWF_EventUpdated);
1.1950 + }
1.1951 + INFO_PRINTF1(_L("GRAPHICS_OPENWFC_NATIVESTREAM_0112_2L: Thread 2 exits"));
1.1952 + SymbianStreamRemoveReference(ns);
1.1953 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.1954 + }
1.1955 +
1.1956 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0112_3L()
1.1957 + {
1.1958 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.1959 + TRAPD(err, GrowCleanupStackL());
1.1960 + ASSERT_TRUE(err == KErrNone);
1.1961 +
1.1962 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.1963 +
1.1964 + INFO_PRINTF1(_L("GRAPHICS_OPENWFC_NATIVESTREAM_0112_2L: Thread 3 start, Notify Observer"));
1.1965 + TSurfaceId surface = gVarInstance.SurfaceID();
1.1966 + SymbianStreamType ns;
1.1967 + err = SymbianStreamAcquire(&surface,&ns);
1.1968 + ASSERT_TRUE(err == KErrNone);
1.1969 + ASSERT_TRUE(ns);
1.1970 +
1.1971 + khronos_int32_t bufferIndex;
1.1972 + TTimeIntervalMicroSeconds32 delay(32000), zeroDelay(0);
1.1973 + while (delay > zeroDelay)
1.1974 + {
1.1975 + khronos_int32_t writeBuffer;
1.1976 + err = SymbianStreamAcquireWriteBuffer(ns,&writeBuffer);
1.1977 + ASSERT_TRUE(err == KErrNone);
1.1978 + const TSurfaceId* getId = NULL;
1.1979 + err = SymbianStreamGetBufferId(ns,writeBuffer,&bufferIndex,&getId);
1.1980 + ASSERT_TRUE(err == KErrNone);
1.1981 + INFO_PRINTF2(_L("Thread 3 - Write buffer %i acquired"), bufferIndex);
1.1982 +
1.1983 + INFO_PRINTF2(_L("Thread 3 going to send notification after %i second"), delay.Int());
1.1984 + User::AfterHighRes(delay);
1.1985 + delay = delay.Int() - 58;
1.1986 + err = SymbianStreamReleaseWriteBuffer(ns, writeBuffer);
1.1987 + ASSERT_TRUE(err == KErrNone);
1.1988 + }
1.1989 + TInt count = 50;
1.1990 + while (count--)
1.1991 + {
1.1992 + khronos_int32_t writeBuffer;
1.1993 + err = SymbianStreamAcquireWriteBuffer(ns,&writeBuffer);
1.1994 + ASSERT_TRUE(err == KErrNone);
1.1995 + const TSurfaceId* getId = NULL;
1.1996 + err = SymbianStreamGetBufferId(ns,writeBuffer,&bufferIndex,&getId);
1.1997 + ASSERT_TRUE(err == KErrNone);
1.1998 + INFO_PRINTF2(_L("Thread 3 - Write buffer %i acquired"), bufferIndex);
1.1999 +
1.2000 + INFO_PRINTF1(_L("Thread 3 going to send notification without delay"));
1.2001 + err = SymbianStreamReleaseWriteBuffer(ns, writeBuffer);
1.2002 + ASSERT_TRUE(err == KErrNone);
1.2003 + }
1.2004 + INFO_PRINTF1(_L("GRAPHICS_OPENWFC_NATIVESTREAM_0112_2L: Thread 3 exits"));
1.2005 +
1.2006 + SymbianStreamRemoveReference(ns);
1.2007 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.2008 + }
1.2009 +
1.2010 +/**
1.2011 +Submit updates to the native stream whilst observers are being added and removed.
1.2012 +Do not run in parallel with 0112_3L
1.2013 +*/
1.2014 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0112_4L()
1.2015 + {
1.2016 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.2017 + TRAPD(err, GrowCleanupStackL());
1.2018 + ASSERT_TRUE(err == KErrNone);
1.2019 +
1.2020 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.2021 +
1.2022 + INFO_PRINTF1(_L("GRAPHICS_OPENWFC_NATIVESTREAM_0112_2L: Thread 3 start, Notify Observer"));
1.2023 +
1.2024 + TTimeIntervalMicroSeconds32 delay(32000), zeroDelay(0);
1.2025 +
1.2026 + iScreenNo = 0;
1.2027 + TRequestStatus displayedStatus, availableStatus, displayedXStatus;
1.2028 + TUint32 timeStamp = 0;
1.2029 + TInt bufferNo = 0;
1.2030 + TInt numBuffers = 2;
1.2031 + TInt displayedX = 5;
1.2032 +
1.2033 + CExtensionContainer* updateExtension = NULL;
1.2034 + err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast<void**>(&updateExtension));
1.2035 + ASSERT_TRUE(err == KErrNone);
1.2036 + MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface<MCompositionSurfaceUpdate>();
1.2037 + ASSERT_NOT_NULL(updateProxy);
1.2038 +
1.2039 + while (delay > zeroDelay)
1.2040 + {
1.2041 + INFO_PRINTF2(_L("Thread 0112_4 submitting update after %i second"), delay.Int());
1.2042 + User::AfterHighRes(delay);
1.2043 + delay = delay.Int() - 58;
1.2044 +
1.2045 + updateProxy->ContentUpdated(gVarInstance.SurfaceID(), //aSurface
1.2046 + bufferNo, //aBuffer
1.2047 + NULL, //aRegion
1.2048 + &availableStatus, //aStatusConsumed
1.2049 + &displayedStatus, //aStatusDisplayed
1.2050 + &timeStamp, //aTimeStamp
1.2051 + &displayedXStatus, //aStatusDispXTimes
1.2052 + &displayedX //aDisplayedXTimes
1.2053 + );
1.2054 +
1.2055 + bufferNo = (bufferNo + 1) % numBuffers;
1.2056 + }
1.2057 +
1.2058 + TInt count = 50;
1.2059 + while (count--)
1.2060 + {
1.2061 + INFO_PRINTF1(_L("Thread 0112_4 Set notifications"));
1.2062 + INFO_PRINTF1(_L("Thread 0112_4 submitting update without delay"));
1.2063 +
1.2064 + updateProxy->ContentUpdated(gVarInstance.SurfaceID(), //aSurface
1.2065 + bufferNo, //aBuffer
1.2066 + NULL, //aRegion
1.2067 + &availableStatus, //aStatusConsumed
1.2068 + &displayedStatus, //aStatusDisplayed
1.2069 + &timeStamp, //aTimeStamp
1.2070 + &displayedXStatus, //aStatusDispXTimes
1.2071 + &displayedX //aDisplayedXTimes
1.2072 + );
1.2073 +
1.2074 + bufferNo = (bufferNo + 1) % numBuffers;
1.2075 + }
1.2076 + INFO_PRINTF1(_L("GRAPHICS_OPENWFC_NATIVESTREAM_0112_4L: Thread exits"));
1.2077 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.2078 + }
1.2079 +
1.2080 +/**
1.2081 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0113
1.2082 +@SYMTestCaseDesc Test displayed notification
1.2083 +@SYMREQ
1.2084 +@SYMPREQ PREQ2400
1.2085 +@SYMTestType CT
1.2086 +@SYMTestPriority High
1.2087 +@SYMTestPurpose Tests an end to end displayed notification.
1.2088 +@SYMTestActions
1.2089 +
1.2090 + 1. Create a surface
1.2091 + 2. Create a native stream for the surface
1.2092 + 3. Register the test class as an observer for ESOWF_EventUpdated to act as a fake composer
1.2093 + 4. Register for displayed notifications
1.2094 + 5. Submit an update to the surface
1.2095 + 6. The observer function should be invoked and verifies that stream and event parameters.
1.2096 + 7. The tester simulates the end of a composition by firing owfNativeStreanProcessNotifications
1.2097 + 8. Wait on the displayed request status.
1.2098 + 9. Remove the source stream updated observer
1.2099 + 10. Destroy the native stream.
1.2100 +
1.2101 + The test is then repeated but the compositor claims the native stream is not visible.
1.2102 +
1.2103 +@SYMTestExpectedResults
1.2104 + No errors, displayed status completed with KErrNone.
1.2105 +
1.2106 + **/
1.2107 +
1.2108 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0113L()
1.2109 + {
1.2110 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.2111 + TRAPD(err, GrowCleanupStackL());
1.2112 + ASSERT_TRUE(err == KErrNone);
1.2113 +
1.2114 + iSourceStreamUpdatedCalled = 0;
1.2115 + iImmediateAvailable = EFalse;
1.2116 + iImmediateVisible = SYM_CONTENT_NOT_VISIBLE;
1.2117 + iContextUpdatedFlags = 0;
1.2118 + iScreenNo = 0;
1.2119 +
1.2120 + for (TInt i = 0; i < 2; ++i)
1.2121 + {
1.2122 + TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4);
1.2123 + ASSERT_FALSE(surface.IsNull());
1.2124 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.2125 +
1.2126 + CTestNativeStream::iTester = this;
1.2127 + TBool visible = (i == 0);
1.2128 +
1.2129 + RHeap* threadHeap3 = &User::Heap();
1.2130 + err = SymbianStreamAcquire(&surface,&iNs);
1.2131 + ASSERT_TRUE(err == KErrNone);
1.2132 + ASSERT_TRUE(iNs);
1.2133 +
1.2134 + iExpectedSourceStreamUpdatedEventMask = 0;
1.2135 + err = SymbianStreamAddObserver(iNs, SourceStreamUpdatedCallback, this);
1.2136 + ASSERT_TRUE(err == KErrNone);
1.2137 +
1.2138 + TRequestStatus statusDisplayed;
1.2139 + TUint32 displayedTime;
1.2140 +
1.2141 + CExtensionContainer* updateExtension = NULL;
1.2142 + err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast<void**>(&updateExtension));
1.2143 + ASSERT_TRUE(err == KErrNone);
1.2144 + MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface<MCompositionSurfaceUpdate>();
1.2145 + ASSERT_NOT_NULL(updateProxy);
1.2146 +
1.2147 + iSourceStreamUpdatedCalled = 0;
1.2148 + updateProxy->ContentUpdated(surface, //aSurface
1.2149 + 0, //aBuffer
1.2150 + NULL, //aRegion
1.2151 + NULL, //aStatusConsumed
1.2152 + &statusDisplayed, //aStatusDisplayed
1.2153 + &displayedTime, //aTimeStamp
1.2154 + NULL, //aStatusDispXTimes
1.2155 + NULL //aDisplayedXTimes
1.2156 + );
1.2157 +
1.2158 + ASSERT_TRUE(iSourceStreamUpdatedCalled == 1);
1.2159 + err = SymbianStreamRemoveObserver(iNs, this, ESOWF_EventUpdated);
1.2160 + ASSERT_TRUE(err == KErrNone);
1.2161 +
1.2162 + iExpectedSourceStreamUpdatedEventMask = ESOWF_EventDisplayed;
1.2163 + err = SymbianStreamAddExtendedObserver(iNs, SourceStreamUpdatedCallback, this, iScreenNo, ESOWF_EventUpdated);
1.2164 + ASSERT_TRUE(err == KErrNone);
1.2165 +
1.2166 + updateProxy->ContentUpdated(surface, //aSurface
1.2167 + 0, //aBuffer
1.2168 + NULL, //aRegion
1.2169 + NULL, //aStatusConsumed
1.2170 + &statusDisplayed, //aStatusDisplayed
1.2171 + &displayedTime, //aTimeStamp
1.2172 + NULL, //aStatusDispXTimes
1.2173 + NULL //aDisplayedXTimes
1.2174 + );
1.2175 +
1.2176 + ASSERT_TRUE(iSourceStreamUpdatedCalled);
1.2177 +
1.2178 + // Pretend that a composition has occured
1.2179 + ++iStreamUpdatedSerialNumber;
1.2180 + if (visible)
1.2181 + {
1.2182 + khronos_int32_t newNotificationsMask = 0;
1.2183 + SymbianStreamProcessNotifications(iNs,
1.2184 + ESOWF_EventDisplayed,
1.2185 + iScreenNo,
1.2186 + iStreamUpdatedSerialNumber,
1.2187 + &newNotificationsMask);
1.2188 +
1.2189 + // No updates during composition so newNotificationMask should still be zero
1.2190 + ASSERT_TRUE(newNotificationsMask == 0);
1.2191 + }
1.2192 + // Simulate multiple sources
1.2193 + SymbianStreamCheckVisible(iNs, ESOWF_EventDisplayed, iScreenNo, iStreamUpdatedSerialNumber);
1.2194 + SymbianStreamCheckVisible(iNs, ESOWF_EventDisplayed, iScreenNo, iStreamUpdatedSerialNumber);
1.2195 +
1.2196 + // Make sure displayed event was completed
1.2197 + User::WaitForRequest(statusDisplayed);
1.2198 + if (visible)
1.2199 + {
1.2200 + ASSERT_EQUALS(statusDisplayed.Int(), KErrNone);
1.2201 + }
1.2202 + else
1.2203 + {
1.2204 + ASSERT_EQUALS(statusDisplayed.Int(), KErrNotVisible);
1.2205 + }
1.2206 +
1.2207 + err = SymbianStreamRemoveObserver(iNs, this, ESOWF_EventUpdated);
1.2208 + ASSERT_TRUE(err == KErrNone);
1.2209 + SymbianStreamRemoveReference(iNs);
1.2210 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.2211 + iUtility->DestroySurface(surface);
1.2212 + }
1.2213 + }
1.2214 +
1.2215 +/**
1.2216 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0114
1.2217 +@SYMTestCaseDesc Test available notification
1.2218 +@SYMREQ
1.2219 +@SYMPREQ PREQ2400
1.2220 +@SYMTestType CT
1.2221 +@SYMTestPriority High
1.2222 +@SYMTestPurpose Tests an end to end available notification.
1.2223 +@SYMTestActions
1.2224 +
1.2225 + 1. Create a surface
1.2226 + 2. Create a native stream for the surface
1.2227 + 3. Register the test class as an observer for ESOWF_EventUpdated to act as a fake composer
1.2228 + 4. Register for displayed notifications
1.2229 + 5. Submit an update to the surface
1.2230 + 6. The observer function should be invoked and verifies that stream and event parameters.
1.2231 + 7. The tester simulates the end of a composition by firing owfNativeStreanProcessNotifications
1.2232 + 8. Verify that available notification has not been sent.
1.2233 + 9. Send another display update to change the read buffer to buffer 1
1.2234 + 10. Verify that the source-stream updated callback is invoked.
1.2235 + 11. The tester simulates the end of a composition by firing owfNativeStreanProcessNotifications
1.2236 + 12. Wait for available status to be completed
1.2237 + 13. Remove the source stream updated observer
1.2238 + 14. Destroy the native stream.
1.2239 +
1.2240 + The test is then repeated but the compositor claims the native stream is not visible.
1.2241 +
1.2242 +@SYMTestExpectedResults
1.2243 + No errors, available status completed with KErrNone.
1.2244 +
1.2245 + **/
1.2246 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0114L()
1.2247 + {
1.2248 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.2249 + TRAPD(err, GrowCleanupStackL());
1.2250 + ASSERT_TRUE(err == KErrNone);
1.2251 +
1.2252 + iScreenNo = 0;
1.2253 + iContextUpdatedFlags = 0;
1.2254 + iStreamUpdatedSerialNumber = 1;
1.2255 + iSourceStreamUpdatedCalled = 0;
1.2256 + // during compositio or first time after a commit
1.2257 + iImmediateAvailable = EFalse;
1.2258 + iImmediateVisible = SYM_CONTENT_VISIBLE;
1.2259 +
1.2260 + for (TInt i = 0; i < 2; ++i)
1.2261 + {
1.2262 + TBool visible = (i == 0);
1.2263 + TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4);
1.2264 + ASSERT_FALSE(surface.IsNull());
1.2265 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.2266 +
1.2267 + CTestNativeStream::iTester = this;
1.2268 +
1.2269 + err = SymbianStreamAcquire(&surface,&iNs);
1.2270 + ASSERT_TRUE(err == KErrNone);
1.2271 + ASSERT_TRUE(iNs);
1.2272 +
1.2273 + err = SymbianStreamAddExtendedObserver(iNs, SourceStreamUpdatedCallback, this, iScreenNo, ESOWF_EventUpdated);
1.2274 + ASSERT_TRUE(err == KErrNone);
1.2275 +
1.2276 + TRequestStatus statusAvailable;
1.2277 + iSourceStreamUpdatedCalled = 0;
1.2278 +
1.2279 + CExtensionContainer* updateExtension = NULL;
1.2280 + err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast<void**>(&updateExtension));
1.2281 + ASSERT_TRUE(err == KErrNone);
1.2282 + MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface<MCompositionSurfaceUpdate>();
1.2283 + ASSERT_NOT_NULL(updateProxy);
1.2284 +
1.2285 + ASSERT_TRUE(iSourceStreamUpdatedCalled == 0);
1.2286 +
1.2287 + iExpectedSourceStreamUpdatedEventMask = 0;
1.2288 + //we are during a composition
1.2289 + ++iStreamUpdatedSerialNumber;
1.2290 + updateProxy->ContentUpdated(surface, //aSurface
1.2291 + 0, //aBuffer
1.2292 + NULL, //aRegion
1.2293 + &statusAvailable, //aStatusConsumed
1.2294 + NULL, //aStatusDisplayed
1.2295 + NULL, //aTimeStamp
1.2296 + NULL, //aStatusDispXTimes
1.2297 + NULL //aDisplayedXTimes
1.2298 + );
1.2299 +
1.2300 + // Verify that the context's callback is invoked when SubmitUpdate is called.
1.2301 + ASSERT_TRUE(iSourceStreamUpdatedCalled == 2);
1.2302 +
1.2303 + // Available should only be compled when submit update is called with a different buffer no.
1.2304 + // if the stream is multi-buffered.
1.2305 + ASSERT_EQUALS(statusAvailable.Int(), KRequestPending);
1.2306 +
1.2307 + // Pretend that a composition has occured
1.2308 + khronos_int32_t newNotificationsMask = 0;
1.2309 + if (visible)
1.2310 + {
1.2311 + SymbianStreamProcessNotifications(iNs,
1.2312 + 0,
1.2313 + iScreenNo,
1.2314 + iStreamUpdatedSerialNumber,
1.2315 + &newNotificationsMask);
1.2316 +
1.2317 + // No updates during composition so newNotificationMask should still be zero
1.2318 + ASSERT_TRUE(newNotificationsMask == 0);
1.2319 + SymbianStreamProcessNotifications(iNs,
1.2320 + 0,
1.2321 + iScreenNo,
1.2322 + iStreamUpdatedSerialNumber,
1.2323 + &newNotificationsMask);
1.2324 +
1.2325 + // No updates during composition so newNotificationMask should still be zero
1.2326 + ASSERT_TRUE(newNotificationsMask == 0);
1.2327 + }
1.2328 + SymbianStreamCheckVisible(iNs, ESOWF_EventAvailable, iScreenNo, iStreamUpdatedSerialNumber);
1.2329 + SymbianStreamCheckVisible(iNs, ESOWF_EventAvailable, iScreenNo, iStreamUpdatedSerialNumber);
1.2330 +
1.2331 + // Available for buffer zero should not be completed yet
1.2332 + ASSERT_EQUALS(statusAvailable.Int(), KRequestPending);
1.2333 +
1.2334 + // Update and switch to buffer 1
1.2335 + iExpectedSourceStreamUpdatedEventMask = ESOWF_EventAvailable;
1.2336 + //we are during a composition
1.2337 + ++iStreamUpdatedSerialNumber;
1.2338 + updateProxy->ContentUpdated(surface, //aSurface
1.2339 + 1, //aBuffer
1.2340 + NULL, //aRegion
1.2341 + NULL, //aStatusConsumed
1.2342 + NULL, //aStatusDisplayed
1.2343 + NULL, //aTimeStamp
1.2344 + NULL, //aStatusDispXTimes
1.2345 + NULL //aDisplayedXTimes
1.2346 + );
1.2347 +
1.2348 + ASSERT_TRUE(iSourceStreamUpdatedCalled == 4);
1.2349 +
1.2350 + // Consume update on buffer 1. This should make buffer 0 available
1.2351 + if (visible)
1.2352 + {
1.2353 + SymbianStreamProcessNotifications(iNs,
1.2354 + ESOWF_EventAvailable,
1.2355 + iScreenNo,
1.2356 + iStreamUpdatedSerialNumber,
1.2357 + &newNotificationsMask);
1.2358 +
1.2359 + ASSERT_TRUE(newNotificationsMask == 0);
1.2360 +
1.2361 + SymbianStreamProcessNotifications(iNs,
1.2362 + 0,
1.2363 + iScreenNo,
1.2364 + ++iStreamUpdatedSerialNumber,
1.2365 + &newNotificationsMask);
1.2366 + ASSERT_TRUE(newNotificationsMask == 0);
1.2367 + }
1.2368 + SymbianStreamCheckVisible(iNs, ESOWF_EventAvailable, iScreenNo, iStreamUpdatedSerialNumber);
1.2369 + SymbianStreamCheckVisible(iNs, ESOWF_EventAvailable, iScreenNo, iStreamUpdatedSerialNumber);
1.2370 +
1.2371 + // Make sure displayed event was completed
1.2372 + User::WaitForRequest(statusAvailable);
1.2373 + if (visible)
1.2374 + {
1.2375 + ASSERT_EQUALS(statusAvailable.Int(), KErrNone);
1.2376 + }
1.2377 + else
1.2378 + {
1.2379 + ASSERT_EQUALS(statusAvailable.Int(), KErrNotVisible);
1.2380 + }
1.2381 +
1.2382 + err = SymbianStreamRemoveObserver(iNs, this, ESOWF_EventUpdated);
1.2383 + ASSERT_TRUE(err == KErrNone);
1.2384 + SymbianStreamRemoveReference(iNs);
1.2385 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.2386 + iUtility->DestroySurface(surface);
1.2387 + }
1.2388 + }
1.2389 +
1.2390 +/**
1.2391 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0115
1.2392 +@SYMTestCaseDesc Test displayed x times notification
1.2393 +@SYMREQ
1.2394 +@SYMPREQ PREQ2400
1.2395 +@SYMTestType CT
1.2396 +@SYMTestPriority High
1.2397 +@SYMTestPurpose Verify that the surface stream adaptation processes displayed x times
1.2398 + notifications correctly.
1.2399 +@SYMTestActions
1.2400 +
1.2401 + 1. Create a surface
1.2402 + 2. Create a native stream for the surface
1.2403 + 3. Register the test class as an observer for ESOWF_EventUpdated to act as a fake composer
1.2404 + 4. Register for displayed notifications
1.2405 + 5. Submit an update to the surface
1.2406 + 6. The observer function should be invoked and verifies that stream and event parameters.
1.2407 + 7. The tester simulates the end of a composition by firing SymbianStreamProcessNotifications
1.2408 + 8. If X has not been reached yet verify that displayed x status is not completed then goto 6.
1.2409 + Otherwise, goto step 9.
1.2410 + 9. Verify displayed-x-times status is completed with KErrNone
1.2411 + 10. Remove the observer
1.2412 + 11. Destroy the native stream.
1.2413 +
1.2414 + The test is then repeated but the compositor claims the native stream is not visible.
1.2415 +
1.2416 +@SYMTestExpectedResults
1.2417 + No errors, displayed-x-times status completed with KErrNone.
1.2418 +
1.2419 +*/
1.2420 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0115L()
1.2421 + {
1.2422 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.2423 + TRAPD(err, GrowCleanupStackL());
1.2424 + ASSERT_TRUE(err == KErrNone);
1.2425 +
1.2426 + iScreenNo = 0;
1.2427 + iContextUpdatedFlags = 0;
1.2428 + iStreamUpdatedSerialNumber = 1;
1.2429 + iImmediateAvailable = EFalse;
1.2430 + iImmediateVisible = SYM_CONTENT_VISIBLE;
1.2431 +
1.2432 + for (TInt i = 0; i < 2; ++i)
1.2433 + {
1.2434 + TBool visible = (i == 0);
1.2435 + iSourceStreamUpdatedCalled = 0;
1.2436 + TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4);
1.2437 + ASSERT_FALSE(surface.IsNull());
1.2438 +
1.2439 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.2440 + err = SymbianStreamAcquire(&surface, &iNs);
1.2441 + ASSERT_TRUE(err == KErrNone);
1.2442 + ASSERT_TRUE(iNs);
1.2443 +
1.2444 + err = SymbianStreamAddExtendedObserver(iNs, SourceStreamUpdatedCallback, this, iScreenNo, ESOWF_EventUpdated);
1.2445 + ASSERT_TRUE(err == KErrNone);
1.2446 +
1.2447 + TRequestStatus statusDisplayedX;
1.2448 + TInt X = 5;
1.2449 +
1.2450 + CExtensionContainer* updateExtension = NULL;
1.2451 + err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast<void**>(&updateExtension));
1.2452 + ASSERT_TRUE(err == KErrNone);
1.2453 + MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface<MCompositionSurfaceUpdate>();
1.2454 + ASSERT_NOT_NULL(updateProxy);
1.2455 +
1.2456 + iExpectedSourceStreamUpdatedEventMask = ESOWF_EventDisplayedX;
1.2457 +
1.2458 + updateProxy->ContentUpdated(surface, //aSurface
1.2459 + 0, //aBuffer
1.2460 + NULL, //aRegion
1.2461 + NULL, //aStatusConsumed
1.2462 + NULL, //aStatusDisplayed
1.2463 + NULL, //aTimeStamp
1.2464 + &statusDisplayedX, //aStatusDispXTimes
1.2465 + &X //aDisplayedXTimes
1.2466 + );
1.2467 +
1.2468 + ASSERT_TRUE(iSourceStreamUpdatedCalled == 2);
1.2469 +
1.2470 +
1.2471 + khronos_int32_t events = ESOWF_EventDisplayedX;
1.2472 + for (TInt i = 0; i < X; ++i)
1.2473 + {
1.2474 + // Pretend that a composition has occured
1.2475 + ++iStreamUpdatedSerialNumber;
1.2476 +
1.2477 + if (visible)
1.2478 + {
1.2479 + khronos_int32_t newNotificationsMask = 0;
1.2480 + SymbianStreamProcessNotifications(iNs,
1.2481 + events,
1.2482 + iScreenNo,
1.2483 + iStreamUpdatedSerialNumber,
1.2484 + &newNotificationsMask);
1.2485 +
1.2486 + SymbianStreamCheckVisible(iNs, events, iScreenNo, iStreamUpdatedSerialNumber);
1.2487 + SymbianStreamCheckVisible(iNs, events, iScreenNo, iStreamUpdatedSerialNumber);
1.2488 +
1.2489 + if (i < X -1)
1.2490 + {
1.2491 + ASSERT_TRUE(newNotificationsMask == ESOWF_EventDisplayedX);
1.2492 + ASSERT_EQUALS(statusDisplayedX.Int(), KRequestPending);
1.2493 + }
1.2494 + else
1.2495 + {
1.2496 + ASSERT_TRUE(newNotificationsMask == 0);
1.2497 + User::WaitForRequest(statusDisplayedX);
1.2498 + ASSERT_EQUALS(statusDisplayedX.Int(), KErrNone);
1.2499 + }
1.2500 + }
1.2501 + else
1.2502 + {
1.2503 + SymbianStreamCheckVisible(iNs, events, iScreenNo, iStreamUpdatedSerialNumber);
1.2504 + SymbianStreamCheckVisible(iNs, events, iScreenNo, iStreamUpdatedSerialNumber);
1.2505 + User::WaitForRequest(statusDisplayedX);
1.2506 + ASSERT_EQUALS(statusDisplayedX.Int(), KErrNotVisible);
1.2507 + break;
1.2508 + }
1.2509 + }
1.2510 +
1.2511 + err = SymbianStreamRemoveObserver(iNs, this, ESOWF_EventUpdated);
1.2512 + ASSERT_TRUE(err == KErrNone);
1.2513 + SymbianStreamRemoveReference(iNs);
1.2514 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.2515 +
1.2516 + iUtility->DestroySurface(surface);
1.2517 + }
1.2518 + }
1.2519 +
1.2520 +
1.2521 +/**
1.2522 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0116
1.2523 +@SYMTestCaseDesc Test all notifications together
1.2524 +@SYMREQ
1.2525 +@SYMPREQ PREQ2400
1.2526 +@SYMTestType CT
1.2527 +@SYMTestPriority High
1.2528 +@SYMTestPurpose Verify that the surface stream adaptation processes displayed x times
1.2529 + notifications correctly.
1.2530 +@SYMTestActions
1.2531 +
1.2532 + 1. Create a surface
1.2533 + 2. Create a native stream for the surface
1.2534 + 3. Register the test class as an observer for ESOWF_EventUpdated to act as a fake composer
1.2535 + 4. Register available, displayed and displayed-x-times notifications.
1.2536 + 5. Submit an update to the surface
1.2537 + 6. Wait for the displayed notification to complete.
1.2538 + 7. The observer function should be invoked and verifies that stream and event parameters.
1.2539 + 8. The tester simulates the end of a composition by firing SymbianStreamProcessNotifications
1.2540 + 9. If X has not been reached yet verify that displayedx and available status is not completed
1.2541 + then goto 5; otherwise, goto step 11.
1.2542 + 10. Verify displayed-x-times status is completed with KErrNone
1.2543 + 11. Submit an update on a different buffer number
1.2544 + 12. The tester simulates the end of a composition by firing SymbianStreamProcessNotifications
1.2545 + 13. Verify that the available status is completed with KErrNone
1.2546 + 14. Destroy the native stream.
1.2547 +
1.2548 +@SYMTestExpectedResults
1.2549 + No errors, displayed-x-times status completed with KErrNone.
1.2550 +
1.2551 +*/
1.2552 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0116L()
1.2553 + {
1.2554 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.2555 + TRAPD(err, GrowCleanupStackL());
1.2556 + ASSERT_TRUE(err == KErrNone);
1.2557 +
1.2558 + iScreenNo = 0;
1.2559 + iContextUpdatedFlags = 0;
1.2560 + iStreamUpdatedSerialNumber = 1;
1.2561 + iSourceStreamUpdatedCalled = 0;
1.2562 + iImmediateAvailable = EFalse;
1.2563 + iImmediateVisible = SYM_CONTENT_VISIBLE;
1.2564 +
1.2565 + TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4);
1.2566 + ASSERT_FALSE(surface.IsNull());
1.2567 +
1.2568 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.2569 + err = SymbianStreamAcquire(&surface, &iNs);
1.2570 + ASSERT_TRUE(err == KErrNone);
1.2571 + ASSERT_TRUE(iNs);
1.2572 +
1.2573 + err = SymbianStreamAddExtendedObserver(iNs, SourceStreamUpdatedCallback, this, iScreenNo, ESOWF_EventUpdated);
1.2574 + ASSERT_TRUE(err == KErrNone);
1.2575 +
1.2576 + TRequestStatus statusDisplayedX;
1.2577 + TRequestStatus statusAvailable;
1.2578 + TRequestStatus statusDisplayed;
1.2579 +
1.2580 + TInt X = 5;
1.2581 + TUint32 displayedTime = 0;
1.2582 +
1.2583 + CExtensionContainer* updateExtension = NULL;
1.2584 + err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast<void**>(&updateExtension));
1.2585 + ASSERT_TRUE(err == KErrNone);
1.2586 + MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface<MCompositionSurfaceUpdate>();
1.2587 + ASSERT_NOT_NULL(updateProxy);
1.2588 +
1.2589 + // the composition is signalled as ongoing (busy system)
1.2590 + iImmediateAvailable = EFalse;
1.2591 + // we expect, initially that the composer is asked to check only for the displayed notifications
1.2592 + iExpectedSourceStreamUpdatedEventMask = ESOWF_EventDisplayedX | ESOWF_EventDisplayed;
1.2593 +
1.2594 + updateProxy->ContentUpdated(surface, //aSurface
1.2595 + 0, //aBuffer
1.2596 + NULL, //aRegion
1.2597 + &statusAvailable, //aStatusConsumed
1.2598 + &statusDisplayed, //aStatusDisplayed
1.2599 + &displayedTime, //aTimeStamp
1.2600 + &statusDisplayedX, //aStatusDispXTimes
1.2601 + &X //aDisplayedXTimes
1.2602 + );
1.2603 +
1.2604 + ASSERT_TRUE(iSourceStreamUpdatedCalled == 2);
1.2605 + // simulating the ongoing composition, the processing to be deferred for the following one
1.2606 + khronos_int32_t newNotificationsMask = 0;
1.2607 + SymbianStreamProcessNotifications(iNs,
1.2608 + iExpectedSourceStreamUpdatedEventMask,
1.2609 + iScreenNo,
1.2610 + iStreamUpdatedSerialNumber++,
1.2611 + &newNotificationsMask);
1.2612 +
1.2613 + ASSERT_TRUE(newNotificationsMask == iExpectedSourceStreamUpdatedEventMask);
1.2614 +
1.2615 + for (TInt i = 0; i < X; ++i)
1.2616 + {
1.2617 + // Pretend that a composition has occured
1.2618 +
1.2619 + khronos_int32_t events = newNotificationsMask;
1.2620 + // we process the expected notifications
1.2621 + newNotificationsMask = 0;
1.2622 + SymbianStreamProcessNotifications(iNs,
1.2623 + events,
1.2624 + iScreenNo,
1.2625 + iStreamUpdatedSerialNumber++,
1.2626 + &newNotificationsMask);
1.2627 +
1.2628 + // No updates during composition so newNotificationMask should still be zero
1.2629 +
1.2630 + if (i == 0)
1.2631 + {
1.2632 + User::WaitForRequest(statusDisplayed);
1.2633 + ASSERT_EQUALS(statusDisplayed.Int(), KErrNone);
1.2634 + }
1.2635 +
1.2636 +
1.2637 + if (i < X - 1)
1.2638 + {
1.2639 + ASSERT_TRUE(newNotificationsMask == ESOWF_EventDisplayedX);
1.2640 + // Displayed X times for buffer zero should not be completed yet
1.2641 + ASSERT_EQUALS(statusDisplayedX.Int(), KRequestPending);
1.2642 + ASSERT_EQUALS(statusAvailable.Int(), KRequestPending);
1.2643 + }
1.2644 + else
1.2645 + {
1.2646 + ASSERT_TRUE(newNotificationsMask == 0);
1.2647 + User::WaitForRequest(statusDisplayedX);
1.2648 + ASSERT_EQUALS(statusDisplayedX.Int(), KErrNone);
1.2649 + }
1.2650 + }
1.2651 +
1.2652 + // the composition is, still, signalled as ongoing (busy system)
1.2653 + iImmediateAvailable = EFalse;
1.2654 + // we expect, initially that the composer is asked to check only for the displayed notifications
1.2655 + iExpectedSourceStreamUpdatedEventMask = ESOWF_EventAvailable;
1.2656 + iUtility->SubmitUpdate(KAllScreens, surface, 1, 0);
1.2657 + ASSERT_TRUE(iSourceStreamUpdatedCalled == 4);
1.2658 +
1.2659 + SymbianStreamProcessNotifications(iNs,
1.2660 + iExpectedSourceStreamUpdatedEventMask,
1.2661 + iScreenNo,
1.2662 + iStreamUpdatedSerialNumber++,
1.2663 + &newNotificationsMask);
1.2664 +
1.2665 + User::WaitForRequest(statusAvailable);
1.2666 + ASSERT_EQUALS(statusAvailable.Int(), KErrNone);
1.2667 + ASSERT_TRUE(newNotificationsMask == 0);
1.2668 +
1.2669 + SymbianStreamRemoveReference(iNs);
1.2670 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.2671 +
1.2672 + iUtility->DestroySurface(surface);
1.2673 + }
1.2674 +
1.2675 +/**
1.2676 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0117_1
1.2677 +@SYMTestCaseDesc Test displayed notification is cancelled when there are no registered SUS
1.2678 + notification observers
1.2679 +@SYMREQ
1.2680 +@SYMPREQ PREQ2400
1.2681 +@SYMTestType CT
1.2682 +@SYMTestPriority High
1.2683 +@SYMTestPurpose Verify that the surface stream adaptation cancels the displayed notification
1.2684 + when the native stream has not registered any observers for SUS notifications
1.2685 +@SYMTestActions
1.2686 +
1.2687 + 1. Create a surface
1.2688 + 2. Create a native stream for the surface
1.2689 + 3. Register the test class as an observer for ESOWF_EventUpdated to act as a fake composer
1.2690 + 4. Do not add any SUS notification observers to the native stream
1.2691 + 5. Register for displayed notification.
1.2692 + 6. Submit an update to the surface
1.2693 + 7. The observer function should be invoked and verifies that stream and event parameters.
1.2694 + 8. The tester simulates the end of a composition by firing SymbianStreamProcessNotifications
1.2695 + 9. Verify displayed status is completed with KErrCancel
1.2696 + 10. Destroy the native stream.
1.2697 +
1.2698 +@SYMTestExpectedResults
1.2699 + No errors, displayed status completed with KErrCancel.
1.2700 +
1.2701 +*/
1.2702 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0117_1L()
1.2703 + {
1.2704 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.2705 + TRAPD(err, GrowCleanupStackL());
1.2706 + ASSERT_TRUE(err == KErrNone);
1.2707 +
1.2708 + iScreenNo = 0;
1.2709 + iContextUpdatedFlags = 0;
1.2710 + iStreamUpdatedSerialNumber = 1;
1.2711 + iSourceStreamUpdatedCalled = 0;
1.2712 + iImmediateVisible = SYM_CONTENT_VISIBLE;
1.2713 + TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4);
1.2714 + ASSERT_FALSE(surface.IsNull());
1.2715 +
1.2716 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.2717 + err = SymbianStreamAcquire(&surface, &iNs);
1.2718 + ASSERT_TRUE(err == KErrNone);
1.2719 + ASSERT_TRUE(iNs);
1.2720 +
1.2721 + // Do not add observers for SUS notifications!
1.2722 +
1.2723 + iExpectedSourceStreamUpdatedEventMask = 0;
1.2724 + err = SymbianStreamAddObserver(iNs, SourceStreamUpdatedCallback, this);
1.2725 + ASSERT_TRUE(err == KErrNone);
1.2726 +
1.2727 + TRequestStatus statusDisplayed;
1.2728 + TUint32 timeStamp = 0;
1.2729 +
1.2730 + CExtensionContainer* updateExtension = NULL;
1.2731 + err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast<void**>(&updateExtension));
1.2732 + ASSERT_TRUE(err == KErrNone);
1.2733 + MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface<MCompositionSurfaceUpdate>();
1.2734 + ASSERT_NOT_NULL(updateProxy);
1.2735 +
1.2736 + updateProxy->ContentUpdated(surface, //aSurface
1.2737 + 0, //aBuffer
1.2738 + NULL, //aRegion
1.2739 + NULL, //aStatusConsumed
1.2740 + &statusDisplayed, //aStatusDisplayed
1.2741 + &timeStamp, //aTimeStamp
1.2742 + NULL, //aStatusDispXTimes
1.2743 + NULL //aDisplayedXTimes
1.2744 + );
1.2745 +
1.2746 + // Verify that the context's callback is invoked when SubmitUpdate is called.
1.2747 + ASSERT_TRUE(iSourceStreamUpdatedCalled == 1);
1.2748 +
1.2749 + // Pretend that a composition has occured
1.2750 + khronos_int32_t notificationsMask = 0;
1.2751 + khronos_int32_t newNotificationsMask = 0;
1.2752 +
1.2753 + SymbianStreamProcessNotifications(iNs,
1.2754 + ESOWF_EventAvailable | ESOWF_EventDisplayed |ESOWF_EventDisplayedX,
1.2755 + iScreenNo,
1.2756 + ++iStreamUpdatedSerialNumber,
1.2757 + &newNotificationsMask);
1.2758 +
1.2759 + // No updates during composition so newNotificationMask should still be zero
1.2760 + ASSERT_EQUALS(newNotificationsMask, notificationsMask);
1.2761 +
1.2762 + // The displayed notification should be cancelled as we have no observers registered
1.2763 + ASSERT_EQUALS(statusDisplayed.Int(), KErrCancel);
1.2764 + ASSERT_TRUE(timeStamp == 0);
1.2765 +
1.2766 + SymbianStreamRemoveReference(iNs);
1.2767 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.2768 + }
1.2769 +
1.2770 +/**
1.2771 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0117_2
1.2772 +@SYMTestCaseDesc Test displayed x times notification is cancelled when there are no registered SUS
1.2773 + notification observers
1.2774 +@SYMREQ
1.2775 +@SYMPREQ PREQ2400
1.2776 +@SYMTestType CT
1.2777 +@SYMTestPriority High
1.2778 +@SYMTestPurpose Verify that the surface stream adaptation cancels the displayed x times notification
1.2779 + when the native stream has not registered any observers for SUS notifications
1.2780 +@SYMTestActions
1.2781 +
1.2782 + 1. Create a surface
1.2783 + 2. Create a native stream for the surface
1.2784 + 3. Register the test class as an observer for ESOWF_EventUpdated to act as a fake composer
1.2785 + 4. Do not add any SUS notification observers to the native stream
1.2786 + 5. Register for displayed x times notification.
1.2787 + 6. Submit an update to the surface
1.2788 + 7. The observer function should be invoked and verifies that stream and event parameters.
1.2789 + 8. The tester simulates the end of a composition by firing SymbianStreamProcessNotifications
1.2790 + 9. Verify displayed x time status is completed with KErrCancel
1.2791 + 10. Destroy the native stream.
1.2792 +
1.2793 +@SYMTestExpectedResults
1.2794 + No errors, displayed x times status completed with KErrCancel.
1.2795 +
1.2796 +*/
1.2797 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0117_2L()
1.2798 + {
1.2799 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.2800 + TRAPD(err, GrowCleanupStackL());
1.2801 + ASSERT_TRUE(err == KErrNone);
1.2802 +
1.2803 + iScreenNo = 0;
1.2804 + iContextUpdatedFlags = 0;
1.2805 + iStreamUpdatedSerialNumber = 1;
1.2806 + iSourceStreamUpdatedCalled = 0;
1.2807 + iImmediateVisible = SYM_CONTENT_VISIBLE;
1.2808 + TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4);
1.2809 + ASSERT_FALSE(surface.IsNull());
1.2810 +
1.2811 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.2812 + err = SymbianStreamAcquire(&surface, &iNs);
1.2813 + ASSERT_TRUE(err == KErrNone);
1.2814 + ASSERT_TRUE(iNs);
1.2815 +
1.2816 + // Do not add observers for SUS notifications!
1.2817 +
1.2818 + iExpectedSourceStreamUpdatedEventMask = 0;
1.2819 + err = SymbianStreamAddObserver(iNs, SourceStreamUpdatedCallback, this);
1.2820 + ASSERT_TRUE(err == KErrNone);
1.2821 +
1.2822 + TRequestStatus statusDisplayedX;
1.2823 + TInt X = 5;
1.2824 +
1.2825 + CExtensionContainer* updateExtension = NULL;
1.2826 + err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast<void**>(&updateExtension));
1.2827 + ASSERT_TRUE(err == KErrNone);
1.2828 + MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface<MCompositionSurfaceUpdate>();
1.2829 + ASSERT_NOT_NULL(updateProxy);
1.2830 +
1.2831 + updateProxy->ContentUpdated(surface, //aSurface
1.2832 + 0, //aBuffer
1.2833 + NULL, //aRegion
1.2834 + NULL, //aStatusConsumed
1.2835 + NULL, //aStatusDisplayed
1.2836 + NULL, //aTimeStamp
1.2837 + &statusDisplayedX, //aStatusDispXTimes
1.2838 + &X //aDisplayedXTimes
1.2839 + );
1.2840 +
1.2841 + // Verify that the context's callback is invoked when SubmitUpdate is called.
1.2842 + ASSERT_TRUE(iSourceStreamUpdatedCalled == 1);
1.2843 +
1.2844 + User::WaitForRequest(statusDisplayedX);
1.2845 + ASSERT_EQUALS(statusDisplayedX.Int(), KErrCancel);
1.2846 +
1.2847 + for (TInt i = 0; i < X; ++i)
1.2848 + {
1.2849 + // Pretend that a composition has occured
1.2850 + khronos_int32_t newNotificationsMask = 0;
1.2851 + SymbianStreamProcessNotifications(iNs,
1.2852 + ESOWF_EventAvailable | ESOWF_EventDisplayed |ESOWF_EventDisplayedX,
1.2853 + iScreenNo,
1.2854 + ++iStreamUpdatedSerialNumber,
1.2855 + &newNotificationsMask);
1.2856 +
1.2857 + // No updates during composition so newNotificationMask should still be zero
1.2858 + ASSERT_TRUE(newNotificationsMask == 0);
1.2859 + }
1.2860 +
1.2861 + SymbianStreamRemoveReference(iNs);
1.2862 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.2863 + }
1.2864 +
1.2865 +/**
1.2866 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0117_3
1.2867 +@SYMTestCaseDesc Test available notification is cancelled when there are no registered SUS
1.2868 + notification observers
1.2869 +@SYMREQ
1.2870 +@SYMPREQ PREQ2400
1.2871 +@SYMTestType CT
1.2872 +@SYMTestPriority High
1.2873 +@SYMTestPurpose Verify that the surface stream adaptation cancels the available notification
1.2874 + when the native stream has not registered any observers for SUS notifications
1.2875 +@SYMTestActions
1.2876 +
1.2877 + 1. Create a surface
1.2878 + 2. Create a native stream for the surface
1.2879 + 3. Register the test class as an observer for ESOWF_EventUpdated to act as a fake composer
1.2880 + 4. Do not add any SUS notification observers to the native stream
1.2881 + 5. Register for available notification.
1.2882 + 6. Submit an update to the surface
1.2883 + 7. The observer function should be invoked and verifies that stream and event parameters.
1.2884 + 8. The tester simulates the end of a composition by firing SymbianStreamProcessNotifications
1.2885 + 9. Verify available status is completed with KErrCancel
1.2886 + 10. Destroy the native stream.
1.2887 +
1.2888 +@SYMTestExpectedResults
1.2889 + No errors, available status completed with KErrCancel.
1.2890 +
1.2891 +*/
1.2892 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0117_3L()
1.2893 + {
1.2894 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.2895 + TRAPD(err, GrowCleanupStackL());
1.2896 + ASSERT_TRUE(err == KErrNone);
1.2897 +
1.2898 + iScreenNo = 0;
1.2899 + iContextUpdatedFlags = 0;
1.2900 + iStreamUpdatedSerialNumber = 1;
1.2901 + iSourceStreamUpdatedCalled = 0;
1.2902 + iImmediateVisible = SYM_CONTENT_VISIBLE;
1.2903 + TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4);
1.2904 + ASSERT_FALSE(surface.IsNull());
1.2905 +
1.2906 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.2907 + err = SymbianStreamAcquire(&surface, &iNs);
1.2908 + ASSERT_TRUE(err == KErrNone);
1.2909 + ASSERT_TRUE(iNs);
1.2910 +
1.2911 + // Do not add observers for SUS notifications!
1.2912 +
1.2913 + iExpectedSourceStreamUpdatedEventMask = 0;
1.2914 + err = SymbianStreamAddObserver(iNs, SourceStreamUpdatedCallback, this);
1.2915 + ASSERT_TRUE(err == KErrNone);
1.2916 +
1.2917 + TRequestStatus statusAvailable;
1.2918 +
1.2919 + CExtensionContainer* updateExtension = NULL;
1.2920 + err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast<void**>(&updateExtension));
1.2921 + ASSERT_TRUE(err == KErrNone);
1.2922 + MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface<MCompositionSurfaceUpdate>();
1.2923 + ASSERT_NOT_NULL(updateProxy);
1.2924 +
1.2925 + updateProxy->ContentUpdated(surface, //aSurface
1.2926 + 0, //aBuffer
1.2927 + NULL, //aRegion
1.2928 + &statusAvailable, //aStatusConsumed
1.2929 + NULL, //aStatusDisplayed
1.2930 + NULL, //aTimeStamp
1.2931 + NULL, //aStatusDispXTimes
1.2932 + NULL //aDisplayedXTimes
1.2933 + );
1.2934 +
1.2935 + // Verify that the context's callback is invoked when SubmitUpdate is called.
1.2936 + ASSERT_TRUE(iSourceStreamUpdatedCalled == 1);
1.2937 +
1.2938 + // Available should only be completed when submit update is called with a different buffer no.
1.2939 + // But, when there are no registered SUS observers, the notification should complete immediately
1.2940 + // with KErrCancel
1.2941 + ASSERT_EQUALS(statusAvailable.Int(), KErrCancel);
1.2942 +
1.2943 + // Pretend that a composition has occured
1.2944 + khronos_int32_t newNotificationsMask = 0;
1.2945 + SymbianStreamProcessNotifications(iNs,
1.2946 + ESOWF_EventAvailable | ESOWF_EventDisplayed |ESOWF_EventDisplayedX,
1.2947 + iScreenNo,
1.2948 + ++iStreamUpdatedSerialNumber,
1.2949 + &newNotificationsMask);
1.2950 +
1.2951 + ASSERT_TRUE(newNotificationsMask == 0);
1.2952 +
1.2953 + // Update and switch to buffer 1
1.2954 + iExpectedSourceStreamUpdatedEventMask = 0;
1.2955 + iUtility->SubmitUpdate(KAllScreens, surface, 1, 0);
1.2956 + ASSERT_TRUE(iSourceStreamUpdatedCalled == 2);
1.2957 +
1.2958 + // Consume update on buffer 1. This should make buffer 0 available
1.2959 + SymbianStreamProcessNotifications(iNs,
1.2960 + ESOWF_EventAvailable | ESOWF_EventDisplayed |ESOWF_EventDisplayedX,
1.2961 + iScreenNo,
1.2962 + ++iStreamUpdatedSerialNumber,
1.2963 + &newNotificationsMask);
1.2964 +
1.2965 + ASSERT_TRUE(newNotificationsMask == 0);
1.2966 +
1.2967 + User::WaitForRequest(statusAvailable);
1.2968 + ASSERT_EQUALS(statusAvailable.Int(), KErrCancel);
1.2969 +
1.2970 + SymbianStreamRemoveReference(iNs);
1.2971 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.2972 + }
1.2973 +
1.2974 +/**
1.2975 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0117_4
1.2976 +@SYMTestCaseDesc Test all notifications are cancelled when there are no registered SUS
1.2977 + notification observers
1.2978 +@SYMREQ
1.2979 +@SYMPREQ PREQ2400
1.2980 +@SYMTestType CT
1.2981 +@SYMTestPriority High
1.2982 +@SYMTestPurpose Verify that the surface stream adaptation cancels all notifications
1.2983 + when the native stream has not registered any observers for SUS notifications
1.2984 +@SYMTestActions
1.2985 +
1.2986 + 1. Create a surface
1.2987 + 2. Create a native stream for the surface
1.2988 + 3. Register the test class as an observer for ESOWF_EventUpdated to act as a fake composer
1.2989 + 4. Do not add any SUS notification observers to the native stream
1.2990 + 5. Register for displayed, available and displayed x times notifications
1.2991 + 6. Submit an update to the surface
1.2992 + 7. The observer function should be invoked and verifies that stream and event parameters
1.2993 + 8. The tester simulates the end of a composition by firing SymbianStreamProcessNotifications
1.2994 + 9. Verify all notification statuses completed with KErrCancel
1.2995 + 10. Destroy the native stream.
1.2996 +
1.2997 +@SYMTestExpectedResults
1.2998 + No errors, all notification statuses completed with KErrCancel.
1.2999 +
1.3000 +*/
1.3001 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0117_4L()
1.3002 + {
1.3003 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.3004 + TRAPD(err, GrowCleanupStackL());
1.3005 + ASSERT_TRUE(err == KErrNone);
1.3006 +
1.3007 + iScreenNo = 0;
1.3008 + iContextUpdatedFlags = 0;
1.3009 + iStreamUpdatedSerialNumber = 1;
1.3010 + iSourceStreamUpdatedCalled = 0;
1.3011 + iImmediateVisible = SYM_CONTENT_VISIBLE;
1.3012 + TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4);
1.3013 + ASSERT_FALSE(surface.IsNull());
1.3014 +
1.3015 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.3016 + err = SymbianStreamAcquire(&surface, &iNs);
1.3017 + ASSERT_TRUE(err == KErrNone);
1.3018 + ASSERT_TRUE(iNs);
1.3019 +
1.3020 + // Do not add observers for SUS notifications!
1.3021 +
1.3022 + iExpectedSourceStreamUpdatedEventMask = 0;
1.3023 + err = SymbianStreamAddObserver(iNs, SourceStreamUpdatedCallback, this);
1.3024 + ASSERT_TRUE(err == KErrNone);
1.3025 +
1.3026 + TRequestStatus statusDisplayedX;
1.3027 + TRequestStatus statusAvailable;
1.3028 + TRequestStatus statusDisplayed;
1.3029 + TInt X = 5;
1.3030 + TUint32 displayedTime = 0;
1.3031 +
1.3032 + CExtensionContainer* updateExtension = NULL;
1.3033 + err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast<void**>(&updateExtension));
1.3034 + ASSERT_TRUE(err == KErrNone);
1.3035 + MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface<MCompositionSurfaceUpdate>();
1.3036 + ASSERT_NOT_NULL(updateProxy);
1.3037 +
1.3038 + updateProxy->ContentUpdated(surface, //aSurface
1.3039 + 0, //aBuffer
1.3040 + NULL, //aRegion
1.3041 + &statusAvailable, //aStatusConsumed
1.3042 + &statusDisplayed, //aStatusDisplayed
1.3043 + &displayedTime, //aTimeStamp
1.3044 + &statusDisplayedX, //aStatusDispXTimes
1.3045 + &X //aDisplayedXTimes
1.3046 + );
1.3047 +
1.3048 + // Verify that the context's callback is invoked when SubmitUpdate is called.
1.3049 + ASSERT_TRUE(iSourceStreamUpdatedCalled == 1);
1.3050 +
1.3051 + for (TInt i = 0; i < X; ++i)
1.3052 + {
1.3053 + // Pretend that a composition has occured
1.3054 + khronos_int32_t newNotificationsMask = 0;
1.3055 +
1.3056 + SymbianStreamProcessNotifications(iNs,
1.3057 + ESOWF_EventAvailable | ESOWF_EventDisplayed |ESOWF_EventDisplayedX,
1.3058 + iScreenNo,
1.3059 + ++iStreamUpdatedSerialNumber,
1.3060 + &newNotificationsMask);
1.3061 +
1.3062 + // No updates during composition so newNotificationMask should still be zero
1.3063 + ASSERT_TRUE(newNotificationsMask == 0);
1.3064 +
1.3065 + if (i == 0)
1.3066 + {
1.3067 + User::WaitForRequest(statusDisplayed);
1.3068 + User::WaitForRequest(statusDisplayedX);
1.3069 + User::WaitForRequest(statusAvailable);
1.3070 + }
1.3071 +
1.3072 + ASSERT_EQUALS(statusAvailable.Int(), KErrCancel);
1.3073 + ASSERT_EQUALS(statusDisplayed.Int(), KErrCancel);
1.3074 + ASSERT_EQUALS(statusDisplayedX.Int(), KErrCancel);
1.3075 + }
1.3076 +
1.3077 + updateProxy->ContentUpdated(surface, //aSurface
1.3078 + 0, //aBuffer
1.3079 + NULL, //aRegion
1.3080 + NULL, //aStatusConsumed
1.3081 + NULL, //aStatusDisplayed
1.3082 + NULL, //aTimeStamp
1.3083 + NULL, //aStatusDispXTimes
1.3084 + NULL //aDisplayedXTimes
1.3085 + );
1.3086 +
1.3087 + // Verify that the context's callback is invoked when SubmitUpdate is called.
1.3088 + ASSERT_TRUE(iSourceStreamUpdatedCalled == 2);
1.3089 +
1.3090 + khronos_int32_t newNotificationsMask = 0;
1.3091 + SymbianStreamProcessNotifications(iNs,
1.3092 + ESOWF_EventAvailable | ESOWF_EventDisplayed |ESOWF_EventDisplayedX,
1.3093 + iScreenNo,
1.3094 + ++iStreamUpdatedSerialNumber,
1.3095 + &newNotificationsMask);
1.3096 +
1.3097 + ASSERT_EQUALS(statusAvailable.Int(), KErrCancel);
1.3098 + ASSERT_TRUE(displayedTime == 0);
1.3099 +
1.3100 + SymbianStreamRemoveReference(iNs);
1.3101 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.3102 + }
1.3103 +
1.3104 +/**
1.3105 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0118_1
1.3106 +@SYMTestCaseDesc Test displayed notification is cancelled when content updated is called on
1.3107 + surface which is not registered with a native stream
1.3108 +@SYMREQ
1.3109 +@SYMPREQ PREQ2400
1.3110 +@SYMTestType CT
1.3111 +@SYMTestPriority High
1.3112 +@SYMTestPurpose Verify that the surface stream adaptation cancels the displayed notification
1.3113 + added to a surface which does not have a native stream associated with it
1.3114 +@SYMTestActions
1.3115 +
1.3116 + 1. Create a surface
1.3117 + 2. Register for displayed notification.
1.3118 + 3. Submit an update to the surface
1.3119 + 4. Verify displayed status is completed with KErrSurfaceNotRegistered
1.3120 +
1.3121 +@SYMTestExpectedResults
1.3122 + No errors, displayed status completed with KErrSurfaceNotRegistered.
1.3123 +
1.3124 +*/
1.3125 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0118_1L()
1.3126 + {
1.3127 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.3128 + TRAPD(err, GrowCleanupStackL());
1.3129 + ASSERT_TRUE(err == KErrNone);
1.3130 +
1.3131 + iScreenNo = 0;
1.3132 + iContextUpdatedFlags = 0;
1.3133 + iStreamUpdatedSerialNumber = 1;
1.3134 + iSourceStreamUpdatedCalled = 0;
1.3135 + iImmediateVisible = SYM_CONTENT_VISIBLE;
1.3136 + TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4);
1.3137 + ASSERT_FALSE(surface.IsNull());
1.3138 +
1.3139 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.3140 + TRequestStatus statusDisplayed;
1.3141 + TUint32 timeStamp = 0;
1.3142 +
1.3143 + CExtensionContainer* updateExtension = NULL;
1.3144 + err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast<void**>(&updateExtension));
1.3145 + ASSERT_TRUE(err == KErrNone);
1.3146 + MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface<MCompositionSurfaceUpdate>();
1.3147 + ASSERT_NOT_NULL(updateProxy);
1.3148 +
1.3149 + updateProxy->ContentUpdated(surface, //aSurface
1.3150 + 0, //aBuffer
1.3151 + NULL, //aRegion
1.3152 + NULL, //aStatusConsumed
1.3153 + &statusDisplayed, //aStatusDisplayed
1.3154 + &timeStamp, //aTimeStamp
1.3155 + NULL, //aStatusDispXTimes
1.3156 + NULL //aDisplayedXTimes
1.3157 + );
1.3158 +
1.3159 + User::WaitForRequest(statusDisplayed);
1.3160 +
1.3161 + // The displayed notification should return with a surface registration error as there
1.3162 + // isn't a native stream registered with surface...
1.3163 + ASSERT_EQUALS(statusDisplayed.Int(), KErrSurfaceNotRegistered);
1.3164 + ASSERT_TRUE(timeStamp == 0);
1.3165 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.3166 + }
1.3167 +
1.3168 +/**
1.3169 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0118_2
1.3170 +@SYMTestCaseDesc Test displayed x times notification is cancelled when content updated is called on
1.3171 + surface which is not registered with a native stream
1.3172 +@SYMREQ
1.3173 +@SYMPREQ PREQ2400
1.3174 +@SYMTestType CT
1.3175 +@SYMTestPriority High
1.3176 +@SYMTestPurpose Verify that the surface stream adaptation cancels the displayed x times notification
1.3177 + added to a surface which does not have a native stream associated with it
1.3178 +@SYMTestActions
1.3179 +
1.3180 + 1. Create a surface
1.3181 + 2. Register for displayed x times notification.
1.3182 + 3. Submit an update to the surface
1.3183 + 4. Verify displayed x times status is completed with KErrSurfaceNotRegistered
1.3184 +
1.3185 +@SYMTestExpectedResults
1.3186 + No errors, displayed x times status completed with KErrSurfaceNotRegistered.
1.3187 +
1.3188 +*/
1.3189 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0118_2L()
1.3190 + {
1.3191 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.3192 + TRAPD(err, GrowCleanupStackL());
1.3193 + ASSERT_TRUE(err == KErrNone);
1.3194 +
1.3195 + iScreenNo = 0;
1.3196 + iContextUpdatedFlags = 0;
1.3197 + iStreamUpdatedSerialNumber = 1;
1.3198 + iSourceStreamUpdatedCalled = 0;
1.3199 + iImmediateVisible = SYM_CONTENT_VISIBLE;
1.3200 + TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4);
1.3201 + ASSERT_FALSE(surface.IsNull());
1.3202 +
1.3203 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.3204 +
1.3205 + // Do not create a native stream for surface!
1.3206 +
1.3207 + TRequestStatus statusDisplayedXTimes;
1.3208 + TInt X = 5;
1.3209 +
1.3210 + CExtensionContainer* updateExtension = NULL;
1.3211 + err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast<void**>(&updateExtension));
1.3212 + ASSERT_TRUE(err == KErrNone);
1.3213 + MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface<MCompositionSurfaceUpdate>();
1.3214 + ASSERT_NOT_NULL(updateProxy);
1.3215 +
1.3216 + updateProxy->ContentUpdated(surface, //aSurface
1.3217 + 0, //aBuffer
1.3218 + NULL, //aRegion
1.3219 + NULL, //aStatusConsumed
1.3220 + NULL, //aStatusDisplayed
1.3221 + NULL, //aTimeStamp
1.3222 + &statusDisplayedXTimes, //aStatusDispXTimes
1.3223 + &X //aDisplayedXTimes
1.3224 + );
1.3225 +
1.3226 + User::WaitForRequest(statusDisplayedXTimes);
1.3227 +
1.3228 + // The displayed x times notification should return with a surface registration error as there
1.3229 + // isn't a native stream registered with surface...
1.3230 + ASSERT_EQUALS(statusDisplayedXTimes.Int(), KErrSurfaceNotRegistered);
1.3231 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.3232 + }
1.3233 +
1.3234 +/**
1.3235 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0118_3
1.3236 +@SYMTestCaseDesc Test available notification is cancelled when content updated is called on
1.3237 + surface which is not registered with a native stream
1.3238 +@SYMREQ
1.3239 +@SYMPREQ PREQ2400
1.3240 +@SYMTestType CT
1.3241 +@SYMTestPriority High
1.3242 +@SYMTestPurpose Verify that the surface stream adaptation cancels the available notification
1.3243 + added to a surface which does not have a native stream associated with it
1.3244 +@SYMTestActions
1.3245 +
1.3246 + 1. Create a surface
1.3247 + 2. Rregister for available notification.
1.3248 + 3. Submit an update to the surface
1.3249 + 4. Verify available status is completed with KErrSurfaceNotRegistered
1.3250 +
1.3251 +@SYMTestExpectedResults
1.3252 + No errors, available status completed with KErrSurfaceNotRegistered.
1.3253 +
1.3254 +*/
1.3255 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0118_3L()
1.3256 + {
1.3257 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.3258 + TRAPD(err, GrowCleanupStackL());
1.3259 + ASSERT_TRUE(err == KErrNone);
1.3260 +
1.3261 + iScreenNo = 0;
1.3262 + iContextUpdatedFlags = 0;
1.3263 + iStreamUpdatedSerialNumber = 1;
1.3264 + iSourceStreamUpdatedCalled = 0;
1.3265 + iImmediateVisible = SYM_CONTENT_VISIBLE;
1.3266 + TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4);
1.3267 + ASSERT_FALSE(surface.IsNull());
1.3268 +
1.3269 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.3270 +
1.3271 + // Do not create a native stream for surface!
1.3272 +
1.3273 + TRequestStatus statusAvailable;
1.3274 +
1.3275 + CExtensionContainer* updateExtension = NULL;
1.3276 + err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast<void**>(&updateExtension));
1.3277 + ASSERT_TRUE(err == KErrNone);
1.3278 + MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface<MCompositionSurfaceUpdate>();
1.3279 + ASSERT_NOT_NULL(updateProxy);
1.3280 +
1.3281 + updateProxy->ContentUpdated(surface, //aSurface
1.3282 + 0, //aBuffer
1.3283 + NULL, //aRegion
1.3284 + &statusAvailable, //aStatusConsumed
1.3285 + NULL, //aStatusDisplayed
1.3286 + NULL, //aTimeStamp
1.3287 + NULL, //aStatusDispXTimes
1.3288 + NULL //aDisplayedXTimes
1.3289 + );
1.3290 +
1.3291 + User::WaitForRequest(statusAvailable);
1.3292 +
1.3293 + // The available notification should return with a surface registration error as there
1.3294 + // isn't a native stream registered with surface...
1.3295 + ASSERT_EQUALS(statusAvailable.Int(), KErrSurfaceNotRegistered);
1.3296 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.3297 + }
1.3298 +
1.3299 +/**
1.3300 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0118_4
1.3301 +@SYMTestCaseDesc Test all notifications are cancelled when content updated is called on
1.3302 + surface which is not registered with a native stream
1.3303 +@SYMREQ
1.3304 +@SYMPREQ PREQ2400
1.3305 +@SYMTestType CT
1.3306 +@SYMTestPriority High
1.3307 +@SYMTestPurpose Verify that the surface stream adaptation cancels all notifications
1.3308 + added to a surface which does not have a native stream associated with it
1.3309 +@SYMTestActions
1.3310 +
1.3311 + 1. Create a surface
1.3312 + 2. Register for displayed, available and displayed x times notifications.
1.3313 + 3. Submit an update to the surface
1.3314 + 4. Verify all notification statuses completed with KErrSurfaceNotRegistered
1.3315 +
1.3316 +@SYMTestExpectedResults
1.3317 + No errors, all notification statuses completed with KErrSurfaceNotRegistered.
1.3318 +
1.3319 +*/
1.3320 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0118_4L()
1.3321 + {
1.3322 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.3323 + TRAPD(err, GrowCleanupStackL());
1.3324 + ASSERT_TRUE(err == KErrNone);
1.3325 +
1.3326 + iScreenNo = 0;
1.3327 + iContextUpdatedFlags = 0;
1.3328 + iStreamUpdatedSerialNumber = 1;
1.3329 + iSourceStreamUpdatedCalled = 0;
1.3330 + iImmediateVisible = SYM_CONTENT_VISIBLE;
1.3331 + TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4);
1.3332 + ASSERT_FALSE(surface.IsNull());
1.3333 +
1.3334 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.3335 +
1.3336 + // Do not create a native stream for surface!
1.3337 +
1.3338 + TRequestStatus statusDisplayed, statusAvailable, statusDisplayedXTimes;
1.3339 + TInt X = 5;
1.3340 + TUint32 timeStamp = 0;
1.3341 +
1.3342 + CExtensionContainer* updateExtension = NULL;
1.3343 + err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast<void**>(&updateExtension));
1.3344 + ASSERT_TRUE(err == KErrNone);
1.3345 + MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface<MCompositionSurfaceUpdate>();
1.3346 + ASSERT_NOT_NULL(updateProxy);
1.3347 +
1.3348 + updateProxy->ContentUpdated(surface, //aSurface
1.3349 + 0, //aBuffer
1.3350 + NULL, //aRegion
1.3351 + &statusAvailable, //aStatusConsumed
1.3352 + &statusDisplayed, //aStatusDisplayed
1.3353 + &timeStamp, //aTimeStamp
1.3354 + &statusDisplayedXTimes, //aStatusDispXTimes
1.3355 + &X //aDisplayedXTimes
1.3356 + );
1.3357 +
1.3358 + User::WaitForRequest(statusDisplayed);
1.3359 + User::WaitForRequest(statusAvailable);
1.3360 + User::WaitForRequest(statusDisplayedXTimes);
1.3361 +
1.3362 + // All notifications should return with a surface registration error as there
1.3363 + // isn't a native stream registered with surface...
1.3364 + ASSERT_EQUALS(statusDisplayed.Int(), KErrSurfaceNotRegistered);
1.3365 + ASSERT_EQUALS(statusAvailable.Int(), KErrSurfaceNotRegistered);
1.3366 + ASSERT_EQUALS(statusDisplayedXTimes.Int(), KErrSurfaceNotRegistered);
1.3367 + ASSERT_TRUE(timeStamp == 0);
1.3368 +
1.3369 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.3370 + }
1.3371 +
1.3372 +/**
1.3373 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0119_1
1.3374 +@SYMTestCaseDesc Test overflow conditions on notifications for displayed
1.3375 +@SYMREQ
1.3376 +@SYMPREQ PREQ2400
1.3377 +@SYMTestType CT
1.3378 +@SYMTestPriority High
1.3379 +@SYMTestPurpose Verify that the surface stream adaptation correctly handles duplicate displayed
1.3380 + notifications registered by SUS for content updates on the same screen and buffer
1.3381 +@SYMTestActions
1.3382 +
1.3383 + 1. Create a surface
1.3384 + 2. Create a native stream for the surface
1.3385 + 3. Register the test class as an observer for ESOWF_EventUpdated to act as a fake composer
1.3386 + 4. Register for displayed notification (d1)
1.3387 + 5. Submit an update to the surface
1.3388 + 6. Register for displayed notification (d2)
1.3389 + 7. Submit an update to the surface
1.3390 + 8. The observer function should be invoked and verifies that stream and event parameters.
1.3391 + 9. The tester simulates the end of a composition by firing SymbianStreamProcessNotifications
1.3392 + 10. Verify d1 status is completed with KErrOverflow and d2 status is completed with KErrNone
1.3393 + 11. Destroy the native stream
1.3394 +
1.3395 +@SYMTestExpectedResults
1.3396 + No errors, d1 status completed with KErrOverflow, d2 status completed with KErrNone.
1.3397 +
1.3398 +*/
1.3399 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0119_1L()
1.3400 + {
1.3401 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.3402 + TRAPD(err, GrowCleanupStackL());
1.3403 + ASSERT_TRUE(err == KErrNone);
1.3404 +
1.3405 + iScreenNo = 0;
1.3406 + iContextUpdatedFlags = 0;
1.3407 + iStreamUpdatedSerialNumber = 1;
1.3408 + iSourceStreamUpdatedCalled = 0;
1.3409 + iImmediateVisible = SYM_CONTENT_VISIBLE;
1.3410 + TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4);
1.3411 + ASSERT_FALSE(surface.IsNull());
1.3412 +
1.3413 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.3414 + err = SymbianStreamAcquire(&surface, &iNs);
1.3415 + ASSERT_TRUE(err == KErrNone);
1.3416 + ASSERT_TRUE(iNs);;
1.3417 +
1.3418 + iExpectedSourceStreamUpdatedEventMask = ESOWF_EventDisplayed;
1.3419 + err = SymbianStreamAddExtendedObserver(iNs, SourceStreamUpdatedCallback, this, iScreenNo, ESOWF_EventUpdated);
1.3420 + ASSERT_TRUE(err == KErrNone);
1.3421 +
1.3422 + TRequestStatus statusDisplayed1, statusDisplayed2;
1.3423 + TUint32 timeStamp1 = 0;
1.3424 + TUint32 timeStamp2 = 0;
1.3425 +
1.3426 + CExtensionContainer* updateExtension = NULL;
1.3427 + err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast<void**>(&updateExtension));
1.3428 + ASSERT_TRUE(err == KErrNone);
1.3429 + MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface<MCompositionSurfaceUpdate>();
1.3430 + ASSERT_NOT_NULL(updateProxy);
1.3431 +
1.3432 + updateProxy->ContentUpdated(surface, //aSurface
1.3433 + 0, //aBuffer
1.3434 + NULL, //aRegion
1.3435 + NULL, //aStatusConsumed
1.3436 + &statusDisplayed1, //aStatusDisplayed
1.3437 + &timeStamp1, //aTimeStamp
1.3438 + NULL, //aStatusDispXTimes
1.3439 + NULL //aDisplayedXTimes
1.3440 + );
1.3441 +
1.3442 + ASSERT_TRUE(iSourceStreamUpdatedCalled == 2);
1.3443 +
1.3444 + updateProxy->ContentUpdated(surface, //aSurface
1.3445 + 0, //aBuffer
1.3446 + NULL, //aRegion
1.3447 + NULL, //aStatusConsumed
1.3448 + &statusDisplayed2, //aStatusDisplayed
1.3449 + &timeStamp2, //aTimeStamp
1.3450 + NULL, //aStatusDispXTimes
1.3451 + NULL //aDisplayedXTimes
1.3452 + );
1.3453 + ASSERT_TRUE(iSourceStreamUpdatedCalled == 4);
1.3454 +
1.3455 + User::WaitForRequest(statusDisplayed1);
1.3456 + ASSERT_EQUALS(statusDisplayed1.Int(), KErrOverflow);
1.3457 + ASSERT_TRUE(timeStamp1 == 0);
1.3458 +
1.3459 + // Verify that the context's callback is invoked when SubmitUpdate is called.
1.3460 + ASSERT_TRUE(iSourceStreamUpdatedCalled);
1.3461 +
1.3462 + // Pretend that a composition has occured
1.3463 + khronos_int32_t newNotificationsMask = 0;
1.3464 + SymbianStreamProcessNotifications(iNs,
1.3465 + iExpectedSourceStreamUpdatedEventMask,
1.3466 + iScreenNo,
1.3467 + ++iStreamUpdatedSerialNumber,
1.3468 + &newNotificationsMask);
1.3469 +
1.3470 + ASSERT_TRUE(newNotificationsMask == 0);
1.3471 +
1.3472 + // Make sure displayed event was completed
1.3473 + User::WaitForRequest(statusDisplayed2);
1.3474 + ASSERT_EQUALS(statusDisplayed2.Int(), KErrNone);
1.3475 + ASSERT_TRUE(timeStamp2);
1.3476 +
1.3477 + SymbianStreamRemoveReference(iNs);
1.3478 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.3479 + }
1.3480 +
1.3481 +/**
1.3482 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0119_2
1.3483 +@SYMTestCaseDesc Test overflow conditions on notifications for displayed-x-times
1.3484 +@SYMREQ
1.3485 +@SYMPREQ PREQ2400
1.3486 +@SYMTestType CT
1.3487 +@SYMTestPriority High
1.3488 +@SYMTestPurpose Verify that the surface stream adaptation correctly handles duplicate displayed
1.3489 + x times notifications registered by SUS for content updates on the same screen
1.3490 + and buffer
1.3491 +@SYMTestActions
1.3492 +
1.3493 + 1. Create a surface
1.3494 + 2. Create a native stream for the surface
1.3495 + 3. Register the test class as an observer for ESOWF_EventUpdated to act as a fake composer
1.3496 + 4. Register for displayed x times notification (d1)
1.3497 + 5. Submit an update to the surface
1.3498 + 6. Register for displayed x times notification (d2)
1.3499 + 7. Submit an update to the surface
1.3500 + 8. The observer function should be invoked and verifies that stream and event parameters.
1.3501 + 9. The tester simulates the end of a composition by firing SymbianStreamProcessNotifications
1.3502 + 10. Verify d1 status is completed with KErrOverflow and d2 status is completed with KErrNone
1.3503 + 11. Destroy the native stream
1.3504 +
1.3505 +@SYMTestExpectedResults
1.3506 + No errors, d1 status completed with KErrOverflow, d2 status completed with KErrNone.
1.3507 +
1.3508 +*/
1.3509 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0119_2L()
1.3510 + {
1.3511 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.3512 + TRAPD(err, GrowCleanupStackL());
1.3513 + ASSERT_TRUE(err == KErrNone);
1.3514 +
1.3515 + iScreenNo = 0;
1.3516 + TInt X = 5;
1.3517 + iContextUpdatedFlags = 0;
1.3518 + iStreamUpdatedSerialNumber = 1;
1.3519 + iSourceStreamUpdatedCalled = 0;
1.3520 + iImmediateVisible = SYM_CONTENT_VISIBLE;
1.3521 + TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4);
1.3522 + ASSERT_FALSE(surface.IsNull());
1.3523 +
1.3524 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.3525 + err = SymbianStreamAcquire(&surface, &iNs);
1.3526 + ASSERT_TRUE(err == KErrNone);
1.3527 + ASSERT_TRUE(iNs);
1.3528 +
1.3529 + iExpectedSourceStreamUpdatedEventMask = ESOWF_EventDisplayedX;
1.3530 + err = SymbianStreamAddExtendedObserver(iNs, SourceStreamUpdatedCallback, this, iScreenNo, ESOWF_EventUpdated);
1.3531 + ASSERT_TRUE(err == KErrNone);
1.3532 +
1.3533 + TRequestStatus statusDisplayedX1, statusDisplayedX2;
1.3534 +
1.3535 + CExtensionContainer* updateExtension = NULL;
1.3536 + err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast<void**>(&updateExtension));
1.3537 + ASSERT_TRUE(err == KErrNone);
1.3538 + MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface<MCompositionSurfaceUpdate>();
1.3539 + ASSERT_NOT_NULL(updateProxy);
1.3540 +
1.3541 + updateProxy->ContentUpdated(surface, //aSurface
1.3542 + 0, //aBuffer
1.3543 + NULL, //aRegion
1.3544 + NULL, //aStatusConsumed
1.3545 + NULL, //aStatusDisplayed
1.3546 + NULL, //aTimeStamp
1.3547 + &statusDisplayedX1, //aStatusDispXTimes
1.3548 + &X //aDisplayedXTimes
1.3549 + );
1.3550 +
1.3551 + ASSERT_TRUE(iSourceStreamUpdatedCalled == 2);
1.3552 +
1.3553 + updateProxy->ContentUpdated(surface, //aSurface
1.3554 + 0, //aBuffer
1.3555 + NULL, //aRegion
1.3556 + NULL, //aStatusConsumed
1.3557 + NULL, //aStatusDisplayed
1.3558 + NULL, //aTimeStamp
1.3559 + &statusDisplayedX2, //aStatusDispXTimes
1.3560 + &X //aDisplayedXTimes
1.3561 + );
1.3562 +
1.3563 + ASSERT_TRUE(iSourceStreamUpdatedCalled == 4);
1.3564 +
1.3565 + User::WaitForRequest(statusDisplayedX1);
1.3566 + ASSERT_EQUALS(statusDisplayedX1.Int(), KErrOverflow);
1.3567 +
1.3568 + for (TInt i = 0; i < X; ++i)
1.3569 + {
1.3570 + ASSERT_EQUALS(statusDisplayedX2.Int(), KRequestPending);
1.3571 +
1.3572 + // Pretend that a composition has occured
1.3573 + khronos_int32_t newNotificationsMask = 0;
1.3574 + SymbianStreamProcessNotifications(iNs,
1.3575 + ESOWF_EventDisplayedX,
1.3576 + iScreenNo,
1.3577 + ++iStreamUpdatedSerialNumber,
1.3578 + &newNotificationsMask);
1.3579 +
1.3580 + if (i < X -1)
1.3581 + {
1.3582 + ASSERT_TRUE(newNotificationsMask == ESOWF_EventDisplayedX);
1.3583 + }
1.3584 + else
1.3585 + {
1.3586 + ASSERT_TRUE(newNotificationsMask == 0);
1.3587 + }
1.3588 + }
1.3589 +
1.3590 + // Make sure displayed event was completed
1.3591 + User::WaitForRequest(statusDisplayedX2);
1.3592 + ASSERT_EQUALS(statusDisplayedX2.Int(), KErrNone);
1.3593 +
1.3594 + SymbianStreamRemoveReference(iNs);
1.3595 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.3596 + }
1.3597 +
1.3598 +/**
1.3599 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0119_3
1.3600 +@SYMTestCaseDesc Test overflow conditions on notifications for available
1.3601 +@SYMREQ
1.3602 +@SYMPREQ PREQ2400
1.3603 +@SYMTestType CT
1.3604 +@SYMTestPriority High
1.3605 +@SYMTestPurpose Verify that the surface stream adaptation correctly handles duplicate available
1.3606 + notifications registered by SUS for content updates on the same screen and buffer
1.3607 +@SYMTestActions
1.3608 +
1.3609 + 1. Create a surface
1.3610 + 2. Create a native stream for the surface
1.3611 + 3. Register the test class as an observer for ESOWF_EventUpdated to act as a fake composer
1.3612 + 4. Register for available notification (a1)
1.3613 + 5. Submit an update to the surface
1.3614 + 6. Register for available notification (a2)
1.3615 + 7. Submit an update to the surface
1.3616 + 8. The observer function should be invoked and verifies that stream and event parameters.
1.3617 + 9. The tester simulates the end of a composition by firing SymbianStreamProcessNotifications
1.3618 + 10. Verify d1 status is completed with KErrOverflow and d2 status is completed with KErrNone
1.3619 + 11. Destroy the native stream
1.3620 +
1.3621 +@SYMTestExpectedResults
1.3622 + No errors, a1 status completed with KErrOverflow, a2 status completed with KErrNone.
1.3623 +
1.3624 +*/
1.3625 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0119_3L()
1.3626 + {
1.3627 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.3628 + TRAPD(err, GrowCleanupStackL());
1.3629 + ASSERT_TRUE(err == KErrNone);
1.3630 +
1.3631 + iScreenNo = 0;
1.3632 + iContextUpdatedFlags = 0;
1.3633 + iStreamUpdatedSerialNumber = 1;
1.3634 + iSourceStreamUpdatedCalled = 0;
1.3635 + iImmediateAvailable = EFalse;
1.3636 + iImmediateVisible = SYM_CONTENT_VISIBLE;
1.3637 + TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4);
1.3638 + ASSERT_FALSE(surface.IsNull());
1.3639 +
1.3640 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.3641 + err = SymbianStreamAcquire(&surface, &iNs);
1.3642 + ASSERT_TRUE(err == KErrNone);
1.3643 + ASSERT_TRUE(iNs);
1.3644 +
1.3645 + err = SymbianStreamAddExtendedObserver(iNs, SourceStreamUpdatedCallback, this, iScreenNo, ESOWF_EventUpdated);
1.3646 + ASSERT_TRUE(err == KErrNone);
1.3647 +
1.3648 + TRequestStatus statusAvailable1, statusAvailable2, statusAvailable3;
1.3649 +
1.3650 + CExtensionContainer* updateExtension = NULL;
1.3651 + err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast<void**>(&updateExtension));
1.3652 + ASSERT_TRUE(err == KErrNone);
1.3653 + MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface<MCompositionSurfaceUpdate>();
1.3654 + ASSERT_NOT_NULL(updateProxy);
1.3655 +
1.3656 + iExpectedSourceStreamUpdatedEventMask = 0;
1.3657 + updateProxy->ContentUpdated(surface, //aSurface
1.3658 + 0, //aBuffer
1.3659 + NULL, //aRegion
1.3660 + &statusAvailable1, //aStatusConsumed
1.3661 + NULL, //aStatusDisplayed
1.3662 + NULL, //aTimeStamp
1.3663 + NULL, //aStatusDispXTimes
1.3664 + NULL //aDisplayedXTimes
1.3665 + );
1.3666 +
1.3667 + // Verify that the context's callback is invoked when SubmitUpdate is called.
1.3668 + ASSERT_TRUE(iSourceStreamUpdatedCalled == 2);
1.3669 +
1.3670 + iExpectedSourceStreamUpdatedEventMask = ESOWF_EventAvailable;
1.3671 + updateProxy->ContentUpdated(surface, //aSurface
1.3672 + 0, //aBuffer
1.3673 + NULL, //aRegion
1.3674 + &statusAvailable2, //aStatusConsumed
1.3675 + NULL, //aStatusDisplayed
1.3676 + NULL, //aTimeStamp
1.3677 + NULL, //aStatusDispXTimes
1.3678 + NULL //aDisplayedXTimes
1.3679 + );
1.3680 +
1.3681 + // Verify that the context's callback is invoked when SubmitUpdate is called.
1.3682 + ASSERT_TRUE(iSourceStreamUpdatedCalled == 4);
1.3683 +
1.3684 + iExpectedSourceStreamUpdatedEventMask = ESOWF_EventAvailable;
1.3685 + updateProxy->ContentUpdated(surface, //aSurface
1.3686 + 0, //aBuffer
1.3687 + NULL, //aRegion
1.3688 + &statusAvailable3, //aStatusConsumed
1.3689 + NULL, //aStatusDisplayed
1.3690 + NULL, //aTimeStamp
1.3691 + NULL, //aStatusDispXTimes
1.3692 + NULL //aDisplayedXTimes
1.3693 + );
1.3694 +
1.3695 + // Verify that the context's callback is invoked when SubmitUpdate is called.
1.3696 + ASSERT_TRUE(iSourceStreamUpdatedCalled == 6);
1.3697 +
1.3698 + User::WaitForRequest(statusAvailable1);
1.3699 + ASSERT_EQUALS(statusAvailable1.Int(), KErrOverflow);
1.3700 +
1.3701 + // Pretend that a composition has occured
1.3702 + khronos_int32_t newNotificationsMask = 0;
1.3703 + SymbianStreamProcessNotifications(iNs,
1.3704 + ESOWF_EventAvailable,
1.3705 + iScreenNo,
1.3706 + iStreamUpdatedSerialNumber,
1.3707 + &newNotificationsMask);
1.3708 +
1.3709 + ASSERT_TRUE(newNotificationsMask == 0);
1.3710 +
1.3711 + // Make sure displayed event was completed
1.3712 + User::WaitForRequest(statusAvailable2);
1.3713 + ASSERT_EQUALS(statusAvailable2.Int(), KErrNone);
1.3714 +
1.3715 + SymbianStreamRemoveReference(iNs);
1.3716 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.3717 + }
1.3718 +
1.3719 +/**
1.3720 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0120_1
1.3721 +@SYMTestCaseDesc Test overflow conditions on notifications for displayed
1.3722 +@SYMREQ
1.3723 +@SYMPREQ PREQ2400
1.3724 +@SYMTestType CT
1.3725 +@SYMTestPriority High
1.3726 +@SYMTestPurpose Verify that the surface stream adaptation correctly handles duplicate notifications
1.3727 + registered by SUS for content updates on different buffers
1.3728 +@SYMTestActions
1.3729 +
1.3730 + 1. Create a surface
1.3731 + 2. Create a native stream for the surface
1.3732 + 3. Register the test class as an observer for ESOWF_EventUpdated to act as a fake composer
1.3733 + 4. Register for displayed notification (d1)
1.3734 + 5. Submit an update to the surface on buffer 0
1.3735 + 6. Register for displayed notification (d2)
1.3736 + 7. Submit an update to the surface on buffer 1
1.3737 + 8. The observer function should be invoked and verifies that stream and event parameters.
1.3738 + 9. The tester simulates the end of a composition by firing SymbianStreamProcessNotifications
1.3739 + 10. Verify d1 status is completed with KErrOverflow and d2 status is completed with KErrNone
1.3740 + 11. Destroy the native stream
1.3741 +
1.3742 +@SYMTestExpectedResults
1.3743 + No errors, d1 status completed with KErrOverflow, d2 status completed with KErrNone.
1.3744 +
1.3745 +*/
1.3746 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0120_1L()
1.3747 + {
1.3748 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.3749 + TRAPD(err, GrowCleanupStackL());
1.3750 + ASSERT_TRUE(err == KErrNone);
1.3751 +
1.3752 + iScreenNo = 0;
1.3753 + iContextUpdatedFlags = 0;
1.3754 + iStreamUpdatedSerialNumber = 1;
1.3755 + iSourceStreamUpdatedCalled = 0;
1.3756 + iImmediateVisible = SYM_CONTENT_VISIBLE;
1.3757 + TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4);
1.3758 + ASSERT_FALSE(surface.IsNull());
1.3759 +
1.3760 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.3761 + err = SymbianStreamAcquire(&surface, &iNs);
1.3762 + ASSERT_TRUE(err == KErrNone);
1.3763 + ASSERT_TRUE(iNs);
1.3764 +
1.3765 + err = SymbianStreamAddExtendedObserver(iNs, SourceStreamUpdatedCallback, this, iScreenNo, ESOWF_EventUpdated);
1.3766 + ASSERT_TRUE(err == KErrNone);
1.3767 + iExpectedSourceStreamUpdatedEventMask = ESOWF_EventDisplayed;
1.3768 +
1.3769 + TRequestStatus statusDisplayed1, statusDisplayed2;
1.3770 + TUint32 timeStamp1 = 0;
1.3771 + TUint32 timeStamp2 = 0;
1.3772 +
1.3773 + CExtensionContainer* updateExtension = NULL;
1.3774 + err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast<void**>(&updateExtension));
1.3775 + ASSERT_TRUE(err == KErrNone);
1.3776 + MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface<MCompositionSurfaceUpdate>();
1.3777 + ASSERT_NOT_NULL(updateProxy);
1.3778 +
1.3779 + updateProxy->ContentUpdated(surface, //aSurface
1.3780 + 0, //aBuffer
1.3781 + NULL, //aRegion
1.3782 + NULL, //aStatusConsumed
1.3783 + &statusDisplayed1, //aStatusDisplayed
1.3784 + &timeStamp1, //aTimeStamp
1.3785 + NULL, //aStatusDispXTimes
1.3786 + NULL //aDisplayedXTimes
1.3787 + );
1.3788 +
1.3789 + // Verify that the context's callback is invoked when SubmitUpdate is called.
1.3790 + ASSERT_TRUE(iSourceStreamUpdatedCalled == 2);
1.3791 +
1.3792 + updateProxy->ContentUpdated(surface, //aSurface
1.3793 + 1, //aBuffer
1.3794 + NULL, //aRegion
1.3795 + NULL, //aStatusConsumed
1.3796 + &statusDisplayed2, //aStatusDisplayed
1.3797 + &timeStamp2, //aTimeStamp
1.3798 + NULL, //aStatusDispXTimes
1.3799 + NULL //aDisplayedXTimes
1.3800 + );
1.3801 +
1.3802 + ASSERT_TRUE(iSourceStreamUpdatedCalled == 4);
1.3803 +
1.3804 + User::WaitForRequest(statusDisplayed1);
1.3805 + ASSERT_EQUALS(statusDisplayed1.Int(), KErrOverflow);
1.3806 +
1.3807 + // Pretend that a composition has occured
1.3808 + khronos_int32_t newNotificationsMask = 0;
1.3809 + SymbianStreamProcessNotifications(iNs,
1.3810 + iExpectedSourceStreamUpdatedEventMask,
1.3811 + iScreenNo,
1.3812 + ++iStreamUpdatedSerialNumber,
1.3813 + &newNotificationsMask);
1.3814 +
1.3815 + ASSERT_TRUE(newNotificationsMask == 0);
1.3816 +
1.3817 + // Make sure displayed event was completed
1.3818 + User::WaitForRequest(statusDisplayed2);
1.3819 + ASSERT_EQUALS(statusDisplayed2.Int(), KErrNone);
1.3820 +
1.3821 + SymbianStreamRemoveReference(iNs);
1.3822 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.3823 + }
1.3824 +
1.3825 +
1.3826 +/**
1.3827 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0120_2
1.3828 +@SYMTestCaseDesc Test overflow conditions on notifications for displayed-x-times
1.3829 +@SYMREQ
1.3830 +@SYMPREQ PREQ2400
1.3831 +@SYMTestType CT
1.3832 +@SYMTestPriority High
1.3833 +@SYMTestPurpose Verify that the surface stream adaptation correctly handles duplicate notifications
1.3834 + registered by SUS for content updates on different buffers
1.3835 +@SYMTestActions
1.3836 +
1.3837 + 1. Create a surface
1.3838 + 2. Create a native stream for the surface
1.3839 + 3. Register the test class as an observer for ESOWF_EventUpdated to act as a fake composer
1.3840 + 4. Register for displayed-x-times notification (d1)
1.3841 + 5. Submit an update to the surface on buffer 0
1.3842 + 6. Register for displayed-x-times notification (d2)
1.3843 + 7. Submit an update to the surface on buffer 1
1.3844 + 8. The observer function should be invoked and verifies that stream and event parameters.
1.3845 + 9. Verify d1 status is completed with KErrOverflow
1.3846 + 10. The tester simulates the end of a composition by firing SymbianStreamProcessNotifications
1.3847 + 11. Step 11. is repeated 5 times to simulate 5 compositions.
1.3848 + 12. Verify that d2 status is completed with KErrNone
1.3849 + 13. Destroy the native stream
1.3850 +
1.3851 +@SYMTestExpectedResults
1.3852 + No errors, d1 status completed with KErrOverflow, d2 status completed with KErrNone.
1.3853 +
1.3854 +*/
1.3855 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0120_2L()
1.3856 + {
1.3857 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.3858 + TRAPD(err, GrowCleanupStackL());
1.3859 + ASSERT_TRUE(err == KErrNone);
1.3860 +
1.3861 + iScreenNo = 0;
1.3862 + iContextUpdatedFlags = 0;
1.3863 + iStreamUpdatedSerialNumber = 1;
1.3864 + iSourceStreamUpdatedCalled = 0;
1.3865 + TInt X = 5;
1.3866 + TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4);
1.3867 + ASSERT_FALSE(surface.IsNull());
1.3868 +
1.3869 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.3870 + err = SymbianStreamAcquire(&surface, &iNs);
1.3871 + ASSERT_TRUE(err == KErrNone);
1.3872 + ASSERT_TRUE(iNs);
1.3873 +
1.3874 + err = SymbianStreamAddExtendedObserver(iNs, SourceStreamUpdatedCallback, this, iScreenNo, ESOWF_EventUpdated);
1.3875 + ASSERT_TRUE(err == KErrNone);
1.3876 + iExpectedSourceStreamUpdatedEventMask = ESOWF_EventDisplayedX;
1.3877 +
1.3878 + TRequestStatus statusDisplayedX1, statusDisplayedX2;
1.3879 +
1.3880 + CExtensionContainer* updateExtension = NULL;
1.3881 + err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast<void**>(&updateExtension));
1.3882 + ASSERT_TRUE(err == KErrNone);
1.3883 + MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface<MCompositionSurfaceUpdate>();
1.3884 + ASSERT_NOT_NULL(updateProxy);
1.3885 +
1.3886 + updateProxy->ContentUpdated(surface, //aSurface
1.3887 + 0, //aBuffer
1.3888 + NULL, //aRegion
1.3889 + NULL, //aStatusConsumed
1.3890 + NULL, //aStatusDisplayed
1.3891 + NULL, //aTimeStamp
1.3892 + &statusDisplayedX1, //aStatusDispXTimes
1.3893 + &X //aDisplayedXTimes
1.3894 + );
1.3895 +
1.3896 + // Verify that the context's callback is invoked when SubmitUpdate is called.
1.3897 + ASSERT_TRUE(iSourceStreamUpdatedCalled == 2);
1.3898 +
1.3899 + updateProxy->ContentUpdated(surface, //aSurface
1.3900 + 1, //aBuffer
1.3901 + NULL, //aRegion
1.3902 + NULL, //aStatusConsumed
1.3903 + NULL, //aStatusDisplayed
1.3904 + NULL, //aTimeStamp
1.3905 + &statusDisplayedX2, //aStatusDispXTimes
1.3906 + &X //aDisplayedXTimes
1.3907 + );
1.3908 +
1.3909 + // Verify that the context's callback is invoked when SubmitUpdate is called.
1.3910 + ASSERT_TRUE(iSourceStreamUpdatedCalled == 4);
1.3911 +
1.3912 + User::WaitForRequest(statusDisplayedX1);
1.3913 + ASSERT_EQUALS(statusDisplayedX1.Int(), KErrOverflow);
1.3914 +
1.3915 + for (TInt i = 0; i < X; ++i)
1.3916 + {
1.3917 + ASSERT_EQUALS(statusDisplayedX2.Int(), KRequestPending);
1.3918 +
1.3919 + // Pretend that a composition has occured
1.3920 + khronos_int32_t newNotificationsMask = 0;
1.3921 + SymbianStreamProcessNotifications(iNs,
1.3922 + iExpectedSourceStreamUpdatedEventMask,
1.3923 + iScreenNo,
1.3924 + ++iStreamUpdatedSerialNumber,
1.3925 + &newNotificationsMask);
1.3926 + if (i < X -1)
1.3927 + {
1.3928 + ASSERT_TRUE(newNotificationsMask == ESOWF_EventDisplayedX);
1.3929 + }
1.3930 + else
1.3931 + {
1.3932 + ASSERT_TRUE(newNotificationsMask == 0);
1.3933 + }
1.3934 + }
1.3935 +
1.3936 + // Make sure displayed event was completed
1.3937 + User::WaitForRequest(statusDisplayedX2);
1.3938 + ASSERT_EQUALS(statusDisplayedX2.Int(), KErrNone);
1.3939 +
1.3940 + SymbianStreamRemoveReference(iNs);
1.3941 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.3942 + }
1.3943 +
1.3944 +/**
1.3945 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0120_3
1.3946 +@SYMTestCaseDesc Test overflow conditions on notifications for available
1.3947 +@SYMREQ
1.3948 +@SYMPREQ PREQ2400
1.3949 +@SYMTestType CT
1.3950 +@SYMTestPriority High
1.3951 +@SYMTestPurpose Verify that the surface stream adaptation correctly handles duplicate notifications
1.3952 + registered by SUS for content updates on different buffers
1.3953 +@SYMTestActions
1.3954 +
1.3955 + 1. Create a surface
1.3956 + 2. Create a native stream for the surface
1.3957 + 3. Register the test class as an observer for ESOWF_EventUpdated to act as a fake composer
1.3958 + 4. Register for available notification (d1)
1.3959 + 5. Submit an update to the surface on buffer 0
1.3960 + 6. Register for available notification (d2)
1.3961 + 7. Submit an update to the surface on buffer 1
1.3962 + 8. The observer function should be invoked and verifies that stream and event parameters.
1.3963 + 9. The tester simulates the end of a composition by firing SymbianStreamProcessNotifications
1.3964 + 10. Verify d1 status is completed with KErrOverflow and d2 status is completed with KErrNone
1.3965 + 11. Destroy the native stream
1.3966 +
1.3967 +@SYMTestExpectedResults
1.3968 + No errors, d1 status completed with KErrOverflow, d2 status completed with KErrNone.
1.3969 +
1.3970 +*/
1.3971 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0120_3L()
1.3972 + {
1.3973 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.3974 + TRAPD(err, GrowCleanupStackL());
1.3975 + ASSERT_TRUE(err == KErrNone);
1.3976 +
1.3977 + iScreenNo = 0;
1.3978 + iContextUpdatedFlags = 0;
1.3979 + iStreamUpdatedSerialNumber = 1;
1.3980 + iSourceStreamUpdatedCalled = 0;
1.3981 + //force composition, otherwise we may never be able to experience the overflow
1.3982 + iImmediateAvailable = EFalse;
1.3983 + iImmediateVisible = SYM_CONTENT_VISIBLE;
1.3984 + TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4);
1.3985 + ASSERT_FALSE(surface.IsNull());
1.3986 +
1.3987 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.3988 + err = SymbianStreamAcquire(&surface, &iNs);
1.3989 + ASSERT_TRUE(err == KErrNone);
1.3990 + ASSERT_TRUE(iNs);
1.3991 +
1.3992 + err = SymbianStreamAddExtendedObserver(iNs, SourceStreamUpdatedCallback, this, iScreenNo, ESOWF_EventUpdated);
1.3993 + ASSERT_TRUE(err == KErrNone);
1.3994 +
1.3995 + TRequestStatus statusAvailable1, statusAvailable2, statusAvailable3;
1.3996 +
1.3997 + CExtensionContainer* updateExtension = NULL;
1.3998 + err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast<void**>(&updateExtension));
1.3999 + ASSERT_TRUE(err == KErrNone);
1.4000 + MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface<MCompositionSurfaceUpdate>();
1.4001 + ASSERT_NOT_NULL(updateProxy);
1.4002 +
1.4003 + iExpectedSourceStreamUpdatedEventMask = 0;
1.4004 +
1.4005 + updateProxy->ContentUpdated(surface, //aSurface
1.4006 + 0, //aBuffer
1.4007 + NULL, //aRegion
1.4008 + &statusAvailable1, //aStatusConsumed
1.4009 + NULL, //aStatusDisplayed
1.4010 + NULL, //aTimeStamp
1.4011 + NULL, //aStatusDispXTimes
1.4012 + NULL //aDisplayedXTimes
1.4013 + );
1.4014 +
1.4015 + // Verify that the context's callback is invoked when SubmitUpdate is called.
1.4016 + ASSERT_TRUE(iSourceStreamUpdatedCalled == 2);
1.4017 +
1.4018 + iExpectedSourceStreamUpdatedEventMask = ESOWF_EventAvailable;
1.4019 +
1.4020 + updateProxy->ContentUpdated(surface, //aSurface
1.4021 + 1, //aBuffer
1.4022 + NULL, //aRegion
1.4023 + &statusAvailable2, //aStatusConsumed
1.4024 + NULL, //aStatusDisplayed
1.4025 + NULL, //aTimeStamp
1.4026 + NULL, //aStatusDispXTimes
1.4027 + NULL //aDisplayedXTimes
1.4028 + );
1.4029 +
1.4030 + // Verify that the context's callback is invoked when SubmitUpdate is called.
1.4031 + ASSERT_TRUE(iSourceStreamUpdatedCalled == 4);
1.4032 +
1.4033 + iExpectedSourceStreamUpdatedEventMask = ESOWF_EventAvailable;
1.4034 +
1.4035 + updateProxy->ContentUpdated(surface, //aSurface
1.4036 + 2, //aBuffer
1.4037 + NULL, //aRegion
1.4038 + &statusAvailable3, //aStatusConsumed
1.4039 + NULL, //aStatusDisplayed
1.4040 + NULL, //aTimeStamp
1.4041 + NULL, //aStatusDispXTimes
1.4042 + NULL //aDisplayedXTimes
1.4043 + );
1.4044 +
1.4045 + // Verify that the context's callback is invoked when SubmitUpdate is called.
1.4046 + ASSERT_TRUE(iSourceStreamUpdatedCalled == 6);
1.4047 +
1.4048 + // Theoretically KErrNone could be returned because buffer 0 is actually available.
1.4049 + // However, this would be a change in behaviour.
1.4050 + User::WaitForRequest(statusAvailable1);
1.4051 + ASSERT_EQUALS(statusAvailable1.Int(), KErrOverflow);
1.4052 +
1.4053 + // Pretend that a composition has occured
1.4054 + khronos_int32_t newNotificationsMask = 0;
1.4055 + SymbianStreamProcessNotifications(iNs,
1.4056 + iExpectedSourceStreamUpdatedEventMask,
1.4057 + iScreenNo,
1.4058 + iStreamUpdatedSerialNumber,
1.4059 + &newNotificationsMask);
1.4060 +
1.4061 + ASSERT_TRUE(newNotificationsMask == 0);
1.4062 +
1.4063 + // Make sure displayed event was completed
1.4064 + User::WaitForRequest(statusAvailable2);
1.4065 + ASSERT_EQUALS(statusAvailable2.Int(), KErrNone);
1.4066 +
1.4067 + SymbianStreamRemoveReference(iNs);
1.4068 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.4069 + }
1.4070 +
1.4071 +
1.4072 +
1.4073 +/**
1.4074 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0122
1.4075 +@SYMTestCaseDesc
1.4076 +@SYMREQ
1.4077 +@SYMPREQ PREQ2400
1.4078 +@SYMTestType CT
1.4079 +@SYMTestPriority High
1.4080 +@SYMTestPurpose Tests an end to end displayed notification.
1.4081 +@SYMTestActions
1.4082 +
1.4083 + 1. Create a surface.
1.4084 + 2. Create a native stream for the surface.
1.4085 + 3. Register an observer for content-update events.
1.4086 + 4. Register notifications for displayed, available and displayed-x-times.
1.4087 + 5. Submit an update to the surface
1.4088 + 6. Remove the content-updated observer.
1.4089 + 7. Wait for the request status objects to be completed.
1.4090 +
1.4091 +@SYMTestExpectedResults
1.4092 + The notification status objects are completed with KErrCancel.
1.4093 +
1.4094 + **/
1.4095 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0122L()
1.4096 + {
1.4097 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.4098 + TRAPD(err, GrowCleanupStackL());
1.4099 + ASSERT_TRUE(err == KErrNone);
1.4100 +
1.4101 + iScreenNo = 0;
1.4102 + iContextUpdatedFlags = 0;
1.4103 + iStreamUpdatedSerialNumber = 1;
1.4104 + iSourceStreamUpdatedCalled = 0;
1.4105 + CTestNativeStream::iTester = this;
1.4106 + iImmediateVisible = SYM_CONTENT_VISIBLE;
1.4107 + TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4);
1.4108 + ASSERT_FALSE(surface.IsNull());
1.4109 +
1.4110 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.4111 + err = SymbianStreamAcquire(&surface, &iNs);
1.4112 + ASSERT_TRUE(err == KErrNone);
1.4113 + ASSERT_TRUE(iNs);
1.4114 +
1.4115 + err = SymbianStreamAddExtendedObserver(iNs, SourceStreamUpdatedCallback, this, iScreenNo, ESOWF_EventUpdated);
1.4116 + ASSERT_TRUE(err == KErrNone);
1.4117 +
1.4118 + TRequestStatus statusDisplayed, statusAvailable, statusDisplayedX;
1.4119 + TUint32 displayedTime = 0;
1.4120 + TInt X = 42;
1.4121 +
1.4122 + CExtensionContainer* updateExtension = NULL;
1.4123 + err = SymbianStreamHasRegisteredScreenNotifications(iScreenNo,reinterpret_cast<void**>(&updateExtension));
1.4124 + ASSERT_TRUE(err == KErrNone);
1.4125 + MCompositionSurfaceUpdate* updateProxy=updateExtension->GetInterface<MCompositionSurfaceUpdate>();
1.4126 + ASSERT_NOT_NULL(updateProxy);
1.4127 +
1.4128 + iExpectedSourceStreamUpdatedEventMask = ESOWF_EventDisplayed | ESOWF_EventDisplayedX;
1.4129 +
1.4130 + updateProxy->ContentUpdated(surface, //aSurface
1.4131 + 0, //aBuffer
1.4132 + NULL, //aRegion
1.4133 + &statusAvailable, //aStatusConsumed
1.4134 + &statusDisplayed, //aStatusDisplayed
1.4135 + &displayedTime, //aTimeStamp
1.4136 + &statusDisplayedX, //aStatusDispXTimes
1.4137 + &X //aDisplayedXTimes
1.4138 + );
1.4139 +
1.4140 + ASSERT_TRUE(iSourceStreamUpdatedCalled == 2);
1.4141 + err = SymbianStreamRemoveObserver(iNs, this, ESOWF_EventUpdated);
1.4142 + ASSERT_TRUE(err == KErrNone);
1.4143 +
1.4144 + User::WaitForRequest(statusDisplayed);
1.4145 + ASSERT_EQUALS(statusDisplayed.Int(), KErrCancel);
1.4146 + User::WaitForRequest(statusAvailable);
1.4147 + ASSERT_EQUALS(statusAvailable.Int(), KErrCancel);
1.4148 + User::WaitForRequest(statusDisplayedX);
1.4149 + ASSERT_EQUALS(statusDisplayedX.Int(), KErrCancel);
1.4150 +
1.4151 + SymbianStreamRemoveReference(iNs);
1.4152 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.4153 +
1.4154 + iUtility->DestroySurface(surface);
1.4155 + }
1.4156 +
1.4157 +/**
1.4158 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0130
1.4159 +@SYMTestCaseDesc Add/remove Sym observers - positive test cases
1.4160 +@SYMREQ
1.4161 +@SYMPREQ PREQ2400
1.4162 +@SYMTestType CT
1.4163 +@SYMTestPriority
1.4164 +@SYMTestPurpose Verify that Sym observers can be added, removed and re-added
1.4165 +@SYMTestActions
1.4166 + Create a surface with 1 buffer
1.4167 + Add a Sym observer (displayed notification)
1.4168 + Remove the Sym observer
1.4169 + Add the Sym observer
1.4170 +@SYMTestExpectedResults
1.4171 + KErrNone is returned when the Sym observer is added
1.4172 + KErrNone is returned when the Sym observer is removed
1.4173 + KErrNone is returned when the Sym observer is re-added
1.4174 + **/
1.4175 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0130L()
1.4176 + {
1.4177 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.4178 + TRAPD(err, GrowCleanupStackL());
1.4179 + ASSERT_TRUE(err == KErrNone);
1.4180 +
1.4181 + TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 1);
1.4182 + ASSERT_FALSE(surface.IsNull());
1.4183 +
1.4184 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.4185 + SymbianStreamType ns;
1.4186 + err = SymbianStreamAcquire(&surface,&ns);
1.4187 + ASSERT_TRUE(err == KErrNone);
1.4188 + ASSERT_TRUE(ns);
1.4189 +
1.4190 + TInt32 screenNumber = 0;
1.4191 + TInt localnumber = 0;
1.4192 + err = SymbianStreamAddExtendedObserver(ns, TestUpdateCallback, &localnumber, screenNumber, ESOWF_EventDisplayed);
1.4193 + ASSERT_TRUE(err == KErrNone);
1.4194 + err = SymbianStreamRemoveObserver(ns, &localnumber, ESOWF_EventDisplayed);
1.4195 + ASSERT_TRUE(err == KErrNone);
1.4196 + err = SymbianStreamAddExtendedObserver(ns, TestUpdateCallback, &localnumber, screenNumber, ESOWF_EventDisplayed);
1.4197 + ASSERT_TRUE(err == KErrNone);
1.4198 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.4199 + }
1.4200 +
1.4201 +/**
1.4202 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0131
1.4203 +@SYMTestCaseDesc Add/remove Sym observers - negative test cases
1.4204 +@SYMREQ
1.4205 +@SYMPREQ PREQ2400
1.4206 +@SYMTestType CT
1.4207 +@SYMTestPriority
1.4208 +@SYMTestPurpose Verify that Sym observers reject invalid parameters
1.4209 +@SYMTestActions
1.4210 + Create a surface with 1 buffer
1.4211 + Add an invalid Sym observer (invalid event flag)
1.4212 + Remove a non-existent Sym observer
1.4213 + Add a valid Sym observer
1.4214 + Add the same Sym observer
1.4215 + Remove the valid Sym observer
1.4216 + Remove the same Sym observer
1.4217 +@SYMTestExpectedResults
1.4218 + KErrArgument is returned and the observer list is un-changed
1.4219 + KErrNotFound is returned and the observer list is un-changed
1.4220 + KErrOverflow is returned when the Sym observer is added again and the observer list is un-changed
1.4221 + KErrNotFound is returned when the Sym observer is removed again the observer list is un-changed
1.4222 + **/
1.4223 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0131L()
1.4224 + {
1.4225 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.4226 + TRAPD(err, GrowCleanupStackL());
1.4227 + ASSERT_TRUE(err == KErrNone);
1.4228 +
1.4229 + TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 1);
1.4230 + ASSERT_FALSE(surface.IsNull());
1.4231 +
1.4232 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.4233 + SymbianStreamType ns;
1.4234 + err = SymbianStreamAcquire(&surface, &ns);
1.4235 + ASSERT_TRUE(err == KErrNone);
1.4236 + ASSERT_TRUE(ns);
1.4237 +
1.4238 + TInt32 screenNumber = 0;
1.4239 + err = SymbianStreamAddExtendedObserver(ns, NULL, NULL, screenNumber, ESOWF_NoEvent);
1.4240 + ASSERT_TRUE(err == KErrArgument);
1.4241 + err = SymbianStreamRemoveObserver(ns, &screenNumber, ESOWF_EventDisplayed);
1.4242 + ASSERT_TRUE(err == KErrNotFound);
1.4243 +
1.4244 + // add the same observer twice
1.4245 + err = SymbianStreamAddExtendedObserver(ns, NULL, NULL, screenNumber, ESOWF_EventDisplayed);
1.4246 + ASSERT_TRUE(err == KErrArgument);
1.4247 + err = SymbianStreamAddExtendedObserver(ns, NULL, NULL, screenNumber, ESOWF_EventDisplayed);
1.4248 + ASSERT_TRUE(err == KErrArgument);
1.4249 +
1.4250 + // remove the same observer
1.4251 + err = SymbianStreamRemoveObserver(ns, &screenNumber, ESOWF_EventDisplayed);
1.4252 + ASSERT_TRUE(err == KErrNotFound);
1.4253 + err = SymbianStreamRemoveObserver(ns, &screenNumber, ESOWF_EventDisplayed);
1.4254 + ASSERT_TRUE(err == KErrNotFound);
1.4255 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.4256 + }
1.4257 +
1.4258 +/**
1.4259 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0132
1.4260 +@SYMTestCaseDesc Destroy a native stream when a Sym observer is registered
1.4261 +@SYMREQ
1.4262 +@SYMPREQ PREQ2400
1.4263 +@SYMTestType CT
1.4264 +@SYMTestPriority
1.4265 +@SYMTestPurpose Verify that Sym observers are safely removed before native stream destruction
1.4266 +@SYMTestActions
1.4267 + Create a surface with 1 buffer
1.4268 + Add a Sym observer (displayed notification)
1.4269 + Destroy the native stream
1.4270 + Create another native stream using the surface created previously
1.4271 + Remove the same Sym observer added in step 2
1.4272 +@SYMTestExpectedResults
1.4273 + KErrNone is returned when the Sym observer is added
1.4274 + KErrNotFound is returned when the Sym observer is attempting to be removed
1.4275 + **/
1.4276 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0132L()
1.4277 + {
1.4278 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.4279 + TRAPD(err, GrowCleanupStackL());
1.4280 + ASSERT_TRUE(err == KErrNone);
1.4281 +
1.4282 + TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 1);
1.4283 + ASSERT_FALSE(surface.IsNull());
1.4284 +
1.4285 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.4286 + SymbianStreamType ns;
1.4287 + err = SymbianStreamAcquire(&surface, &ns);
1.4288 + ASSERT_TRUE(err == KErrNone);
1.4289 + ASSERT_TRUE(ns);
1.4290 +
1.4291 + TInt screenNumber = 0;
1.4292 + err = SymbianStreamAddExtendedObserver(ns, NULL, NULL, screenNumber, ESOWF_EventDisplayed);
1.4293 + ASSERT_TRUE(err == KErrArgument);
1.4294 +
1.4295 + SymbianStreamRemoveReference(ns);
1.4296 +
1.4297 + SymbianStreamType ns2;
1.4298 + err = SymbianStreamAcquire(&surface, &ns2);
1.4299 + ASSERT_TRUE(err == KErrNone);
1.4300 + ASSERT_TRUE(ns2);
1.4301 +
1.4302 + err = SymbianStreamRemoveObserver(ns2, &screenNumber, ESOWF_EventDisplayed);
1.4303 + ASSERT_TRUE(err == KErrNotFound);
1.4304 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.4305 + }
1.4306 +
1.4307 +/**
1.4308 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0133
1.4309 +@SYMTestCaseDesc Test the construction/destruction of a CContentUpdateProxy
1.4310 +@SYMREQ
1.4311 +@SYMPREQ PREQ2400
1.4312 +@SYMTestType CT
1.4313 +@SYMTestPriority
1.4314 +@SYMTestPurpose Verify that additional screens can be created and destroyed
1.4315 +@SYMTestActions
1.4316 +
1.4317 + 1. Create a new CContentUpdateProxy (screen 1)
1.4318 + 2. Verify API version and Internal version are correct
1.4319 + 3. Create a surface
1.4320 + 4. Create a native stream for the surface
1.4321 + 5. Register the test class as an observer for ESOWF_EventUpdated to act as a fake composer
1.4322 + 6. Submit an update to the surface
1.4323 + 7. The observer function should be invoked and verifies that stream and event parameters.
1.4324 + 8. Verify that the source-stream updated callback is invoked.
1.4325 + 9. Destroy the native stream.
1.4326 + 10. Destroy the CContentUpdateProxy (screen 1)
1.4327 +
1.4328 +@SYMTestExpectedResults
1.4329 + KErrNone is returned when screen 1 is created
1.4330 + API version and Internal version match expected results
1.4331 + KErrNone is returned when screen 1 is destroyed
1.4332 + **/
1.4333 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0133L()
1.4334 + {
1.4335 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.4336 + TRAPD(err, GrowCleanupStackL());
1.4337 + ASSERT_TRUE(err == KErrNone);
1.4338 +
1.4339 + // Register a new screen
1.4340 + iScreenNo = 0;
1.4341 + iContextUpdatedFlags = 0;
1.4342 + iStreamUpdatedSerialNumber = 1;
1.4343 + iSourceStreamUpdatedCalled = 0;
1.4344 + iImmediateVisible = SYM_CONTENT_VISIBLE;
1.4345 +
1.4346 + TSurfaceId surface=iUtility->CreateSurfaceL(TSize(100,100), EUidPixelFormatARGB_8888_PRE, 400, 4);
1.4347 + ASSERT_FALSE(surface.IsNull());
1.4348 +
1.4349 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.4350 + err = SymbianStreamRegisterScreenNotifications(1, 0, KCompositorVersion);
1.4351 + ASSERT_TRUE(err == KErrNone);
1.4352 +
1.4353 +
1.4354 + CExtensionContainer* updateExtension = NULL;
1.4355 + err = SymbianStreamHasRegisteredScreenNotifications(1,reinterpret_cast<void**>(&updateExtension));
1.4356 + ASSERT_TRUE(err == KErrNone);
1.4357 + MCompositionSurfaceUpdate* screen1=updateExtension->GetInterface<MCompositionSurfaceUpdate>();
1.4358 + ASSERT_NOT_NULL(screen1);
1.4359 +
1.4360 + TVersion expectedVersion(KCompositorVersionMajor,KCompositorVersionMinor,KCompositorVersionRevision);
1.4361 +
1.4362 + ASSERT_EQUALS(screen1->ApiVersion(), 3);
1.4363 + ASSERT_TRUE(screen1->InternalVersion().iBuild == expectedVersion.iBuild &&
1.4364 + screen1->InternalVersion().iMajor == expectedVersion.iMajor &&
1.4365 + screen1->InternalVersion().iMinor == expectedVersion.iMinor);
1.4366 +
1.4367 + err = SymbianStreamAcquire(&surface, &iNs);
1.4368 + ASSERT_TRUE(err == KErrNone);
1.4369 + ASSERT_TRUE(iNs);
1.4370 +
1.4371 + iExpectedSourceStreamUpdatedEventMask = 0;
1.4372 + err = SymbianStreamAddObserver(iNs, SourceStreamUpdatedCallback, this);
1.4373 + ASSERT_TRUE(err == KErrNone);
1.4374 +
1.4375 + iSourceStreamUpdatedCalled = EFalse;
1.4376 + screen1->ContentUpdated(surface,0,NULL,NULL,NULL,NULL,NULL,NULL);
1.4377 +
1.4378 + // Verify that the context's callback (screen 1) is invoked when SubmitUpdate is called.
1.4379 + ASSERT_TRUE(iSourceStreamUpdatedCalled == 1);
1.4380 +
1.4381 + SymbianStreamRemoveReference(iNs);
1.4382 +
1.4383 + // Destroy the context (screen 1)
1.4384 + err = SymbianStreamUnregisterScreenNotifications(1);
1.4385 + ASSERT_TRUE(err == KErrNone);
1.4386 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.4387 + }
1.4388 +
1.4389 +/**
1.4390 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0140
1.4391 +@SYMTestCaseDesc Negative test - Acquire write/read buffers and retrieve the buffer ptr (single threaded test).
1.4392 +@SYMREQ
1.4393 +@SYMPREQ PREQ2400
1.4394 +@SYMTestType CT
1.4395 +@SYMTestPriority
1.4396 +@SYMTestPurpose Verify SymbianStreamAcquireWriteBuffer(), SymbianStreamReleaseWriteBuffer(),
1.4397 + SymbianStreamAcquireReadBuffer() and SymbianStreamReleaseReadBuffer() methods
1.4398 + work as expected.
1.4399 +
1.4400 +@SYMTestActions
1.4401 + Create a native stream
1.4402 + For each buffer:
1.4403 + - Acquire the read buffer
1.4404 + - Acquire the write buffer
1.4405 + - Release the write buffer
1.4406 + - Acquire the read buffer
1.4407 +
1.4408 + Repeat for each buffer. Finally:
1.4409 + Acquire the write buffer
1.4410 + Release the write buffer
1.4411 +@SYMTestExpectedResults
1.4412 + For each buffer of the native stream, check:
1.4413 + - The read buffer should be aquired successfully
1.4414 + If the number of buffers = 1, check:
1.4415 + - The write buffer should be aquired successfully
1.4416 + If the number of buffers > 1, check:
1.4417 + - The write buffer before the final one should be aquired successfully
1.4418 + - The final acquire write buffer call should return OWF_INVALID_HANDLE if not single buffered
1.4419 + **/
1.4420 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0140L(TInt aNumBuffers)
1.4421 + {
1.4422 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.4423 + TRAPD(err, GrowCleanupStackL());
1.4424 + ASSERT_TRUE(err == KErrNone);
1.4425 +
1.4426 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.4427 +
1.4428 + ASSERT_TRUE(aNumBuffers > 0);
1.4429 +
1.4430 + TSize surfaceSize(TSize(100,100));
1.4431 + khronos_int32_t width = surfaceSize.iWidth;
1.4432 + khronos_int32_t height = surfaceSize.iHeight;
1.4433 +
1.4434 + OWF_IMAGE_FORMAT pixelFormat =
1.4435 + {
1.4436 + OWF_IMAGE_ARGB8888,
1.4437 + ETrue,
1.4438 + ETrue,
1.4439 + aNumBuffers
1.4440 + };
1.4441 +
1.4442 + SymbianStreamType ns=helperCreateImageStream(width,
1.4443 + height,
1.4444 + &pixelFormat,
1.4445 + aNumBuffers);
1.4446 + ASSERT_TRUE(ns);
1.4447 +
1.4448 + khronos_int32_t writeBuffer = 0;
1.4449 + khronos_int32_t readBuffer = 0;
1.4450 + TInt bufferCount;
1.4451 +
1.4452 + if (aNumBuffers == 1)
1.4453 + {
1.4454 + bufferCount = aNumBuffers;
1.4455 + }
1.4456 + else
1.4457 + {
1.4458 + bufferCount = aNumBuffers - 1;
1.4459 + }
1.4460 +
1.4461 + RArray<TInt> bufferHandleArray;
1.4462 +
1.4463 + // Loop through the buffers
1.4464 + for (TInt count=0; count<bufferCount; count++)
1.4465 + {
1.4466 + err = SymbianStreamAcquireReadBuffer(ns, &readBuffer);
1.4467 + ASSERT_TRUE(err == KErrNone);
1.4468 + ASSERT_TRUE(readBuffer);
1.4469 + bufferHandleArray.Append(readBuffer);
1.4470 +
1.4471 + // Acquire the write buffer
1.4472 + err = SymbianStreamAcquireWriteBuffer(ns, &writeBuffer);
1.4473 + ASSERT_TRUE(err == KErrNone);
1.4474 + ASSERT_TRUE(writeBuffer);
1.4475 + SymbianStreamReleaseWriteBuffer(ns,writeBuffer);
1.4476 + }
1.4477 +
1.4478 + // Acquire final read buffer
1.4479 + khronos_int32_t finalReadBuffer;
1.4480 + err = SymbianStreamAcquireReadBuffer(ns, &finalReadBuffer);
1.4481 + ASSERT_TRUE(err == KErrNone);
1.4482 + ASSERT_TRUE(finalReadBuffer);
1.4483 + bufferHandleArray.Append(finalReadBuffer);
1.4484 +
1.4485 + khronos_int32_t finalWriteBuffer;
1.4486 + err = SymbianStreamAcquireWriteBuffer(ns, &finalWriteBuffer);
1.4487 + ASSERT_TRUE(err != KErrBadHandle);
1.4488 +
1.4489 + // Final checks
1.4490 + if (aNumBuffers == 1)
1.4491 + {
1.4492 + ASSERT_TRUE(finalWriteBuffer);
1.4493 + err = SymbianStreamReleaseWriteBuffer(ns,finalWriteBuffer);
1.4494 + ASSERT_TRUE(err == KErrNone);
1.4495 + }
1.4496 + else
1.4497 + {
1.4498 + ASSERT_FALSE(finalWriteBuffer);
1.4499 + }
1.4500 +
1.4501 + for (TInt x=0; x < bufferHandleArray.Count(); ++x)
1.4502 + {
1.4503 + err = SymbianStreamReleaseReadBuffer(ns,bufferHandleArray[x]);
1.4504 + ASSERT_TRUE(err == KErrNone);
1.4505 + }
1.4506 +
1.4507 + err = SymbianStreamAcquireWriteBuffer(ns,&writeBuffer);
1.4508 + ASSERT_TRUE(err == KErrNone);
1.4509 + ASSERT_TRUE(writeBuffer);
1.4510 + err = SymbianStreamReleaseWriteBuffer(ns,writeBuffer);
1.4511 + ASSERT_TRUE(err == KErrNone);
1.4512 + ASSERT_TRUE(writeBuffer);
1.4513 +
1.4514 + bufferHandleArray.Close();
1.4515 + SymbianStreamRemoveReference(ns);
1.4516 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.4517 + }
1.4518 +
1.4519 +/**
1.4520 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0141
1.4521 +@SYMTestCaseDesc Negative test - Acquire multiple read buffers before releasing write buffer (single threaded test).
1.4522 +@SYMREQ
1.4523 +@SYMPREQ PREQ2400
1.4524 +@SYMTestType CT
1.4525 +@SYMTestPriority
1.4526 +@SYMTestPurpose Verify SymbianStreamAcquireWriteBuffer(), SymbianStreamReleaseWriteBuffer(),
1.4527 + SymbianStreamAcquireReadBuffer() and SymbianStreamReleaseReadBuffer() methods
1.4528 + work as expected.
1.4529 +
1.4530 +@SYMTestActions
1.4531 + Create a native stream
1.4532 + For each buffer:
1.4533 + - Acquire the read buffer multiple times
1.4534 + - Acquire the write buffer
1.4535 + - Acquire the read buffer
1.4536 + - Release the write buffer
1.4537 + - Acquire the read buffer
1.4538 +
1.4539 +@SYMTestExpectedResults
1.4540 + For each buffer of the native stream, check:
1.4541 + - The read buffer index should remain the same before release write bufffer is called
1.4542 + If the number of buffers = 1, check:
1.4543 + - The buffer index is always the same
1.4544 + If the number of buffers > 1, check:
1.4545 + - The buffer index increments after release write buffer is called
1.4546 + **/
1.4547 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0141L(TInt aNumBuffers)
1.4548 + {
1.4549 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.4550 + TRAPD(err, GrowCleanupStackL());
1.4551 + ASSERT_TRUE(err == KErrNone);
1.4552 +
1.4553 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.4554 +
1.4555 + ASSERT_TRUE(aNumBuffers > 0);
1.4556 +
1.4557 + TSize surfaceSize(TSize(100,100));
1.4558 + khronos_int32_t width = surfaceSize.iWidth;
1.4559 + khronos_int32_t height = surfaceSize.iHeight;
1.4560 +
1.4561 + OWF_IMAGE_FORMAT pixelFormat =
1.4562 + {
1.4563 + OWF_IMAGE_ARGB8888,
1.4564 + ETrue,
1.4565 + ETrue,
1.4566 + aNumBuffers
1.4567 + };
1.4568 +
1.4569 + SymbianStreamType ns=helperCreateImageStream(width,
1.4570 + height,
1.4571 + &pixelFormat,
1.4572 + aNumBuffers);
1.4573 + ASSERT_TRUE(ns);
1.4574 +
1.4575 + khronos_int32_t writeBuffer = 0;
1.4576 + khronos_int32_t readBuffer = 0;
1.4577 + khronos_int32_t bufferIndexRead1, bufferIndexRead2, bufferIndexRead3, bufferIndexRead4;
1.4578 + khronos_int32_t bufferIndexWrite;
1.4579 +
1.4580 + err = SymbianStreamAcquireReadBuffer(ns, &readBuffer);
1.4581 + ASSERT_TRUE(err == KErrNone);
1.4582 + ASSERT_TRUE(readBuffer);
1.4583 + const TSurfaceId* getId = NULL;
1.4584 + err = SymbianStreamGetBufferId(ns,readBuffer,&bufferIndexRead1,&getId);
1.4585 + ASSERT_TRUE(err == KErrNone);
1.4586 + err = SymbianStreamReleaseReadBuffer(ns,readBuffer);
1.4587 + ASSERT_TRUE(err == KErrNone);
1.4588 +
1.4589 + err = SymbianStreamAcquireReadBuffer(ns, &readBuffer);
1.4590 + ASSERT_TRUE(err == KErrNone);
1.4591 + ASSERT_TRUE(readBuffer);
1.4592 + err = SymbianStreamGetBufferId(ns,readBuffer,&bufferIndexRead2,&getId);
1.4593 + ASSERT_TRUE(err == KErrNone);
1.4594 + SymbianStreamReleaseReadBuffer(ns,readBuffer);
1.4595 + ASSERT_EQUALS(bufferIndexRead1, bufferIndexRead2);
1.4596 +
1.4597 + err = SymbianStreamAcquireWriteBuffer(ns,&writeBuffer);
1.4598 + ASSERT_TRUE(err == KErrNone);
1.4599 + ASSERT_TRUE(writeBuffer);
1.4600 + err = SymbianStreamGetBufferId(ns,writeBuffer,&bufferIndexWrite,&getId);
1.4601 + ASSERT_TRUE(err == KErrNone);
1.4602 + if (aNumBuffers == 1)
1.4603 + {
1.4604 + ASSERT_EQUALS(bufferIndexRead2, bufferIndexWrite);
1.4605 + }
1.4606 + else
1.4607 + {
1.4608 + ASSERT_NOT_EQUALS((bufferIndexRead2), bufferIndexWrite);
1.4609 + }
1.4610 +
1.4611 + err = SymbianStreamAcquireReadBuffer(ns,&readBuffer);
1.4612 + ASSERT_TRUE(err == KErrNone);
1.4613 + ASSERT_TRUE(readBuffer);
1.4614 + err = SymbianStreamGetBufferId(ns,readBuffer,&bufferIndexRead3,&getId);
1.4615 + ASSERT_TRUE(err == KErrNone);
1.4616 + err = SymbianStreamReleaseReadBuffer(ns,readBuffer);
1.4617 + ASSERT_TRUE(err == KErrNone);
1.4618 + ASSERT_EQUALS(bufferIndexRead3, bufferIndexRead2);
1.4619 +
1.4620 + err = SymbianStreamReleaseWriteBuffer(ns,writeBuffer);
1.4621 + ASSERT_TRUE(err == KErrNone);
1.4622 +
1.4623 + err = SymbianStreamAcquireReadBuffer(ns,&readBuffer);
1.4624 + ASSERT_TRUE(err == KErrNone);
1.4625 + ASSERT_TRUE(readBuffer);
1.4626 + err = SymbianStreamGetBufferId(ns,readBuffer,&bufferIndexRead4,&getId);
1.4627 + ASSERT_TRUE(err == KErrNone);
1.4628 + err = SymbianStreamReleaseReadBuffer(ns,readBuffer);
1.4629 + ASSERT_TRUE(err == KErrNone);
1.4630 + if (aNumBuffers == 1)
1.4631 + {
1.4632 + ASSERT_EQUALS(bufferIndexRead3, bufferIndexRead4);
1.4633 + }
1.4634 + else
1.4635 + {
1.4636 + ASSERT_NOT_EQUALS((bufferIndexRead3), bufferIndexRead4);
1.4637 + }
1.4638 +
1.4639 + SymbianStreamRemoveReference(ns);
1.4640 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.4641 + }
1.4642 +
1.4643 +/**
1.4644 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0142
1.4645 +@SYMTestCaseDesc Special surface ID unit tests
1.4646 +@SYMREQ
1.4647 +@SYMPREQ PREQ2400
1.4648 +@SYMTestType
1.4649 +@SYMTestPriority
1.4650 +@SYMTestPurpose Exercise special surface creation and flip operations
1.4651 +
1.4652 +@SYMTestActions
1.4653 + Generate a special surface ID with pixel formats of type
1.4654 + EUidPixelFormatARGB_8888_PRE, EUidPixelFormatRGB_888,
1.4655 + EUidPixelFormatRGB_565, and EUidPixelFormatRGB_332. Then
1.4656 + - Acquire the read buffer
1.4657 + - Acquire the write buffer
1.4658 + - Check that they are the same
1.4659 + - Add a value to the read buffer
1.4660 + - Check that the write buffer has the same value
1.4661 + - Release the write buffer
1.4662 + - Release the read buffer
1.4663 + Then reset the special surface ID, acquire a stream, and read header data.
1.4664 + Set the flip flag to true and re-acquire the stream.
1.4665 + Compare header data of pre-flip and post-flip cases.
1.4666 +
1.4667 +@SYMTestExpectedResults
1.4668 + Read/write buffer pairs are always identical.
1.4669 + Flipped stream has width and height switched and stride is different
1.4670 + **/
1.4671 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0142L()
1.4672 + {
1.4673 + _LIT(KDisplayChannelLdd, "display0.ldd");
1.4674 +
1.4675 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.4676 + TRAPD(err, GrowCleanupStackL());
1.4677 + ASSERT_TRUE(err == KErrNone);
1.4678 +
1.4679 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.4680 +
1.4681 + err = User::LoadLogicalDevice(KDisplayChannelLdd);
1.4682 + RDisplayChannel testChannel;
1.4683 + if (err == KErrNone || err == KErrAlreadyExists)
1.4684 + {
1.4685 + User::LeaveIfError(testChannel.Open(0));
1.4686 + }
1.4687 +
1.4688 + TSurfaceId testId;
1.4689 + SymbianStreamType ns;
1.4690 + TUidPixelFormat testGuids[] = {EUidPixelFormatARGB_8888_PRE, EUidPixelFormatRGB_888, EUidPixelFormatRGB_565, EUidPixelFormatRGB_332};
1.4691 + TInt size = sizeof(testGuids) / sizeof(testGuids[0]);
1.4692 + TUint8 *pWriteBuffer = NULL;
1.4693 + khronos_int32_t writeBuffer;
1.4694 + TUint8 *pReadBuffer = NULL;
1.4695 + khronos_int32_t readBuffer;
1.4696 +
1.4697 + TInt halStride = 0;
1.4698 + TInt halMode = 0;
1.4699 +
1.4700 + // For header variables before flipping
1.4701 + TInt32 preFlipWidth = 0;
1.4702 + TInt32 preFlipHeight = 0;
1.4703 + TInt32 preFlipStreamStride = 0;
1.4704 + TInt32 preFlipStreamFormat = EUidPixelFormatUnknown;
1.4705 + TInt32 preFlipStreamPixelSize = 0;
1.4706 +
1.4707 + // For header variables after flipping
1.4708 + TInt32 width = 0;
1.4709 + TInt32 height = 0;
1.4710 + TInt32 streamStride = 0;
1.4711 + TInt32 streamFormat = EUidPixelFormatUnknown;
1.4712 + TInt32 streamPixelSize = 0;
1.4713 +
1.4714 + for (TInt ii = 0; ii < size; ii++)
1.4715 + {
1.4716 + HAL::Get(0, HALData::EDisplayMode, halMode);
1.4717 +
1.4718 + testId.iInternal[TSurfaceId::TScreenSurfaceUsage::EScreenField] = 0; // Screen number
1.4719 + testId.iInternal[TSurfaceId::TScreenSurfaceUsage::EHalField] = halMode; // Rotation and hal mode index
1.4720 + testId.iInternal[TSurfaceId::TScreenSurfaceUsage::ETypeGuidField] = testGuids[ii]; //May be zero for non-GCE modes
1.4721 + testId.iInternal[TSurfaceId::TScreenSurfaceUsage::ETypeClassField] = ((TUint32)(TSurfaceId::EScreenSurface) << TSurfaceId::TScreenSurfaceUsage::ETypeClassShift); // Type
1.4722 +
1.4723 + err = SymbianStreamAcquire(&testId, &ns);
1.4724 + ASSERT_TRUE(err == KErrNone);
1.4725 + ASSERT_TRUE(ns);
1.4726 +
1.4727 + err = SymbianStreamAcquireWriteBuffer(ns,&writeBuffer);
1.4728 + ASSERT_TRUE(err == KErrNone);
1.4729 +
1.4730 + err = SymbianStreamGetBufferPointer(ns,writeBuffer,reinterpret_cast<void**>(&pWriteBuffer));
1.4731 + ASSERT_TRUE(err == KErrNone);
1.4732 + ASSERT_NOT_NULL(pWriteBuffer);
1.4733 +
1.4734 + err = SymbianStreamReleaseWriteBuffer(ns,writeBuffer);
1.4735 + ASSERT_TRUE(err == KErrNone);
1.4736 +
1.4737 + err = SymbianStreamAcquireReadBuffer(ns,&readBuffer);
1.4738 + ASSERT_TRUE(err == KErrNone);
1.4739 +
1.4740 + err = SymbianStreamGetBufferPointer(ns,readBuffer,reinterpret_cast<void**>(&pReadBuffer));
1.4741 + ASSERT_TRUE(err == KErrNone);
1.4742 + ASSERT_NOT_NULL(pReadBuffer);
1.4743 +
1.4744 + err = SymbianStreamReleaseReadBuffer(ns,readBuffer);
1.4745 + ASSERT_TRUE(err == KErrNone);
1.4746 +
1.4747 + ASSERT_SAME(pWriteBuffer, pReadBuffer);
1.4748 +
1.4749 + *pWriteBuffer = 0xFF;
1.4750 + ASSERT_TRUE(*pReadBuffer == 0xFF);
1.4751 +
1.4752 + halStride = halMode;
1.4753 + HAL::Get(0, HALData::EDisplayOffsetBetweenLines, halStride);
1.4754 +
1.4755 + SymbianStreamGetHeader(ns, &preFlipWidth, &preFlipHeight, &preFlipStreamStride, &preFlipStreamFormat, &preFlipStreamPixelSize);
1.4756 + ASSERT_TRUE(preFlipStreamStride == halStride);
1.4757 +
1.4758 + // Now the flipping test
1.4759 + halMode = halMode^TSurfaceId::TScreenSurfaceUsage::EHalFlippedFlag;
1.4760 + testId.iInternal[TSurfaceId::TScreenSurfaceUsage::EHalField] = halMode;
1.4761 +
1.4762 + err = SymbianStreamAcquire(&testId, &ns);
1.4763 + ASSERT_TRUE(err == KErrNone);
1.4764 + ASSERT_TRUE(ns);
1.4765 +
1.4766 + halStride = halMode;
1.4767 + HAL::Get(0, HALData::EDisplayOffsetBetweenLines, halStride);
1.4768 + SymbianStreamGetHeader(ns, &width, &height, &streamStride, &streamFormat, &streamPixelSize);
1.4769 +
1.4770 + ASSERT_EQUALS(preFlipWidth, height);
1.4771 + ASSERT_EQUALS(preFlipHeight, width);
1.4772 + ASSERT_EQUALS((TInt32)preFlipStreamFormat,(TInt32)streamFormat);
1.4773 + ASSERT_TRUE(streamStride == halStride);
1.4774 + ASSERT_EQUALS(preFlipStreamPixelSize, streamPixelSize);
1.4775 +
1.4776 + SymbianStreamGetHeader(ns, NULL, NULL, NULL, NULL, NULL);
1.4777 + // Clearing the flip flag
1.4778 + halMode = halMode&~TSurfaceId::TScreenSurfaceUsage::EHalFlippedFlag;
1.4779 +
1.4780 + SymbianStreamRemoveReference(ns);
1.4781 +
1.4782 + *pWriteBuffer = NULL;
1.4783 + pWriteBuffer = NULL;
1.4784 + *pReadBuffer = NULL;
1.4785 + pReadBuffer = NULL;
1.4786 + }
1.4787 +
1.4788 + testChannel.Close();
1.4789 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.4790 + }
1.4791 +
1.4792 +/*
1.4793 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0143
1.4794 +@SYMTestCaseDesc Call eglsync helper functions
1.4795 +@SYMREQ
1.4796 +@SYMPREQ
1.4797 +@SYMTestType
1.4798 +@SYMTestPriority Low
1.4799 +@SYMTestPurpose Make calls of eglsync helper functions for coverage results
1.4800 +@SYMTestActions
1.4801 + Make calls of eglsync helper functions
1.4802 +@SYMTestExpectedResults
1.4803 + Test should pass without errors
1.4804 + */
1.4805 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0143L()
1.4806 + {
1.4807 + // This test is commented out because it won't build for Bullseye.
1.4808 +#ifdef EGLSYNCHELPER_INCLUDED
1.4809 + INFO_PRINTF1(_L("Test of egl sync helper functions"));
1.4810 +
1.4811 + RHeap* mainHeap = COpenWfcStreamMap::InstanceL().GetMainHeap();
1.4812 + TRAPD(err, GrowCleanupStackL());
1.4813 + ASSERT_TRUE(err == KErrNone);
1.4814 +
1.4815 + CleanupStack::PushL(TCleanupItem(PopHeap, User::SwitchHeap(mainHeap)));
1.4816 +
1.4817 + EGLDisplay eglDisplay;
1.4818 + eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
1.4819 + ASSERT_FALSE(eglDisplay == EGL_NO_DISPLAY);
1.4820 + ASSERT_FALSE(eglDisplay == EGL_BAD_ALLOC);
1.4821 + ASSERT_EQUALS(eglGetError(),EGL_SUCCESS);
1.4822 + eglInitialize(eglDisplay, NULL, NULL);
1.4823 + ASSERT_EQUALS(eglGetError(),EGL_SUCCESS);
1.4824 +
1.4825 + EGLint attrib_list[1] = {EGL_NONE};
1.4826 + EGLSyncKHR sync;
1.4827 + sync = eglCreateSyncKHR(eglDisplay,EGL_SYNC_REUSABLE_KHR, attrib_list);
1.4828 + ASSERT_NOT_EQUALS(sync,EGL_NO_SYNC_KHR);
1.4829 + ASSERT_EQUALS(eglGetError(),EGL_SUCCESS);
1.4830 +
1.4831 + eglSignalSyncKHR(eglDisplay, sync, EGL_SIGNALED_KHR);
1.4832 + eglGetSyncAttribKHR(eglDisplay, sync, NULL, NULL);
1.4833 + eglClientWaitSyncKHR(eglDisplay, sync, 0, 0);
1.4834 +
1.4835 + EGLBoolean eglSyncError = eglDestroySyncKHR(eglDisplay, sync);
1.4836 + sync = EGL_NO_SYNC_KHR;
1.4837 + if (eglSyncError != EGL_TRUE)
1.4838 + {
1.4839 + INFO_PRINTF2(_L("TearDown: eglSyncError line %d"),__LINE__);
1.4840 + }
1.4841 + CleanupStack::PopAndDestroy(); // switch the heap back to current thread's one
1.4842 +#endif
1.4843 + }
1.4844 +
1.4845 +/*
1.4846 +@SYMTestCaseID GFX_OPENWFC_NATIVESTREAM_0144
1.4847 +@SYMTestCaseDesc Panic test
1.4848 +@SYMREQ
1.4849 +@SYMPREQ
1.4850 +@SYMTestType
1.4851 +@SYMTestPriority Low
1.4852 +@SYMTestPurpose Test that will cause a panic.
1.4853 +@SYMTestActions
1.4854 + Aquire a symbian stream by passing in a NULL ns
1.4855 +@SYMTestExpectedResults
1.4856 + Test should panic with the expected panic code 1000008
1.4857 +*/
1.4858 +void CTestNativeStream::GRAPHICS_OPENWFC_NATIVESTREAM_0144L()
1.4859 + {
1.4860 + INFO_PRINTF1(_L("Panic test. The expected panic code is 1000008"));
1.4861 +
1.4862 + SymbianStreamBuffer bufferHandle;
1.4863 + // Pass in a NULL ns will cause panic EOwfSymbianStreamBadArgument (1000008)
1.4864 + SymbianStreamAcquireReadBuffer(NULL, &bufferHandle);
1.4865 + }