os/graphics/windowing/windowserver/test/t_integ/src/t_wservintegstepbasic.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
/**
sl@0
    17
 @file
sl@0
    18
 @test
sl@0
    19
 @internalComponent
sl@0
    20
*/
sl@0
    21
sl@0
    22
#include "t_wservintegstepbasic.h"
sl@0
    23
#include <test/tefunit.h>
sl@0
    24
#include <e32const.h>	//KNullUidValue
sl@0
    25
#include <pixelformats.h>
sl@0
    26
sl@0
    27
namespace t_wservintegstepbasic
sl@0
    28
	{
sl@0
    29
	static const TUint delay=100000;	//0.5 sec
sl@0
    30
sl@0
    31
	const TInt KSurfaceWidth = 50;
sl@0
    32
	const TInt KSurfaceHeight = 50;
sl@0
    33
	const TUidPixelFormat KSurfaceFormat = EUidPixelFormatXRGB_8888;
sl@0
    34
	const TInt KBytesPerPixel = 4;	// Four bytes per pixel for the format above.
sl@0
    35
sl@0
    36
	// Events delivered to this handle are thrown away
sl@0
    37
	const TUint32 ENullWsHandle = 0xFFFFFFFF;
sl@0
    38
	_LIT(KT_WServIntegStepBasicTestId,"testid");
sl@0
    39
	_LIT(KT_BasicStepPanicTxt, "t_wservintegstepbasic");
sl@0
    40
	}
sl@0
    41
sl@0
    42
using namespace t_wservintegstepbasic;
sl@0
    43
sl@0
    44
CT_WServIntegStepBasic::CT_WServIntegStepBasic()
sl@0
    45
	{
sl@0
    46
	SetTestStepName(KT_WServIntegStepBasic);
sl@0
    47
	}
sl@0
    48
sl@0
    49
sl@0
    50
CT_WServIntegStepBasic::~CT_WServIntegStepBasic()
sl@0
    51
	{
sl@0
    52
	delete iGc;
sl@0
    53
	delete iScreen;
sl@0
    54
	iWinGroup.Close();
sl@0
    55
	iWsSession.Flush();
sl@0
    56
	iWsSession.Close();
sl@0
    57
	}
sl@0
    58
sl@0
    59
sl@0
    60
enum TVerdict CT_WServIntegStepBasic::doTestStepPreambleL()
sl@0
    61
	{
sl@0
    62
	TVerdict ret=CTestStep::doTestStepPreambleL();
sl@0
    63
sl@0
    64
	if ( !GetIntFromConfig( ConfigSection(), KT_WServIntegStepBasicTestId, iTestId ) )
sl@0
    65
		{
sl@0
    66
		User::Leave(KErrNotFound);
sl@0
    67
		}
sl@0
    68
	else
sl@0
    69
		{
sl@0
    70
		User::LeaveIfError(iWsSession.Connect());
sl@0
    71
		iScreen = new (ELeave) CWsScreenDevice(iWsSession);
sl@0
    72
		User::LeaveIfError(iScreen->Construct());
sl@0
    73
		iWinGroup  = RWindowGroup(iWsSession);
sl@0
    74
		User::LeaveIfError(iWinGroup.Construct(ENullWsHandle) );
sl@0
    75
		iWinGroup.AutoForeground(ETrue);
sl@0
    76
		iGc = new (ELeave) CWindowGc(iScreen);
sl@0
    77
		User::LeaveIfError(iGc->Construct());
sl@0
    78
		iWsSession.Flush();
sl@0
    79
		}
sl@0
    80
	return ret;
sl@0
    81
	}
sl@0
    82
sl@0
    83
enum TVerdict CT_WServIntegStepBasic::doTestStepPostambleL()
sl@0
    84
	{
sl@0
    85
	return TestStepResult();
sl@0
    86
	}
sl@0
    87
sl@0
    88
/**
sl@0
    89
Starts test step
sl@0
    90
More detail on each test step can be
sl@0
    91
found in the respective script file.
sl@0
    92
@internalComponent
sl@0
    93
@return TVerdict pass / fail
sl@0
    94
@pre N/A
sl@0
    95
@post N/A
sl@0
    96
*/
sl@0
    97
enum TVerdict CT_WServIntegStepBasic::doTestStepL()
sl@0
    98
	{
sl@0
    99
	__UHEAP_MARK;
sl@0
   100
sl@0
   101
	RWindow win;
sl@0
   102
	RBlankWindow blankWin;
sl@0
   103
sl@0
   104
	switch( iTestId )
sl@0
   105
		{
sl@0
   106
		case 1:
sl@0
   107
			Graphics_Wserv_Gce_1L(win);
sl@0
   108
			break;
sl@0
   109
		case 2:
sl@0
   110
			Graphics_Wserv_Gce_2L(blankWin);
sl@0
   111
			break;
sl@0
   112
		case 3:
sl@0
   113
			Graphics_Wserv_Gce_3L();
sl@0
   114
			break;
sl@0
   115
		case 4:
sl@0
   116
			Graphics_Wserv_Gce_4L(win);
sl@0
   117
			break;
sl@0
   118
		case 5:
sl@0
   119
			Graphics_Wserv_Gce_5L(win);
sl@0
   120
			break;
sl@0
   121
		case 6:
sl@0
   122
			Graphics_Wserv_Gce_6L(win);
sl@0
   123
			break;
sl@0
   124
		case 7:
sl@0
   125
			//Test removed in CR1489
sl@0
   126
			break;
sl@0
   127
		case 8:
sl@0
   128
			//Test removed in CR1489
sl@0
   129
			break;
sl@0
   130
		case 9:
sl@0
   131
			//Test removed in CR1489
sl@0
   132
			break;
sl@0
   133
		case 10:
sl@0
   134
			//Test removed in CR1489
sl@0
   135
			break;
sl@0
   136
		case 11:
sl@0
   137
			Graphics_Wserv_Gce_11L(win);
sl@0
   138
			break;
sl@0
   139
		case 12:
sl@0
   140
			//Test removed in CR1489
sl@0
   141
			break;
sl@0
   142
		case 13:
sl@0
   143
			Graphics_Wserv_Gce_13L(win);
sl@0
   144
			break;
sl@0
   145
		case 14:
sl@0
   146
			//Test removed in CR1489
sl@0
   147
			break;
sl@0
   148
		case 15:
sl@0
   149
			Graphics_Wserv_Gce_15L(win);
sl@0
   150
			break;
sl@0
   151
		case 16:
sl@0
   152
			//Test removed in CR1489
sl@0
   153
			break;
sl@0
   154
		case 17:
sl@0
   155
			Graphics_Wserv_Gce_17L(win);
sl@0
   156
			break;
sl@0
   157
		case 18:
sl@0
   158
			//Test removed in CR1489
sl@0
   159
			break;
sl@0
   160
		case 19:
sl@0
   161
			Graphics_Wserv_Gce_19L(win);
sl@0
   162
			break;
sl@0
   163
		case 20:
sl@0
   164
			//Test removed in CR1489
sl@0
   165
			break;
sl@0
   166
		case 21:
sl@0
   167
			Graphics_Wserv_Gce_21L(win);
sl@0
   168
			break;
sl@0
   169
		case 22:
sl@0
   170
			Graphics_Wserv_Gce_22L(win);
sl@0
   171
			break;
sl@0
   172
		case 23:
sl@0
   173
			//Test removed in CR1489
sl@0
   174
			break;
sl@0
   175
		case 24:
sl@0
   176
			//Test removed in CR1489
sl@0
   177
			break;
sl@0
   178
		case 25:
sl@0
   179
			//Test removed in CR1489
sl@0
   180
			break;
sl@0
   181
		case 26:
sl@0
   182
			//Test removed in CR1489
sl@0
   183
			break;
sl@0
   184
		case 27:
sl@0
   185
			//Test removed in CR1489
sl@0
   186
			break;
sl@0
   187
		case 28:
sl@0
   188
			//Test removed in CR1489
sl@0
   189
			break;
sl@0
   190
		case 29:
sl@0
   191
			//Test removed in CR1489
sl@0
   192
			break;
sl@0
   193
		case 30:
sl@0
   194
			//Test removed in CR1489
sl@0
   195
			break;
sl@0
   196
		case 31:
sl@0
   197
			Graphics_Wserv_Gce_31L(blankWin);
sl@0
   198
			break;
sl@0
   199
		case 32:
sl@0
   200
			Graphics_Wserv_Gce_32L(win);
sl@0
   201
			break;
sl@0
   202
		case 33:
sl@0
   203
			Graphics_Wserv_Gce_33L(win);
sl@0
   204
			break;
sl@0
   205
		case 34:
sl@0
   206
			Graphics_Wserv_Gce_34L(win);
sl@0
   207
			break;
sl@0
   208
		case 35:
sl@0
   209
			Graphics_Wserv_Gce_35L(win);
sl@0
   210
			break;
sl@0
   211
		case 36:
sl@0
   212
			Graphics_Wserv_Gce_36L(win);
sl@0
   213
			break;
sl@0
   214
		case 37:
sl@0
   215
			//Test removed in CR1489
sl@0
   216
			break;
sl@0
   217
		default:
sl@0
   218
			User::Panic(KT_BasicStepPanicTxt, KErrNotFound);  //Unexpected value!
sl@0
   219
		}
sl@0
   220
sl@0
   221
	__UHEAP_MARKEND;
sl@0
   222
	return TestStepResult();
sl@0
   223
	}
sl@0
   224
sl@0
   225
//Test setting a surface as the background of a window
sl@0
   226
void CT_WServIntegStepBasic::Graphics_Wserv_Gce_1L(RWindow& aWin)
sl@0
   227
	{
sl@0
   228
	CreateSurfaceL(iSurfaceId);
sl@0
   229
	CreateRWindowL(aWin);
sl@0
   230
	TEST(KErrNone==aWin.SetBackgroundSurface(iSurfaceId));
sl@0
   231
	ForceWindowToRedraw(aWin);
sl@0
   232
	DestroySurface();
sl@0
   233
	aWin.Close();
sl@0
   234
	}
sl@0
   235
//Test setting a surface as the background of a RBlankWindow
sl@0
   236
void CT_WServIntegStepBasic::Graphics_Wserv_Gce_2L(RBlankWindow& aBlankWin)
sl@0
   237
	{
sl@0
   238
	CreateSurfaceL(iSurfaceId);
sl@0
   239
	CreateRBlankWindowL(aBlankWin);
sl@0
   240
	TEST(KErrNone==aBlankWin.SetBackgroundSurface(iSurfaceId));
sl@0
   241
	ForceWindowToRedraw(aBlankWin);
sl@0
   242
	DestroySurface();
sl@0
   243
	aBlankWin.Close();
sl@0
   244
	}
sl@0
   245
sl@0
   246
//Negative test for setting a surface as the background of a RBackedUpWindow
sl@0
   247
void CT_WServIntegStepBasic::Graphics_Wserv_Gce_3L()
sl@0
   248
	{
sl@0
   249
	CreateSurfaceL(iSurfaceId);
sl@0
   250
	RBackedUpWindow backedUpWindow( iWsSession );
sl@0
   251
	CleanupClosePushL( backedUpWindow );
sl@0
   252
	User::LeaveIfError( backedUpWindow.Construct( iWinGroup, EColor16MA, ENullWsHandle) );
sl@0
   253
	backedUpWindow.SetSizeErr( iScreen->SizeInPixels() );
sl@0
   254
	backedUpWindow.SetVisible( ETrue );
sl@0
   255
	backedUpWindow.Activate();
sl@0
   256
	iWsSession.Flush();
sl@0
   257
	User::After(delay);
sl@0
   258
	// Expect a panic here - TClientPanic::EWservPanicDrawable
sl@0
   259
	backedUpWindow.SetBackgroundSurface( iSurfaceId );
sl@0
   260
	DestroySurface();
sl@0
   261
	CleanupStack::PopAndDestroy( &backedUpWindow );
sl@0
   262
	}
sl@0
   263
sl@0
   264
//Test for moving a window with its background set
sl@0
   265
void CT_WServIntegStepBasic::Graphics_Wserv_Gce_4L(RWindow& aWin)
sl@0
   266
	{
sl@0
   267
	// Create window and assign a surface to it
sl@0
   268
	ASSERT_EQUALS( EPass, SetSurfaceL(aWin,iSurfaceId));
sl@0
   269
	TSize scrSize(iScreen->SizeInPixels());
sl@0
   270
	// move the window around
sl@0
   271
	aWin.SetPosition( TPoint( (scrSize.iWidth)-KTempWindowWidth, 0) );
sl@0
   272
	iWsSession.Flush();
sl@0
   273
	User::After(delay);
sl@0
   274
	aWin.SetPosition( TPoint(aWin.Position().iX, (scrSize.iHeight)-KTempWindowHeight ));
sl@0
   275
	iWsSession.Flush();
sl@0
   276
	User::After(delay);
sl@0
   277
	aWin.SetPosition( TPoint(0, (scrSize.iHeight)-KTempWindowHeight) );
sl@0
   278
	iWsSession.Flush();
sl@0
   279
	User::After(delay);
sl@0
   280
	aWin.SetPosition(TPoint(0,0));
sl@0
   281
	iWsSession.Flush();
sl@0
   282
	User::After(delay);
sl@0
   283
	DestroySurface();
sl@0
   284
	aWin.Close();
sl@0
   285
		}
sl@0
   286
sl@0
   287
//Test moving a window with its background set partially and wholly offscreen
sl@0
   288
void CT_WServIntegStepBasic::Graphics_Wserv_Gce_5L(RWindow& aWin)
sl@0
   289
	{
sl@0
   290
	ASSERT_EQUALS( EPass, SetSurfaceL(aWin,iSurfaceId));
sl@0
   291
	TSize screenSize(iScreen->SizeInPixels());
sl@0
   292
	// partially off screen
sl@0
   293
	TUint xCord=(screenSize.iWidth-KTempWindowWidth)+(KTempWindowWidth/2);
sl@0
   294
	TUint yCord=(screenSize.iHeight-KTempWindowHeight)+(KTempWindowHeight/2);
sl@0
   295
	aWin.SetPosition(TPoint(xCord,yCord));
sl@0
   296
	iWsSession.Flush();
sl@0
   297
	User::After(delay);
sl@0
   298
	// wholly off screen
sl@0
   299
	aWin.SetPosition( TPoint(screenSize.iWidth, screenSize.iHeight) );
sl@0
   300
	iWsSession.Flush();
sl@0
   301
	User::After(delay);
sl@0
   302
	DestroySurface();
sl@0
   303
	aWin.Close();
sl@0
   304
	}
sl@0
   305
sl@0
   306
//Test resizing a window with its background set to a surface
sl@0
   307
void CT_WServIntegStepBasic::Graphics_Wserv_Gce_6L(RWindow& aWin)
sl@0
   308
	{
sl@0
   309
	ASSERT_EQUALS( EPass, SetSurfaceL(aWin,iSurfaceId));
sl@0
   310
	TSize sz(aWin.Size());
sl@0
   311
	aWin.SetSize( sz+TPoint(20,0) );
sl@0
   312
	iWsSession.Flush();
sl@0
   313
	User::After( delay );
sl@0
   314
	aWin.SetSize( sz+TPoint(0,20) );
sl@0
   315
	iWsSession.Flush();
sl@0
   316
	User::After( delay );
sl@0
   317
	aWin.SetSize( sz+TPoint(20,20) );
sl@0
   318
	iWsSession.Flush();
sl@0
   319
	User::After( delay );
sl@0
   320
	aWin.SetSize( TSize(KSurfaceWidth, KSurfaceHeight ) );
sl@0
   321
	iWsSession.Flush();
sl@0
   322
	User::After( delay );
sl@0
   323
  	DestroySurface();
sl@0
   324
	aWin.Close();
sl@0
   325
	}
sl@0
   326
sl@0
   327
sl@0
   328
// Test Opaque drawing in front of a background surface
sl@0
   329
void CT_WServIntegStepBasic::Graphics_Wserv_Gce_11L(RWindow& aWin)
sl@0
   330
	{
sl@0
   331
	ASSERT_EQUALS( EPass, SetSurfaceL(aWin,iSurfaceId));
sl@0
   332
	// Opaque drawing on bkgd surface
sl@0
   333
	DrawShape( aWin, 0x0000FF00 );
sl@0
   334
	DestroySurface();
sl@0
   335
	aWin.Close();
sl@0
   336
	}
sl@0
   337
sl@0
   338
//Test Semi-transparent drawing in front of a background surface
sl@0
   339
void CT_WServIntegStepBasic::Graphics_Wserv_Gce_13L(RWindow& aWin)
sl@0
   340
	{
sl@0
   341
	ASSERT_EQUALS( EPass, SetSurfaceL(aWin,iSurfaceId));
sl@0
   342
	// semi Transp on bkgd surface
sl@0
   343
	DrawShape( aWin, 0x8000FF00 );
sl@0
   344
	DestroySurface();
sl@0
   345
	aWin.Close();
sl@0
   346
	}
sl@0
   347
sl@0
   348
//Test that an opaque window can be put in front of an Rwindow with background surface
sl@0
   349
void CT_WServIntegStepBasic::Graphics_Wserv_Gce_15L(RWindow& aWin)
sl@0
   350
	{
sl@0
   351
	ASSERT_EQUALS( EPass, SetSurfaceL(aWin,iSurfaceId));
sl@0
   352
	CleanupClosePushL(aWin);
sl@0
   353
	// draw 2nd window partially over the first one
sl@0
   354
	RWindow win2;
sl@0
   355
	CreateRWindowL(win2, TPoint(10,10), KRgbGreen );
sl@0
   356
	DestroySurface();
sl@0
   357
	CleanupStack::PopAndDestroy(&aWin);
sl@0
   358
	win2.Close();
sl@0
   359
	aWin.Close();
sl@0
   360
	}
sl@0
   361
sl@0
   362
//Test that a semi-transparent window can be put in front of a Rwindow with surface
sl@0
   363
void CT_WServIntegStepBasic::Graphics_Wserv_Gce_17L(RWindow& aWin)
sl@0
   364
	{
sl@0
   365
	ASSERT_EQUALS( EPass, SetSurfaceL(aWin,iSurfaceId));
sl@0
   366
	CleanupClosePushL(aWin);
sl@0
   367
	// draw semi Transp win partially over first win with surface
sl@0
   368
	RWindow win2;
sl@0
   369
	CreateRWindowL(win2, TPoint(10,10));
sl@0
   370
	INFO_PRINTF1(_L("Destroy Surface"));
sl@0
   371
	DestroySurface();
sl@0
   372
	CleanupStack::PopAndDestroy(&aWin);
sl@0
   373
	win2.Close();
sl@0
   374
	aWin.Close();
sl@0
   375
	}
sl@0
   376
sl@0
   377
//Test updating a background surface
sl@0
   378
void CT_WServIntegStepBasic::Graphics_Wserv_Gce_19L(RWindow& aWin)
sl@0
   379
	{
sl@0
   380
	ASSERT_EQUALS( EPass, SetSurfaceL(aWin,iSurfaceId));
sl@0
   381
	CleanupClosePushL(aWin);
sl@0
   382
	// create a 2nd surface
sl@0
   383
	TSurfaceId surfaceId2;
sl@0
   384
	CreateSurfaceL(surfaceId2, 0x0000FF00);
sl@0
   385
	ASSERT_EQUALS( KErrNone, aWin.SetBackgroundSurface(surfaceId2) );
sl@0
   386
	ForceWindowToRedraw(aWin);
sl@0
   387
	TInt ret = iSurfaceManager.CloseSurface(surfaceId2);
sl@0
   388
	if(ret!=KErrNone)
sl@0
   389
		{
sl@0
   390
		INFO_PRINTF1(_L("Surface manager failed to close surface"));
sl@0
   391
		}
sl@0
   392
	// destroys iSurfaceId plus closes iSurfaceUpdateSession,iChunk,iSurfaceManager
sl@0
   393
	DestroySurface();
sl@0
   394
	CleanupStack::PopAndDestroy(&aWin);
sl@0
   395
	}
sl@0
   396
sl@0
   397
//Test shape of a window is applied to window a surface
sl@0
   398
void CT_WServIntegStepBasic::Graphics_Wserv_Gce_21L(RWindow& aWin)
sl@0
   399
	{
sl@0
   400
	ASSERT_EQUALS( EPass, SetSurfaceL(aWin,iSurfaceId));
sl@0
   401
	TRect rc[2] = { TRect(0,0,100,200),TRect(100,120,200,200) };
sl@0
   402
	RRegion region(2, rc);
sl@0
   403
	aWin.SetShape( region );
sl@0
   404
	User::After(delay);	// For DEBUG
sl@0
   405
	DestroySurface();
sl@0
   406
	aWin.Close();
sl@0
   407
	}
sl@0
   408
sl@0
   409
//Test that a valid key color is returned when a surface
sl@0
   410
//has been set as the background of a window
sl@0
   411
void CT_WServIntegStepBasic::Graphics_Wserv_Gce_22L(RWindow& aWin)
sl@0
   412
	{
sl@0
   413
	ASSERT_EQUALS( EPass, SetSurfaceL(aWin,iSurfaceId));
sl@0
   414
	TRgb colValue(aWin.KeyColor());
sl@0
   415
	if ( aWin.DisplayMode()==EColor16MA || aWin.DisplayMode()==EColor16MAP )
sl@0
   416
		{
sl@0
   417
		TEST(aWin.KeyColor().Internal()==0x00000000);
sl@0
   418
		}
sl@0
   419
	else
sl@0
   420
		{
sl@0
   421
		TEST(aWin.KeyColor().Alpha()==0xFF);
sl@0
   422
		}
sl@0
   423
	aWin.Close();
sl@0
   424
	}
sl@0
   425
sl@0
   426
//Test that the use of SetColor() i.e. with no parameters removes
sl@0
   427
//any surface assigned to the window
sl@0
   428
void CT_WServIntegStepBasic::Graphics_Wserv_Gce_31L(RBlankWindow& aBlankWin)
sl@0
   429
	{
sl@0
   430
	CreateSurfaceL(iSurfaceId);
sl@0
   431
	CreateRBlankWindowL(aBlankWin);
sl@0
   432
	ASSERT_EQUALS(KErrNone, aBlankWin.SetBackgroundSurface(iSurfaceId));
sl@0
   433
	ForceWindowToRedraw(aBlankWin);
sl@0
   434
	aBlankWin.SetColor();
sl@0
   435
	ForceWindowToRedraw(aBlankWin);
sl@0
   436
	DestroySurface();
sl@0
   437
	aBlankWin.Close();
sl@0
   438
	}
sl@0
   439
sl@0
   440
//Test that the shaped window maintains the surface when moved
sl@0
   441
void CT_WServIntegStepBasic::Graphics_Wserv_Gce_32L(RWindow& aWin)
sl@0
   442
	{
sl@0
   443
	ASSERT_EQUALS( EPass, SetSurfaceL(aWin,iSurfaceId));
sl@0
   444
	TRect rc[2] = { TRect(0,0,100,200),TRect(100,120,200,200) };
sl@0
   445
	RRegion region(2, rc);
sl@0
   446
	aWin.SetShape( region );
sl@0
   447
	User::After(delay);
sl@0
   448
	aWin.SetPosition( TPoint( aWin.Position().iX+10, aWin.Position().iY+10 ) );
sl@0
   449
	iWsSession.Flush();
sl@0
   450
	User::After(delay);
sl@0
   451
	DestroySurface();
sl@0
   452
	aWin.Close();
sl@0
   453
	}
sl@0
   454
sl@0
   455
//Test that window and surface scale to the new size when a shaped
sl@0
   456
//window with surface is resized
sl@0
   457
void CT_WServIntegStepBasic::Graphics_Wserv_Gce_33L(RWindow& aWin)
sl@0
   458
	{
sl@0
   459
	ASSERT_EQUALS( EPass, SetSurfaceL(aWin,iSurfaceId));
sl@0
   460
	TRect rc[2] = { TRect(0,0,100,200),TRect(100,120,200,200) };
sl@0
   461
	RRegion region(2, rc);
sl@0
   462
	aWin.SetShape( region );
sl@0
   463
	User::After(delay);
sl@0
   464
	aWin.SetSize( TSize(200,150) );
sl@0
   465
	iWsSession.Flush();
sl@0
   466
	User::After(delay);
sl@0
   467
	DestroySurface();
sl@0
   468
	aWin.Close();
sl@0
   469
	}
sl@0
   470
sl@0
   471
//Test that the background surface blends with the semi transparent window
sl@0
   472
void CT_WServIntegStepBasic::Graphics_Wserv_Gce_34L(RWindow& aWin)
sl@0
   473
	{
sl@0
   474
	ASSERT_EQUALS( EPass, SetSurfaceL(aWin,iSurfaceId));
sl@0
   475
	CleanupClosePushL(aWin);
sl@0
   476
	ForceWindowToRedraw(aWin);
sl@0
   477
	RWindow win2;
sl@0
   478
	CreateRWindowL(win2,TPoint(10,0), 0x80A9B9C9);
sl@0
   479
	// draw semi Transp on window bkgd
sl@0
   480
	DrawShape( win2, 0x8000FF00 );
sl@0
   481
	DestroySurface();
sl@0
   482
	CleanupStack::PopAndDestroy(&aWin);
sl@0
   483
	win2.Close();
sl@0
   484
	aWin.Close();
sl@0
   485
	}
sl@0
   486
sl@0
   487
// Test that the corner style is applied to the window with surface
sl@0
   488
void CT_WServIntegStepBasic::Graphics_Wserv_Gce_35L(RWindow& aWin)
sl@0
   489
	{
sl@0
   490
	ASSERT_EQUALS( EPass, SetSurfaceL(aWin,iSurfaceId));
sl@0
   491
	aWin.SetCornerType( EWindowCorner5 );
sl@0
   492
	User::After(delay);
sl@0
   493
	DestroySurface();
sl@0
   494
	aWin.Close();
sl@0
   495
	}
sl@0
   496
sl@0
   497
/***
sl@0
   498
Test that shaped windows with background surfaces arranged such that
sl@0
   499
the back window overlaps the front's bounding box, but not its shaped
sl@0
   500
region (e.g. the front is L-shaped and the back overlaps the area within
sl@0
   501
the 'L'). In this situation, the back window's surface should be visible
sl@0
   502
in the overlap area
sl@0
   503
*/
sl@0
   504
void CT_WServIntegStepBasic::Graphics_Wserv_Gce_36L(RWindow& aWin)
sl@0
   505
	{
sl@0
   506
	ASSERT_EQUALS( EPass, SetSurfaceL(aWin,iSurfaceId));
sl@0
   507
	CleanupClosePushL(aWin);
sl@0
   508
	TRect rc1[2] = { TRect(110,20,150,80),TRect(150,60,200,100) };
sl@0
   509
	RRegion region1(2, rc1);
sl@0
   510
	aWin.SetShape( region1 );
sl@0
   511
	User::After(delay);
sl@0
   512
sl@0
   513
	// create a 2nd surface
sl@0
   514
	TSurfaceId surfaceId2;
sl@0
   515
	CreateSurfaceL(surfaceId2,0x00ABCDEF);
sl@0
   516
	RWindow win2;
sl@0
   517
	CreateRWindowL(win2);
sl@0
   518
	ASSERT_EQUALS( KErrNone, win2.SetBackgroundSurface(surfaceId2));
sl@0
   519
	User::After(delay);
sl@0
   520
	TRect rc2[2] = { TRect(0,0,100,200),TRect(100,120,200,200) };
sl@0
   521
	RRegion region2(2, rc2);
sl@0
   522
	win2.SetShape( region2 );
sl@0
   523
	User::After(delay);
sl@0
   524
sl@0
   525
	TInt ret = iSurfaceManager.CloseSurface(surfaceId2);
sl@0
   526
	if(ret!=KErrNone)
sl@0
   527
		{
sl@0
   528
		INFO_PRINTF1(_L("Surface manager failed to close surface"));
sl@0
   529
		}
sl@0
   530
	// destroys iSurfaceId plus closes iSurfaceUpdateSession,iChunk,iSurfaceManager
sl@0
   531
	DestroySurface();
sl@0
   532
	CleanupStack::PopAndDestroy(&aWin);
sl@0
   533
	win2.Close();
sl@0
   534
	aWin.Close();
sl@0
   535
	}
sl@0
   536
sl@0
   537
sl@0
   538
/**
sl@0
   539
Creates a RWindow
sl@0
   540
sl@0
   541
@param aWin	The window object
sl@0
   542
@param aPos	The Position of the window
sl@0
   543
@param aBkgdColor The background color of the window
sl@0
   544
@param aSize The size of the window
sl@0
   545
*/
sl@0
   546
void CT_WServIntegStepBasic::CreateRWindowL(RWindow& aWin, const TPoint& aPos, const TRgb& aBkgdColor, const TSize& aWinSize)
sl@0
   547
	{
sl@0
   548
	aWin = RWindow( iWsSession );
sl@0
   549
	CleanupClosePushL( aWin );
sl@0
   550
	User::LeaveIfError( aWin.Construct( iWinGroup, ENullWsHandle ) );
sl@0
   551
	CleanupStack::Pop(&aWin);
sl@0
   552
	aWin.SetExtent(aPos, aWinSize);
sl@0
   553
	aWin.SetBackgroundColor( aBkgdColor );
sl@0
   554
	aWin.Activate();
sl@0
   555
	aWin.BeginRedraw();
sl@0
   556
	aWin.EndRedraw();
sl@0
   557
	aWin.SetVisible( ETrue );
sl@0
   558
	iWsSession.Flush();
sl@0
   559
	User::After(delay);
sl@0
   560
	}
sl@0
   561
sl@0
   562
/**
sl@0
   563
Creates a RBlankWindow
sl@0
   564
sl@0
   565
@param aBlankWin The window object
sl@0
   566
*/
sl@0
   567
void CT_WServIntegStepBasic::CreateRBlankWindowL(RBlankWindow& aBlankWin)
sl@0
   568
	{
sl@0
   569
	aBlankWin = RBlankWindow(iWsSession);
sl@0
   570
	CleanupClosePushL(aBlankWin);
sl@0
   571
	User::LeaveIfError(aBlankWin.Construct(iWinGroup, ENullWsHandle) );
sl@0
   572
	TSize sz( KTempWindowWidth, KTempWindowHeight );
sl@0
   573
	aBlankWin.SetSize(sz);
sl@0
   574
	aBlankWin.SetColor(TRgb(0x800000FF));	// 0xAABBGGRR
sl@0
   575
	aBlankWin.Activate();
sl@0
   576
	CleanupStack::Pop(&aBlankWin);
sl@0
   577
	iWsSession.Flush();
sl@0
   578
	User::After(delay);
sl@0
   579
	}
sl@0
   580
sl@0
   581
void CT_WServIntegStepBasic::ForceWindowToRedraw(RWindowBase& aWin)
sl@0
   582
	{
sl@0
   583
	aWin.SetVisible( EFalse );
sl@0
   584
	iWsSession.Flush();
sl@0
   585
	aWin.SetVisible( ETrue );
sl@0
   586
	iWsSession.Flush();
sl@0
   587
	User::After(delay);
sl@0
   588
	}
sl@0
   589
sl@0
   590
void CT_WServIntegStepBasic::CreateSurfaceManager()
sl@0
   591
	{
sl@0
   592
	INFO_PRINTF1(_L("Loading the device driver"));
sl@0
   593
	TInt ret = iSurfaceManager.Open();
sl@0
   594
	if(ret==KErrNone)
sl@0
   595
		{
sl@0
   596
		INFO_PRINTF1(_L("Creating surface manager OK"));
sl@0
   597
		}
sl@0
   598
	}
sl@0
   599
sl@0
   600
/**
sl@0
   601
Set up code for creating a surface and fill it with a color
sl@0
   602
sl@0
   603
@param aSurfaceId The surface object, to be initialized.
sl@0
   604
@param aColorPattern The color to fill the surface with.
sl@0
   605
*/
sl@0
   606
void CT_WServIntegStepBasic::CreateSurfaceL(TSurfaceId& aSurfaceId, TUint aColorPattern)
sl@0
   607
	{
sl@0
   608
	INFO_PRINTF1(_L("Creating a surface manager"));
sl@0
   609
	CreateSurfaceManager();
sl@0
   610
sl@0
   611
	INFO_PRINTF1(_L("Setting up surface attributes"));
sl@0
   612
	RSurfaceManager::TSurfaceCreationAttributesBuf attribs;
sl@0
   613
	RSurfaceManager::TSurfaceCreationAttributes& surfaceCreationAtribs=attribs();
sl@0
   614
sl@0
   615
	surfaceCreationAtribs.iSize.iWidth = KSurfaceWidth;
sl@0
   616
	surfaceCreationAtribs.iSize.iHeight = KSurfaceHeight;
sl@0
   617
	surfaceCreationAtribs.iBuffers = 1;
sl@0
   618
	surfaceCreationAtribs.iPixelFormat = KSurfaceFormat;
sl@0
   619
	surfaceCreationAtribs.iStride = KBytesPerPixel*KSurfaceWidth;
sl@0
   620
	surfaceCreationAtribs.iOffsetToFirstBuffer = 0;
sl@0
   621
	surfaceCreationAtribs.iAlignment = 4;
sl@0
   622
	surfaceCreationAtribs.iContiguous = EFalse;
sl@0
   623
	surfaceCreationAtribs.iMappable = ETrue;
sl@0
   624
	INFO_PRINTF1(_L("Call to CreateSurfaceL()"));
sl@0
   625
	TInt err = iSurfaceManager.CreateSurface(attribs, aSurfaceId);
sl@0
   626
	if (err == KErrNone)
sl@0
   627
		{
sl@0
   628
		//we have a surface, so map it in
sl@0
   629
		INFO_PRINTF1(_L("Surface created ok, mapping to it"));
sl@0
   630
		TInt err = iSurfaceManager.MapSurface(aSurfaceId, iChunk);
sl@0
   631
		User::LeaveIfError(err);
sl@0
   632
		TUint32* surfacePtr = reinterpret_cast<TUint32*>(iChunk.Base());
sl@0
   633
		TUint32* linePtr = surfacePtr;
sl@0
   634
sl@0
   635
		// Fill first line
sl@0
   636
		for (TInt xx = 0; xx < KSurfaceWidth; xx++)
sl@0
   637
			{
sl@0
   638
			surfacePtr[xx] = aColorPattern;
sl@0
   639
			}
sl@0
   640
sl@0
   641
		// Now copy that to the other lines
sl@0
   642
		TInt stride = KBytesPerPixel * KSurfaceWidth;
sl@0
   643
		for (TInt yy = 1; yy < KSurfaceHeight; yy++)
sl@0
   644
			{
sl@0
   645
			linePtr += KSurfaceWidth;
sl@0
   646
			Mem::Move(linePtr, surfacePtr, stride);
sl@0
   647
			}
sl@0
   648
		}
sl@0
   649
sl@0
   650
	INFO_PRINTF1(_L("Create Surface update session"));
sl@0
   651
	CreateSurfaceUpdateSessionL();
sl@0
   652
	err = iSurfaceUpdateSession.SubmitUpdate(KAllScreens, aSurfaceId, 0, NULL);
sl@0
   653
	if (err!=KErrNone)
sl@0
   654
		{
sl@0
   655
	   INFO_PRINTF1(_L("Fail in submitting update"));
sl@0
   656
		}
sl@0
   657
	}
sl@0
   658
sl@0
   659
void CT_WServIntegStepBasic::CreateSurfaceUpdateSessionL()
sl@0
   660
	{
sl@0
   661
	TInt ret = iSurfaceUpdateSession.Connect();
sl@0
   662
sl@0
   663
	if (ret==KErrAlreadyExists)
sl@0
   664
		{
sl@0
   665
		INFO_PRINTF1(_L("Device driver already loaded"));
sl@0
   666
		}
sl@0
   667
	else if (ret==KErrNone)
sl@0
   668
		{
sl@0
   669
		INFO_PRINTF1(_L("Connected to surface update server"));
sl@0
   670
		}
sl@0
   671
	else
sl@0
   672
		{
sl@0
   673
		INFO_PRINTF1(_L("Fatal error connecting to surface update server"));
sl@0
   674
		User::LeaveIfError(ret);
sl@0
   675
		}
sl@0
   676
	}
sl@0
   677
sl@0
   678
void CT_WServIntegStepBasic::DestroySurface()
sl@0
   679
	{
sl@0
   680
	INFO_PRINTF1(_L("Destroy Surface update session"));
sl@0
   681
	iSurfaceUpdateSession.Close();
sl@0
   682
sl@0
   683
	//close the chunk
sl@0
   684
	INFO_PRINTF1(_L("Closing chunk"));
sl@0
   685
	iChunk.Close();
sl@0
   686
sl@0
   687
	INFO_PRINTF1(_L("Closing surface"));
sl@0
   688
	TInt ret = iSurfaceManager.CloseSurface(iSurfaceId);
sl@0
   689
	if(ret!=KErrNone)
sl@0
   690
		{
sl@0
   691
		INFO_PRINTF1(_L("Surface manager failed to close"));
sl@0
   692
		}
sl@0
   693
sl@0
   694
	INFO_PRINTF1(_L("Destroy Surface Manager"));
sl@0
   695
	iSurfaceManager.Close();
sl@0
   696
	}
sl@0
   697
sl@0
   698
/**
sl@0
   699
Common set up code for assigning a surface to the window. Calls other utility
sl@0
   700
functions for creating a window and a surface
sl@0
   701
sl@0
   702
@param aWin	The window object
sl@0
   703
@param aSurfaceId	The surface object, to be initialized.
sl@0
   704
*/
sl@0
   705
TVerdict CT_WServIntegStepBasic::SetSurfaceL(RWindow& aWin, TSurfaceId& aSurfaceId)
sl@0
   706
	{
sl@0
   707
	TVerdict verdict=EPass;
sl@0
   708
	CreateRWindowL(aWin);
sl@0
   709
	CleanupClosePushL(aWin);
sl@0
   710
	CreateSurfaceL( aSurfaceId );
sl@0
   711
	CleanupStack::Pop(&aWin);
sl@0
   712
	if ( aWin.SetBackgroundSurface(aSurfaceId)!=KErrNone)
sl@0
   713
		{
sl@0
   714
		verdict=EFail;
sl@0
   715
		}
sl@0
   716
	iWsSession.Flush();
sl@0
   717
	ForceWindowToRedraw(aWin);
sl@0
   718
	return verdict;
sl@0
   719
	}
sl@0
   720
sl@0
   721
/**
sl@0
   722
Draw an Ellipse shape
sl@0
   723
sl@0
   724
@param aWin	The window object, connected to a session
sl@0
   725
@param aColor The (transparent/opaque)color which the shape is filled with
sl@0
   726
*/
sl@0
   727
void CT_WServIntegStepBasic::DrawShape(RWindow& aWin, const TRgb& aColor)
sl@0
   728
	{
sl@0
   729
   	iGc->Activate( aWin );
sl@0
   730
   	iGc->SetBrushColor( aColor );
sl@0
   731
   	iGc->SetBrushStyle( CGraphicsContext::ESolidBrush );
sl@0
   732
   	TRect rect(TPoint(0,0), TPoint(aWin.Size().iWidth, aWin.Size().iHeight));
sl@0
   733
   	iGc->DrawEllipse(rect);
sl@0
   734
   	iWsSession.Flush();
sl@0
   735
   	User::After(delay);
sl@0
   736
   	iGc->Deactivate();
sl@0
   737
	}
sl@0
   738