os/graphics/graphicscomposition/openwfcompositionengine/test/tscreeninterface/tscreeninterface.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/graphicscomposition/openwfcompositionengine/test/tscreeninterface/tscreeninterface.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,971 @@
1.4 +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
1.5 +//
1.6 +// Permission is hereby granted, free of charge, to any person obtaining a
1.7 +// copy of this software and/or associated documentation files (the
1.8 +// "Materials"), to deal in the Materials without restriction, including
1.9 +// without limitation the rights to use, copy, modify, merge, publish,
1.10 +// distribute, sublicense, and/or sell copies of the Materials, and to
1.11 +// permit persons to whom the Materials are furnished to do so, subject to
1.12 +// the following conditions:
1.13 +//
1.14 +// The above copyright notice and this permission notice shall be included
1.15 +// in all copies or substantial portions of the Materials.
1.16 +//
1.17 +// THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1.18 +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1.19 +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
1.20 +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
1.21 +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
1.22 +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
1.23 +// MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
1.24 +//
1.25 +// Description:
1.26 +// Implementation of test class for OpenWF-C RI display driver interface
1.27 +//
1.28 +
1.29 +#include <WF/openwfc_ri_display.h>
1.30 +#include <WF/openwfc_ri_display_update.h>
1.31 +#include <test/extendtef.h>
1.32 +#include <test/tefunit.h>
1.33 +#include <hal.h>
1.34 +#include "tscreeninterface.h"
1.35 +
1.36 +#define KCompositorVersion 0x01023456
1.37 +#define KRgbRed TRgb(0x0000ff)
1.38 +#define KRgbGreen TRgb(0x00ff00)
1.39 +#define KRgbYellow TRgb(0x00ffff)
1.40 +#define KRgbBlue TRgb(0xff0000)
1.41 +
1.42 +const TInt KDefaultScreenNumber = 0;
1.43 +const TTimeIntervalMicroSeconds32 KDelay = 1000000; //delay in microseconds
1.44 +const TTimeIntervalMicroSeconds32 KMinimalDelay = 1000; //delay in microseconds
1.45 +
1.46 +_LIT(KImageSectionName, "ImageInfo");
1.47 +_LIT(KContiguousFlag, "ContiguousFlag");
1.48 +_LIT(KNonFastpathablePixelFormat, "NonFastpathablePixelFormat");
1.49 +_LIT(KFastpathablePixelFormat, "FastpathablePixelFormat");
1.50 +
1.51 +/*
1.52 + * CTestScreenInterface implementation
1.53 + */
1.54 +
1.55 +CTestScreenInterface::CTestScreenInterface()
1.56 +:iContiguous(EFlagNotListed),
1.57 + iFastpathablePixelFormat(EUidPixelFormatARGB_8888_PRE),
1.58 + iNonFastpathablePixelFormat(EUidPixelFormatRGB_565),
1.59 + iMappable(ETrue),
1.60 + iMaxBuffers(2),
1.61 + iMinBuffers(1),
1.62 + iCacheAttrib(ECacheNotlisted)
1.63 + {
1.64 + // No implementation required
1.65 + }
1.66 +
1.67 +CTestScreenInterface::~CTestScreenInterface()
1.68 + {
1.69 + TearDown();
1.70 + }
1.71 +
1.72 +void CTestScreenInterface::SetupL()
1.73 + {
1.74 + iUtility = CStreamUtility::NewL();
1.75 + iRed.SetInternal(0xFFFF0000);
1.76 + iGreen.SetInternal(0xFF00FF00);
1.77 + iBlue.SetInternal(0xFF0000FF);
1.78 + ReadIniData();
1.79 + User::After(KDelay); // consider reading delay from ini file
1.80 + }
1.81 +
1.82 +/**
1.83 + * test Suite furniture
1.84 + **/
1.85 +void CTestScreenInterface::TearDownL()
1.86 + {
1.87 + // Nothing leaves in this function,
1.88 + // but TearDownL() is needed for the CTestFixture (TEF) interface
1.89 + TearDown();
1.90 + }
1.91 +
1.92 +void CTestScreenInterface::TearDown()
1.93 + {
1.94 + if(iUtility)
1.95 + {
1.96 + delete iUtility;
1.97 + iUtility = NULL;
1.98 + }
1.99 + }
1.100 +
1.101 +// Create a suite of all the tests
1.102 +CTestSuite* CTestScreenInterface::CreateSuiteL(const TDesC& aName)
1.103 + {
1.104 + SymbianStreamRegisterScreenNotifications(0, 10, KCompositorVersion);
1.105 + SUB_SUITE_OPT(CTestScreenInterface,NULL);
1.106 +
1.107 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0100L);
1.108 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0101L);
1.109 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0102L);
1.110 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0103L);
1.111 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0104L);
1.112 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0105L);
1.113 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0106L);
1.114 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0107L);
1.115 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0108L);
1.116 + ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0109L);
1.117 +
1.118 + END_SUITE;
1.119 +
1.120 + }
1.121 +
1.122 +/// This handles any non-member uses of the extended ASSERT_XXX macros
1.123 +void TefUnitFailLeaveL()
1.124 + {
1.125 + User::Leave(KErrTEFUnitFail);
1.126 + }
1.127 +
1.128 +void CTestScreenInterface::ReadIniData()
1.129 + {
1.130 + TBool contiguousFlag;
1.131 + TBool returnValue = iConfig.GetBool(KImageSectionName, KContiguousFlag, contiguousFlag);
1.132 + if (returnValue)
1.133 + {
1.134 + if(contiguousFlag)
1.135 + {
1.136 + iContiguous = EContiguous;
1.137 + }
1.138 + else
1.139 + {
1.140 + iContiguous = ENonContiguous;
1.141 + }
1.142 + }
1.143 +
1.144 + TInt fastpathablePixelFormat;
1.145 + returnValue = iConfig.GetHex(KImageSectionName, KFastpathablePixelFormat, fastpathablePixelFormat);
1.146 + if(returnValue)
1.147 + {
1.148 + iFastpathablePixelFormat = static_cast<TUidPixelFormat>(fastpathablePixelFormat);
1.149 + }
1.150 +
1.151 + TInt nonFastpathablePixelFormat;
1.152 + returnValue = iConfig.GetHex(KImageSectionName, KNonFastpathablePixelFormat, nonFastpathablePixelFormat);
1.153 + if(returnValue)
1.154 + {
1.155 + iNonFastpathablePixelFormat = static_cast<TUidPixelFormat>(nonFastpathablePixelFormat);
1.156 + }
1.157 + }
1.158 +
1.159 +TInt CTestScreenInterface::BaseTestContiguousFlag(TBool aContiguous)
1.160 + {
1.161 + COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber);
1.162 + CleanupStack::PushL(screenContext);
1.163 +
1.164 + TUint32 screenRotation = COpenWFC_RI_Display::EScreenRotate0;
1.165 + screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation,
1.166 + &screenRotation,
1.167 + sizeof(screenRotation));
1.168 + screenContext->CommitAttribute();
1.169 +
1.170 + COpenWFC_RI_Display::TScreenGeometryAttribute attributes;
1.171 + screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes,
1.172 + sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute));
1.173 +
1.174 + TSurfaceId surface = TSurfaceId::CreateNullId();
1.175 + SymbianStreamType ns=iUtility->CreateStreamL(TSize(attributes.iNormalWidth,attributes.iNormalHeight),
1.176 + iFastpathablePixelFormat, attributes.iNormalStride,
1.177 + surface, aContiguous, 1);
1.178 + ASSERT_FALSE((*ns).IsNull());
1.179 +
1.180 + iUtility->FillStreamL(ns, KRgbGreen);
1.181 +
1.182 + TInt err = screenContext->SetTopLayerSurface(ns);
1.183 + Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrAll, _L("SetTopLayerSurface() returned %i"),err );
1.184 + RDebug::Printf("SetTopLayerSurface() returned %i",err);
1.185 +
1.186 + if (err==KErrNone)
1.187 + { //Must successfully SetTopLayerSurface before calling UpdateDisplay.
1.188 + screenContext->UpdateDisplay();
1.189 + }
1.190 +
1.191 + CleanupStack::PopAndDestroy(screenContext);
1.192 +
1.193 + return err;
1.194 + }
1.195 +
1.196 +/**
1.197 +@SYMTestCaseID GRAPHICS_OPENWFC_SCREENINTERFACE_0100
1.198 +@SYMTestCaseDesc Create a screen size stream and display on screen
1.199 +@SYMREQ
1.200 +@SYMPREQ REQ 417-54885
1.201 +@SYMTestType Unit Test
1.202 +@SYMTestPriority High
1.203 +@SYMTestPurpose Verify a COpenWFC_RI_Display object can be properly created and a stream can be displayed on screen
1.204 +@SYMTestActions
1.205 + Create a screen context
1.206 + Set display attributes
1.207 + Create a screen size stream based on the display attributes with contigous and non-contiguous flags
1.208 + Fill the stream
1.209 + Associates the stream with the topmost display layer
1.210 + Update the screen
1.211 +@SYMTestExpectedResults
1.212 + If contiguous flag is set in the ini file, and the stream is created using the flag,
1.213 + the stream should be properly displayed on screen. The stream created using the opposit flag from ini value should fail.
1.214 + If contiguous flag is not set in the ini file,
1.215 + the stream should be properly displayed on screen for contiguous and non-contiguous flag.
1.216 + **/
1.217 +void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0100L()
1.218 + {
1.219 + INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0100L()"));
1.220 + LOG((" *** CTestScreenInterface test 0100L"));
1.221 +
1.222 + if(iContiguous != EFlagNotListed)
1.223 + {
1.224 +
1.225 + // We expect the opposit flag to the one from the ini file to fail
1.226 + if(iContiguous == EContiguous)
1.227 + {
1.228 + ASSERT_TRUE(KErrNotSupported == BaseTestContiguousFlag(ENonContiguous));
1.229 + }
1.230 + else
1.231 + {
1.232 + ASSERT_TRUE(KErrNotSupported == BaseTestContiguousFlag(EContiguous));
1.233 + }
1.234 + // The contiguous flag from the ini file should pass
1.235 + ASSERT_TRUE(KErrNone == BaseTestContiguousFlag(iContiguous));
1.236 + // The last run here should be the "good" run so that it can do a Display() call.
1.237 + }
1.238 + else
1.239 + {
1.240 + // Contiguous or Non-contiguous flags should both pass if nothing set in the ini file
1.241 + ASSERT_TRUE(KErrNone == BaseTestContiguousFlag(EContiguous));
1.242 + ASSERT_TRUE(KErrNone == BaseTestContiguousFlag(ENonContiguous));
1.243 + }
1.244 + INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0100L() done"));
1.245 + LOG((" *** CTestScreenInterface test 0100L done"));
1.246 + }
1.247 +
1.248 +/**
1.249 +@SYMTestCaseID GRAPHICS_OPENWFC_SCREENINTERFACE_0101
1.250 +@SYMTestCaseDesc Create a stream, display on screen, then rotate the screen involving scaling
1.251 +@SYMREQ
1.252 +@SYMPREQ REQ 417-54885
1.253 +@SYMTestType Unit Test
1.254 +@SYMTestPriority Medium
1.255 +@SYMTestPurpose Verify screen rotation works
1.256 +@SYMTestActions
1.257 + Create a screen context
1.258 + Set display attributes
1.259 + Create a screen size stream
1.260 + Fill the stream
1.261 + Associates the stream with the topmost display layer
1.262 + Update the screen
1.263 + Rotate the screen 90 degrees, 180 degrees, 270 degrees
1.264 + Update the screen respectively
1.265 +@SYMTestExpectedResults
1.266 + Methods should complete without error.
1.267 + The stream should be properly displayed on screen
1.268 + **/
1.269 +void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0101L()
1.270 + {
1.271 + INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0101L()"));
1.272 + LOG((" *** CTestScreenInterface test 0101L"));
1.273 +
1.274 + COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber);
1.275 + CleanupStack::PushL(screenContext);
1.276 +
1.277 + COpenWFC_RI_Display::TScreenGeometryAttribute attributes;
1.278 + screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes,
1.279 + sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute));
1.280 +
1.281 + if (attributes.iSupportedRotations > 1)
1.282 + {
1.283 + INFO_PRINTF2(_L("Number of supported rotations: %i "), attributes.iSupportedRotations);
1.284 + TUint32 screenRotation0 = COpenWFC_RI_Display::EScreenRotate0;
1.285 + screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation,
1.286 + &screenRotation0,
1.287 + sizeof(screenRotation0));
1.288 + screenContext->CommitAttribute();
1.289 +
1.290 + TSurfaceId surface = TSurfaceId::CreateNullId();
1.291 + SymbianStreamType ns=iUtility->CreateStreamL(TSize(attributes.iNormalWidth,attributes.iNormalHeight),
1.292 + iFastpathablePixelFormat, attributes.iNormalStride,
1.293 + surface, iContiguous, 1);
1.294 +
1.295 + ASSERT_FALSE((*ns).IsNull());
1.296 + iUtility->FillStreamL(ns, KRgbRed);
1.297 +
1.298 + TInt err = screenContext->SetTopLayerSurface(ns);
1.299 + ASSERT_TRUE(err == KErrNone);
1.300 +
1.301 + err = screenContext->UpdateDisplay();
1.302 + ASSERT_TRUE(err == KErrNone);
1.303 +
1.304 + INFO_PRINTF1(_L("Rotate screen 90 degree"));
1.305 + // Rotate screen 90 degree and test
1.306 + TUint32 screenRotation1 = COpenWFC_RI_Display::EScreenRotate90;
1.307 + screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation,
1.308 + &screenRotation1,
1.309 + sizeof(screenRotation1));
1.310 + screenContext->CommitAttribute();
1.311 +
1.312 + err = screenContext->UpdateDisplay();
1.313 + ASSERT_TRUE(err == KErrNone);
1.314 +
1.315 + if (attributes.iSupportedRotations > 2)
1.316 + {
1.317 + INFO_PRINTF1(_L("Rotate screen 180 degree"));
1.318 + // Rotate screen 180 degree and test
1.319 + TUint32 screenRotation2 = COpenWFC_RI_Display::EScreenRotate180;
1.320 + screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation,
1.321 + &screenRotation2,
1.322 + sizeof(screenRotation2));
1.323 + screenContext->CommitAttribute();
1.324 +
1.325 + err = screenContext->UpdateDisplay();
1.326 + ASSERT_TRUE(err == KErrNone);
1.327 + }
1.328 +
1.329 + if (attributes.iSupportedRotations > 3)
1.330 + {
1.331 + INFO_PRINTF1(_L("Rotate screen 270 degree"));
1.332 + // Rotate screen 270 degree and test
1.333 + TUint32 screenRotation3 = COpenWFC_RI_Display::EScreenRotate270;
1.334 + screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation,
1.335 + &screenRotation3,
1.336 + sizeof(screenRotation3));
1.337 + screenContext->CommitAttribute();
1.338 +
1.339 + err = screenContext->UpdateDisplay();
1.340 + ASSERT_TRUE(err == KErrNone);
1.341 + }
1.342 +
1.343 + // Set screen back to rotation 0
1.344 + screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation,
1.345 + &screenRotation0,
1.346 + sizeof(screenRotation0));
1.347 + screenContext->CommitAttribute();
1.348 + err = screenContext->UpdateDisplay();
1.349 + ASSERT_TRUE(err == KErrNone);
1.350 + }
1.351 + else
1.352 + {
1.353 + INFO_PRINTF1(_L("Screen rotation is not supported. Test skipped."));
1.354 + }
1.355 +
1.356 + CleanupStack::PopAndDestroy(screenContext);
1.357 + }
1.358 +
1.359 +/**
1.360 +@SYMTestCaseID GRAPHICS_OPENWFC_SCREENINTERFACE_0102
1.361 +@SYMTestCaseDesc Create a stream, display on screen, then rotate the screen, not involving scaling
1.362 +@SYMREQ
1.363 +@SYMPREQ REQ 417-54885
1.364 +@SYMTestType Unit Test
1.365 +@SYMTestPriority Medium
1.366 +@SYMTestPurpose Verify screen rotation works
1.367 +@SYMTestActions
1.368 + Create a screen context
1.369 + Set display attributes
1.370 + Create a stream of the size (screenHeight, screenWidth)
1.371 + Fill the stream
1.372 + Associates the stream with the topmost display layer
1.373 + Update the screen
1.374 + Rotate the screen 90 degrees
1.375 + Update the screen
1.376 +@SYMTestExpectedResults
1.377 + Methods should complete without error.
1.378 + The stream should be properly displayed on screen
1.379 + **/
1.380 +void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0102L()
1.381 + {
1.382 + INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0102L()"));
1.383 + LOG((" *** CTestScreenInterface test 0102L"));
1.384 +
1.385 + COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber);
1.386 + CleanupStack::PushL(screenContext);
1.387 +
1.388 + COpenWFC_RI_Display::TScreenGeometryAttribute attributes;
1.389 + screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes,
1.390 + sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute));
1.391 +
1.392 + if (attributes.iSupportedRotations > 1)
1.393 + {
1.394 + INFO_PRINTF2(_L("Number of supported rotations: %i "), attributes.iSupportedRotations);
1.395 + TUint32 screenRotation0 = COpenWFC_RI_Display::EScreenRotate0;
1.396 + screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation,
1.397 + &screenRotation0,
1.398 + sizeof(screenRotation0));
1.399 + screenContext->CommitAttribute();
1.400 +
1.401 + TSurfaceId surface = TSurfaceId::CreateNullId();
1.402 + SymbianStreamType ns=iUtility->CreateStreamL(TSize(attributes.iNormalHeight,attributes.iNormalWidth),
1.403 + iFastpathablePixelFormat, attributes.iNormalStride,
1.404 + surface, iContiguous, 1);
1.405 +
1.406 + ASSERT_FALSE((*ns).IsNull());
1.407 + iUtility->FillStreamL(ns, KRgbRed);
1.408 +
1.409 + TInt err = screenContext->SetTopLayerSurface(ns);
1.410 + ASSERT_TRUE(err == KErrNone);
1.411 +
1.412 + err = screenContext->UpdateDisplay();
1.413 + ASSERT_TRUE(err == KErrNone);
1.414 +
1.415 + INFO_PRINTF1(_L("Rotate screen 90 degree"));
1.416 + // Rotate screen 90 degree and test
1.417 + TUint32 screenRotation1 = COpenWFC_RI_Display::EScreenRotate90;
1.418 + screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation,
1.419 + &screenRotation1,
1.420 + sizeof(screenRotation1));
1.421 + screenContext->CommitAttribute();
1.422 +
1.423 + err = screenContext->UpdateDisplay();
1.424 + ASSERT_TRUE(err == KErrNone);
1.425 + }
1.426 + else
1.427 + {
1.428 + INFO_PRINTF1(_L("Screen rotation is not supported. Test skipped."));
1.429 + }
1.430 +
1.431 + CleanupStack::PopAndDestroy(screenContext);
1.432 + }
1.433 +
1.434 +/**
1.435 +@SYMTestCaseID GRAPHICS_OPENWFC_SCREENINTERFACE_0103
1.436 +@SYMTestCaseDesc Create a stream, fill the stream several times and display on screen
1.437 +@SYMREQ
1.438 +@SYMPREQ REQ 417-54885
1.439 +@SYMTestType Unit Test
1.440 +@SYMTestPriority High
1.441 +@SYMTestPurpose Check displaying stream repeatedly
1.442 +@SYMTestActions
1.443 + Create a screen context
1.444 + Set display attributes
1.445 + Create a screen size stream
1.446 + Fill the stream
1.447 + Associates the stream with the topmost display layer
1.448 + Update the screen
1.449 + Repeat filling the stream, associate with toplayer and update several times
1.450 + Destory the screen context
1.451 +@SYMTestExpectedResults
1.452 + Methods should complete without error.
1.453 + Each time, the stream should be properly displayed on screen
1.454 + **/
1.455 +void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0103L()
1.456 + {
1.457 + INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0103L()"));
1.458 + LOG((" *** CTestScreenInterface test 0103L"));
1.459 +
1.460 + COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber);
1.461 + CleanupStack::PushL(screenContext);
1.462 +
1.463 + TUint32 screenRotation = COpenWFC_RI_Display::EScreenRotate0;
1.464 + screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation,
1.465 + &screenRotation,
1.466 + sizeof(screenRotation));
1.467 + screenContext->CommitAttribute();
1.468 +
1.469 + COpenWFC_RI_Display::TScreenGeometryAttribute attributes;
1.470 + screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes,
1.471 + sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute));
1.472 +
1.473 + TSurfaceId surface = TSurfaceId::CreateNullId();
1.474 + SymbianStreamType ns=iUtility->CreateStreamL(TSize(attributes.iNormalWidth,attributes.iNormalHeight),
1.475 + iFastpathablePixelFormat, attributes.iNormalStride,
1.476 + surface, iContiguous, 1);
1.477 + ASSERT_FALSE((*ns).IsNull());
1.478 +
1.479 + iUtility->FillStreamL(ns, KRgbYellow);
1.480 + TInt err = screenContext->SetTopLayerSurface(ns);
1.481 + ASSERT_TRUE(err == KErrNone);
1.482 + err = screenContext->UpdateDisplay();
1.483 + ASSERT_TRUE(err == KErrNone);
1.484 + User::After(KDelay);
1.485 +
1.486 + iUtility->FillStreamL(ns, KRgbRed);
1.487 + err = screenContext->SetTopLayerSurface(ns);
1.488 + ASSERT_TRUE(err == KErrNone);
1.489 + err = screenContext->UpdateDisplay();
1.490 + ASSERT_TRUE(err == KErrNone);
1.491 + User::After(KDelay);
1.492 +
1.493 + iUtility->FillStreamL(ns, KRgbGreen);
1.494 + err = screenContext->SetTopLayerSurface(ns);
1.495 + ASSERT_TRUE(err == KErrNone);
1.496 + err = screenContext->UpdateDisplay();
1.497 + ASSERT_TRUE(err == KErrNone);
1.498 + User::After(KDelay);
1.499 +
1.500 + iUtility->FillStreamL(ns, KRgbYellow);
1.501 + err = screenContext->SetTopLayerSurface(ns);
1.502 + ASSERT_TRUE(err == KErrNone);
1.503 + err = screenContext->UpdateDisplay();
1.504 + ASSERT_TRUE(err == KErrNone);
1.505 + User::After(KDelay);
1.506 +
1.507 + iUtility->FillStreamL(ns, KRgbRed);
1.508 + err = screenContext->SetTopLayerSurface(ns);
1.509 + ASSERT_TRUE(err == KErrNone);
1.510 + err = screenContext->UpdateDisplay();
1.511 + ASSERT_TRUE(err == KErrNone);
1.512 + User::After(KDelay);
1.513 +
1.514 + // Set a non-topmost layer
1.515 + err = screenContext->SetLayerSurface(1, ns);
1.516 + ASSERT_TRUE(err == KErrArgument);
1.517 +
1.518 + CleanupStack::PopAndDestroy(screenContext);
1.519 + }
1.520 +
1.521 +/**
1.522 +@SYMTestCaseID GRAPHICS_OPENWFC_SCREENINTERFACE_0104
1.523 +@SYMTestCaseDesc Display all display attributes
1.524 +@SYMREQ
1.525 +@SYMPREQ REQ 417-54885
1.526 +@SYMTestType Unit Test
1.527 +@SYMTestPriority High
1.528 +@SYMTestPurpose Check display attributes
1.529 +@SYMTestActions
1.530 + Create a screen context
1.531 + Set display attributes
1.532 + Get all display attribtues
1.533 + Destory the screen context
1.534 +@SYMTestExpectedResults
1.535 + Methods should complete without error.
1.536 + Display attributes should be correct
1.537 + **/
1.538 +void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0104L()
1.539 + {
1.540 + INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0104L()"));
1.541 + LOG((" *** CTestScreenInterface test 0104L"));
1.542 +
1.543 + COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber);
1.544 + CleanupStack::PushL(screenContext);
1.545 +
1.546 + COpenWFC_RI_Display::TScreenGeometryAttribute attributes;
1.547 + screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes,
1.548 + sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute));
1.549 +
1.550 + INFO_PRINTF1(_L("Printing attribute values: "));
1.551 + INFO_PRINTF2(_L("EScreenAttributeSupportedRotation: %i "), attributes.iSupportedRotations);
1.552 + INFO_PRINTF2(_L("EScreenAttributeCurrentRotation: 0x%x "), attributes.iCurrentRotation);
1.553 + INFO_PRINTF2(_L("EScreenAttributeDefaultRotation: 0x%x "), attributes.iDefaultRotation);
1.554 + INFO_PRINTF2(_L("EScreenAttributeBytesPerPixel: %i "), attributes.iBytesPerPixel);
1.555 + INFO_PRINTF2(_L("EScreenAttributeFlippedHeight: %i "), attributes.iFlippedHeight);
1.556 + INFO_PRINTF2(_L("EScreenAttributeFlippedWidth: %i "), attributes.iFlippedWidth);
1.557 + INFO_PRINTF2(_L("EScreenAttributeFlippedStride: %i "), attributes.iFlippedStride);
1.558 + INFO_PRINTF2(_L("EScreenAttributeNormalHeight: %i "), attributes.iNormalHeight);
1.559 + INFO_PRINTF2(_L("EScreenAttributeNormalWidth: %i "), attributes.iNormalWidth);
1.560 + INFO_PRINTF2(_L("EScreenAttributeNormalStride: %i "), attributes.iNormalStride);
1.561 + INFO_PRINTF2(_L("EScreenAttributePixelFormat: 0x%x "), attributes.iPixelFormat);
1.562 +
1.563 + CleanupStack::PopAndDestroy(screenContext);
1.564 + }
1.565 +
1.566 +/**
1.567 +@SYMTestCaseID GRAPHICS_OPENWFC_SCREENINTERFACE_0105
1.568 +@SYMTestCaseDesc Create a screen size stream of non-fastpathable pixel format and display on screen
1.569 +@SYMREQ
1.570 +@SYMPREQ REQ 417-54885
1.571 +@SYMTestType Unit Test - Negative Test
1.572 +@SYMTestPriority High
1.573 +@SYMTestPurpose Verify a COpenWFC_RI_Display object can be properly created and a stream can be displayed on screen
1.574 +@SYMTestActions
1.575 + Create a screen context
1.576 + Set display attributes
1.577 + Create a screen size stream based on the display attributes with a non-fastpathable pixelformat
1.578 + Fill the stream
1.579 + Associate the stream with the topmost display layer
1.580 +@SYMTestExpectedResults
1.581 + Test should pass.
1.582 + SetTopLayerSurface should return KErrNotSupported.
1.583 + **/
1.584 +void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0105L()
1.585 + {
1.586 + INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0105L()"));
1.587 + LOG((" *** CTestScreenInterface test 0105L"));
1.588 +
1.589 + if (!iNonFastpathablePixelFormat)
1.590 + {
1.591 + INFO_PRINTF1(_L("No non-fastpathable format specified - negative test cannot be run."));
1.592 + User::Leave(KErrTEFUnitInconclusive);
1.593 + }
1.594 + COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber);
1.595 + CleanupStack::PushL(screenContext);
1.596 +
1.597 + TUint32 screenRotation = COpenWFC_RI_Display::EScreenRotate0;
1.598 + screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation,
1.599 + &screenRotation,
1.600 + sizeof(screenRotation));
1.601 + screenContext->CommitAttribute();
1.602 +
1.603 + COpenWFC_RI_Display::TScreenGeometryAttribute attributes;
1.604 + screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes,
1.605 + sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute));
1.606 +
1.607 + TSurfaceId surface = TSurfaceId::CreateNullId();
1.608 + SymbianStreamType ns=iUtility->CreateStreamL(TSize(attributes.iNormalWidth,attributes.iNormalHeight),
1.609 + iNonFastpathablePixelFormat, attributes.iNormalStride,
1.610 + surface, iContiguous, 1);
1.611 + ASSERT_FALSE((*ns).IsNull());
1.612 +
1.613 + iUtility->FillStreamL(ns, KRgbGreen);
1.614 +
1.615 + ASSERT_TRUE(KErrNotSupported == screenContext->SetTopLayerSurface(ns));
1.616 +
1.617 + CleanupStack::PopAndDestroy(screenContext);
1.618 + }
1.619 +
1.620 +/**
1.621 +@SYMTestCaseID GRAPHICS_OPENWFC_SCREENINTERFACE_0106
1.622 +@SYMTestCaseDesc Create a stream, display on screen and repeat for a number of times
1.623 +@SYMREQ
1.624 +@SYMPREQ REQ 417-54885
1.625 +@SYMTestType Unit Test
1.626 +@SYMTestPriority High
1.627 +@SYMTestPurpose Check stream display repeatedly
1.628 +@SYMTestActions
1.629 + Create a screen context
1.630 + Set display attributes
1.631 + Create a stream
1.632 + Fill the stream
1.633 + Associates the stream with the topmost display layer
1.634 + Update the screen
1.635 + Destory the screen context
1.636 + Repeat the above actions for a number of times in a for loop
1.637 +@SYMTestExpectedResults
1.638 + Methods should complete without error.
1.639 + Each time, the stream should be properly displayed on screen
1.640 + **/
1.641 +void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0106L()
1.642 + {
1.643 + INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0106L()"));
1.644 + LOG((" *** CTestScreenInterface test 0106L"));
1.645 +
1.646 + SymbianStreamType ns = NULL;
1.647 + const TInt loopMaxNum = 10;
1.648 +
1.649 + for (TInt i = 0; i < loopMaxNum; ++i)
1.650 + {
1.651 + //INFO_PRINTF2(_L("Create screen context and stream loop: %i"), i);
1.652 +
1.653 + COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber);
1.654 + CleanupStack::PushL(screenContext);
1.655 +
1.656 + TUint32 screenRotation = COpenWFC_RI_Display::EScreenRotate0;
1.657 + screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation,
1.658 + &screenRotation,
1.659 + sizeof(screenRotation));
1.660 + screenContext->CommitAttribute();
1.661 +
1.662 + COpenWFC_RI_Display::TScreenGeometryAttribute attributes;
1.663 + screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes,
1.664 + sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute));
1.665 +
1.666 + if(ns == NULL)
1.667 + {
1.668 + TSurfaceId surface = TSurfaceId::CreateNullId();
1.669 + ns=iUtility->CreateStreamL(TSize(attributes.iNormalWidth,attributes.iNormalHeight),
1.670 + iFastpathablePixelFormat, attributes.iNormalStride,
1.671 + surface, iContiguous, 1);
1.672 + ASSERT_FALSE((*ns).IsNull());
1.673 + }
1.674 +
1.675 + if(i%3 == 0)
1.676 + {
1.677 + iUtility->FillStreamL(ns, KRgbRed);
1.678 + }
1.679 + else if (i%3 == 1)
1.680 + {
1.681 + iUtility->FillStreamL(ns, KRgbGreen);
1.682 + }
1.683 + else
1.684 + {
1.685 + iUtility->FillStreamL(ns, KRgbBlue);
1.686 + }
1.687 +
1.688 + TInt err = screenContext->SetTopLayerSurface(ns);
1.689 + ASSERT_TRUE(err == KErrNone);
1.690 +
1.691 + err = screenContext->UpdateDisplay();
1.692 + ASSERT_TRUE(err == KErrNone);
1.693 +
1.694 + CleanupStack::PopAndDestroy(screenContext);
1.695 +
1.696 + User::After(KDelay);
1.697 + }
1.698 + }
1.699 +
1.700 +/**
1.701 +@SYMTestCaseID GRAPHICS_OPENWFC_SCREENINTERFACE_0107
1.702 +@SYMTestCaseDesc Simple Non Trivial Attributes
1.703 +@SYMREQ
1.704 +@SYMPREQ REQ 417-54885
1.705 +@SYMTestType Unit Test
1.706 +@SYMTestPriority High
1.707 +@SYMTestPurpose Check that simple non-trivial attributes are accepted by SetTopLayerSurface.
1.708 + Note this test does not pass in "real" attributes, so the result is predictable.
1.709 +@SYMTestActions
1.710 + Create a screen context
1.711 + Set display attributes
1.712 + Create a fastpathable stream
1.713 + Fill the stream
1.714 + Associate the stream with the topmost display layer
1.715 + and NULL Non Trivial Atrributes
1.716 + Update the screen
1.717 + Associate the stream with the topmost display layer
1.718 + and empty Non Trivial Atrributes
1.719 + Update the screen
1.720 + Associate the stream with the topmost display layer
1.721 + and wrong Non Trivial Atrributes
1.722 + This should fail
1.723 + Destory the screen context
1.724 +@SYMTestExpectedResults
1.725 + SetTopLayerSurface should not fail, except for wrong attribute.
1.726 + SetTopLayerSurface should not crash or panic.
1.727 + **/
1.728 +void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0107L()
1.729 + {
1.730 + INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0107L()"));
1.731 + LOG((" *** CTestScreenInterface test 0107L"));
1.732 +
1.733 + COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber);
1.734 + CleanupStack::PushL(screenContext);
1.735 +
1.736 + TUint32 screenRotation = COpenWFC_RI_Display::EScreenRotate0;
1.737 + screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation,
1.738 + &screenRotation,
1.739 + sizeof(screenRotation));
1.740 + screenContext->CommitAttribute();
1.741 +
1.742 + COpenWFC_RI_Display::TScreenGeometryAttribute attributes;
1.743 + screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes,
1.744 + sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute));
1.745 +
1.746 + TSurfaceId surface = TSurfaceId::CreateNullId();
1.747 + SymbianStreamType ns=iUtility->CreateStreamL(TSize(attributes.iNormalWidth,attributes.iNormalHeight),
1.748 + iFastpathablePixelFormat, attributes.iNormalStride,
1.749 + surface, iContiguous, 1);
1.750 + ASSERT_FALSE((*ns).IsNull());
1.751 +
1.752 + iUtility->FillStreamL(ns, KRgbGreen);
1.753 +
1.754 + TInt err = screenContext->SetTopLayerSurface(ns,NULL);
1.755 + ASSERT_FALSE(err);
1.756 + screenContext->UpdateDisplay();
1.757 +
1.758 + TInt emptyList=0;
1.759 + err = screenContext->SetTopLayerSurface(ns,&emptyList);
1.760 + ASSERT_FALSE(err);
1.761 + screenContext->UpdateDisplay();
1.762 +
1.763 + TInt wrongList=-1;
1.764 + err = screenContext->SetTopLayerSurface(ns,&wrongList);
1.765 + ASSERT_TRUE(err);
1.766 +
1.767 + //Calling UpdateDisplay should fall-back to the previous setting of top layer surface
1.768 + screenContext->UpdateDisplay();
1.769 +
1.770 + CleanupStack::PopAndDestroy(screenContext);
1.771 + }
1.772 +
1.773 +/**
1.774 +@SYMTestCaseID GRAPHICS_OPENWFC_SCREENINTERFACE_0108
1.775 +@SYMTestCaseDesc Test getting and setting attributes
1.776 +@SYMREQ
1.777 +@SYMPREQ REQ 417-54885
1.778 +@SYMTestType Unit Test
1.779 +@SYMTestPriority High
1.780 +@SYMTestPurpose Check getting and setting attibutes with good and bad values
1.781 +@SYMTestActions
1.782 + Create a screen context
1.783 + Get and set attributes with good and bad values
1.784 + Destory the screen context
1.785 +@SYMTestExpectedResults
1.786 + GetAttribute should always succeed with all valid TScreenAttribute values
1.787 + and appropriate attribute size
1.788 + SetAttribute should succeed for modifying the current rotation
1.789 + Invalid valued for getting and setting attributes should return correct error code
1.790 + **/
1.791 +void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0108L()
1.792 + {
1.793 + INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0108L()"));
1.794 + LOG((" *** CTestScreenInterface test 0108L"));
1.795 +
1.796 + COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber);
1.797 + CleanupStack::PushL(screenContext);
1.798 +
1.799 + COpenWFC_RI_Display::TScreenGeometryAttribute attributes;
1.800 + TInt err;
1.801 +
1.802 + for(TUint ii = COpenWFC_RI_Display::EScreenAttributeInvalid; ii <= COpenWFC_RI_Display::EScreenAttributeScreenGeometry; ++ii)
1.803 + {
1.804 + if(ii == COpenWFC_RI_Display::EScreenAttributeScreenGeometry)
1.805 + {
1.806 + err = screenContext->GetAttribute(ii, &attributes,
1.807 + sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute));
1.808 + }
1.809 + else
1.810 + {
1.811 + err = screenContext->GetAttribute(ii, &attributes,
1.812 + sizeof(COpenWFC_RI_Display::TScreenAttribute));
1.813 + }
1.814 +
1.815 + if(ii == COpenWFC_RI_Display::EScreenAttributeInvalid)
1.816 + {
1.817 + ASSERT_TRUE(err == KErrNotSupported);
1.818 + }
1.819 + else
1.820 + {
1.821 + ASSERT_TRUE(err == KErrNone);
1.822 + }
1.823 + }
1.824 +
1.825 + TUint32 screenRotation = COpenWFC_RI_Display::EScreenRotate0;
1.826 + err = screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation, &screenRotation,
1.827 + sizeof(screenRotation));
1.828 + // The only parameter that can be modified is the current rotation
1.829 + ASSERT_TRUE(err == KErrNone);
1.830 +
1.831 + err = screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeSupportedRotation, &screenRotation,
1.832 + sizeof(screenRotation));
1.833 + ASSERT_TRUE(err == KErrNotSupported);
1.834 +
1.835 + // Set attribute to NULL
1.836 + err = screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, NULL,
1.837 + sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute));
1.838 + ASSERT_TRUE(err == KErrArgument);
1.839 +
1.840 + // Set attribute size to be 0
1.841 + err = screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeBytesPerPixel, &attributes, 0);
1.842 + ASSERT_TRUE(err == KErrArgument);
1.843 +
1.844 + // Set attribute == NULL
1.845 + err = screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeBytesPerPixel, NULL,
1.846 + sizeof(COpenWFC_RI_Display::TScreenAttribute));
1.847 + ASSERT_TRUE(err != KErrNone);
1.848 +
1.849 + // Set attribute with wrong size
1.850 + err = screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes,
1.851 + sizeof(COpenWFC_RI_Display::TScreenAttribute));
1.852 + ASSERT_TRUE(err != KErrNone);
1.853 +
1.854 + CleanupStack::PopAndDestroy(screenContext);
1.855 + }
1.856 +
1.857 +/**
1.858 +@SYMTestCaseID GRAPHICS_OPENWFC_SCREENINTERFACE_0109
1.859 +@SYMTestCaseDesc Create a stream, display on screen and repeat for a number of times
1.860 +@SYMREQ
1.861 +@SYMPREQ REQ 417-54885
1.862 +@SYMTestType Unit Test
1.863 +@SYMTestPriority High
1.864 +@SYMTestPurpose Check stream display repeatedly
1.865 +@SYMTestActions
1.866 + Create a screen context
1.867 + Set display attributes
1.868 + Repeat the below actions for a number of times in a for loop
1.869 + Create a stream
1.870 + Fill the stream
1.871 + Associates the stream with the topmost display layer
1.872 + Update the screen
1.873 + Finally
1.874 + Destory the screen context
1.875 +
1.876 +@SYMTestExpectedResults
1.877 + Methods should complete without error.
1.878 + Each time, the stream should be properly displayed on screen
1.879 + The streams should be destroyed in a timely manner after they stop being displayed
1.880 + **/
1.881 +
1.882 +void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0109L()
1.883 + {
1.884 + INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0109L()"));
1.885 + LOG((" *** CTestScreenInterface test 0106L"));
1.886 + _LIT(KDirectPost, "DirectPost");
1.887 + TBool directPost; //If DirectPost is not defined then the exact order of buffer releasing cannot be asserted.
1.888 + TBool definedDirectPost = iConfig.GetBool(KImageSectionName, KDirectPost, directPost);
1.889 + TInt offset;
1.890 + TInt error;
1.891 + TSurfaceId surface;
1.892 + SymbianStreamType ns = NULL;
1.893 + TSurfaceId prevsurface = TSurfaceId::CreateNullId();
1.894 +
1.895 + COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber);
1.896 + CleanupStack::PushL(screenContext);
1.897 +
1.898 + for (TInt i = 0; i < 10; ++i)
1.899 + {
1.900 + //INFO_PRINTF2(_L("Create stream loop: %i"), i);
1.901 +
1.902 + TUint32 screenRotation = COpenWFC_RI_Display::EScreenRotate0;
1.903 + screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation,
1.904 + &screenRotation,
1.905 + sizeof(screenRotation));
1.906 + screenContext->CommitAttribute();
1.907 +
1.908 + COpenWFC_RI_Display::TScreenGeometryAttribute attributes;
1.909 + screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes,
1.910 + sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute));
1.911 +
1.912 + surface = TSurfaceId::CreateNullId();
1.913 + ns=iUtility->CreateStreamL(TSize(attributes.iNormalWidth,attributes.iNormalHeight),
1.914 + iFastpathablePixelFormat, attributes.iNormalStride,
1.915 + surface, iContiguous, 2);
1.916 + ASSERT_FALSE((*ns).IsNull());
1.917 +
1.918 + if(i%3 == 0)
1.919 + {
1.920 + iUtility->FillStreamL(ns, KRgbRed);
1.921 + }
1.922 + else if (i%3 == 1)
1.923 + {
1.924 + iUtility->FillStreamL(ns, KRgbGreen);
1.925 + }
1.926 + else
1.927 + {
1.928 + iUtility->FillStreamL(ns, KRgbBlue);
1.929 + }
1.930 +
1.931 +
1.932 + if (!prevsurface.IsNull())
1.933 + {
1.934 + error=iUtility->Manager().GetBufferOffset(prevsurface,0,offset);
1.935 + ASSERT_TRUE(definedDirectPost ? error == (directPost?KErrNone:KErrArgument) :1);
1.936 + }
1.937 + TInt err = screenContext->SetTopLayerSurface(ns);
1.938 + ASSERT_TRUE(err == KErrNone);
1.939 + //GetBufferOffset is a safe way to check if the surface is still alive
1.940 + if (!prevsurface.IsNull())
1.941 + {
1.942 + error=iUtility->Manager().GetBufferOffset(prevsurface,0,offset);
1.943 + ASSERT_TRUE(definedDirectPost ? error == (directPost?KErrNone:KErrArgument) :1);
1.944 + }
1.945 +
1.946 + err = screenContext->UpdateDisplay();
1.947 + ASSERT_TRUE(err == KErrNone);
1.948 +
1.949 + User::After(KMinimalDelay);
1.950 +
1.951 + error=iUtility->Manager().GetBufferOffset(surface,0,offset);
1.952 + ASSERT_TRUE(definedDirectPost ? error == (directPost?KErrNone:KErrArgument) :1);
1.953 +
1.954 + if (!prevsurface.IsNull())
1.955 + {
1.956 + error=iUtility->Manager().GetBufferOffset(prevsurface,0,offset);
1.957 + ASSERT_TRUE(error); //previous surface should definitely be deleted by now
1.958 + }
1.959 + iUtility->DestroyStream(ns);
1.960 + error=iUtility->Manager().GetBufferOffset(surface,0,offset);
1.961 + ASSERT_TRUE(definedDirectPost ? error == (directPost?KErrNone:KErrArgument) :1);
1.962 + prevsurface=surface;
1.963 +
1.964 + User::After(KDelay);
1.965 + }
1.966 + CleanupStack::PopAndDestroy(screenContext);
1.967 +
1.968 + if (!prevsurface.IsNull())
1.969 + {
1.970 + error=iUtility->Manager().GetBufferOffset(surface,0,offset);
1.971 + ASSERT_TRUE(error); //previous surface should definitely be deleted by now
1.972 + }
1.973 + }
1.974 +