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