os/graphics/windowing/windowserver/test/tauto/talphawin.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 1996-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
// Test alpha channel transparent windows
sl@0
    15
// Test that draw operations with non-opaque colours do alpha blending in EColor64K and EColor16MA display modes
sl@0
    16
// Test that alpha channel transparent windows are drawn correctly when windows move, redraw, change visibility, etc.
sl@0
    17
// In the draw operation tests, the left window draws opaque pink on white background, the right window blends semi-transparent red on white background,
sl@0
    18
// and the results are compared.
sl@0
    19
// In the transparent window tests, the right window contains several transparent windows, which are moved, redrawn, visibility changed, etc,
sl@0
    20
// the left window contains a single window in which we draw what we expect the right window to look like. The results are compared.
sl@0
    21
// In each case, the left and right windows should be identical
sl@0
    22
// 
sl@0
    23
//
sl@0
    24
sl@0
    25
sl@0
    26
#include "TALPHAWIN.H"
sl@0
    27
sl@0
    28
enum
sl@0
    29
	{
sl@0
    30
	EOpDrawRect,
sl@0
    31
	EOpDrawLine,
sl@0
    32
	EOpDrawEllipse,
sl@0
    33
	EOpDrawText,
sl@0
    34
	EOpDrawTextVertical,
sl@0
    35
	EOpDrawTextAntiAliased,
sl@0
    36
	EOpBitBlt,
sl@0
    37
	EOpBitBltMasked,
sl@0
    38
	ENumDrawOps
sl@0
    39
	};
sl@0
    40
sl@0
    41
sl@0
    42
enum
sl@0
    43
	{
sl@0
    44
	ERed = 0x1,
sl@0
    45
	EGreen = 0x2,
sl@0
    46
	EBlue = 0x4,
sl@0
    47
sl@0
    48
	EAlphaTransparency = 0x8,
sl@0
    49
	ETransparencyFactor = 0x10,
sl@0
    50
	// defaults to non-transparent
sl@0
    51
sl@0
    52
	EOpaque = 0x20,
sl@0
    53
	ETransparent = 0x40,
sl@0
    54
	// defaults to semi-transparent
sl@0
    55
sl@0
    56
	EModeColor64K = 0x80,
sl@0
    57
	EModeColor16MA = 0x100,
sl@0
    58
	// defaults to 64k
sl@0
    59
sl@0
    60
	EInvisible = 0x200,
sl@0
    61
sl@0
    62
	EActive = 0xf000000
sl@0
    63
	};
sl@0
    64
sl@0
    65
sl@0
    66
TRgb ColourFromDrawState(TInt aDrawState)
sl@0
    67
	{
sl@0
    68
	TInt red = (aDrawState & ERed) ? 255 : 0;
sl@0
    69
	TInt green = (aDrawState & EGreen) ? 255 : 0;
sl@0
    70
	TInt blue = (aDrawState & EBlue) ? 255 : 0;
sl@0
    71
	TInt alpha = 128;
sl@0
    72
	if (aDrawState & EOpaque)
sl@0
    73
		alpha = 255;
sl@0
    74
	if (aDrawState & ETransparent)
sl@0
    75
		alpha = 0;
sl@0
    76
	return TRgb(red, green, blue, alpha);
sl@0
    77
	}
sl@0
    78
sl@0
    79
sl@0
    80
sl@0
    81
//
sl@0
    82
// CTAlphaWinTest
sl@0
    83
//
sl@0
    84
sl@0
    85
CTAlphaWin::CTAlphaWin(CTestStep* aStep):
sl@0
    86
	CTWsGraphicsBase(aStep)
sl@0
    87
	{
sl@0
    88
	}
sl@0
    89
sl@0
    90
CTAlphaWin::~CTAlphaWin()
sl@0
    91
	{
sl@0
    92
	iTestWin.DeleteAll();
sl@0
    93
	delete iRefWin;
sl@0
    94
	}
sl@0
    95
sl@0
    96
void CTAlphaWin::ConstructL()
sl@0
    97
	{
sl@0
    98
	if(TransparencySupportedL() == KErrNotSupported)
sl@0
    99
			return;
sl@0
   100
sl@0
   101
	TSize winSize = BaseWin->Size();
sl@0
   102
sl@0
   103
	iTestWin[0] = CTAlphaWindow::NewL(this, TestWin, TPoint(0,0), winSize, ERed | EGreen | EBlue | EOpaque);
sl@0
   104
	iTestWin[1] = CTAlphaWindow::NewL(this, TestWin, TPoint(0,0), TSize(winSize.iWidth/2, winSize.iHeight/2), ERed | EAlphaTransparency);
sl@0
   105
	iTestWin[2] = CTAlphaWindow::NewL(this, TestWin, TPoint(winSize.iWidth/3,0), TSize(winSize.iWidth/2, winSize.iHeight/2), EGreen | EAlphaTransparency);
sl@0
   106
	iTestWin[3] = CTAlphaWindow::NewL(this, TestWin, TPoint(winSize.iWidth/6, winSize.iHeight/3), TSize(winSize.iWidth/2, winSize.iHeight/2), EBlue | EAlphaTransparency);
sl@0
   107
	iTestWin[4] = CTAlphaWindow::NewL(this, TestWin, TPoint(winSize.iWidth/4,winSize.iHeight/6), TSize(winSize.iWidth/3,winSize.iHeight/3), ERed | EGreen | EBlue | EAlphaTransparency | ETransparent);
sl@0
   108
sl@0
   109
	iRefWin = CTAlphaRefWin::NewL(BaseWin, TPoint(0,0), winSize, iTestWin);
sl@0
   110
	//Clearing the windows
sl@0
   111
	BaseWin->ClearWin();
sl@0
   112
	TestWin->ClearWin();
sl@0
   113
	}
sl@0
   114
sl@0
   115
void CTAlphaWin::ConfigureDisplayModes(TDisplayMode aRequiredMode = EColor16M)
sl@0
   116
	{
sl@0
   117
	TInt i;
sl@0
   118
	for (i=0; i<5; i++)
sl@0
   119
		{
sl@0
   120
		iTestWin[i]->BaseWin()->SetRequiredDisplayMode(aRequiredMode);
sl@0
   121
		}
sl@0
   122
	iRefWin->BaseWin()->SetRequiredDisplayMode(aRequiredMode);
sl@0
   123
	}
sl@0
   124
sl@0
   125
sl@0
   126
void CTAlphaWin::TestSemiTransparentDrawingL()
sl@0
   127
	{
sl@0
   128
	TSize winSize = BaseWin->Size();
sl@0
   129
sl@0
   130
	// In this window, we draw opaque pink
sl@0
   131
	CTDrawOpWin* drawWin = CTDrawOpWin::NewL(this, BaseWin, TPoint(0,0), winSize, TRgb(255,127,127,255));
sl@0
   132
sl@0
   133
	// In this window, we blend semi-transparent red
sl@0
   134
	CTDrawOpWin* blendWin = CTDrawOpWin::NewL(this, TestWin, TPoint(0,0), winSize, TRgb(255,0,0,128));
sl@0
   135
sl@0
   136
	const TInt tolerance = 9;//8 - wouldn't be enough!! The defect 	DEF112334 was raised
sl@0
   137
	for (TInt i=EOpDrawRect; i<ENumDrawOps; i++)
sl@0
   138
		{
sl@0
   139
		
sl@0
   140
	//	User::After(1000000);// helpful when debugging
sl@0
   141
		drawWin->SetDrawOp(i);
sl@0
   142
		blendWin->SetDrawOp(i);
sl@0
   143
		drawWin->DrawNow();
sl@0
   144
		blendWin->DrawNow();
sl@0
   145
		TheClient->Flush();
sl@0
   146
		TheClient->WaitForRedrawsToFinish();
sl@0
   147
sl@0
   148
		if((i == EOpDrawTextAntiAliased) && (TheClient->iScreen->DisplayMode() == EColor16MA) || (TheClient->iScreen->DisplayMode() == EColor16MAP))
sl@0
   149
			{		
sl@0
   150
			TSize winSize=BaseWin->Size();
sl@0
   151
			TRect rect1(BaseWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),winSize);
sl@0
   152
			TRect rect2(TestWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),winSize);
sl@0
   153
sl@0
   154
			CheckRectL(rect1, rect2, winSize, TheClient->iScreen->DisplayMode(), tolerance, _L("CTAlphaWin::TestSemiTransparentDrawingL()"));
sl@0
   155
			}
sl@0
   156
		else
sl@0
   157
			{
sl@0
   158
			CheckRect(BaseWin,TestWin,_L("CTAlphaWin::TestSemiTransparentDrawingL()"));
sl@0
   159
			}	
sl@0
   160
		}
sl@0
   161
	delete drawWin;
sl@0
   162
	delete blendWin;
sl@0
   163
	}
sl@0
   164
sl@0
   165
void CTAlphaWin::TestTransparentDrawingL()
sl@0
   166
	{
sl@0
   167
	TSize winSize = BaseWin->Size();
sl@0
   168
sl@0
   169
	// In this window, we draw opaque white
sl@0
   170
	CTDrawOpWin* drawWin = CTDrawOpWin::NewL(this, BaseWin, TPoint(0,0), winSize, TRgb(255,255,255,255));
sl@0
   171
sl@0
   172
	// In this window, we blend transparent red
sl@0
   173
	CTDrawOpWin* blendWin = CTDrawOpWin::NewL(this, TestWin, TPoint(0,0), winSize, TRgb(255,0,0,0));
sl@0
   174
sl@0
   175
	for (TInt i=EOpDrawRect; i<ENumDrawOps; i++)
sl@0
   176
		{
sl@0
   177
		//User::After(1000000);// helpful when debugging
sl@0
   178
		drawWin->SetDrawOp(i);
sl@0
   179
		blendWin->SetDrawOp(i);
sl@0
   180
		drawWin->DrawNow();
sl@0
   181
		blendWin->DrawNow();
sl@0
   182
		TheClient->Flush();
sl@0
   183
		TheClient->WaitForRedrawsToFinish();
sl@0
   184
		CheckRect(BaseWin,TestWin,_L("CTAlphaWin::TestTransparentDrawingL()"));
sl@0
   185
		}
sl@0
   186
	delete drawWin;
sl@0
   187
	delete blendWin;
sl@0
   188
	}
sl@0
   189
sl@0
   190
void CTAlphaWin::CheckRectL(const TRect& aRect1, const TRect& aRect2, TSize aSize, TDisplayMode aRequiredMode, TInt aTolerance, const TDesC& aErrorMsg)
sl@0
   191
	{
sl@0
   192
	CFbsBitmap *bmp1 = new (ELeave) CFbsBitmap;
sl@0
   193
	CleanupStack::PushL(bmp1);
sl@0
   194
	User::LeaveIfError(bmp1->Create(aSize, aRequiredMode));
sl@0
   195
sl@0
   196
	CFbsBitmap *bmp2 = new (ELeave) CFbsBitmap;
sl@0
   197
	CleanupStack::PushL(bmp2);
sl@0
   198
	User::LeaveIfError(bmp2->Create(aSize, aRequiredMode));
sl@0
   199
	
sl@0
   200
	User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(bmp1, aRect1));	
sl@0
   201
	User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(bmp2, aRect2));	
sl@0
   202
sl@0
   203
	TRgb *rgbBuf1=(TRgb *)User::AllocL(aSize.iWidth*sizeof(TRgb));	
sl@0
   204
	TRgb *rgbBuf2=(TRgb *)User::Alloc(aSize.iWidth*sizeof(TRgb));	
sl@0
   205
	if(!rgbBuf2)
sl@0
   206
		{
sl@0
   207
		User::Free(rgbBuf1);
sl@0
   208
		User::Leave(KErrNoMemory);
sl@0
   209
		}
sl@0
   210
	TBool equal = ETrue;
sl@0
   211
	TInt maxDeviation = 0;
sl@0
   212
	for(TInt yy = 0; yy < aSize.iHeight && equal; yy++)
sl@0
   213
		{
sl@0
   214
		TPtr8 ptr1((TUint8 *)rgbBuf1,aSize.iWidth*sizeof(TRgb));
sl@0
   215
		bmp1->GetScanLine(ptr1, TPoint(0, yy), aSize.iWidth, ERgb);
sl@0
   216
		TPtr8 ptr2((TUint8 *)rgbBuf2,aSize.iWidth*sizeof(TRgb));
sl@0
   217
		bmp2->GetScanLine(ptr2, TPoint(0, yy), aSize.iWidth, ERgb);
sl@0
   218
		
sl@0
   219
		TRgb *rgbBufCur1 = rgbBuf1;
sl@0
   220
		TRgb *rgbBufCur2 = rgbBuf2;
sl@0
   221
		for(TInt ii = 0; ii < aSize.iWidth; ii++)
sl@0
   222
			{
sl@0
   223
			TInt delta = Abs(rgbBufCur1->Red()-rgbBufCur2->Red());
sl@0
   224
			TInt delta1 = Abs(rgbBufCur1->Green()-rgbBufCur2->Green());
sl@0
   225
			TInt delta2 = Abs(rgbBufCur1->Blue()-rgbBufCur2->Blue());
sl@0
   226
			
sl@0
   227
			if((delta > aTolerance) || (delta1 > aTolerance) || (delta2 > aTolerance))
sl@0
   228
				{
sl@0
   229
				equal = EFalse;
sl@0
   230
				}
sl@0
   231
			TInt maxItermedia = Max(delta1, delta2);
sl@0
   232
			maxItermedia = Max(maxItermedia, delta);
sl@0
   233
			maxDeviation = Max(maxItermedia, maxDeviation);
sl@0
   234
sl@0
   235
			rgbBufCur1++;	
sl@0
   236
			rgbBufCur2++;	
sl@0
   237
			}
sl@0
   238
		}
sl@0
   239
	
sl@0
   240
	User::Free(rgbBuf1);
sl@0
   241
	User::Free(rgbBuf2);
sl@0
   242
sl@0
   243
	CleanupStack::PopAndDestroy(2,bmp1);
sl@0
   244
sl@0
   245
	if (!equal)
sl@0
   246
		{
sl@0
   247
		INFO_PRINTF3(_L("%S CheckRectA failed, max deviation %d"), &aErrorMsg, maxDeviation);
sl@0
   248
		}
sl@0
   249
	else if(maxDeviation)
sl@0
   250
		{
sl@0
   251
		INFO_PRINTF4(_L("%S CheckRectA passed with tolerance %d, max deviation %d"), &aErrorMsg, aTolerance, maxDeviation);
sl@0
   252
		}
sl@0
   253
		
sl@0
   254
	iStep->TEST(equal);
sl@0
   255
	}
sl@0
   256
sl@0
   257
void CTAlphaWin::TestCondition()
sl@0
   258
	{
sl@0
   259
	// User::After(1000000);// helpful when debugging
sl@0
   260
	iRefWin->DrawNow();
sl@0
   261
	TheClient->Flush();
sl@0
   262
	TheClient->WaitForRedrawsToFinish();
sl@0
   263
	CheckRect(BaseWin,TestWin,_L("CTAlphaWin::TestCondition()"));
sl@0
   264
	}
sl@0
   265
sl@0
   266
void CTAlphaWin::TestConditionL()
sl@0
   267
	{
sl@0
   268
	iRefWin->DrawNow();
sl@0
   269
	TheClient->Flush();
sl@0
   270
	TheClient->WaitForRedrawsToFinish();
sl@0
   271
sl@0
   272
	const TInt tolerance = 9;
sl@0
   273
	TSize winSize=BaseWin->Size();
sl@0
   274
	TRect rect1(BaseWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),winSize);
sl@0
   275
	TRect rect2(TestWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),winSize);
sl@0
   276
	CheckRectL(rect1, rect2, winSize, TheClient->iScreen->DisplayMode(), tolerance, _L("CTAlphaWin::TestCondition()"));
sl@0
   277
	}
sl@0
   278
sl@0
   279
void CTAlphaWin::TestInitialConfiguration()
sl@0
   280
	{
sl@0
   281
	if(TheClient->iScreen->DisplayMode() == EColor64K)
sl@0
   282
		{
sl@0
   283
		TestConditionL();
sl@0
   284
		}
sl@0
   285
	else
sl@0
   286
		{
sl@0
   287
		TestCondition();
sl@0
   288
		}
sl@0
   289
	}
sl@0
   290
sl@0
   291
void CTAlphaWin::TestMove()
sl@0
   292
	{
sl@0
   293
	// Test moving windows, both in front and behind
sl@0
   294
	for (TInt i = 0; i<5; i++)
sl@0
   295
		{
sl@0
   296
		TPoint pos = iTestWin[i]->Position();
sl@0
   297
		pos += TPoint(10,10);
sl@0
   298
		iTestWin[i]->SetPos(pos);
sl@0
   299
		TestCondition();
sl@0
   300
		}
sl@0
   301
	for (TInt j = 0; j<5; j++)
sl@0
   302
		{
sl@0
   303
		TPoint pos = iTestWin[j]->Position();
sl@0
   304
		pos -= TPoint(10,10);
sl@0
   305
		iTestWin[j]->SetPos(pos);
sl@0
   306
		TestCondition();
sl@0
   307
		}
sl@0
   308
	}
sl@0
   309
sl@0
   310
sl@0
   311
void CTAlphaWin::TestRedraw()
sl@0
   312
	{
sl@0
   313
	// Test redrawing windows, both in front and behind
sl@0
   314
	for (TInt i=0; i<5; i++)
sl@0
   315
		{
sl@0
   316
		iTestWin[i]->DrawNow();
sl@0
   317
		TestCondition();
sl@0
   318
		}
sl@0
   319
	}
sl@0
   320
sl@0
   321
sl@0
   322
void CTAlphaWin::TestInvisible()
sl@0
   323
	{
sl@0
   324
	// Test making windows visible and invisible, both in front and behind
sl@0
   325
	for (TInt i=0; i<5; i++)
sl@0
   326
		{
sl@0
   327
		iTestWin[i]->SetVisible(EFalse);
sl@0
   328
		TestCondition();
sl@0
   329
		iTestWin[i]->SetVisible(ETrue);
sl@0
   330
		TestCondition();
sl@0
   331
		}
sl@0
   332
	}
sl@0
   333
sl@0
   334
void CTAlphaWin::TestChildrenL()
sl@0
   335
	{
sl@0
   336
	struct CTAlphaWinChildren: public TCleanupItem
sl@0
   337
		{
sl@0
   338
			static void Destroy(TAny* trg)
sl@0
   339
				{
sl@0
   340
				static_cast<CTAlphaWindow*>(trg)->DestroyChildren();				
sl@0
   341
				}
sl@0
   342
			CTAlphaWinChildren(CTAlphaWindow*trg):	TCleanupItem(Destroy,trg)	
sl@0
   343
				{}
sl@0
   344
			
sl@0
   345
		};
sl@0
   346
	CleanupStack::PushL(CTAlphaWinChildren(iTestWin[2]));
sl@0
   347
	iTestWin[2]->CreateChildrenL(3);
sl@0
   348
	TestCondition();
sl@0
   349
	TestMove();
sl@0
   350
	CleanupStack::PopAndDestroy(iTestWin[2]);
sl@0
   351
	}
sl@0
   352
sl@0
   353
sl@0
   354
void CTAlphaWin::TestAntiAliasedTextTransparentL()
sl@0
   355
	{
sl@0
   356
sl@0
   357
	//Clear the screen
sl@0
   358
	for (TInt i=0; i<5; i++)
sl@0
   359
		{
sl@0
   360
		iTestWin[i]->SetVisible(EFalse);
sl@0
   361
		}
sl@0
   362
	iRefWin->SetVisible(EFalse);
sl@0
   363
	TheClient->iWs.Flush();
sl@0
   364
sl@0
   365
	//Create a new test window on the left
sl@0
   366
	//Create a transparent window:
sl@0
   367
	TSize winSize = BaseWin->Size();
sl@0
   368
sl@0
   369
	RWindow theWin(TestWin->Client()->iWs);
sl@0
   370
	User::LeaveIfError(theWin.Construct(*(TestWin->WinTreeNode()),(TUint32)&theWin));
sl@0
   371
sl@0
   372
	theWin.SetExtent(TPoint(0,0), winSize);
sl@0
   373
	theWin.SetBackgroundColor(TRgb(127,0,255,127));
sl@0
   374
	TDisplayMode mode = EColor16MAP;
sl@0
   375
	theWin.SetRequiredDisplayMode(mode);
sl@0
   376
	theWin.SetVisible(ETrue);
sl@0
   377
	theWin.SetTransparencyAlphaChannel();
sl@0
   378
	theWin.Activate();
sl@0
   379
	TheClient->iWs.Flush();
sl@0
   380
	CleanupClosePushL(theWin);
sl@0
   381
sl@0
   382
	//get windows screen device.
sl@0
   383
	CWsScreenDevice *device;
sl@0
   384
	device = new (ELeave)CWsScreenDevice(TestWin->Client()->iWs);//(TheClient->iWs);
sl@0
   385
	User::LeaveIfError(device->Construct(iTest->ScreenNumber()));
sl@0
   386
	CleanupStack::PushL(device);
sl@0
   387
sl@0
   388
	TFontSpec fs1;
sl@0
   389
	CFont *font1;
sl@0
   390
	CFont *font2;
sl@0
   391
	fs1.iTypeface.iName = KTestFontTypefaceName;
sl@0
   392
	fs1.iHeight = 16;
sl@0
   393
	fs1.iFontStyle.SetBitmapType(EDefaultGlyphBitmap);
sl@0
   394
	int error = TheClient->iScreen->GetNearestFontToDesignHeightInPixels((CFont*&)font1,fs1);
sl@0
   395
	if (error)
sl@0
   396
		{
sl@0
   397
		TheClient->iScreen->ReleaseFont(font1);
sl@0
   398
		User::Panic(_L("font not created"),error);
sl@0
   399
		}
sl@0
   400
	fs1.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
sl@0
   401
	error = TheClient->iScreen->GetNearestFontToDesignHeightInPixels((CFont*&)font2,fs1);
sl@0
   402
	if (error)
sl@0
   403
		{
sl@0
   404
		TheClient->iScreen->ReleaseFont(font1);
sl@0
   405
		TheClient->iScreen->ReleaseFont(font2);
sl@0
   406
		User::Panic(_L("font not created"),error);
sl@0
   407
		}
sl@0
   408
sl@0
   409
	CWindowGc *gc;
sl@0
   410
	device->CreateContext(gc);
sl@0
   411
	CleanupStack::PushL(gc);
sl@0
   412
sl@0
   413
	theWin.Invalidate();
sl@0
   414
	theWin.BeginRedraw();
sl@0
   415
	gc->Activate(theWin);
sl@0
   416
sl@0
   417
	gc->SetPenStyle( CGraphicsContext::ESolidPen );
sl@0
   418
	gc->SetPenColor( TRgb( 0, 0, 0, 127 ) );
sl@0
   419
sl@0
   420
	//draw text for anti-aliasing needs an open font (scalable).
sl@0
   421
	int typefaces = TheClient->iScreen->NumTypefaces();
sl@0
   422
sl@0
   423
	gc->UseFont(font1);
sl@0
   424
	gc->SetBrushStyle( CGraphicsContext::ENullBrush );
sl@0
   425
	gc->DrawText(_L("Test"),TPoint(10,20));
sl@0
   426
	gc->DiscardFont();
sl@0
   427
	gc->UseFont(font2);
sl@0
   428
	gc->DrawText(_L("Test"),TPoint(10,60));
sl@0
   429
	gc->DiscardFont();
sl@0
   430
sl@0
   431
	//destruction and tidying up
sl@0
   432
	gc->Deactivate();
sl@0
   433
	theWin.EndRedraw();
sl@0
   434
	TheClient->iWs.Flush();
sl@0
   435
sl@0
   436
	TheClient->iScreen->ReleaseFont(font1);
sl@0
   437
	TheClient->iScreen->ReleaseFont(font2);
sl@0
   438
	CleanupStack::PopAndDestroy(gc);//gc
sl@0
   439
	CleanupStack::PopAndDestroy(device);//device
sl@0
   440
sl@0
   441
	//do not close the test window yet since there is a comparison
sl@0
   442
	//required
sl@0
   443
sl@0
   444
	//now do the same on an off screen bitmap.  Then create a window
sl@0
   445
	//and put the bitmap onto it.
sl@0
   446
	//create a colour bitmap
sl@0
   447
	//
sl@0
   448
	CFbsBitmap *bitmapOne;
sl@0
   449
	bitmapOne = new (ELeave)CFbsBitmap();
sl@0
   450
	CleanupStack::PushL(bitmapOne);
sl@0
   451
	User::LeaveIfError(bitmapOne->Create(winSize,mode));
sl@0
   452
sl@0
   453
	CFbsBitmapDevice *deviceOne=CFbsBitmapDevice::NewL(bitmapOne);
sl@0
   454
	CleanupStack::PushL(deviceOne);
sl@0
   455
sl@0
   456
	CFont *font3;
sl@0
   457
	CFont *font4;
sl@0
   458
	fs1.iFontStyle.SetBitmapType(EDefaultGlyphBitmap);
sl@0
   459
	error = TheClient->iScreen->GetNearestFontToDesignHeightInPixels((CFont*&)font3,fs1);
sl@0
   460
	if (error)
sl@0
   461
		{
sl@0
   462
		TheClient->iScreen->ReleaseFont(font3);
sl@0
   463
		User::Panic(_L("font not created"),error);
sl@0
   464
		}
sl@0
   465
	fs1.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
sl@0
   466
	error = TheClient->iScreen->GetNearestFontToDesignHeightInPixels((CFont*&)font4,fs1);
sl@0
   467
	if (error)
sl@0
   468
		{
sl@0
   469
		TheClient->iScreen->ReleaseFont(font3);
sl@0
   470
		TheClient->iScreen->ReleaseFont(font4);
sl@0
   471
		User::Panic(_L("font not created"),error);
sl@0
   472
		}
sl@0
   473
	CFbsBitGc *bGcOne = CFbsBitGc::NewL();
sl@0
   474
	CleanupStack::PushL(bGcOne);
sl@0
   475
sl@0
   476
	bGcOne->Activate(deviceOne);
sl@0
   477
sl@0
   478
	bGcOne->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
   479
	bGcOne->SetBrushColor(TRgb(127,0,255,127));
sl@0
   480
	bGcOne->DrawRect(TRect(0,0,winSize.iWidth,winSize.iHeight));
sl@0
   481
sl@0
   482
	bGcOne->SetPenStyle(CGraphicsContext::ESolidPen);
sl@0
   483
	bGcOne->SetPenColor(TRgb(0,0,0,127));
sl@0
   484
sl@0
   485
	bGcOne->UseFont(font3);
sl@0
   486
	bGcOne->SetBrushStyle( CGraphicsContext::ENullBrush );
sl@0
   487
	bGcOne->DrawText(_L("Test"),TPoint(10,20));
sl@0
   488
	bGcOne->DiscardFont();
sl@0
   489
	bGcOne->UseFont(font4);
sl@0
   490
	bGcOne->DrawText(_L("Test"),TPoint(10,60));
sl@0
   491
	bGcOne->DiscardFont();
sl@0
   492
	//destruction and tidying up
sl@0
   493
	//measure the text
sl@0
   494
	CFont::TMeasureTextOutput textSize;
sl@0
   495
	font4->MeasureText(_L("Test"),NULL,&textSize);
sl@0
   496
sl@0
   497
	TheClient->iScreen->ReleaseFont(font3);
sl@0
   498
	TheClient->iScreen->ReleaseFont(font4);
sl@0
   499
sl@0
   500
	//display at the left
sl@0
   501
	RWindow refWin(BaseWin->Client()->iWs);
sl@0
   502
	CleanupClosePushL(refWin);
sl@0
   503
	User::LeaveIfError(refWin.Construct(*(BaseWin->WinTreeNode()),(TUint32)&refWin));
sl@0
   504
sl@0
   505
	refWin.SetExtent(TPoint(0,0), winSize);
sl@0
   506
	refWin.SetRequiredDisplayMode(mode);
sl@0
   507
	refWin.SetVisible(ETrue);
sl@0
   508
	refWin.SetTransparencyAlphaChannel();
sl@0
   509
	refWin.Activate();
sl@0
   510
	TheClient->iWs.Flush();
sl@0
   511
sl@0
   512
	//a gc for the ref win
sl@0
   513
	CWsScreenDevice *refDevice;
sl@0
   514
	refDevice = new (ELeave)CWsScreenDevice(BaseWin->Client()->iWs);
sl@0
   515
	User::LeaveIfError(refDevice->Construct(iTest->ScreenNumber()));
sl@0
   516
	CleanupStack::PushL(refDevice);
sl@0
   517
	CWindowGc *gcRef;
sl@0
   518
	refDevice->CreateContext(gcRef);
sl@0
   519
	CleanupStack::PushL(gcRef);
sl@0
   520
sl@0
   521
	refWin.Invalidate();
sl@0
   522
	refWin.BeginRedraw();
sl@0
   523
	gcRef->Activate(refWin);
sl@0
   524
	gcRef->BitBlt(TPoint(0,0), bitmapOne);
sl@0
   525
	gcRef->Deactivate();
sl@0
   526
	refWin.EndRedraw();
sl@0
   527
	TheClient->iWs.Flush();
sl@0
   528
sl@0
   529
	TPoint refPos = refWin.AbsPosition();
sl@0
   530
	TPoint winPos = theWin.AbsPosition();
sl@0
   531
sl@0
   532
	//Compare the anti-aliased text areas
sl@0
   533
	TInt textLength=textSize.iBounds.iBr.iX;
sl@0
   534
	TInt textHeight=Abs(textSize.iBounds.iTl.iY);
sl@0
   535
sl@0
   536
	TRect rect1(refPos.iX+10,refPos.iY+60-textHeight,
sl@0
   537
			refPos.iX+10+textLength,refPos.iY+60);
sl@0
   538
	TRect rect2(winPos.iX+10,winPos.iY+60-textHeight,
sl@0
   539
			winPos.iX+10+textLength,winPos.iY+60);
sl@0
   540
sl@0
   541
	TBool match = refDevice->RectCompare(rect1,rect2);
sl@0
   542
	TEST(match);
sl@0
   543
sl@0
   544
	CleanupStack::PopAndDestroy(gcRef);
sl@0
   545
	CleanupStack::PopAndDestroy(refDevice);
sl@0
   546
	CleanupStack::PopAndDestroy(&refWin);
sl@0
   547
sl@0
   548
	CleanupStack::PopAndDestroy(bGcOne);
sl@0
   549
	CleanupStack::PopAndDestroy(deviceOne);
sl@0
   550
	CleanupStack::PopAndDestroy(bitmapOne);
sl@0
   551
	CleanupStack::PopAndDestroy(&theWin);//theWin
sl@0
   552
sl@0
   553
	}
sl@0
   554
//
sl@0
   555
// CTDrawOpWin
sl@0
   556
//
sl@0
   557
sl@0
   558
CTDrawOpWin* CTDrawOpWin::NewL(CTAlphaWin* aTest, CTWinBase* aParent, TPoint aPos, TSize aSize, TRgb aDrawColour)
sl@0
   559
	{
sl@0
   560
	CTDrawOpWin* theWin = new(ELeave) CTDrawOpWin(aTest,aDrawColour);
sl@0
   561
sl@0
   562
	theWin->ConstructL(*aParent);
sl@0
   563
	theWin->SetExtL(aPos, aSize);
sl@0
   564
	theWin->AssignGC(*TheClient->iGc);
sl@0
   565
	if (TheClient->iScreen->DisplayMode() == EColor16MA)
sl@0
   566
		{
sl@0
   567
		theWin->BaseWin()->SetRequiredDisplayMode(EColor16MA);
sl@0
   568
		}
sl@0
   569
	else
sl@0
   570
		{
sl@0
   571
		theWin->BaseWin()->SetRequiredDisplayMode(EColor64K);
sl@0
   572
		}
sl@0
   573
		
sl@0
   574
	theWin->Activate();
sl@0
   575
	theWin->DrawNow();
sl@0
   576
sl@0
   577
	return theWin;
sl@0
   578
	}
sl@0
   579
sl@0
   580
CTDrawOpWin::CTDrawOpWin(CTAlphaWin* aTest, TRgb aDrawColour)
sl@0
   581
: iTest(aTest), iDrawColour(aDrawColour)
sl@0
   582
	{}
sl@0
   583
sl@0
   584
sl@0
   585
void CTDrawOpWin::SetDrawOp(TInt aDrawOp)
sl@0
   586
	{
sl@0
   587
	iDrawOp = aDrawOp;
sl@0
   588
	}
sl@0
   589
sl@0
   590
sl@0
   591
void CTDrawOpWin::Draw()
sl@0
   592
	{
sl@0
   593
	_LIT(KText,"Text test");
sl@0
   594
sl@0
   595
	iGc->SetPenColor(iDrawColour);
sl@0
   596
	iGc->SetBrushColor(iDrawColour);
sl@0
   597
	TSize size = Size();
sl@0
   598
	TInt top = 5;
sl@0
   599
	TInt left = 5;
sl@0
   600
	TInt bottom = size.iHeight - 5;
sl@0
   601
	TInt right = size.iWidth - 5;
sl@0
   602
	TInt square = Min(bottom-top,right-left);
sl@0
   603
sl@0
   604
	switch (iDrawOp)
sl@0
   605
		{
sl@0
   606
	case EOpDrawRect:
sl@0
   607
		iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
   608
		iGc->SetPenStyle(CGraphicsContext::ENullPen);
sl@0
   609
		iGc->DrawRect(TRect(left,top,right,bottom));
sl@0
   610
		break;
sl@0
   611
	case EOpDrawLine:
sl@0
   612
		//!! FAILS
sl@0
   613
		//!! The endpoint of the line is drawn twice, with the result that it is darker when we do blending
sl@0
   614
		//!! Not intending to fix at the moment
sl@0
   615
		/*
sl@0
   616
		iGc->SetPenStyle(CGraphicsContext::ESolidPen);
sl@0
   617
		iGc->SetPenSize(TSize(4,4));
sl@0
   618
		// The lines must not overlap, otherwise the blended lines will be darker at the overlap
sl@0
   619
		iGc->DrawLine(TPoint(left+5,top), TPoint(left+square,top));
sl@0
   620
		iGc->DrawLine(TPoint(left+5,top+5), TPoint(left+square,top+square));
sl@0
   621
		iGc->DrawLine(TPoint(left,top+5), TPoint(left,top+square));
sl@0
   622
		*/
sl@0
   623
		break;
sl@0
   624
	case EOpDrawEllipse:
sl@0
   625
		iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
   626
		iGc->SetPenStyle(CGraphicsContext::ENullPen);
sl@0
   627
		iGc->DrawEllipse(TRect(left,top,right,bottom));
sl@0
   628
		break;
sl@0
   629
	case EOpDrawText:
sl@0
   630
	case EOpDrawTextVertical:
sl@0
   631
		{
sl@0
   632
		iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
sl@0
   633
		iGc->SetPenStyle(CGraphicsContext::ESolidPen);
sl@0
   634
		CFont* font;
sl@0
   635
		TFontSpec fontSpec(KTestFontTypefaceName,200);
sl@0
   636
		User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips(font, fontSpec));
sl@0
   637
		iGc->UseFont(font);
sl@0
   638
		if (iDrawOp==EOpDrawText)
sl@0
   639
			iGc->DrawText(KText(), TPoint(5,30));
sl@0
   640
		else
sl@0
   641
			iGc->DrawTextVertical(KText(), TPoint(5,30), EFalse);
sl@0
   642
		iGc->DiscardFont();
sl@0
   643
		TheClient->iScreen->ReleaseFont(font);
sl@0
   644
		}
sl@0
   645
		break;
sl@0
   646
	case EOpDrawTextAntiAliased:
sl@0
   647
		{
sl@0
   648
		iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
sl@0
   649
		iGc->SetPenStyle(CGraphicsContext::ESolidPen);
sl@0
   650
		CFont* font;
sl@0
   651
		TFontSpec fontSpec(KTestFontTypefaceName,600);
sl@0
   652
		fontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold);
sl@0
   653
		fontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
sl@0
   654
sl@0
   655
		User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips(font, fontSpec));
sl@0
   656
		iGc->UseFont(font);
sl@0
   657
		iGc->DrawText(KText(), TPoint(5,30));
sl@0
   658
		iGc->DiscardFont();
sl@0
   659
		TheClient->iScreen->ReleaseFont(font);
sl@0
   660
		}
sl@0
   661
		break;
sl@0
   662
	case EOpBitBlt:
sl@0
   663
		break;
sl@0
   664
	case EOpBitBltMasked:
sl@0
   665
		break;
sl@0
   666
	default:
sl@0
   667
		break;
sl@0
   668
		};
sl@0
   669
	}
sl@0
   670
sl@0
   671
sl@0
   672
sl@0
   673
//
sl@0
   674
// CTAlphaWindow
sl@0
   675
//
sl@0
   676
sl@0
   677
CTAlphaWindow::~CTAlphaWindow()
sl@0
   678
	{
sl@0
   679
	DestroyChildren();
sl@0
   680
	}
sl@0
   681
sl@0
   682
CTAlphaWindow* CTAlphaWindow::NewL(CTAlphaWin* aTest, CTWinBase* aParent, TPoint aPos, TSize aSize, TInt aDrawState)
sl@0
   683
	{
sl@0
   684
	CTAlphaWindow* theWin = new (ELeave) CTAlphaWindow(aTest);
sl@0
   685
sl@0
   686
	theWin->ConstructL(*aParent);
sl@0
   687
	theWin->SetExtL(aPos, aSize);
sl@0
   688
	theWin->SetDrawState(aDrawState);
sl@0
   689
sl@0
   690
	theWin->AssignGC(*TheClient->iGc);
sl@0
   691
sl@0
   692
	theWin->Activate();
sl@0
   693
	theWin->iDrawState |= EActive;
sl@0
   694
	theWin->DrawNow();
sl@0
   695
sl@0
   696
	return theWin;
sl@0
   697
	}
sl@0
   698
sl@0
   699
void CTAlphaWindow::SetDrawState(TInt aDrawState)
sl@0
   700
	{
sl@0
   701
	TBool active = iDrawState & EActive;
sl@0
   702
	iDrawState = aDrawState & 0x7fffffff;
sl@0
   703
sl@0
   704
	TRgb colour = ColourFromDrawState(iDrawState);
sl@0
   705
	((RWindow*) DrawableWin())->SetBackgroundColor(colour);
sl@0
   706
sl@0
   707
	if (iDrawState & EModeColor16MA)
sl@0
   708
		BaseWin()->SetRequiredDisplayMode(EColor16MA);
sl@0
   709
	else
sl@0
   710
		BaseWin()->SetRequiredDisplayMode(EColor64K);
sl@0
   711
sl@0
   712
	BaseWin()->SetVisible(! (iDrawState & EInvisible));
sl@0
   713
sl@0
   714
	if (!active)
sl@0
   715
		{
sl@0
   716
		if (iDrawState & EAlphaTransparency)
sl@0
   717
			((RWindow*) DrawableWin())->SetTransparencyAlphaChannel();
sl@0
   718
		else if (iDrawState & ETransparencyFactor)
sl@0
   719
			((RWindow*) DrawableWin())->SetTransparencyFactor(TRgb(128,128,128));
sl@0
   720
		}
sl@0
   721
sl@0
   722
	if (active)
sl@0
   723
		iDrawState |= EActive;
sl@0
   724
	}
sl@0
   725
sl@0
   726
void CTAlphaWindow::SetVisible(TBool aVisible)
sl@0
   727
	{
sl@0
   728
	if (aVisible)
sl@0
   729
		iDrawState &= ~EInvisible;
sl@0
   730
	else
sl@0
   731
		iDrawState |= EInvisible;
sl@0
   732
	BaseWin()->SetVisible(aVisible);
sl@0
   733
	}
sl@0
   734
sl@0
   735
void CTAlphaWindow::CreateChildrenL(TInt aDepth)
sl@0
   736
	{
sl@0
   737
	DestroyChildren();
sl@0
   738
	if (aDepth>0)
sl@0
   739
		{
sl@0
   740
		TSize size = Size();
sl@0
   741
		iChild1 = CTAlphaWindow::NewL(iTest, this, TPoint(size.iWidth/3,0), TSize(2*size.iWidth/3, 2*size.iHeight/3), ERed | EGreen | EBlue | EOpaque);
sl@0
   742
		iChild2 = CTAlphaWindow::NewL(iTest, this, TPoint(0,size.iHeight/3), TSize(2*size.iWidth/3, 2*size.iHeight/3), ERed | EGreen | EBlue | EAlphaTransparency);
sl@0
   743
		iChild2->CreateChildrenL(aDepth-1);
sl@0
   744
		}
sl@0
   745
	}
sl@0
   746
sl@0
   747
void CTAlphaWindow::DestroyChildren()
sl@0
   748
	{
sl@0
   749
	if (iChild1)
sl@0
   750
		{
sl@0
   751
		iChild1->DestroyChildren();
sl@0
   752
		delete iChild1;
sl@0
   753
		iChild1 = NULL;
sl@0
   754
		}
sl@0
   755
	if (iChild2)
sl@0
   756
		{
sl@0
   757
		iChild2->DestroyChildren();
sl@0
   758
		delete iChild2;
sl@0
   759
		iChild2 = NULL;
sl@0
   760
		}
sl@0
   761
	}
sl@0
   762
sl@0
   763
TInt CTAlphaWindow::DrawState()
sl@0
   764
	{
sl@0
   765
	return iDrawState;
sl@0
   766
	}
sl@0
   767
sl@0
   768
void CTAlphaWindow::Draw()
sl@0
   769
	{
sl@0
   770
	// we draw a diagonal line from top left to bottom right
sl@0
   771
	// we use the complementary colour to the window background colour
sl@0
   772
	TInt red = (iDrawState & ERed) ? 0 : 255;
sl@0
   773
	TInt green = (iDrawState & EGreen) ? 0 : 255;
sl@0
   774
	TInt blue = (iDrawState & EBlue) ? 0 : 255;
sl@0
   775
	TRgb color(red,green,blue);
sl@0
   776
sl@0
   777
	TSize size = Size();
sl@0
   778
	iGc->SetPenColor(color);
sl@0
   779
	iGc->SetPenSize(TSize(4,4));
sl@0
   780
	iGc->DrawLine(TPoint(0,0), TPoint(size.iWidth, size.iHeight));
sl@0
   781
	}
sl@0
   782
sl@0
   783
sl@0
   784
//
sl@0
   785
// CTAlphaRefWin
sl@0
   786
//
sl@0
   787
sl@0
   788
CTAlphaRefWin::CTAlphaRefWin(TFixedArray<CTAlphaWindow*,5>& aAlphaWin)
sl@0
   789
: iAlphaWin(aAlphaWin)
sl@0
   790
	{}
sl@0
   791
sl@0
   792
CTAlphaRefWin* CTAlphaRefWin::NewL(CTWinBase* aParent, TPoint aPos, TSize aSize, TFixedArray<CTAlphaWindow*,5>& aAlphaWin)
sl@0
   793
	{
sl@0
   794
	CTAlphaRefWin* theWin = new(ELeave) CTAlphaRefWin(aAlphaWin);
sl@0
   795
sl@0
   796
	theWin->ConstructL(*aParent);
sl@0
   797
	theWin->SetExtL(aPos, aSize);
sl@0
   798
	theWin->AssignGC(*TheClient->iGc);
sl@0
   799
	theWin->BaseWin()->SetRequiredDisplayMode(EColor64K);
sl@0
   800
sl@0
   801
	theWin->Activate();
sl@0
   802
	theWin->DrawNow();
sl@0
   803
sl@0
   804
	return theWin;
sl@0
   805
	}
sl@0
   806
sl@0
   807
void CTAlphaRefWin::Draw()
sl@0
   808
	{
sl@0
   809
	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
   810
	iGc->SetBrushColor(KRgbWhite);
sl@0
   811
	iGc->Clear();
sl@0
   812
sl@0
   813
	// Note, the order of the windows in the array must correspond to their z-order
sl@0
   814
	for (TInt i=0; i<5; i++)
sl@0
   815
		DrawWindow(iAlphaWin[i], iAlphaWin[i]->Position());
sl@0
   816
	}
sl@0
   817
sl@0
   818
void CTAlphaRefWin::DrawWindow(CTAlphaWindow* aWindow, TPoint aPos)
sl@0
   819
	{
sl@0
   820
	TInt drawState = aWindow->DrawState();
sl@0
   821
	if ( (drawState & EInvisible) || ! (drawState & EActive) )
sl@0
   822
		return;
sl@0
   823
sl@0
   824
	TRgb colour = ColourFromDrawState(drawState);
sl@0
   825
	if (drawState & EOpaque)
sl@0
   826
		colour.SetAlpha(255);
sl@0
   827
	if (drawState & ETransparent)
sl@0
   828
		colour.SetAlpha(0);
sl@0
   829
	iGc->SetBrushColor(colour);
sl@0
   830
sl@0
   831
	TPoint tl = aPos;
sl@0
   832
	TPoint br = tl + aWindow->Size();
sl@0
   833
	TRect rect(tl,br);
sl@0
   834
	iGc->Clear(rect);
sl@0
   835
sl@0
   836
	TInt red = (drawState & ERed) ? 0 : 255;
sl@0
   837
	TInt green = (drawState & EGreen) ? 0 : 255;
sl@0
   838
	TInt blue = (drawState & EBlue) ? 0 : 255;
sl@0
   839
	colour = TRgb(red,green,blue);
sl@0
   840
sl@0
   841
	iGc->SetClippingRect(rect);
sl@0
   842
sl@0
   843
	TSize size = Size();
sl@0
   844
	iGc->SetPenColor(colour);
sl@0
   845
	iGc->SetPenSize(TSize(4,4));
sl@0
   846
	iGc->DrawLine(tl, br);
sl@0
   847
sl@0
   848
	iGc->CancelClippingRect();
sl@0
   849
sl@0
   850
	if (aWindow->iChild1)
sl@0
   851
		DrawWindow(aWindow->iChild1, aPos + aWindow->iChild1->Position() );
sl@0
   852
	if (aWindow->iChild2)
sl@0
   853
		DrawWindow(aWindow->iChild2, aPos + aWindow->iChild2->Position() );
sl@0
   854
	}
sl@0
   855
sl@0
   856
sl@0
   857
//
sl@0
   858
// Main test loop
sl@0
   859
//
sl@0
   860
void CTAlphaWin::RunTestCaseL(TInt /*aCurTestCase*/)
sl@0
   861
	{
sl@0
   862
	//User::After(TTimeIntervalMicroSeconds32(1000 * 1000));
sl@0
   863
	((CTAlphaWinStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
sl@0
   864
	switch (++iTest->iState)
sl@0
   865
		{
sl@0
   866
/**
sl@0
   867
sl@0
   868
  @SYMTestCaseID GRAPHICS-WSERV-0278
sl@0
   869
sl@0
   870
  @SYMDEF             DEF081259
sl@0
   871
sl@0
   872
  @SYMPREQ 915
sl@0
   873
sl@0
   874
  @SYMTestCaseDesc Semi-transparent drawing
sl@0
   875
sl@0
   876
  @SYMTestPriority High
sl@0
   877
sl@0
   878
  @SYMTestStatus Implemented
sl@0
   879
sl@0
   880
  @SYMTestActions Use draw operations with semi-transparent pen or brush colours
sl@0
   881
sl@0
   882
  @SYMTestExpectedResults Draw operations must do alpha blending
sl@0
   883
sl@0
   884
*/
sl@0
   885
	case 1:
sl@0
   886
		{
sl@0
   887
		((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0278"));
sl@0
   888
		if(TransparencySupportedL() == KErrNotSupported)
sl@0
   889
			{
sl@0
   890
			LOG_MESSAGE(_L("Test(1) complete - Transparency not supported\n"));
sl@0
   891
			TestComplete();
sl@0
   892
			break;
sl@0
   893
			}
sl@0
   894
		TDisplayMode mode = TheClient->iScreen->DisplayMode();
sl@0
   895
		if (mode < EColor64K)
sl@0
   896
			{
sl@0
   897
			LOG_MESSAGE(_L("Test(1) complete - Display mode < EColor64K\n"));
sl@0
   898
			TestComplete();
sl@0
   899
			break;
sl@0
   900
			}
sl@0
   901
		_LIT(KSemiTrans64K,"(1) Semi transparent drawing Color64K");
sl@0
   902
		iTest->LogSubTest(KSemiTrans64K);
sl@0
   903
		TestSemiTransparentDrawingL();
sl@0
   904
		break;
sl@0
   905
		}
sl@0
   906
		
sl@0
   907
/**
sl@0
   908
sl@0
   909
  @SYMTestCaseID GRAPHICS-WSERV-0287
sl@0
   910
sl@0
   911
  @SYMDEF             DEF081259
sl@0
   912
sl@0
   913
  @SYMPREQ 915
sl@0
   914
sl@0
   915
  @SYMTestCaseDesc Invisible. All windows are in EColor16MA display mode.
sl@0
   916
sl@0
   917
  @SYMTestPriority High
sl@0
   918
sl@0
   919
  @SYMTestStatus Implemented
sl@0
   920
sl@0
   921
  @SYMTestActions Transparent alpha channel windows are made invisible and visible both in front and behind one another
sl@0
   922
sl@0
   923
  @SYMTestExpectedResults The windows are redrawn correctly, as compared to a reference drawing
sl@0
   924
sl@0
   925
*/
sl@0
   926
	case 2:
sl@0
   927
		((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0287"));
sl@0
   928
		ConfigureDisplayModes(EColor16MA);
sl@0
   929
		if(TransparencySupportedL()==KErrNone)
sl@0
   930
			{
sl@0
   931
			_LIT(KInvisible16MA,"(2) Invisible Color16MA");
sl@0
   932
			iTest->LogSubTest(KInvisible16MA);
sl@0
   933
			TestInvisible();
sl@0
   934
			}
sl@0
   935
		break;
sl@0
   936
sl@0
   937
/**
sl@0
   938
sl@0
   939
  @SYMTestCaseID GRAPHICS-WSERV-0280
sl@0
   940
sl@0
   941
  @SYMDEF             DEF081259
sl@0
   942
sl@0
   943
  @SYMPREQ 915
sl@0
   944
sl@0
   945
  @SYMTestCaseDesc Initial Configuration. All windows are in EColor64K display mode.
sl@0
   946
sl@0
   947
  @SYMTestPriority High
sl@0
   948
sl@0
   949
  @SYMTestStatus Implemented
sl@0
   950
sl@0
   951
  @SYMTestActions Several windows are set to be transparent alpha channel, and given semi-transparent or transparent background colours
sl@0
   952
sl@0
   953
  @SYMTestExpectedResults The transparent window configuration matches a reference drawing created using only alpha blending
sl@0
   954
sl@0
   955
*/
sl@0
   956
	//Test 3 to 6 can't be run without transparency support
sl@0
   957
	case 3:
sl@0
   958
		((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0280"));
sl@0
   959
		ConfigureDisplayModes(EColor64K);
sl@0
   960
		if(TransparencySupportedL()==KErrNone)
sl@0
   961
			{
sl@0
   962
			_LIT(KInitialConfiguration64K,"(3) Initial configuration Color64K");
sl@0
   963
			iTest->LogSubTest(KInitialConfiguration64K);
sl@0
   964
			TestInitialConfiguration();
sl@0
   965
			}
sl@0
   966
		break;
sl@0
   967
/**
sl@0
   968
sl@0
   969
  @SYMTestCaseID GRAPHICS-WSERV-0281
sl@0
   970
sl@0
   971
  @SYMDEF             DEF081259
sl@0
   972
sl@0
   973
  @SYMPREQ 915
sl@0
   974
sl@0
   975
  @SYMTestCaseDesc Move. All windows are in EColor64K display mode.
sl@0
   976
sl@0
   977
  @SYMTestPriority High
sl@0
   978
sl@0
   979
  @SYMTestStatus Implemented
sl@0
   980
sl@0
   981
  @SYMTestActions Transparent alpha channel windows are moved both in front and behind one another
sl@0
   982
sl@0
   983
  @SYMTestExpectedResults The windows are redrawn correctly, as compared to a reference drawing
sl@0
   984
sl@0
   985
*/
sl@0
   986
	case 4:
sl@0
   987
		((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0281"));
sl@0
   988
		if(TransparencySupportedL()==KErrNone)
sl@0
   989
			{
sl@0
   990
			_LIT(KMove64K,"(4) Move Color64K");
sl@0
   991
			iTest->LogSubTest(KMove64K);
sl@0
   992
			TestMove();
sl@0
   993
			}
sl@0
   994
		break;
sl@0
   995
/**
sl@0
   996
sl@0
   997
  @SYMTestCaseID GRAPHICS-WSERV-0282
sl@0
   998
sl@0
   999
  @SYMDEF             DEF081259
sl@0
  1000
sl@0
  1001
  @SYMPREQ 915
sl@0
  1002
sl@0
  1003
  @SYMTestCaseDesc Redraw. All windows are in EColor64K display mode.
sl@0
  1004
sl@0
  1005
  @SYMTestPriority High
sl@0
  1006
sl@0
  1007
  @SYMTestStatus Implemented
sl@0
  1008
sl@0
  1009
  @SYMTestActions Transparent alpha channel windows are redrawn both in front and behind one another
sl@0
  1010
sl@0
  1011
  @SYMTestExpectedResults The windows are redrawn correctly, as compared to a reference drawing
sl@0
  1012
sl@0
  1013
*/
sl@0
  1014
	case 5:
sl@0
  1015
		((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0282"));
sl@0
  1016
		if(TransparencySupportedL()==KErrNone)
sl@0
  1017
			{
sl@0
  1018
			_LIT(KRedraw64K,"(5) Redraw Color64K");
sl@0
  1019
			iTest->LogSubTest(KRedraw64K);
sl@0
  1020
			TestRedraw();
sl@0
  1021
			}
sl@0
  1022
		break;
sl@0
  1023
/**
sl@0
  1024
sl@0
  1025
  @SYMTestCaseID GRAPHICS-WSERV-0283-0001
sl@0
  1026
sl@0
  1027
  @SYMDEF             DEF081259
sl@0
  1028
sl@0
  1029
  @SYMPREQ 915
sl@0
  1030
sl@0
  1031
  @SYMTestCaseDesc Invisible. All windows are in EColor64K display mode.
sl@0
  1032
sl@0
  1033
  @SYMTestPriority High
sl@0
  1034
sl@0
  1035
  @SYMTestStatus Implemented
sl@0
  1036
sl@0
  1037
  @SYMTestActions Transparent alpha channel windows are made invisible and visible both in front and behind one another
sl@0
  1038
sl@0
  1039
  @SYMTestExpectedResults The windows are redrawn correctly, as compared to a reference drawing
sl@0
  1040
sl@0
  1041
*/
sl@0
  1042
	case 6:
sl@0
  1043
		((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0283-0001"));
sl@0
  1044
		if(TransparencySupportedL()==KErrNone)
sl@0
  1045
			{
sl@0
  1046
			_LIT(KInvisible64K,"(6) Invisible Color64K");
sl@0
  1047
			iTest->LogSubTest(KInvisible64K);
sl@0
  1048
			TestInvisible();
sl@0
  1049
			}
sl@0
  1050
		break;
sl@0
  1051
/**
sl@0
  1052
sl@0
  1053
  @SYMTestCaseID GRAPHICS-WSERV-0283-0002
sl@0
  1054
sl@0
  1055
  @SYMDEF             DEF081259
sl@0
  1056
sl@0
  1057
  @SYMPREQ 915
sl@0
  1058
sl@0
  1059
  @SYMTestCaseDesc Children. All windows are in EColor64K display mode.
sl@0
  1060
sl@0
  1061
  @SYMTestPriority High
sl@0
  1062
sl@0
  1063
  @SYMTestStatus Implemented
sl@0
  1064
sl@0
  1065
  @SYMTestActions Transparent alpha channel windows are given child windows, both transparent and non-transparent,
sl@0
  1066
 			    	and are then moved, redrawn, set visible or invisible both in front and behind one another
sl@0
  1067
sl@0
  1068
  @SYMTestExpectedResults The windows are redrawn correctly, as compared to a reference drawing
sl@0
  1069
sl@0
  1070
*/
sl@0
  1071
	case 7:
sl@0
  1072
		((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0283-0002"));
sl@0
  1073
		_LIT(KChildren64K,"(7)Children Color64K");
sl@0
  1074
		iTest->LogSubTest(KChildren64K);
sl@0
  1075
		TestChildrenL();
sl@0
  1076
		break;
sl@0
  1077
/**
sl@0
  1078
sl@0
  1079
  @SYMTestCaseID GRAPHICS-WSERV-0356
sl@0
  1080
sl@0
  1081
  @SYMDEF             DEF081259
sl@0
  1082
sl@0
  1083
  @SYMPREQ 915
sl@0
  1084
sl@0
  1085
  @SYMTestCaseDesc Initial Configuration. All windows are in EColor64k Dispaly Mode
sl@0
  1086
sl@0
  1087
  @SYMTestPriority High
sl@0
  1088
sl@0
  1089
  @SYMTestStatus Implemented
sl@0
  1090
sl@0
  1091
  @SYMTestActions Tests Anti-aliasing of text
sl@0
  1092
sl@0
  1093
  @SYMTestExpectedResults Anti-alisaing should behave correctly
sl@0
  1094
sl@0
  1095
*/
sl@0
  1096
	case 8:
sl@0
  1097
		((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0356"));
sl@0
  1098
		_LIT(KAntiAliasedText64K,"(8) AntiAliasedText DEF082251 Color64K");
sl@0
  1099
		iTest->LogSubTest(KAntiAliasedText64K);
sl@0
  1100
		TestAntiAliasedTextTransparentL();
sl@0
  1101
		break;
sl@0
  1102
sl@0
  1103
/**
sl@0
  1104
sl@0
  1105
  @SYMTestCaseID GRAPHICS-WSERV-0284
sl@0
  1106
sl@0
  1107
  @SYMDEF             DEF081259
sl@0
  1108
sl@0
  1109
  @SYMPREQ 915
sl@0
  1110
sl@0
  1111
  @SYMTestCaseDesc Initial Configuration. All windows are in EColor16MA display mode.
sl@0
  1112
sl@0
  1113
  @SYMTestPriority High
sl@0
  1114
sl@0
  1115
  @SYMTestStatus Implemented
sl@0
  1116
sl@0
  1117
  @SYMTestActions Several windows are set to be transparent alpha channel, and given semi-transparent or transparent background colours
sl@0
  1118
sl@0
  1119
  @SYMTestExpectedResults The transparent window configuration matches a reference drawing created using only alpha blending
sl@0
  1120
sl@0
  1121
*/
sl@0
  1122
	case 9:
sl@0
  1123
		{ 
sl@0
  1124
		((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0284"));
sl@0
  1125
		ConfigureDisplayModes(EColor16MA);
sl@0
  1126
		TDisplayMode mode1 = TheClient->iScreen->DisplayMode();
sl@0
  1127
	 	_LIT(KInitialConfiguration16MA,"(9)Initial configuration Color16MA");
sl@0
  1128
		iTest->LogSubTest(KInitialConfiguration16MA);
sl@0
  1129
		TestInitialConfiguration();
sl@0
  1130
		break;
sl@0
  1131
		}
sl@0
  1132
/**
sl@0
  1133
sl@0
  1134
  @SYMTestCaseID GRAPHICS-WSERV-0285
sl@0
  1135
sl@0
  1136
  @SYMDEF             DEF081259
sl@0
  1137
sl@0
  1138
  @SYMPREQ 915
sl@0
  1139
sl@0
  1140
  @SYMTestCaseDesc Move. All windows are in EColor16MA display mode.
sl@0
  1141
sl@0
  1142
  @SYMTestPriority High
sl@0
  1143
sl@0
  1144
  @SYMTestStatus Implemented
sl@0
  1145
sl@0
  1146
  @SYMTestActions Transparent alpha channel windows are moved both in front and behind one another
sl@0
  1147
sl@0
  1148
  @SYMTestExpectedResults The windows are redrawn correctly, as compared to a reference drawing
sl@0
  1149
sl@0
  1150
*/
sl@0
  1151
	case 10:
sl@0
  1152
		((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0285"));
sl@0
  1153
		_LIT(KMove16MA,"(10)Move Color16MA");
sl@0
  1154
		iTest->LogSubTest(KMove16MA);
sl@0
  1155
		TestMove();
sl@0
  1156
		break;
sl@0
  1157
/**
sl@0
  1158
sl@0
  1159
  @SYMTestCaseID GRAPHICS-WSERV-0286
sl@0
  1160
sl@0
  1161
  @SYMDEF             DEF081259
sl@0
  1162
sl@0
  1163
  @SYMPREQ 915
sl@0
  1164
sl@0
  1165
  @SYMTestCaseDesc Redraw. All windows are in EColor16MA display mode.
sl@0
  1166
sl@0
  1167
  @SYMTestPriority High
sl@0
  1168
sl@0
  1169
  @SYMTestStatus Implemented
sl@0
  1170
sl@0
  1171
  @SYMTestActions Transparent alpha channel windows are redrawn both in front and behind one another
sl@0
  1172
sl@0
  1173
  @SYMTestExpectedResults The windows are redrawn correctly, as compared to a reference drawing
sl@0
  1174
sl@0
  1175
*/
sl@0
  1176
	case 11:
sl@0
  1177
		((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0286"));
sl@0
  1178
		_LIT(KRedraw16MA,"(11)Redraw Color16MA");
sl@0
  1179
		iTest->LogSubTest(KRedraw16MA);
sl@0
  1180
		TestRedraw();
sl@0
  1181
		break;
sl@0
  1182
		
sl@0
  1183
/**
sl@0
  1184
sl@0
  1185
  @SYMTestCaseID GRAPHICS-WSERV-0279
sl@0
  1186
sl@0
  1187
  @SYMDEF             DEF081259
sl@0
  1188
sl@0
  1189
  @SYMPREQ 915
sl@0
  1190
sl@0
  1191
  @SYMTestCaseDesc Transparent drawing
sl@0
  1192
sl@0
  1193
  @SYMTestPriority High
sl@0
  1194
sl@0
  1195
  @SYMTestStatus Implemented
sl@0
  1196
sl@0
  1197
  @SYMTestActions Use draw operations with transparent pen or brush colours
sl@0
  1198
sl@0
  1199
  @SYMTestExpectedResults Draw operations with transparent pen or brush colours should leave the destination unchanged
sl@0
  1200
sl@0
  1201
*/
sl@0
  1202
sl@0
  1203
	case 12:
sl@0
  1204
		((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0279"));
sl@0
  1205
		ConfigureDisplayModes(EColor64K);
sl@0
  1206
		_LIT(KTrans64K,"(12) Transparent drawing Color64K");
sl@0
  1207
		iTest->LogSubTest(KTrans64K);
sl@0
  1208
		TestTransparentDrawingL();
sl@0
  1209
		break;
sl@0
  1210
sl@0
  1211
sl@0
  1212
/**
sl@0
  1213
sl@0
  1214
  @SYMTestCaseID GRAPHICS-WSERV-0288
sl@0
  1215
sl@0
  1216
  @SYMDEF             DEF081259
sl@0
  1217
sl@0
  1218
  @SYMPREQ 915
sl@0
  1219
sl@0
  1220
  @SYMTestCaseDesc Children. All windows are in EColor16MA display mode.
sl@0
  1221
sl@0
  1222
  @SYMTestPriority High
sl@0
  1223
sl@0
  1224
  @SYMTestStatus Implemented
sl@0
  1225
sl@0
  1226
  @SYMTestActions Transparent alpha channel windows are given child windows, both transparent and non-transparent,
sl@0
  1227
 			    	and are then moved, redrawn, set visible or invisible both in front and behind one another
sl@0
  1228
sl@0
  1229
  @SYMTestExpectedResults The windows are redrawn correctly, as compared to a reference drawing
sl@0
  1230
sl@0
  1231
*/
sl@0
  1232
	case 13:
sl@0
  1233
		((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0288"));
sl@0
  1234
		_LIT(KChildren16MA,"(13) Children Color16MA");
sl@0
  1235
		iTest->LogSubTest(KChildren16MA);
sl@0
  1236
		TestChildrenL();
sl@0
  1237
		break;
sl@0
  1238
/**
sl@0
  1239
sl@0
  1240
  @SYMTestCaseID GRAPHICS-WSERV-0357
sl@0
  1241
sl@0
  1242
  @SYMDEF             DEF081259
sl@0
  1243
sl@0
  1244
  @SYMPREQ 915
sl@0
  1245
sl@0
  1246
  @SYMTestCaseDesc Initial Configuration. All windows are in EColor16MA Dispaly Mode
sl@0
  1247
sl@0
  1248
  @SYMTestPriority High
sl@0
  1249
sl@0
  1250
  @SYMTestStatus Implemented
sl@0
  1251
sl@0
  1252
  @SYMTestActions Tests Anti-aliasing of text
sl@0
  1253
sl@0
  1254
  @SYMTestExpectedResults Anti-alisaing should behave correctly
sl@0
  1255
sl@0
  1256
*/
sl@0
  1257
	case 14:
sl@0
  1258
		((CTAlphaWinStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0357"));
sl@0
  1259
		_LIT(KAntiAliasedText16MA,"(14) AntiAliasedText DEF082251 Color16MA");
sl@0
  1260
		iTest->LogSubTest(KAntiAliasedText16MA);
sl@0
  1261
		TestAntiAliasedTextTransparentL();
sl@0
  1262
		break;
sl@0
  1263
	default:
sl@0
  1264
		((CTAlphaWinStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
sl@0
  1265
		((CTAlphaWinStep*)iStep)->CloseTMSGraphicsStep();
sl@0
  1266
		TestComplete();
sl@0
  1267
		break;
sl@0
  1268
		}
sl@0
  1269
	((CTAlphaWinStep*)iStep)->RecordTestResultL();
sl@0
  1270
	}
sl@0
  1271
sl@0
  1272
__WS_CONSTRUCT_STEP__(AlphaWin)
sl@0
  1273