os/graphics/graphicscomposition/surfaceupdate/tsrc/tsurfaceupdateinteg.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/graphicscomposition/surfaceupdate/tsrc/tsurfaceupdateinteg.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,939 @@
     1.4 +// Copyright (c) 2009 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 +//
    1.18 +
    1.19 +#include <e32std.h>
    1.20 +#include <hal.h>
    1.21 +#include <u32hal.h>
    1.22 +#include <limits.h>
    1.23 +#include <e32const.h>
    1.24 +#include <graphics/surfaceupdateclient.h>
    1.25 +#include <graphics/suerror.h>
    1.26 +#include <graphics/wstestscreencapture.h>
    1.27 +#include <graphics/testscreencapture.h>
    1.28 +#include "surfaceupdatetest.h"
    1.29 +#include "tsurfaceupdateinteg.h"
    1.30 +#include "twindows.h"
    1.31 +#include "tredrawhandler.h"
    1.32 +#include "tsurfacehelper.h"
    1.33 +
    1.34 +const TSize windowSize(160, 100);
    1.35 +const TSize windowHalfSize(windowSize.iWidth / 2, 100);
    1.36 +const TPoint windowTopLeft(10,10);
    1.37 +const TPoint windowTopMiddle(windowTopLeft.iX + windowSize.iWidth / 2, windowTopLeft.iY);
    1.38 +
    1.39 +
    1.40 +CTSurfaceUpdateInteg::CTSurfaceUpdateInteg(CTestStep* aStep) :
    1.41 +	CTGraphicsBase(aStep)
    1.42 +	{
    1.43 +	}
    1.44 +
    1.45 +CTSurfaceUpdateInteg::~CTSurfaceUpdateInteg()
    1.46 +	{
    1.47 +	iWindows.ResetAndDestroy();
    1.48 +	iGroups.ResetAndDestroy();
    1.49 +
    1.50 +	iWsDevs.ResetAndDestroy();
    1.51 +	iGcs.ResetAndDestroy();
    1.52 +	
    1.53 +	delete iRedrawHandler;
    1.54 +	iSurfaceUpdate.Close();
    1.55 +	delete iSurfaceHelper;
    1.56 +	iBitmaps.ResetAndDestroy();
    1.57 +
    1.58 +	delete iGraphicsContext;
    1.59 +	delete iBitmapDevice;
    1.60 +	delete iRefBitmap;
    1.61 +	
    1.62 +	iWs.Close();
    1.63 +	}
    1.64 +
    1.65 +/**
    1.66 + * Create a screen device, drawing context and a window for each screen.
    1.67 + * Create surfaces, open connection to the SUS.
    1.68 + */
    1.69 +void CTSurfaceUpdateInteg::ConstructL()
    1.70 +	{
    1.71 +	INFO_PRINTF1(_L("Test case construction"));
    1.72 +	User::LeaveIfError(iWs.Connect());
    1.73 +	iNumOfScreens = iWs.NumberOfScreens();
    1.74 +	iSurfaceHelper = CSurfaceHelper::NewL();
    1.75 +	const TInt stride = windowSize.iWidth * 4;
    1.76 +	const TInt stride1 = windowHalfSize.iWidth * 4;
    1.77 +	iSurface = iSurfaceHelper->CreateSurfaceL(windowSize, EUidPixelFormatXRGB_8888, stride,1);
    1.78 +	iSurfaceDoubleBuffered = iSurfaceHelper->CreateSurfaceL(windowSize, EUidPixelFormatXRGB_8888, stride,2);
    1.79 +	iSurfaceAbove = iSurfaceHelper->CreateSurfaceL(windowHalfSize, EUidPixelFormatXRGB_8888, stride1, 1);
    1.80 +	iSurfaceAbove1 = iSurfaceHelper->CreateSurfaceL(windowSize, EUidPixelFormatXRGB_8888, stride, 1);
    1.81 +	INFO_PRINTF1(_L("The surfaces have been created"));
    1.82 +
    1.83 +	iRefBitmap = new (ELeave)CFbsBitmap();
    1.84 +	User::LeaveIfError(iRefBitmap->Create(windowSize,EColor16MU));
    1.85 +	iBitmapDevice = CFbsBitmapDevice::NewL(iRefBitmap);
    1.86 +	User::LeaveIfError(iBitmapDevice->CreateContext(iGraphicsContext));
    1.87 +
    1.88 +	//fill the whole surfaces with different color
    1.89 +	iSurfaceHelper->FillRectangleL(iSurfaceAbove, TPoint(), windowHalfSize, KRgbYellow);
    1.90 +	iSurfaceHelper->FillRectangleL(iSurfaceAbove1, TPoint(), windowSize, KRgbYellow);
    1.91 +	iSurfaceHelper->FillRectangleL(iSurface, TPoint(), windowSize, KRgbGreen);
    1.92 +	iSurfaceHelper->FillRectangleL(iSurfaceDoubleBuffered, TPoint(), windowSize, KRgbCyan);
    1.93 +	FillRefBitmap(KRgbGreen);
    1.94 +	INFO_PRINTF1(_L("The surfaces and a reference bitmap have been filled with color"));
    1.95 +	
    1.96 +	User::LeaveIfError(iSurfaceUpdate.Connect());
    1.97 +	
    1.98 +	iRedrawHandler = new (ELeave) CTRedrawHandler(iWs); //will deal with all redrawing command
    1.99 +	iRedrawHandler->Start();
   1.100 +
   1.101 +	//create windows and assign surfaces to them
   1.102 +	for(TInt ii = 0; ii < 2; ii++)
   1.103 +		{
   1.104 +		CWsScreenDevice* wsDev = new (ELeave) CWsScreenDevice(iWs);
   1.105 +		iWsDevs.AppendL(wsDev);
   1.106 +		User::LeaveIfError(wsDev->Construct(ii));
   1.107 +		CWindowGc* gc = NULL;
   1.108 +		User::LeaveIfError(wsDev->CreateContext(gc));
   1.109 +		iGcs.AppendL(gc);
   1.110 +
   1.111 +		CTWindowGroup* defaultGroup = CreateGroupL(wsDev);
   1.112 +		CTWindow* windowSingle = CTWindow::NewL(iWs, *defaultGroup, *gc);
   1.113 +		RegisterWindowL(windowSingle);
   1.114 +		windowSingle->Window()->SetExtent(windowTopLeft, windowSize);
   1.115 +		windowSingle->Window()->SetBackgroundSurface(iSurface);
   1.116 +		windowSingle->Window()->Activate();
   1.117 +		
   1.118 +		CTWindow* windowDouble = CTWindow::NewL(iWs, *defaultGroup, *gc);
   1.119 +		RegisterWindowL(windowDouble);
   1.120 +		windowDouble->Window()->SetExtent(windowTopLeft, windowSize);
   1.121 +		windowDouble->Window()->SetBackgroundSurface(iSurfaceDoubleBuffered);
   1.122 +		windowDouble->Window()->SetVisible(EFalse);
   1.123 +		windowDouble->Window()->Activate();
   1.124 +
   1.125 +		CTWindow* windowAbove = CTWindow::NewL(iWs, *iGroups[ii], *iGcs[ii]);
   1.126 +		RegisterWindowL(windowAbove);
   1.127 +		windowAbove->Window()->SetExtent(windowTopLeft, windowHalfSize);
   1.128 +		windowAbove->Window()->SetBackgroundSurface(iSurfaceAbove);
   1.129 +		windowAbove->Window()->SetVisible(EFalse);
   1.130 +		windowAbove->Window()->Activate();
   1.131 +		if(ii == 0)
   1.132 +			{
   1.133 +			iWindowAbove11 = CTWindow::NewL(iWs, *iGroups[ii], *iGcs[ii]);
   1.134 +			RegisterWindowL(iWindowAbove11);
   1.135 +			iWindowAbove11->Window()->SetExtent(windowTopLeft, windowSize);
   1.136 +			iWindowAbove11->Window()->SetBackgroundSurface(iSurfaceAbove1);
   1.137 +			iWindowAbove11->Window()->SetVisible(EFalse);
   1.138 +			iWindowAbove11->Window()->Activate();
   1.139 +
   1.140 +			iWindowAbove1 = windowAbove;
   1.141 +			iWindowSingleBuffured1 = windowSingle;
   1.142 +			iWindowDoubleBuffured1 = windowDouble;
   1.143 +			}
   1.144 +		else
   1.145 +			{
   1.146 +			iWindowAbove2 = windowAbove;
   1.147 +			iWindowSingleBuffured2 = windowSingle;
   1.148 +			iWindowDoubleBuffured2 = windowDouble;
   1.149 +			}
   1.150 +
   1.151 +	    TPixelsTwipsAndRotation sizeAndRotation;
   1.152 +	    iWsDevs[ii]->GetDefaultScreenSizeAndRotation(sizeAndRotation);
   1.153 +	    CFbsBitmap* bitmap = new (ELeave)CFbsBitmap();
   1.154 +	    iBitmaps.AppendL(bitmap);
   1.155 +	    User::LeaveIfError(bitmap->Create(sizeAndRotation.iPixelSize, EColor16MU));
   1.156 +        INFO_PRINTF4(_L("Bitmap with size: %d, %d was created to match the size of the screen %d"), sizeAndRotation.iPixelSize.iWidth, sizeAndRotation.iPixelSize.iHeight, ii);
   1.157 +		}
   1.158 +	INFO_PRINTF1(_L("The windows have been created"));
   1.159 +	
   1.160 +	iWs.Finish();
   1.161 +	}
   1.162 +
   1.163 +/**
   1.164 + * Create the window group for the given screen device and put it into the list.
   1.165 + */
   1.166 +CTWindowGroup* CTSurfaceUpdateInteg::CreateGroupL(CWsScreenDevice* aScreenDevice)
   1.167 +	{
   1.168 +	CTWindowGroup* group = CTWindowGroup::NewL(iWs, aScreenDevice);
   1.169 +	CleanupStack::PushL(group);
   1.170 +	iGroups.AppendL(group);
   1.171 +	CleanupStack::Pop();
   1.172 +	return group;
   1.173 +	}
   1.174 +
   1.175 +/**
   1.176 + * Append a window into the list for retrawing it and destroying in the future.
   1.177 + */
   1.178 +void CTSurfaceUpdateInteg::RegisterWindowL(CTWindowTreeNode* aWindow)
   1.179 +	{
   1.180 +	CleanupStack::PushL(aWindow);
   1.181 +	iWindows.AppendL(aWindow);
   1.182 +	CleanupStack::Pop(aWindow);
   1.183 +	}
   1.184 +
   1.185 +/**
   1.186 + * Go through all screens and compare the whole surface area with the reference bitmap.
   1.187 + * 
   1.188 + * @return ETrue, if the surface is exactly the same as the reference bitmap or EFalse otherwise. 
   1.189 + */
   1.190 +TBool CTSurfaceUpdateInteg::CompareAllScreens()
   1.191 +	{
   1.192 +	TBool res = ETrue;
   1.193 +	TRect rc(windowTopLeft, windowSize);
   1.194 +	for(TInt ii = 0; (ii < iNumOfScreens) && res; ii++)
   1.195 +		{
   1.196 +		res = Compare(ii, rc, iRefBitmap);
   1.197 +		}
   1.198 +	return res;
   1.199 +	}
   1.200 +
   1.201 +/**
   1.202 + * Compare part of the screen with the reference bitmap.
   1.203 + * 
   1.204 + * @param aScreenNumber Screen number.
   1.205 + * @param aRectSrc The area of the screen to be compared.
   1.206 + * @param aRefBitmap Bitmap for comparison.
   1.207 + * @return ETrue, if given part of the screen is exactly the same as the reference bitmap or EFalse otherwise. 
   1.208 + */
   1.209 +TBool CTSurfaceUpdateInteg::Compare(TInt aScreenNumber, const TRect& aRectSrc, CFbsBitmap* aRefBitmap)
   1.210 +	{
   1.211 +	MTestScreenCapture* csc = static_cast<MTestScreenCapture*> (iWsDevs[aScreenNumber]->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf));
   1.212 +	if(!csc) //shouldn't happen, as we have checked this before
   1.213 +		{
   1.214 +		return EFalse;
   1.215 +		}
   1.216 +	
   1.217 +	TBool res = ETrue;
   1.218 +	TInt ret = csc->ComposeScreen(*(iBitmaps[aScreenNumber]));
   1.219 +	if(ret != KErrNone)
   1.220 +		{
   1.221 +		INFO_PRINTF2(_L("Composition screen failure, err = %d"), ret);
   1.222 +		res = EFalse;
   1.223 +		}
   1.224 +	//Go through all pixels in screen bitmap for specified area and check that they are 
   1.225 +	//identical to corresponding pixels in reference bitmap
   1.226 +	for(TInt ii = 0; (ii < aRectSrc.Height()) && res; ii++)
   1.227 +		{
   1.228 +		for(TInt jj = 0; (jj < aRectSrc.Width()) && res; jj++)
   1.229 +			{
   1.230 +			TRgb refCol;
   1.231 +			aRefBitmap->GetPixel(refCol, TPoint(jj, ii));
   1.232 +			TRgb col;
   1.233 +			(iBitmaps[aScreenNumber])->GetPixel(col, TPoint(jj, ii) + aRectSrc.iTl);
   1.234 +			if(refCol != col)
   1.235 +				{
   1.236 +				res = EFalse;
   1.237 +				}
   1.238 +			}
   1.239 +		}
   1.240 +	//useful for debugging
   1.241 +#ifdef TEST_COMPARE_PARTLY_UPDATED_SCREEN 	
   1.242 +	if(!res)
   1.243 +		{
   1.244 +		iBitmap->Save(_L("c:\\bitmap.mbm"));
   1.245 +		aRefBitmap->Save(_L("c:\\ref.mbm"));
   1.246 +		}
   1.247 +#endif
   1.248 +	
   1.249 +	return res;
   1.250 +	}
   1.251 +
   1.252 +/**
   1.253 + * Fill reference bitmap with color specified.
   1.254 + * 
   1.255 + */
   1.256 +void CTSurfaceUpdateInteg::FillRefBitmap(TRgb aColor)
   1.257 +	{
   1.258 +	TRect rect = TRect(iRefBitmap->SizeInPixels());
   1.259 +	iGraphicsContext->SetBrushColor(aColor);
   1.260 +	iGraphicsContext->SetPenColor(aColor);
   1.261 +	iGraphicsContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.262 +	iGraphicsContext->DrawRect(rect);
   1.263 +	}
   1.264 +
   1.265 +/**
   1.266 +  @SYMTestCaseID  GRAPHIC-SURFACEUPDATE-0026
   1.267 +  	
   1.268 +  @SYMCR CR1650
   1.269 +
   1.270 +  @SYMREQ REQ11596
   1.271 +
   1.272 +  @SYMTestCaseDesc 
   1.273 +  	SubmitUpdate() to cope with Global Updates with surface on various 
   1.274 +  	screens when the dirty region to update may not be visible on all screens
   1.275 +
   1.276 +  @SYMTestPriority High
   1.277 +
   1.278 +  @SYMTestStatus Implemented
   1.279 +	
   1.280 +  @SYMTestActions The test consists of a single surface, visible on 
   1.281 +  screens A (master), B.
   1.282 +	1.	Submit a global update for the surface, passing a null dirty region.
   1.283 +	2.	Submit a global update for the surface, passing a dirty region 
   1.284 +	that is only visible on screens A  (that particular region for the 
   1.285 +	surface is not visible on B).
   1.286 +	3.	Submit a global update for the surface, passing a dirty region 
   1.287 +	that is only visible on screens B (that particular region for the 
   1.288 +	surface is not visible on A).
   1.289 +	4.	Submit a global update for the surface, passing a dirty 
   1.290 +	region that is not visible on any of the screens.
   1.291 +  
   1.292 +  @SYMTestExpectedResults 
   1.293 +  	1.	TRequestStatus signals KErrNone in all cases. Timestamps must 
   1.294 +  	be valid. The surface gets updated on all screens.
   1.295 +	2.	TRequestStatus signals KErrNone in all cases. Timestamps must 
   1.296 +	be valid. The surface gets updated only on screens A. Screen B is unchanged.
   1.297 +	3.	TRequestStatus signals KErrNone in all cases. Timestamps must 
   1.298 +	be valid. The surface gets updated only on screens B. 
   1.299 +	Screen A is unchanged.
   1.300 +	4.	SubmitUpdate() returns KErrNone.
   1.301 +*/
   1.302 +void CTSurfaceUpdateInteg::TestCase1L()
   1.303 +	{
   1.304 +	INFO_PRINTF1(_L("Global Submit Update with/without update region supplied"));
   1.305 +	
   1.306 +	const TInt bufferNumber = 0; 
   1.307 +	TRequestStatus status = KRequestPending;
   1.308 +	TRequestStatus status1 = KRequestPending;
   1.309 +	TRequestStatus status2 = KRequestPending;
   1.310 +	TUint64 timestampComposition = 0;
   1.311 +	TTimeStamp timeStamp; 
   1.312 +	
   1.313 +	//Fill the surface to different colour, submit update for the whole surface 
   1.314 +	//and check that screen is updated correctly
   1.315 +	INFO_PRINTF1(_L("Fill the surface with the blue color"));
   1.316 +	iSurfaceHelper->FillRectangleL(iSurface, TPoint(), windowSize, KRgbBlue);
   1.317 +	FillRefBitmap(KRgbBlue);
   1.318 +	
   1.319 +	INFO_PRINTF1(_L("Updating the whole area of the surface"));
   1.320 +	TUint64 timestampBefore = User::FastCounter();
   1.321 +	iSurfaceUpdate.NotifyWhenAvailable(status);	
   1.322 +	iSurfaceUpdate.NotifyWhenDisplayed(status1, timeStamp);	
   1.323 +	iSurfaceUpdate.NotifyWhenDisplayedXTimes(10, status2);
   1.324 +	iSurfaceUpdate.SubmitUpdate(KAllScreens, iSurface, bufferNumber);
   1.325 +	User::WaitForRequest(status);
   1.326 +	User::WaitForRequest(status1);
   1.327 +	User::WaitForRequest(status2);
   1.328 +	User::After(TTimeIntervalMicroSeconds32(100000)); //useful for visual checking
   1.329 +
   1.330 +	TUint64 timestampAfter = User::FastCounter();
   1.331 +	if(timestampAfter < timestampBefore)
   1.332 +		{
   1.333 +		timestampAfter += UINT_MAX;
   1.334 +		}
   1.335 +	timestampComposition = timeStamp();
   1.336 +	if(timestampComposition < timestampBefore)
   1.337 +		{
   1.338 +		timestampComposition += UINT_MAX;
   1.339 +		}
   1.340 +	
   1.341 +	TEST(status == KErrNone);
   1.342 +	TEST(status1 == KErrNone);
   1.343 +	TEST(status2 == KErrNone);
   1.344 +	TEST(timestampComposition != 0);
   1.345 +	TEST(timestampAfter >= timestampComposition);
   1.346 +	TEST(timestampBefore <= timestampComposition);
   1.347 +	TEST(CompareAllScreens());
   1.348 +
   1.349 +	//Fill the surface to different colour; hide the part of the surface on 
   1.350 +	//the screen which is not a master, submit update for the area of the surface 
   1.351 +	//which is only visible on the master. Check that only master screen gets updated.
   1.352 +	INFO_PRINTF1(_L("Hide the part of the surface on the second screen"));
   1.353 +	iWindowAbove1->Window()->SetVisible(EFalse);
   1.354 +	iWindowAbove2->Window()->SetVisible(ETrue);
   1.355 +	iWs.Finish();
   1.356 +	iSurfaceUpdate.SubmitUpdate(KAllScreens, iSurface, bufferNumber);
   1.357 +	User::After(TTimeIntervalMicroSeconds32(100000)); //useful for visual checking
   1.358 +	
   1.359 +	INFO_PRINTF1(_L("Fill the surface with the green color"));
   1.360 +	iSurfaceHelper->FillRectangleL(iSurface, TPoint(), windowSize, KRgbGreen);
   1.361 +	
   1.362 +	TRect rc(windowHalfSize);
   1.363 +	rc.Shrink(10, 10);
   1.364 +	RRegion region(1, &rc); //this area is hidden if the window above is visible
   1.365 +	timestampBefore = User::FastCounter();
   1.366 +	iSurfaceUpdate.NotifyWhenAvailable(status);	
   1.367 +	iSurfaceUpdate.NotifyWhenDisplayed(status1, timeStamp);	
   1.368 +	iSurfaceUpdate.NotifyWhenDisplayedXTimes(10, status2);
   1.369 +	iSurfaceUpdate.SubmitUpdate(KAllScreens, iSurface, bufferNumber, &region);
   1.370 +	User::WaitForRequest(status);
   1.371 +	User::WaitForRequest(status1);
   1.372 +	User::WaitForRequest(status2);
   1.373 +	User::After(TTimeIntervalMicroSeconds32(1000000)); //useful for visual checking
   1.374 +
   1.375 +	timestampAfter = User::FastCounter();
   1.376 +	if(timestampAfter < timestampBefore)
   1.377 +		{
   1.378 +		timestampAfter += UINT_MAX;
   1.379 +		}
   1.380 +	timestampComposition = timeStamp();
   1.381 +	if(timestampComposition < timestampBefore)
   1.382 +		{
   1.383 +		timestampComposition += UINT_MAX;
   1.384 +		}
   1.385 +	
   1.386 +	TEST(status == KErrNone);
   1.387 +	TEST(status1 == KErrNone);
   1.388 +	TEST(status2 == KErrNone);
   1.389 +	TEST(timestampComposition != 0);
   1.390 +	TEST(timestampAfter >= timestampComposition);
   1.391 +	TEST(timestampBefore <= timestampComposition);
   1.392 +	User::After(TTimeIntervalMicroSeconds32(100000)); //useful for visual checking
   1.393 +
   1.394 +	//first screen should be updated, as the surface is visible here
   1.395 +	TRect rectSrc = rc;
   1.396 +	rectSrc.Move(windowTopLeft);
   1.397 +	FillRefBitmap(KRgbGreen);
   1.398 +	TEST(Compare(0, rectSrc, iRefBitmap));
   1.399 +	//check that second screen doesn't update visible part of the surface 
   1.400 +	FillRefBitmap(KRgbYellow);
   1.401 +	TEST(Compare(1, rectSrc, iRefBitmap));
   1.402 +
   1.403 +	//Fill the surface to different colour; hide the part of the surface 
   1.404 +	//on the master screen, submit update for the area of the surface 
   1.405 +	//which is only visible on non-master. Check that only non-master screen gets updated.
   1.406 +	INFO_PRINTF1(_L("Hide the part of the surface on the first screen"));
   1.407 +	iWindowAbove1->Window()->SetVisible(ETrue);
   1.408 +	iWindowAbove2->Window()->SetVisible(EFalse);
   1.409 +	iWs.Finish();
   1.410 +	User::After(TTimeIntervalMicroSeconds32(100000)); //useful for visual checking
   1.411 +	
   1.412 +	INFO_PRINTF1(_L("Fill the surface with the blue color"));
   1.413 +	iSurfaceHelper->FillRectangleL(iSurface, TPoint(), windowSize, KRgbBlue);
   1.414 +	
   1.415 +	timestampBefore = User::FastCounter();
   1.416 +	iSurfaceUpdate.NotifyWhenAvailable(status);	
   1.417 +	iSurfaceUpdate.NotifyWhenDisplayed(status1, timeStamp);	
   1.418 +	iSurfaceUpdate.NotifyWhenDisplayedXTimes(10, status2);
   1.419 +	iSurfaceUpdate.SubmitUpdate(KAllScreens, iSurface, bufferNumber, &region);
   1.420 +	User::WaitForRequest(status);
   1.421 +	User::WaitForRequest(status1);
   1.422 +	User::WaitForRequest(status2);
   1.423 +	User::After(TTimeIntervalMicroSeconds32(1000000)); //useful for visual checking
   1.424 +
   1.425 +	timestampAfter = User::FastCounter();
   1.426 +	if(timestampAfter < timestampBefore)
   1.427 +		{
   1.428 +		timestampAfter += UINT_MAX;
   1.429 +		}
   1.430 +	timestampComposition = timeStamp();
   1.431 +	if(timestampComposition < timestampBefore)
   1.432 +		{
   1.433 +		timestampComposition += UINT_MAX;
   1.434 +		}
   1.435 +	
   1.436 +	TEST(status == KErrNone);
   1.437 +	TEST(status1 == KErrNone);
   1.438 +	TEST(status2 == KErrNone);
   1.439 +	TEST(timestampComposition != 0);
   1.440 +	TEST(timestampAfter >= timestampComposition);
   1.441 +	TEST(timestampBefore <= timestampComposition);
   1.442 +
   1.443 +	//check that first screen doesn't update visible part of the surface 
   1.444 +	FillRefBitmap(KRgbYellow);
   1.445 +	TEST(Compare(0, rectSrc, iRefBitmap));
   1.446 +	//second screen should be updated, as the surface is visible here
   1.447 +	FillRefBitmap(KRgbBlue);
   1.448 +	TEST(Compare(1, rectSrc, iRefBitmap));
   1.449 +	
   1.450 +	//Fill the surface to different colour; hide the part of the surface on the master screen, 
   1.451 +	//submit update for the area of the surface which is not visible on any screen. 
   1.452 +	//Check that all screens have not been updated.
   1.453 +	INFO_PRINTF1(_L("Hide partly the surface on two screens"));
   1.454 +	iWindowAbove1->Window()->SetVisible(ETrue);
   1.455 +	iWindowAbove2->Window()->SetVisible(ETrue);
   1.456 +	iWs.Finish();
   1.457 +	iSurfaceUpdate.SubmitUpdate(KAllScreens, iSurface, bufferNumber);
   1.458 +	User::After(TTimeIntervalMicroSeconds32(1000000)); //useful for visual checking
   1.459 +	
   1.460 +	INFO_PRINTF1(_L("Fill the surface with the green color"));
   1.461 +	iSurfaceHelper->FillRectangleL(iSurface, TPoint(), windowSize, KRgbGreen);
   1.462 +	FillRefBitmap(KRgbGreen);
   1.463 +	
   1.464 +	timestampBefore = User::FastCounter();
   1.465 +	iSurfaceUpdate.NotifyWhenAvailable(status);	
   1.466 +	iSurfaceUpdate.NotifyWhenDisplayed(status1, timeStamp);	
   1.467 +	iSurfaceUpdate.NotifyWhenDisplayedXTimes(10, status2);
   1.468 +	iSurfaceUpdate.SubmitUpdate(KAllScreens, iSurface, bufferNumber, &region);
   1.469 +	User::WaitForRequest(status);
   1.470 +	User::WaitForRequest(status1);
   1.471 +	User::WaitForRequest(status2);
   1.472 +	User::After(TTimeIntervalMicroSeconds32(1000000)); //useful for visual checking
   1.473 +
   1.474 +	timestampAfter = User::FastCounter();
   1.475 +	if(timestampAfter < timestampBefore)
   1.476 +		{
   1.477 +		timestampAfter += UINT_MAX;
   1.478 +		}
   1.479 +	timestampComposition = timeStamp();
   1.480 +	if(timestampComposition < timestampBefore)
   1.481 +		{
   1.482 +		timestampComposition += UINT_MAX;
   1.483 +		}
   1.484 +	
   1.485 +	TEST(status == KErrNone);
   1.486 +	TEST(status1 == KErrNone);
   1.487 +	TEST(status2 == KErrNone);
   1.488 +	TEST(timestampComposition != 0);
   1.489 +	TEST(timestampAfter >= timestampComposition);
   1.490 +	TEST(timestampBefore <= timestampComposition);
   1.491 +	User::After(TTimeIntervalMicroSeconds32(100000)); //useful for visual checking
   1.492 +	
   1.493 +	//both first and second screen shouldn't be updated, as the surface is not visible here
   1.494 +	FillRefBitmap(KRgbYellow);
   1.495 +	TEST(Compare(0, rectSrc, iRefBitmap));
   1.496 +	TEST(Compare(1, rectSrc, iRefBitmap));
   1.497 +
   1.498 +	INFO_PRINTF1(_L("Return to the initial state"));
   1.499 +	iWindowAbove1->Window()->SetVisible(EFalse);
   1.500 +	iWindowAbove2->Window()->SetVisible(EFalse);
   1.501 +	iWs.Finish();
   1.502 +	iSurfaceUpdate.SubmitUpdate(KAllScreens, iSurface, bufferNumber);
   1.503 +	User::After(TTimeIntervalMicroSeconds32(1000000)); //useful for visual checking
   1.504 +	
   1.505 +	FillRefBitmap(KRgbGreen);
   1.506 +	TEST(CompareAllScreens());
   1.507 +	}
   1.508 +
   1.509 +/**
   1.510 +  @SYMTestCaseID GRAPHIC-SURFACEUPDATE-0031
   1.511 +
   1.512 +  @SYMCR CR1650
   1.513 +
   1.514 +  @SYMREQ REQ11598
   1.515 +
   1.516 +  @SYMTestCaseDesc NotifyWhenAvailable() to deal with global updates and be signalled 
   1.517 + 	correctly when screen is unplugged.
   1.518 + 	
   1.519 +  @SYMTestPriority 	High
   1.520 +
   1.521 +  @SYMTestStatus Implemented
   1.522 +	
   1.523 +  @SYMTestActions 
   1.524 + 	The test consists of a double-buffered surface, visible on screens A 
   1.525 + 	(master) and B,
   1.526 +	1	Make global submit update with notify when available for the buffer 1.
   1.527 +	2	Unplug screen A (notification is still in a progress )
   1.528 +	3	Make global submit update with notify when available for the 
   1.529 +	buffer 2 to trigger notification.
   1.530 +	4	Make global submit update with notify when available for the 
   1.531 +	buffer 1.
   1.532 +	5	Plug in screen A. (notification is still in a progress )
   1.533 +	6	Make global submit update with notify when available for 
   1.534 +	the buffer 2.
   1.535 +  
   1.536 +  @SYMTestExpectedResults 
   1.537 +  	After step 3, notification is received with KErrNone (this is 
   1.538 +  	triggered by the Receiver for screen B).
   1.539 +	After step 6, notification is received with KErrNone (this is 
   1.540 +	triggered by the Receiver for screen A).
   1.541 +*/
   1.542 +void CTSurfaceUpdateInteg::TestCase2L()
   1.543 +	{
   1.544 +	INFO_PRINTF1(_L("Exercising NotifyWhenAvailable while some screens are disconnected."));
   1.545 +
   1.546 +	//hide single-buffered surface and show a double buffered-surface
   1.547 +	iWindowSingleBuffured1->Window()->SetVisible(EFalse);
   1.548 +	iWindowSingleBuffured2->Window()->SetVisible(EFalse);
   1.549 +	iWindowDoubleBuffured1->Window()->SetVisible(ETrue);
   1.550 +	iWindowDoubleBuffured2->Window()->SetVisible(ETrue);
   1.551 +	iWs.Finish();
   1.552 +	iSurfaceUpdate.SubmitUpdate(KAllScreens, iSurface, 0);
   1.553 +	iSurfaceUpdate.SubmitUpdate(KAllScreens, iSurfaceDoubleBuffered, 0);
   1.554 +	FillRefBitmap(KRgbCyan);
   1.555 +	TEST(CompareAllScreens());
   1.556 +	User::After(TTimeIntervalMicroSeconds32(100000)); //useful for visual checking
   1.557 +	
   1.558 +	INFO_PRINTF1(_L("Fill the surface with the blue color"));
   1.559 +	iSurfaceHelper->FillRectangleL(iSurfaceDoubleBuffered, TPoint(), windowSize, KRgbBlue);
   1.560 +	
   1.561 +	INFO_PRINTF1(_L("Disconnect the screen while notify when available request is still in a progress")); 
   1.562 +	TRequestStatus status;
   1.563 +	TSwitchDisplayAndReleaseBuffer param;
   1.564 +	param.iBuffer = 0;
   1.565 +	param.iScreen = 0;
   1.566 +	param.iSurfaceId=iSurfaceDoubleBuffered;
   1.567 +	CCommandDispatcher commandDispatcher(CCommandDispatcher::EDisconnectDisplayAndReleaseBuffer, &param);
   1.568 +	
   1.569 +	//Command dispatcher will be running in the separate thread. 
   1.570 +	//The requirement for this caused by the fact that for dubble-buffered surfaces 
   1.571 +	//the content update receiver will postpone completion of the request for availability until 
   1.572 +	//client sends SubmitUpdate for another buffer. 
   1.573 +	iSurfaceUpdate.NotifyWhenAvailable(status);	
   1.574 +	iSurfaceUpdate.SubmitUpdate(KAllScreens, iSurfaceDoubleBuffered, 1);
   1.575 +	TInt res = commandDispatcher.Start();  //kickoff another thread, which SubmitUpdate 
   1.576 +											//for buffer 1 and disconnects the first screen
   1.577 +	TEST(res == KErrNone);
   1.578 +	User::WaitForRequest(status);//At that point we are blocked until command dispatcher sends SubmitUpdate for the buffer number 1
   1.579 +	TEST(status == KErrNone);
   1.580 +	
   1.581 +	//connect the screen
   1.582 +	INFO_PRINTF1(_L("Connect the screen while notify when available request is still in a progress")); 
   1.583 +	CCommandDispatcher commandDispatcher1(CCommandDispatcher::EConnectDisplayAndReleaseBuffer, &param);
   1.584 +	iSurfaceUpdate.NotifyWhenAvailable(status);	
   1.585 +	iSurfaceUpdate.SubmitUpdate(KAllScreens, iSurfaceDoubleBuffered, 0);
   1.586 +	res = commandDispatcher.Start();//kickoff another thread, which SubmitUpdate 
   1.587 +										//for buffer 1 and connects the first screen
   1.588 +
   1.589 +	TEST(res == KErrNone);
   1.590 +	User::WaitForRequest(status);
   1.591 +	TEST(status == KErrNone);
   1.592 +
   1.593 +	//restore the original state
   1.594 +	iWindowSingleBuffured1->Window()->SetVisible(ETrue);
   1.595 +	iWindowSingleBuffured2->Window()->SetVisible(ETrue);
   1.596 +	iWindowDoubleBuffured1->Window()->SetVisible(EFalse);
   1.597 +	iWindowDoubleBuffured2->Window()->SetVisible(EFalse);
   1.598 +	iWs.Finish();
   1.599 +	iSurfaceUpdate.SubmitUpdate(KAllScreens, iSurface, 0);
   1.600 +	iSurfaceUpdate.SubmitUpdate(KAllScreens, iSurfaceDoubleBuffered, 0);
   1.601 +	FillRefBitmap(KRgbGreen);
   1.602 +	TEST(CompareAllScreens());
   1.603 +	}
   1.604 +
   1.605 +/**
   1.606 +  @SYMTestCaseID GRAPHIC-SURFACEUPDATE-0032
   1.607 +  	
   1.608 +  @SYMCR CR1650
   1.609 +
   1.610 +  @SYMREQ REQ11599, REQ11600, REQ11601
   1.611 +
   1.612 +  @SYMTestCaseDesc NotifyWhenDisplayedXTimes() to deal with global 
   1.613 +  updates and be signalled correctly when screen is unplugged.
   1.614 +	
   1.615 +  @SYMTestPriority 	High
   1.616 +
   1.617 +  @SYMTestStatus Implemented
   1.618 +	
   1.619 +  @SYMTestActions 
   1.620 +  	The test consists of a single-buffered surface, S1, visible on 
   1.621 +  	screens A (master) and B.
   1.622 +
   1.623 +	Screens are ordered in the following priority: A > B
   1.624 +		1	Make global submit update for surface S1 with notify 
   1.625 +		when notify when displayed X times. X should be approximately 10 
   1.626 +		seconds.
   1.627 +		2	Unplug screen A while display XTimes is still in progress.
   1.628 +		3	After receiving notification, plug in screen A
   1.629 +		4	Make global submit update with notify when displayed X times. 
   1.630 +		X should be approximately 10 seconds.
   1.631 +		5	Make global submit update for surface S1, with notify when 
   1.632 +		displayed X times. X should be approximately 10 seconds.
   1.633 +		6	Unplug screen B while display XTimes is still in progress.
   1.634 +        7   Make global submit update for surface S1, with notify when 
   1.635 +        displayed X times. X should be approximately 10 seconds.		
   1.636 +		8	Unplug screen A as well whilst display XTimes is still in progress.
   1.637 +		9   Reconnect both screens
   1.638 +  	
   1.639 +  @SYMTestExpectedResults
   1.640 +  	After the 10 seconds have elapsed from step 1, notification is 
   1.641 +  	received (step 3) with KErrNone (this is triggered by the Receiver 
   1.642 +  	for screen B).
   1.643 +	After 10 seconds have elapsed from step 4, notification is received 
   1.644 +	with KErrNone (this is triggered by the Receiver for screen A).
   1.645 +	After step 8 (which must occur before 10 seconds) notification will 
   1.646 +	be received with KErrNotVisible (ie. The surface is not visible on 
   1.647 +	any screen).
   1.648 +*/
   1.649 +void CTSurfaceUpdateInteg::TestCase3()
   1.650 +	{
   1.651 +	INFO_PRINTF1(_L("Exercising NotifyWhenDisplayedXTimes while some screen is disconnected."));
   1.652 +
   1.653 +	TRequestStatus status;
   1.654 +	TInt count = 100 * 2; 
   1.655 +	iSurfaceUpdate.NotifyWhenDisplayedXTimes(count, status);	
   1.656 +	iSurfaceUpdate.SubmitUpdate(KAllScreens, iSurface, 0);
   1.657 +	
   1.658 +	INFO_PRINTF1(_L("Disconnect the screen when notification when displayed X times request is still in a progress")); 
   1.659 +	TInt displayState = EDisconnect;
   1.660 +	TInt disconnectedScreenNo = 0;
   1.661 +	TInt res = UserSvr::HalFunction(EHalGroupDisplay | (disconnectedScreenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
   1.662 +	TEST(res == KErrNone);
   1.663 +	User::WaitForRequest(status); //The content update receiver will complete notification when “count” number of display refreshes has occurred.  
   1.664 +									//We are not blocked here indefinitely, so there is no point to use a command dispatcher
   1.665 +	TEST(status == KErrNone);
   1.666 +
   1.667 +	//restore the first screen 
   1.668 +	INFO_PRINTF1(_L("Connect the screen when notification when displayed X times request is still in a progress")); 
   1.669 +	displayState = ENormalResolution;
   1.670 +	res = UserSvr::HalFunction(EHalGroupDisplay | (disconnectedScreenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
   1.671 +	TEST(res == KErrNone);
   1.672 +
   1.673 +	iSurfaceUpdate.NotifyWhenDisplayedXTimes(count, status);	
   1.674 +	iSurfaceUpdate.SubmitUpdate(KAllScreens, iSurface, 0);
   1.675 +	User::WaitForRequest(status);
   1.676 +	TEST(status == KErrNone);
   1.677 +	
   1.678 +	// Make sure other surface is not visible
   1.679 +	iWindowAbove11->Window()->SetVisible(EFalse);
   1.680 +	iWs.Finish();
   1.681 +	User::After(TTimeIntervalMicroSeconds32(100000)); //useful for visual checking
   1.682 +	
   1.683 +	// above1 surface should not be visible because window is not visible
   1.684 +	TTimeStamp timeStamp; 
   1.685 +	iSurfaceUpdate.NotifyWhenDisplayed(status, timeStamp);	
   1.686 +	iSurfaceUpdate.SubmitUpdate(KAllScreens, iSurfaceAbove1, 0);
   1.687 +	User::WaitForRequest(status);
   1.688 +	TEST(status == KErrNotVisible);
   1.689 +	
   1.690 +	//disconnect the secondary screen - surface still visible on primary
   1.691 +	INFO_PRINTF1(_L("Disconnect the secondary screen - surface still visible on primary")); 
   1.692 +	displayState = EDisconnect;
   1.693 +	disconnectedScreenNo = 1;
   1.694 +	iSurfaceUpdate.NotifyWhenDisplayedXTimes(count, status);	
   1.695 +	iSurfaceUpdate.SubmitUpdate(KAllScreens, iSurface, 0);
   1.696 +	
   1.697 +	res = UserSvr::HalFunction(EHalGroupDisplay | (disconnectedScreenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
   1.698 +	TEST(res == KErrNone);
   1.699 +	User::WaitForRequest(status);
   1.700 +	TEST(status == KErrNone);
   1.701 +	User::After(TTimeIntervalMicroSeconds32(100000)); //useful for visual checking
   1.702 +
   1.703 +   //disconnect the primary screen - surface now not visible on any screen
   1.704 +    INFO_PRINTF1(_L("Disconnect the primary screen - surface not visible on any screen")); 
   1.705 +    displayState = EDisconnect;
   1.706 +    disconnectedScreenNo = 0;
   1.707 +    iSurfaceUpdate.NotifyWhenDisplayedXTimes(count, status);    
   1.708 +    iSurfaceUpdate.SubmitUpdate(KAllScreens, iSurface, 0);
   1.709 +    
   1.710 +    res = UserSvr::HalFunction(EHalGroupDisplay | (disconnectedScreenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
   1.711 +    TEST(res == KErrNone);
   1.712 +    User::WaitForRequest(status);
   1.713 +    TEST(status == KErrNotVisible); // not visible raised if primary is disconnected
   1.714 +    User::After(TTimeIntervalMicroSeconds32(100000)); //useful for visual checking
   1.715 +        
   1.716 +
   1.717 +    //restore initial state 
   1.718 +    disconnectedScreenNo = 0;
   1.719 +    displayState = ENormalResolution;
   1.720 +    res = UserSvr::HalFunction(EHalGroupDisplay | (disconnectedScreenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
   1.721 +    TEST(res == KErrNone);
   1.722 +    disconnectedScreenNo = 1;
   1.723 +    res = UserSvr::HalFunction(EHalGroupDisplay | (disconnectedScreenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
   1.724 +    TEST(res == KErrNone);
   1.725 +
   1.726 +    
   1.727 +	iWs.Finish();	
   1.728 +	iSurfaceUpdate.SubmitUpdate(KAllScreens, iSurface, 0);
   1.729 +	User::After(TTimeIntervalMicroSeconds32(100000)); //useful for visual checking
   1.730 +	TEST(CompareAllScreens());
   1.731 +	}
   1.732 +
   1.733 +void CTSurfaceUpdateInteg::RunTestCaseL(TInt aCurTestCase)
   1.734 +	{
   1.735 +	((CTSurfaceUpdateIntegStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
   1.736 +	switch(aCurTestCase)
   1.737 +		{
   1.738 +	case 1:
   1.739 +		{
   1.740 +		
   1.741 +		if((static_cast <CTSurfaceUpdateIntegStep*> (iStep)) -> IsScreenCaptureSupported()  && (iNumOfScreens > 1))
   1.742 +			{
   1.743 +			((CTSurfaceUpdateIntegStep*)iStep)->SetTestStepID(_L("GRAPHIC-SURFACEUPDATE-0026"));
   1.744 +			INFO_PRINTF1(_L("TestCase1"));
   1.745 +			TestCase1L();
   1.746 +			}
   1.747 +		else
   1.748 +			{
   1.749 +			((CTSurfaceUpdateIntegStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
   1.750 +			INFO_PRINTF3(_L("The test will be skipped as the environment is not ready: Number of screen : %d, Is screen capture supported: %d"), 
   1.751 +					iNumOfScreens, (static_cast <CTSurfaceUpdateIntegStep*> (iStep)) -> IsScreenCaptureSupported());
   1.752 +			TestComplete();		
   1.753 +			}	
   1.754 +		break;
   1.755 +		}
   1.756 +#ifdef __WINS__
   1.757 +	case 2:
   1.758 +		{
   1.759 +		((CTSurfaceUpdateIntegStep*)iStep)->SetTestStepID(_L("GRAPHIC-SURFACEUPDATE-0031"));
   1.760 +		INFO_PRINTF1(_L("TestCase2"));
   1.761 +		TestCase2L();
   1.762 +		break;
   1.763 +		}
   1.764 +	case 3:
   1.765 +		{
   1.766 +		((CTSurfaceUpdateIntegStep*)iStep)->SetTestStepID(_L("GRAPHIC-SURFACEUPDATE-0032"));
   1.767 +		INFO_PRINTF1(_L("TestCase3"));
   1.768 +		TestCase3();
   1.769 +		break;
   1.770 +		}
   1.771 +#endif		
   1.772 +	default:
   1.773 +		((CTSurfaceUpdateIntegStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
   1.774 +		((CTSurfaceUpdateIntegStep*)iStep)->CloseTMSGraphicsStep();
   1.775 +		TestComplete();		
   1.776 +		break;
   1.777 +		}
   1.778 +	((CTSurfaceUpdateIntegStep*)iStep)->RecordTestResultL();
   1.779 +	}
   1.780 +//--------------
   1.781 +_LIT(KCommandDispatcher, "CommandDispatcher");
   1.782 +const TUint KDefaultHeapSize=0x10000;
   1.783 +
   1.784 +/**
   1.785 + * Launch the command thread.
   1.786 + */
   1.787 +TInt CCommandDispatcher::Start()
   1.788 +	{
   1.789 +	RThread commandThread;
   1.790 +	TInt res = KErrGeneral;
   1.791 +	TBuf<64> commandThreadName;
   1.792 +	TBuf<64> commandThreaMask;
   1.793 +	
   1.794 +	// Guarantee uniqueness of thread name by using timestamp
   1.795 +	TTime tm;
   1.796 +	TBuf<32> timeStamp;
   1.797 +	tm.UniversalTime();
   1.798 +	TRAP(res, tm.FormatL(timeStamp, _L("_%H%T%S%C")));
   1.799 +	if(res != KErrNone)
   1.800 +		{
   1.801 +		return res;
   1.802 +		}
   1.803 +
   1.804 +	commandThreadName.Append(KCommandDispatcher);
   1.805 +	commandThreadName.Append(timeStamp);
   1.806 +	commandThreaMask = commandThreadName;
   1.807 +	commandThreaMask.Insert(0, _L("*"));
   1.808 +	TFindThread findThread(commandThreaMask);
   1.809 +	TFullName name;
   1.810 +	  // Need to check that the thread exists.
   1.811 +	if (findThread.Next(name)!=KErrNone)
   1.812 +		{
   1.813 +		  // Create the thread for the server.
   1.814 +		res = commandThread.Create(commandThreadName,
   1.815 +			CCommandDispatcher::ThreadFunction,
   1.816 +			KDefaultStackSize,
   1.817 +			KDefaultHeapSize,
   1.818 +			KDefaultHeapSize,
   1.819 +			this
   1.820 +			);
   1.821 +			
   1.822 +          // The thread has been created OK so get it started - however
   1.823 +          // we need to make sure that it has started before we continue.
   1.824 +		if (res==KErrNone)
   1.825 +			{
   1.826 +			TRequestStatus rendezvousStatus;
   1.827 +			commandThread.SetPriority(EPriorityNormal);
   1.828 +			commandThread.Rendezvous(rendezvousStatus);
   1.829 +			commandThread.Resume();
   1.830 +			}
   1.831 +		}
   1.832 +	commandThread.Close();
   1.833 +	return res;
   1.834 +	}
   1.835 +
   1.836 +TInt CCommandDispatcher::ThreadFunction(TAny* aAny)
   1.837 +	{
   1.838 +	  // get clean-up stack
   1.839 +	CTrapCleanup* cleanup=CTrapCleanup::New();
   1.840 +	CCommandDispatcher* commandDispatcher = (CCommandDispatcher*) aAny;
   1.841 +	TRAPD(res, commandDispatcher->ExecuteCommandL());
   1.842 +	delete cleanup; 
   1.843 +	return res;
   1.844 +	}
   1.845 +
   1.846 +/**
   1.847 + * Run commands in a thread different to the thread where the instance 
   1.848 + * of the class was initialized.
   1.849 + */
   1.850 +void CCommandDispatcher::ExecuteCommandL()
   1.851 +	{
   1.852 +	switch(iCommandName)
   1.853 +		{
   1.854 +	case EDisconnectDisplayAndReleaseBuffer:
   1.855 +		{
   1.856 +		RSurfaceUpdateSession surfaceUpdate;
   1.857 +		User::LeaveIfError(surfaceUpdate.Connect());
   1.858 +		CleanupClosePushL(surfaceUpdate);
   1.859 +		TSwitchDisplayAndReleaseBuffer* param = static_cast<TSwitchDisplayAndReleaseBuffer*>(iParam); 
   1.860 +		if(!param)
   1.861 +			{
   1.862 +			User::Leave(KErrArgument);
   1.863 +			}
   1.864 +		TInt displayState = EDisconnect;
   1.865 +		TInt screenNumber = param->iScreen;
   1.866 +		TInt bufferNumber = param->iBuffer;
   1.867 +		User::LeaveIfError(UserSvr::HalFunction(EHalGroupDisplay | (screenNumber<<16), EDisplayHalSetDisplayState, &displayState, NULL));
   1.868 +		//Submit Update to unblock the main client thread 
   1.869 +		User::LeaveIfError(surfaceUpdate.SubmitUpdate(KAllScreens, param->iSurfaceId, bufferNumber));
   1.870 +		CleanupStack::PopAndDestroy(&surfaceUpdate);
   1.871 +		break;
   1.872 +		}
   1.873 +	case EConnectDisplayAndReleaseBuffer:
   1.874 +		{
   1.875 +		RSurfaceUpdateSession surfaceUpdate;
   1.876 +		User::LeaveIfError(surfaceUpdate.Connect());
   1.877 +		CleanupClosePushL(surfaceUpdate);
   1.878 +		TSwitchDisplayAndReleaseBuffer* param = static_cast<TSwitchDisplayAndReleaseBuffer*>(iParam); 
   1.879 +		if(!param)
   1.880 +			{
   1.881 +			User::Leave(KErrArgument);
   1.882 +			}
   1.883 +		TInt displayState = ENormalResolution;
   1.884 +		TInt screenNumber = param->iScreen;
   1.885 +		TInt bufferNumber = param->iBuffer;
   1.886 +		User::LeaveIfError(UserSvr::HalFunction(EHalGroupDisplay | (screenNumber<<16), EDisplayHalSetDisplayState, &displayState, NULL));
   1.887 +		//Submit Update to unblock the main client thread 
   1.888 +		User::LeaveIfError(surfaceUpdate.SubmitUpdate(KAllScreens, param->iSurfaceId, bufferNumber));
   1.889 +		CleanupStack::PopAndDestroy(&surfaceUpdate);
   1.890 +		break;
   1.891 +		}
   1.892 +	default:
   1.893 +		User::Leave(KErrNotSupported);
   1.894 +		break;
   1.895 +		}
   1.896 +	}
   1.897 +
   1.898 +//--------------
   1.899 +__CONSTRUCT_STEP__(SurfaceUpdateInteg)
   1.900 +
   1.901 +/**
   1.902 + * Retrieve screen capturing plug-in, if succeed set a flag.
   1.903 + */
   1.904 +void CTSurfaceUpdateIntegStep::TestSetupL()
   1.905 +	{
   1.906 +//	check if the screen capture plug-in presents in the system
   1.907 +	RWsSession ws;
   1.908 +	User::LeaveIfError(ws.Connect());
   1.909 +	CleanupClosePushL(ws);
   1.910 +
   1.911 +	TInt numOfScreens = ws.NumberOfScreens();
   1.912 +	if(numOfScreens < 2)
   1.913 +		{
   1.914 +		ERR_PRINTF2(_L("Environment is not ready, the number of the screens in the system for this test should be 2 or more, the current number is: %d"), numOfScreens);
   1.915 +		User::Leave(KErrNotReady);
   1.916 +		}
   1.917 +	
   1.918 +	CWsScreenDevice* wsDev = new (ELeave) CWsScreenDevice(ws);
   1.919 +	CleanupStack::PushL(wsDev);
   1.920 +	User::LeaveIfError(wsDev->Construct(0));
   1.921 +	TDisplayMode dispMode = wsDev->DisplayMode();
   1.922 +	INFO_PRINTF2(_L("Screen device display mode is: %d."), dispMode);
   1.923 +	
   1.924 +	MTestScreenCapture* csc = static_cast<MTestScreenCapture*> (wsDev->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf));
   1.925 +	if(csc)
   1.926 +		{
   1.927 +		INFO_PRINTF1(_L("Screen capture plug-in presents in the system."));
   1.928 +		iScreenCapture = ETrue;
   1.929 +		}
   1.930 +	else
   1.931 +		{
   1.932 +		INFO_PRINTF1(_L("Screen capture plug-in is not installed in the system, to make automated checking screen capture rendering stage is required, \
   1.933 +see graphics\\wserv_std_plugins\\screencapture"));
   1.934 +		}
   1.935 +	
   1.936 +	CleanupStack::PopAndDestroy(2, &ws); //ws, wsDev
   1.937 +	}
   1.938 +	
   1.939 +void CTSurfaceUpdateIntegStep::TestClose()
   1.940 +	{
   1.941 +	}
   1.942 +