os/graphics/windowing/windowserver/test/t_integ/src/t_wservintegstepbasic.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/windowing/windowserver/test/t_integ/src/t_wservintegstepbasic.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,738 @@
     1.4 +// Copyright (c) 2007-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 +/**
    1.20 + @file
    1.21 + @test
    1.22 + @internalComponent
    1.23 +*/
    1.24 +
    1.25 +#include "t_wservintegstepbasic.h"
    1.26 +#include <test/tefunit.h>
    1.27 +#include <e32const.h>	//KNullUidValue
    1.28 +#include <pixelformats.h>
    1.29 +
    1.30 +namespace t_wservintegstepbasic
    1.31 +	{
    1.32 +	static const TUint delay=100000;	//0.5 sec
    1.33 +
    1.34 +	const TInt KSurfaceWidth = 50;
    1.35 +	const TInt KSurfaceHeight = 50;
    1.36 +	const TUidPixelFormat KSurfaceFormat = EUidPixelFormatXRGB_8888;
    1.37 +	const TInt KBytesPerPixel = 4;	// Four bytes per pixel for the format above.
    1.38 +
    1.39 +	// Events delivered to this handle are thrown away
    1.40 +	const TUint32 ENullWsHandle = 0xFFFFFFFF;
    1.41 +	_LIT(KT_WServIntegStepBasicTestId,"testid");
    1.42 +	_LIT(KT_BasicStepPanicTxt, "t_wservintegstepbasic");
    1.43 +	}
    1.44 +
    1.45 +using namespace t_wservintegstepbasic;
    1.46 +
    1.47 +CT_WServIntegStepBasic::CT_WServIntegStepBasic()
    1.48 +	{
    1.49 +	SetTestStepName(KT_WServIntegStepBasic);
    1.50 +	}
    1.51 +
    1.52 +
    1.53 +CT_WServIntegStepBasic::~CT_WServIntegStepBasic()
    1.54 +	{
    1.55 +	delete iGc;
    1.56 +	delete iScreen;
    1.57 +	iWinGroup.Close();
    1.58 +	iWsSession.Flush();
    1.59 +	iWsSession.Close();
    1.60 +	}
    1.61 +
    1.62 +
    1.63 +enum TVerdict CT_WServIntegStepBasic::doTestStepPreambleL()
    1.64 +	{
    1.65 +	TVerdict ret=CTestStep::doTestStepPreambleL();
    1.66 +
    1.67 +	if ( !GetIntFromConfig( ConfigSection(), KT_WServIntegStepBasicTestId, iTestId ) )
    1.68 +		{
    1.69 +		User::Leave(KErrNotFound);
    1.70 +		}
    1.71 +	else
    1.72 +		{
    1.73 +		User::LeaveIfError(iWsSession.Connect());
    1.74 +		iScreen = new (ELeave) CWsScreenDevice(iWsSession);
    1.75 +		User::LeaveIfError(iScreen->Construct());
    1.76 +		iWinGroup  = RWindowGroup(iWsSession);
    1.77 +		User::LeaveIfError(iWinGroup.Construct(ENullWsHandle) );
    1.78 +		iWinGroup.AutoForeground(ETrue);
    1.79 +		iGc = new (ELeave) CWindowGc(iScreen);
    1.80 +		User::LeaveIfError(iGc->Construct());
    1.81 +		iWsSession.Flush();
    1.82 +		}
    1.83 +	return ret;
    1.84 +	}
    1.85 +
    1.86 +enum TVerdict CT_WServIntegStepBasic::doTestStepPostambleL()
    1.87 +	{
    1.88 +	return TestStepResult();
    1.89 +	}
    1.90 +
    1.91 +/**
    1.92 +Starts test step
    1.93 +More detail on each test step can be
    1.94 +found in the respective script file.
    1.95 +@internalComponent
    1.96 +@return TVerdict pass / fail
    1.97 +@pre N/A
    1.98 +@post N/A
    1.99 +*/
   1.100 +enum TVerdict CT_WServIntegStepBasic::doTestStepL()
   1.101 +	{
   1.102 +	__UHEAP_MARK;
   1.103 +
   1.104 +	RWindow win;
   1.105 +	RBlankWindow blankWin;
   1.106 +
   1.107 +	switch( iTestId )
   1.108 +		{
   1.109 +		case 1:
   1.110 +			Graphics_Wserv_Gce_1L(win);
   1.111 +			break;
   1.112 +		case 2:
   1.113 +			Graphics_Wserv_Gce_2L(blankWin);
   1.114 +			break;
   1.115 +		case 3:
   1.116 +			Graphics_Wserv_Gce_3L();
   1.117 +			break;
   1.118 +		case 4:
   1.119 +			Graphics_Wserv_Gce_4L(win);
   1.120 +			break;
   1.121 +		case 5:
   1.122 +			Graphics_Wserv_Gce_5L(win);
   1.123 +			break;
   1.124 +		case 6:
   1.125 +			Graphics_Wserv_Gce_6L(win);
   1.126 +			break;
   1.127 +		case 7:
   1.128 +			//Test removed in CR1489
   1.129 +			break;
   1.130 +		case 8:
   1.131 +			//Test removed in CR1489
   1.132 +			break;
   1.133 +		case 9:
   1.134 +			//Test removed in CR1489
   1.135 +			break;
   1.136 +		case 10:
   1.137 +			//Test removed in CR1489
   1.138 +			break;
   1.139 +		case 11:
   1.140 +			Graphics_Wserv_Gce_11L(win);
   1.141 +			break;
   1.142 +		case 12:
   1.143 +			//Test removed in CR1489
   1.144 +			break;
   1.145 +		case 13:
   1.146 +			Graphics_Wserv_Gce_13L(win);
   1.147 +			break;
   1.148 +		case 14:
   1.149 +			//Test removed in CR1489
   1.150 +			break;
   1.151 +		case 15:
   1.152 +			Graphics_Wserv_Gce_15L(win);
   1.153 +			break;
   1.154 +		case 16:
   1.155 +			//Test removed in CR1489
   1.156 +			break;
   1.157 +		case 17:
   1.158 +			Graphics_Wserv_Gce_17L(win);
   1.159 +			break;
   1.160 +		case 18:
   1.161 +			//Test removed in CR1489
   1.162 +			break;
   1.163 +		case 19:
   1.164 +			Graphics_Wserv_Gce_19L(win);
   1.165 +			break;
   1.166 +		case 20:
   1.167 +			//Test removed in CR1489
   1.168 +			break;
   1.169 +		case 21:
   1.170 +			Graphics_Wserv_Gce_21L(win);
   1.171 +			break;
   1.172 +		case 22:
   1.173 +			Graphics_Wserv_Gce_22L(win);
   1.174 +			break;
   1.175 +		case 23:
   1.176 +			//Test removed in CR1489
   1.177 +			break;
   1.178 +		case 24:
   1.179 +			//Test removed in CR1489
   1.180 +			break;
   1.181 +		case 25:
   1.182 +			//Test removed in CR1489
   1.183 +			break;
   1.184 +		case 26:
   1.185 +			//Test removed in CR1489
   1.186 +			break;
   1.187 +		case 27:
   1.188 +			//Test removed in CR1489
   1.189 +			break;
   1.190 +		case 28:
   1.191 +			//Test removed in CR1489
   1.192 +			break;
   1.193 +		case 29:
   1.194 +			//Test removed in CR1489
   1.195 +			break;
   1.196 +		case 30:
   1.197 +			//Test removed in CR1489
   1.198 +			break;
   1.199 +		case 31:
   1.200 +			Graphics_Wserv_Gce_31L(blankWin);
   1.201 +			break;
   1.202 +		case 32:
   1.203 +			Graphics_Wserv_Gce_32L(win);
   1.204 +			break;
   1.205 +		case 33:
   1.206 +			Graphics_Wserv_Gce_33L(win);
   1.207 +			break;
   1.208 +		case 34:
   1.209 +			Graphics_Wserv_Gce_34L(win);
   1.210 +			break;
   1.211 +		case 35:
   1.212 +			Graphics_Wserv_Gce_35L(win);
   1.213 +			break;
   1.214 +		case 36:
   1.215 +			Graphics_Wserv_Gce_36L(win);
   1.216 +			break;
   1.217 +		case 37:
   1.218 +			//Test removed in CR1489
   1.219 +			break;
   1.220 +		default:
   1.221 +			User::Panic(KT_BasicStepPanicTxt, KErrNotFound);  //Unexpected value!
   1.222 +		}
   1.223 +
   1.224 +	__UHEAP_MARKEND;
   1.225 +	return TestStepResult();
   1.226 +	}
   1.227 +
   1.228 +//Test setting a surface as the background of a window
   1.229 +void CT_WServIntegStepBasic::Graphics_Wserv_Gce_1L(RWindow& aWin)
   1.230 +	{
   1.231 +	CreateSurfaceL(iSurfaceId);
   1.232 +	CreateRWindowL(aWin);
   1.233 +	TEST(KErrNone==aWin.SetBackgroundSurface(iSurfaceId));
   1.234 +	ForceWindowToRedraw(aWin);
   1.235 +	DestroySurface();
   1.236 +	aWin.Close();
   1.237 +	}
   1.238 +//Test setting a surface as the background of a RBlankWindow
   1.239 +void CT_WServIntegStepBasic::Graphics_Wserv_Gce_2L(RBlankWindow& aBlankWin)
   1.240 +	{
   1.241 +	CreateSurfaceL(iSurfaceId);
   1.242 +	CreateRBlankWindowL(aBlankWin);
   1.243 +	TEST(KErrNone==aBlankWin.SetBackgroundSurface(iSurfaceId));
   1.244 +	ForceWindowToRedraw(aBlankWin);
   1.245 +	DestroySurface();
   1.246 +	aBlankWin.Close();
   1.247 +	}
   1.248 +
   1.249 +//Negative test for setting a surface as the background of a RBackedUpWindow
   1.250 +void CT_WServIntegStepBasic::Graphics_Wserv_Gce_3L()
   1.251 +	{
   1.252 +	CreateSurfaceL(iSurfaceId);
   1.253 +	RBackedUpWindow backedUpWindow( iWsSession );
   1.254 +	CleanupClosePushL( backedUpWindow );
   1.255 +	User::LeaveIfError( backedUpWindow.Construct( iWinGroup, EColor16MA, ENullWsHandle) );
   1.256 +	backedUpWindow.SetSizeErr( iScreen->SizeInPixels() );
   1.257 +	backedUpWindow.SetVisible( ETrue );
   1.258 +	backedUpWindow.Activate();
   1.259 +	iWsSession.Flush();
   1.260 +	User::After(delay);
   1.261 +	// Expect a panic here - TClientPanic::EWservPanicDrawable
   1.262 +	backedUpWindow.SetBackgroundSurface( iSurfaceId );
   1.263 +	DestroySurface();
   1.264 +	CleanupStack::PopAndDestroy( &backedUpWindow );
   1.265 +	}
   1.266 +
   1.267 +//Test for moving a window with its background set
   1.268 +void CT_WServIntegStepBasic::Graphics_Wserv_Gce_4L(RWindow& aWin)
   1.269 +	{
   1.270 +	// Create window and assign a surface to it
   1.271 +	ASSERT_EQUALS( EPass, SetSurfaceL(aWin,iSurfaceId));
   1.272 +	TSize scrSize(iScreen->SizeInPixels());
   1.273 +	// move the window around
   1.274 +	aWin.SetPosition( TPoint( (scrSize.iWidth)-KTempWindowWidth, 0) );
   1.275 +	iWsSession.Flush();
   1.276 +	User::After(delay);
   1.277 +	aWin.SetPosition( TPoint(aWin.Position().iX, (scrSize.iHeight)-KTempWindowHeight ));
   1.278 +	iWsSession.Flush();
   1.279 +	User::After(delay);
   1.280 +	aWin.SetPosition( TPoint(0, (scrSize.iHeight)-KTempWindowHeight) );
   1.281 +	iWsSession.Flush();
   1.282 +	User::After(delay);
   1.283 +	aWin.SetPosition(TPoint(0,0));
   1.284 +	iWsSession.Flush();
   1.285 +	User::After(delay);
   1.286 +	DestroySurface();
   1.287 +	aWin.Close();
   1.288 +		}
   1.289 +
   1.290 +//Test moving a window with its background set partially and wholly offscreen
   1.291 +void CT_WServIntegStepBasic::Graphics_Wserv_Gce_5L(RWindow& aWin)
   1.292 +	{
   1.293 +	ASSERT_EQUALS( EPass, SetSurfaceL(aWin,iSurfaceId));
   1.294 +	TSize screenSize(iScreen->SizeInPixels());
   1.295 +	// partially off screen
   1.296 +	TUint xCord=(screenSize.iWidth-KTempWindowWidth)+(KTempWindowWidth/2);
   1.297 +	TUint yCord=(screenSize.iHeight-KTempWindowHeight)+(KTempWindowHeight/2);
   1.298 +	aWin.SetPosition(TPoint(xCord,yCord));
   1.299 +	iWsSession.Flush();
   1.300 +	User::After(delay);
   1.301 +	// wholly off screen
   1.302 +	aWin.SetPosition( TPoint(screenSize.iWidth, screenSize.iHeight) );
   1.303 +	iWsSession.Flush();
   1.304 +	User::After(delay);
   1.305 +	DestroySurface();
   1.306 +	aWin.Close();
   1.307 +	}
   1.308 +
   1.309 +//Test resizing a window with its background set to a surface
   1.310 +void CT_WServIntegStepBasic::Graphics_Wserv_Gce_6L(RWindow& aWin)
   1.311 +	{
   1.312 +	ASSERT_EQUALS( EPass, SetSurfaceL(aWin,iSurfaceId));
   1.313 +	TSize sz(aWin.Size());
   1.314 +	aWin.SetSize( sz+TPoint(20,0) );
   1.315 +	iWsSession.Flush();
   1.316 +	User::After( delay );
   1.317 +	aWin.SetSize( sz+TPoint(0,20) );
   1.318 +	iWsSession.Flush();
   1.319 +	User::After( delay );
   1.320 +	aWin.SetSize( sz+TPoint(20,20) );
   1.321 +	iWsSession.Flush();
   1.322 +	User::After( delay );
   1.323 +	aWin.SetSize( TSize(KSurfaceWidth, KSurfaceHeight ) );
   1.324 +	iWsSession.Flush();
   1.325 +	User::After( delay );
   1.326 +  	DestroySurface();
   1.327 +	aWin.Close();
   1.328 +	}
   1.329 +
   1.330 +
   1.331 +// Test Opaque drawing in front of a background surface
   1.332 +void CT_WServIntegStepBasic::Graphics_Wserv_Gce_11L(RWindow& aWin)
   1.333 +	{
   1.334 +	ASSERT_EQUALS( EPass, SetSurfaceL(aWin,iSurfaceId));
   1.335 +	// Opaque drawing on bkgd surface
   1.336 +	DrawShape( aWin, 0x0000FF00 );
   1.337 +	DestroySurface();
   1.338 +	aWin.Close();
   1.339 +	}
   1.340 +
   1.341 +//Test Semi-transparent drawing in front of a background surface
   1.342 +void CT_WServIntegStepBasic::Graphics_Wserv_Gce_13L(RWindow& aWin)
   1.343 +	{
   1.344 +	ASSERT_EQUALS( EPass, SetSurfaceL(aWin,iSurfaceId));
   1.345 +	// semi Transp on bkgd surface
   1.346 +	DrawShape( aWin, 0x8000FF00 );
   1.347 +	DestroySurface();
   1.348 +	aWin.Close();
   1.349 +	}
   1.350 +
   1.351 +//Test that an opaque window can be put in front of an Rwindow with background surface
   1.352 +void CT_WServIntegStepBasic::Graphics_Wserv_Gce_15L(RWindow& aWin)
   1.353 +	{
   1.354 +	ASSERT_EQUALS( EPass, SetSurfaceL(aWin,iSurfaceId));
   1.355 +	CleanupClosePushL(aWin);
   1.356 +	// draw 2nd window partially over the first one
   1.357 +	RWindow win2;
   1.358 +	CreateRWindowL(win2, TPoint(10,10), KRgbGreen );
   1.359 +	DestroySurface();
   1.360 +	CleanupStack::PopAndDestroy(&aWin);
   1.361 +	win2.Close();
   1.362 +	aWin.Close();
   1.363 +	}
   1.364 +
   1.365 +//Test that a semi-transparent window can be put in front of a Rwindow with surface
   1.366 +void CT_WServIntegStepBasic::Graphics_Wserv_Gce_17L(RWindow& aWin)
   1.367 +	{
   1.368 +	ASSERT_EQUALS( EPass, SetSurfaceL(aWin,iSurfaceId));
   1.369 +	CleanupClosePushL(aWin);
   1.370 +	// draw semi Transp win partially over first win with surface
   1.371 +	RWindow win2;
   1.372 +	CreateRWindowL(win2, TPoint(10,10));
   1.373 +	INFO_PRINTF1(_L("Destroy Surface"));
   1.374 +	DestroySurface();
   1.375 +	CleanupStack::PopAndDestroy(&aWin);
   1.376 +	win2.Close();
   1.377 +	aWin.Close();
   1.378 +	}
   1.379 +
   1.380 +//Test updating a background surface
   1.381 +void CT_WServIntegStepBasic::Graphics_Wserv_Gce_19L(RWindow& aWin)
   1.382 +	{
   1.383 +	ASSERT_EQUALS( EPass, SetSurfaceL(aWin,iSurfaceId));
   1.384 +	CleanupClosePushL(aWin);
   1.385 +	// create a 2nd surface
   1.386 +	TSurfaceId surfaceId2;
   1.387 +	CreateSurfaceL(surfaceId2, 0x0000FF00);
   1.388 +	ASSERT_EQUALS( KErrNone, aWin.SetBackgroundSurface(surfaceId2) );
   1.389 +	ForceWindowToRedraw(aWin);
   1.390 +	TInt ret = iSurfaceManager.CloseSurface(surfaceId2);
   1.391 +	if(ret!=KErrNone)
   1.392 +		{
   1.393 +		INFO_PRINTF1(_L("Surface manager failed to close surface"));
   1.394 +		}
   1.395 +	// destroys iSurfaceId plus closes iSurfaceUpdateSession,iChunk,iSurfaceManager
   1.396 +	DestroySurface();
   1.397 +	CleanupStack::PopAndDestroy(&aWin);
   1.398 +	}
   1.399 +
   1.400 +//Test shape of a window is applied to window a surface
   1.401 +void CT_WServIntegStepBasic::Graphics_Wserv_Gce_21L(RWindow& aWin)
   1.402 +	{
   1.403 +	ASSERT_EQUALS( EPass, SetSurfaceL(aWin,iSurfaceId));
   1.404 +	TRect rc[2] = { TRect(0,0,100,200),TRect(100,120,200,200) };
   1.405 +	RRegion region(2, rc);
   1.406 +	aWin.SetShape( region );
   1.407 +	User::After(delay);	// For DEBUG
   1.408 +	DestroySurface();
   1.409 +	aWin.Close();
   1.410 +	}
   1.411 +
   1.412 +//Test that a valid key color is returned when a surface
   1.413 +//has been set as the background of a window
   1.414 +void CT_WServIntegStepBasic::Graphics_Wserv_Gce_22L(RWindow& aWin)
   1.415 +	{
   1.416 +	ASSERT_EQUALS( EPass, SetSurfaceL(aWin,iSurfaceId));
   1.417 +	TRgb colValue(aWin.KeyColor());
   1.418 +	if ( aWin.DisplayMode()==EColor16MA || aWin.DisplayMode()==EColor16MAP )
   1.419 +		{
   1.420 +		TEST(aWin.KeyColor().Internal()==0x00000000);
   1.421 +		}
   1.422 +	else
   1.423 +		{
   1.424 +		TEST(aWin.KeyColor().Alpha()==0xFF);
   1.425 +		}
   1.426 +	aWin.Close();
   1.427 +	}
   1.428 +
   1.429 +//Test that the use of SetColor() i.e. with no parameters removes
   1.430 +//any surface assigned to the window
   1.431 +void CT_WServIntegStepBasic::Graphics_Wserv_Gce_31L(RBlankWindow& aBlankWin)
   1.432 +	{
   1.433 +	CreateSurfaceL(iSurfaceId);
   1.434 +	CreateRBlankWindowL(aBlankWin);
   1.435 +	ASSERT_EQUALS(KErrNone, aBlankWin.SetBackgroundSurface(iSurfaceId));
   1.436 +	ForceWindowToRedraw(aBlankWin);
   1.437 +	aBlankWin.SetColor();
   1.438 +	ForceWindowToRedraw(aBlankWin);
   1.439 +	DestroySurface();
   1.440 +	aBlankWin.Close();
   1.441 +	}
   1.442 +
   1.443 +//Test that the shaped window maintains the surface when moved
   1.444 +void CT_WServIntegStepBasic::Graphics_Wserv_Gce_32L(RWindow& aWin)
   1.445 +	{
   1.446 +	ASSERT_EQUALS( EPass, SetSurfaceL(aWin,iSurfaceId));
   1.447 +	TRect rc[2] = { TRect(0,0,100,200),TRect(100,120,200,200) };
   1.448 +	RRegion region(2, rc);
   1.449 +	aWin.SetShape( region );
   1.450 +	User::After(delay);
   1.451 +	aWin.SetPosition( TPoint( aWin.Position().iX+10, aWin.Position().iY+10 ) );
   1.452 +	iWsSession.Flush();
   1.453 +	User::After(delay);
   1.454 +	DestroySurface();
   1.455 +	aWin.Close();
   1.456 +	}
   1.457 +
   1.458 +//Test that window and surface scale to the new size when a shaped
   1.459 +//window with surface is resized
   1.460 +void CT_WServIntegStepBasic::Graphics_Wserv_Gce_33L(RWindow& aWin)
   1.461 +	{
   1.462 +	ASSERT_EQUALS( EPass, SetSurfaceL(aWin,iSurfaceId));
   1.463 +	TRect rc[2] = { TRect(0,0,100,200),TRect(100,120,200,200) };
   1.464 +	RRegion region(2, rc);
   1.465 +	aWin.SetShape( region );
   1.466 +	User::After(delay);
   1.467 +	aWin.SetSize( TSize(200,150) );
   1.468 +	iWsSession.Flush();
   1.469 +	User::After(delay);
   1.470 +	DestroySurface();
   1.471 +	aWin.Close();
   1.472 +	}
   1.473 +
   1.474 +//Test that the background surface blends with the semi transparent window
   1.475 +void CT_WServIntegStepBasic::Graphics_Wserv_Gce_34L(RWindow& aWin)
   1.476 +	{
   1.477 +	ASSERT_EQUALS( EPass, SetSurfaceL(aWin,iSurfaceId));
   1.478 +	CleanupClosePushL(aWin);
   1.479 +	ForceWindowToRedraw(aWin);
   1.480 +	RWindow win2;
   1.481 +	CreateRWindowL(win2,TPoint(10,0), 0x80A9B9C9);
   1.482 +	// draw semi Transp on window bkgd
   1.483 +	DrawShape( win2, 0x8000FF00 );
   1.484 +	DestroySurface();
   1.485 +	CleanupStack::PopAndDestroy(&aWin);
   1.486 +	win2.Close();
   1.487 +	aWin.Close();
   1.488 +	}
   1.489 +
   1.490 +// Test that the corner style is applied to the window with surface
   1.491 +void CT_WServIntegStepBasic::Graphics_Wserv_Gce_35L(RWindow& aWin)
   1.492 +	{
   1.493 +	ASSERT_EQUALS( EPass, SetSurfaceL(aWin,iSurfaceId));
   1.494 +	aWin.SetCornerType( EWindowCorner5 );
   1.495 +	User::After(delay);
   1.496 +	DestroySurface();
   1.497 +	aWin.Close();
   1.498 +	}
   1.499 +
   1.500 +/***
   1.501 +Test that shaped windows with background surfaces arranged such that
   1.502 +the back window overlaps the front's bounding box, but not its shaped
   1.503 +region (e.g. the front is L-shaped and the back overlaps the area within
   1.504 +the 'L'). In this situation, the back window's surface should be visible
   1.505 +in the overlap area
   1.506 +*/
   1.507 +void CT_WServIntegStepBasic::Graphics_Wserv_Gce_36L(RWindow& aWin)
   1.508 +	{
   1.509 +	ASSERT_EQUALS( EPass, SetSurfaceL(aWin,iSurfaceId));
   1.510 +	CleanupClosePushL(aWin);
   1.511 +	TRect rc1[2] = { TRect(110,20,150,80),TRect(150,60,200,100) };
   1.512 +	RRegion region1(2, rc1);
   1.513 +	aWin.SetShape( region1 );
   1.514 +	User::After(delay);
   1.515 +
   1.516 +	// create a 2nd surface
   1.517 +	TSurfaceId surfaceId2;
   1.518 +	CreateSurfaceL(surfaceId2,0x00ABCDEF);
   1.519 +	RWindow win2;
   1.520 +	CreateRWindowL(win2);
   1.521 +	ASSERT_EQUALS( KErrNone, win2.SetBackgroundSurface(surfaceId2));
   1.522 +	User::After(delay);
   1.523 +	TRect rc2[2] = { TRect(0,0,100,200),TRect(100,120,200,200) };
   1.524 +	RRegion region2(2, rc2);
   1.525 +	win2.SetShape( region2 );
   1.526 +	User::After(delay);
   1.527 +
   1.528 +	TInt ret = iSurfaceManager.CloseSurface(surfaceId2);
   1.529 +	if(ret!=KErrNone)
   1.530 +		{
   1.531 +		INFO_PRINTF1(_L("Surface manager failed to close surface"));
   1.532 +		}
   1.533 +	// destroys iSurfaceId plus closes iSurfaceUpdateSession,iChunk,iSurfaceManager
   1.534 +	DestroySurface();
   1.535 +	CleanupStack::PopAndDestroy(&aWin);
   1.536 +	win2.Close();
   1.537 +	aWin.Close();
   1.538 +	}
   1.539 +
   1.540 +
   1.541 +/**
   1.542 +Creates a RWindow
   1.543 +
   1.544 +@param aWin	The window object
   1.545 +@param aPos	The Position of the window
   1.546 +@param aBkgdColor The background color of the window
   1.547 +@param aSize The size of the window
   1.548 +*/
   1.549 +void CT_WServIntegStepBasic::CreateRWindowL(RWindow& aWin, const TPoint& aPos, const TRgb& aBkgdColor, const TSize& aWinSize)
   1.550 +	{
   1.551 +	aWin = RWindow( iWsSession );
   1.552 +	CleanupClosePushL( aWin );
   1.553 +	User::LeaveIfError( aWin.Construct( iWinGroup, ENullWsHandle ) );
   1.554 +	CleanupStack::Pop(&aWin);
   1.555 +	aWin.SetExtent(aPos, aWinSize);
   1.556 +	aWin.SetBackgroundColor( aBkgdColor );
   1.557 +	aWin.Activate();
   1.558 +	aWin.BeginRedraw();
   1.559 +	aWin.EndRedraw();
   1.560 +	aWin.SetVisible( ETrue );
   1.561 +	iWsSession.Flush();
   1.562 +	User::After(delay);
   1.563 +	}
   1.564 +
   1.565 +/**
   1.566 +Creates a RBlankWindow
   1.567 +
   1.568 +@param aBlankWin The window object
   1.569 +*/
   1.570 +void CT_WServIntegStepBasic::CreateRBlankWindowL(RBlankWindow& aBlankWin)
   1.571 +	{
   1.572 +	aBlankWin = RBlankWindow(iWsSession);
   1.573 +	CleanupClosePushL(aBlankWin);
   1.574 +	User::LeaveIfError(aBlankWin.Construct(iWinGroup, ENullWsHandle) );
   1.575 +	TSize sz( KTempWindowWidth, KTempWindowHeight );
   1.576 +	aBlankWin.SetSize(sz);
   1.577 +	aBlankWin.SetColor(TRgb(0x800000FF));	// 0xAABBGGRR
   1.578 +	aBlankWin.Activate();
   1.579 +	CleanupStack::Pop(&aBlankWin);
   1.580 +	iWsSession.Flush();
   1.581 +	User::After(delay);
   1.582 +	}
   1.583 +
   1.584 +void CT_WServIntegStepBasic::ForceWindowToRedraw(RWindowBase& aWin)
   1.585 +	{
   1.586 +	aWin.SetVisible( EFalse );
   1.587 +	iWsSession.Flush();
   1.588 +	aWin.SetVisible( ETrue );
   1.589 +	iWsSession.Flush();
   1.590 +	User::After(delay);
   1.591 +	}
   1.592 +
   1.593 +void CT_WServIntegStepBasic::CreateSurfaceManager()
   1.594 +	{
   1.595 +	INFO_PRINTF1(_L("Loading the device driver"));
   1.596 +	TInt ret = iSurfaceManager.Open();
   1.597 +	if(ret==KErrNone)
   1.598 +		{
   1.599 +		INFO_PRINTF1(_L("Creating surface manager OK"));
   1.600 +		}
   1.601 +	}
   1.602 +
   1.603 +/**
   1.604 +Set up code for creating a surface and fill it with a color
   1.605 +
   1.606 +@param aSurfaceId The surface object, to be initialized.
   1.607 +@param aColorPattern The color to fill the surface with.
   1.608 +*/
   1.609 +void CT_WServIntegStepBasic::CreateSurfaceL(TSurfaceId& aSurfaceId, TUint aColorPattern)
   1.610 +	{
   1.611 +	INFO_PRINTF1(_L("Creating a surface manager"));
   1.612 +	CreateSurfaceManager();
   1.613 +
   1.614 +	INFO_PRINTF1(_L("Setting up surface attributes"));
   1.615 +	RSurfaceManager::TSurfaceCreationAttributesBuf attribs;
   1.616 +	RSurfaceManager::TSurfaceCreationAttributes& surfaceCreationAtribs=attribs();
   1.617 +
   1.618 +	surfaceCreationAtribs.iSize.iWidth = KSurfaceWidth;
   1.619 +	surfaceCreationAtribs.iSize.iHeight = KSurfaceHeight;
   1.620 +	surfaceCreationAtribs.iBuffers = 1;
   1.621 +	surfaceCreationAtribs.iPixelFormat = KSurfaceFormat;
   1.622 +	surfaceCreationAtribs.iStride = KBytesPerPixel*KSurfaceWidth;
   1.623 +	surfaceCreationAtribs.iOffsetToFirstBuffer = 0;
   1.624 +	surfaceCreationAtribs.iAlignment = 4;
   1.625 +	surfaceCreationAtribs.iContiguous = EFalse;
   1.626 +	surfaceCreationAtribs.iMappable = ETrue;
   1.627 +	INFO_PRINTF1(_L("Call to CreateSurfaceL()"));
   1.628 +	TInt err = iSurfaceManager.CreateSurface(attribs, aSurfaceId);
   1.629 +	if (err == KErrNone)
   1.630 +		{
   1.631 +		//we have a surface, so map it in
   1.632 +		INFO_PRINTF1(_L("Surface created ok, mapping to it"));
   1.633 +		TInt err = iSurfaceManager.MapSurface(aSurfaceId, iChunk);
   1.634 +		User::LeaveIfError(err);
   1.635 +		TUint32* surfacePtr = reinterpret_cast<TUint32*>(iChunk.Base());
   1.636 +		TUint32* linePtr = surfacePtr;
   1.637 +
   1.638 +		// Fill first line
   1.639 +		for (TInt xx = 0; xx < KSurfaceWidth; xx++)
   1.640 +			{
   1.641 +			surfacePtr[xx] = aColorPattern;
   1.642 +			}
   1.643 +
   1.644 +		// Now copy that to the other lines
   1.645 +		TInt stride = KBytesPerPixel * KSurfaceWidth;
   1.646 +		for (TInt yy = 1; yy < KSurfaceHeight; yy++)
   1.647 +			{
   1.648 +			linePtr += KSurfaceWidth;
   1.649 +			Mem::Move(linePtr, surfacePtr, stride);
   1.650 +			}
   1.651 +		}
   1.652 +
   1.653 +	INFO_PRINTF1(_L("Create Surface update session"));
   1.654 +	CreateSurfaceUpdateSessionL();
   1.655 +	err = iSurfaceUpdateSession.SubmitUpdate(KAllScreens, aSurfaceId, 0, NULL);
   1.656 +	if (err!=KErrNone)
   1.657 +		{
   1.658 +	   INFO_PRINTF1(_L("Fail in submitting update"));
   1.659 +		}
   1.660 +	}
   1.661 +
   1.662 +void CT_WServIntegStepBasic::CreateSurfaceUpdateSessionL()
   1.663 +	{
   1.664 +	TInt ret = iSurfaceUpdateSession.Connect();
   1.665 +
   1.666 +	if (ret==KErrAlreadyExists)
   1.667 +		{
   1.668 +		INFO_PRINTF1(_L("Device driver already loaded"));
   1.669 +		}
   1.670 +	else if (ret==KErrNone)
   1.671 +		{
   1.672 +		INFO_PRINTF1(_L("Connected to surface update server"));
   1.673 +		}
   1.674 +	else
   1.675 +		{
   1.676 +		INFO_PRINTF1(_L("Fatal error connecting to surface update server"));
   1.677 +		User::LeaveIfError(ret);
   1.678 +		}
   1.679 +	}
   1.680 +
   1.681 +void CT_WServIntegStepBasic::DestroySurface()
   1.682 +	{
   1.683 +	INFO_PRINTF1(_L("Destroy Surface update session"));
   1.684 +	iSurfaceUpdateSession.Close();
   1.685 +
   1.686 +	//close the chunk
   1.687 +	INFO_PRINTF1(_L("Closing chunk"));
   1.688 +	iChunk.Close();
   1.689 +
   1.690 +	INFO_PRINTF1(_L("Closing surface"));
   1.691 +	TInt ret = iSurfaceManager.CloseSurface(iSurfaceId);
   1.692 +	if(ret!=KErrNone)
   1.693 +		{
   1.694 +		INFO_PRINTF1(_L("Surface manager failed to close"));
   1.695 +		}
   1.696 +
   1.697 +	INFO_PRINTF1(_L("Destroy Surface Manager"));
   1.698 +	iSurfaceManager.Close();
   1.699 +	}
   1.700 +
   1.701 +/**
   1.702 +Common set up code for assigning a surface to the window. Calls other utility
   1.703 +functions for creating a window and a surface
   1.704 +
   1.705 +@param aWin	The window object
   1.706 +@param aSurfaceId	The surface object, to be initialized.
   1.707 +*/
   1.708 +TVerdict CT_WServIntegStepBasic::SetSurfaceL(RWindow& aWin, TSurfaceId& aSurfaceId)
   1.709 +	{
   1.710 +	TVerdict verdict=EPass;
   1.711 +	CreateRWindowL(aWin);
   1.712 +	CleanupClosePushL(aWin);
   1.713 +	CreateSurfaceL( aSurfaceId );
   1.714 +	CleanupStack::Pop(&aWin);
   1.715 +	if ( aWin.SetBackgroundSurface(aSurfaceId)!=KErrNone)
   1.716 +		{
   1.717 +		verdict=EFail;
   1.718 +		}
   1.719 +	iWsSession.Flush();
   1.720 +	ForceWindowToRedraw(aWin);
   1.721 +	return verdict;
   1.722 +	}
   1.723 +
   1.724 +/**
   1.725 +Draw an Ellipse shape
   1.726 +
   1.727 +@param aWin	The window object, connected to a session
   1.728 +@param aColor The (transparent/opaque)color which the shape is filled with
   1.729 +*/
   1.730 +void CT_WServIntegStepBasic::DrawShape(RWindow& aWin, const TRgb& aColor)
   1.731 +	{
   1.732 +   	iGc->Activate( aWin );
   1.733 +   	iGc->SetBrushColor( aColor );
   1.734 +   	iGc->SetBrushStyle( CGraphicsContext::ESolidBrush );
   1.735 +   	TRect rect(TPoint(0,0), TPoint(aWin.Size().iWidth, aWin.Size().iHeight));
   1.736 +   	iGc->DrawEllipse(rect);
   1.737 +   	iWsSession.Flush();
   1.738 +   	User::After(delay);
   1.739 +   	iGc->Deactivate();
   1.740 +	}
   1.741 +