os/graphics/windowing/windowserver/test/tdynamicres/src/t_wsdynamicreswinbase.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) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
/**
sl@0
    17
 @file
sl@0
    18
*/
sl@0
    19
sl@0
    20
sl@0
    21
#include <e32std.h>
sl@0
    22
#include <e32math.h>
sl@0
    23
#include <w32std.h>
sl@0
    24
#include <w32debug.h>
sl@0
    25
#include "teflogextensions.h"
sl@0
    26
#include "t_wsdynamicreswinbase.h"
sl@0
    27
#include "globalsettings.h"
sl@0
    28
#include <bitdraw.h>
sl@0
    29
#include <bitdrawinterfaceid.h>
sl@0
    30
#include <u32hal.h>
sl@0
    31
#include <dispchannel.h>
sl@0
    32
#include <graphics/displaycontrol.h>
sl@0
    33
sl@0
    34
#if (!defined(K_DISPLAY_CH_MAJOR_VERSION_NUMBER) && !defined(K_DISPLAY_CH_MINOR_VERSION_NUMBER))
sl@0
    35
#define MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER
sl@0
    36
#endif
sl@0
    37
sl@0
    38
_LIT(KMonospaceTestFontTypefaceName,"Arial");
sl@0
    39
const TInt KMaxFontSize = 150;
sl@0
    40
TBool	CWsDynamicResWinBase::iTransparencyEnabled=EFalse;
sl@0
    41
sl@0
    42
CWsDynamicResWinBase::CWsDynamicResWinBase():
sl@0
    43
	iDoTearDown(EFalse),
sl@0
    44
	iSession(TGlobalSettings::Instance().iScreen)
sl@0
    45
{
sl@0
    46
}
sl@0
    47
sl@0
    48
void CWsDynamicResWinBase::SetupL()
sl@0
    49
	{
sl@0
    50
	SetupL(EFalse);
sl@0
    51
	}
sl@0
    52
CActiveScheduler	CWsDynamicResWinBase::iScheduler;
sl@0
    53
sl@0
    54
void CWsDynamicResWinBase::SetupL(TBool aUseOtherScreenForInfo)
sl@0
    55
	{	
sl@0
    56
	if (CActiveScheduler::Current()!=&iScheduler)
sl@0
    57
		{
sl@0
    58
		new (&iScheduler) CActiveScheduler;
sl@0
    59
		CActiveScheduler::Install(&iScheduler);
sl@0
    60
		}
sl@0
    61
	iDoTearDown=ETrue;
sl@0
    62
	iRed.SetInternal(0xFFFF0000);
sl@0
    63
	iGreen.SetInternal(0xFF00FF00);
sl@0
    64
	iBlue.SetInternal(0xFF0000FF);
sl@0
    65
	iCyan.SetInternal(0xFF00FFFF);
sl@0
    66
	iMagenta.SetInternal(0xFFFF00FF);
sl@0
    67
	iYellow.SetInternal(0xFFFFFF00);
sl@0
    68
	iWhite.SetInternal(0xFFFFFFFF);
sl@0
    69
	iLastGceHoleColor.SetInternal(0);
sl@0
    70
	TITLE_BACKGROUND=iCyan;
sl@0
    71
	COMPARE_BACKGROUND=iBlue;
sl@0
    72
sl@0
    73
	ASSERT_EQUALS_X(iSession.Connect(), KErrNone);
sl@0
    74
sl@0
    75
		{//Stolen from TAuto CloseAllPanicWindows()
sl@0
    76
		TInt idFocus = iSession.GetFocusWindowGroup();
sl@0
    77
		TWsEvent event;
sl@0
    78
		event.SetType(EEventKey); //EEventKeyDown
sl@0
    79
		TKeyEvent *keyEvent = event.Key();
sl@0
    80
		keyEvent->iCode = EKeyEscape;
sl@0
    81
		keyEvent->iScanCode = EStdKeyEscape;
sl@0
    82
		keyEvent->iModifiers = 0;
sl@0
    83
		TInt theLimit = 50;
sl@0
    84
		while(idFocus != NULL && (theLimit-- > 0))
sl@0
    85
			{
sl@0
    86
			iSession.SendEventToAllWindowGroups(event);
sl@0
    87
			TInt idNewFocus = iSession.GetFocusWindowGroup();
sl@0
    88
			if (idNewFocus!=idFocus)
sl@0
    89
				{
sl@0
    90
				INFO_PRINTF1(_L("A window was closed [probably a panic box from the previous test]."));
sl@0
    91
				}
sl@0
    92
			idFocus=idNewFocus;
sl@0
    93
			}
sl@0
    94
		}
sl@0
    95
	TInt err = KErrNone;
sl@0
    96
sl@0
    97
	TRAP(err, iScreenDevice = new (ELeave) CWsScreenDevice(iSession));
sl@0
    98
	PRINT_ON_ERROR2_L(err, _L("Failed to create screen device: %d"), err);
sl@0
    99
	ASSERT_EQUALS_X(iScreenDevice->Construct(TGlobalSettings::Instance().iScreen), KErrNone);
sl@0
   100
	iDisplayMode = iScreenDevice->DisplayMode();	// Get default display mode
sl@0
   101
sl@0
   102
	CheckAndConnectScreen();
sl@0
   103
sl@0
   104
	TRAP(err, iGc = new (ELeave) CWindowGc(iScreenDevice));
sl@0
   105
	PRINT_ON_ERROR2_L(err, _L("Failed to create graphics context: %d"), err);
sl@0
   106
	ASSERT_EQUALS_X(iGc->Construct(), KErrNone);
sl@0
   107
	
sl@0
   108
	iGroup = RWindowGroup(iSession);
sl@0
   109
	ASSERT_EQUALS_X(iGroup.Construct(++iWindowHandle,iScreenDevice), KErrNone);
sl@0
   110
	iGroup.SetOrdinalPositionErr(0, KPasswordWindowGroupPriority - 1); // Added code ---- Fastpath
sl@0
   111
	iSession.Flush();
sl@0
   112
	
sl@0
   113
	if (aUseOtherScreenForInfo)
sl@0
   114
		{
sl@0
   115
		if (iSession.NumberOfScreens()>1)
sl@0
   116
			{	//Create server objects for info windows to appear on alternate screen
sl@0
   117
			TInt alternateScreenNum=iSession.NumberOfScreens()-1;
sl@0
   118
			if (TGlobalSettings::Instance().iScreen==alternateScreenNum)
sl@0
   119
				{	//Alternate screen is last screen, or first screen if that is being tested. 
sl@0
   120
				alternateScreenNum=0;
sl@0
   121
				}
sl@0
   122
			
sl@0
   123
			TRAP(err, iInfoScreenDevice = new (ELeave) CWsScreenDevice(iSession));
sl@0
   124
			PRINT_ON_ERROR2_L(err, _L("Failed to create second screen device: %d"), err);
sl@0
   125
			ASSERT_EQUALS_X(iInfoScreenDevice->Construct(alternateScreenNum), KErrNone);
sl@0
   126
	
sl@0
   127
			TRAP(err, iInfoGc = new (ELeave) CWindowGc(iInfoScreenDevice));
sl@0
   128
			PRINT_ON_ERROR2_L(err, _L("Failed to create second graphics context: %d"), err);
sl@0
   129
			ASSERT_EQUALS_X(iInfoGc->Construct(), KErrNone);
sl@0
   130
sl@0
   131
			iInfoGroupInstance = RWindowGroup(iSession);
sl@0
   132
			ASSERT_EQUALS_X(iInfoGroupInstance.Construct(++iWindowHandle,iInfoScreenDevice), KErrNone);
sl@0
   133
			iInfoGroup=&iInfoGroupInstance;
sl@0
   134
			}
sl@0
   135
		else
sl@0
   136
			{	//If alternate screen is not available then no text or compare windows should be created!
sl@0
   137
			iInfoScreenDevice=iScreenDevice;	//it is "convenient" for the device to still be good.
sl@0
   138
			iInfoGc=NULL;
sl@0
   139
			iInfoGroup=NULL;
sl@0
   140
			}
sl@0
   141
		}
sl@0
   142
	else
sl@0
   143
		{	//
sl@0
   144
		iInfoScreenDevice=iScreenDevice;
sl@0
   145
		iInfoGc=iGc;
sl@0
   146
		iInfoGroup=&iGroup;
sl@0
   147
		}
sl@0
   148
	
sl@0
   149
	if (iInfoGroup && iInfoGc)
sl@0
   150
		{
sl@0
   151
		// Add a plain background window to obscure anything else that
sl@0
   152
		// happens to be behind the test. Setting this window's display mode is also
sl@0
   153
		// used to set the screen device display mode, and hence the composition
sl@0
   154
		// mode: alpha or chroma key.
sl@0
   155
		iBackground = RBlankWindow(iSession);
sl@0
   156
		ASSERT_EQUALS_X(iBackground.Construct(*iInfoGroup, ++iWindowHandle), KErrNone);
sl@0
   157
	
sl@0
   158
		iBackground.SetOrdinalPosition(100);	// Behind anything else in this group.
sl@0
   159
		iBackground.SetColor(TRgb(iWhite));
sl@0
   160
		//iBackground.SetExtent(TPoint(-1000,-1000),TSize(3000,3000));
sl@0
   161
		iBackground.Activate();
sl@0
   162
		iBackground.SetVisible(ETrue);
sl@0
   163
		}
sl@0
   164
	iSession.Flush();
sl@0
   165
	
sl@0
   166
	RWindow testTrans(iSession);
sl@0
   167
	ASSERT_EQUALS_X(testTrans.Construct(iGroup, ++iWindowHandle), KErrNone);
sl@0
   168
	iTransparencyEnabled=(testTrans.SetTransparencyFactor(iWhite)==KErrNone);
sl@0
   169
	if (iTransparencyEnabled)
sl@0
   170
		{
sl@0
   171
		TTestName testName;
sl@0
   172
		testName.Format(_L("Screen %i, depth %i: Found Trans Man"),
sl@0
   173
				TGlobalSettings::Instance().iScreen
sl@0
   174
			);
sl@0
   175
		UpdateTitleWindowL(testName,KMaxInfoLines-1);
sl@0
   176
		}
sl@0
   177
	else
sl@0
   178
		{
sl@0
   179
		TTestName testName;
sl@0
   180
		testName.Format(_L("Screen %i, depth %i: No Trans Man"),
sl@0
   181
				TGlobalSettings::Instance().iScreen
sl@0
   182
			);
sl@0
   183
		UpdateTitleWindowL(testName,KMaxInfoLines-1);
sl@0
   184
		}
sl@0
   185
	testTrans.Close();
sl@0
   186
	}
sl@0
   187
sl@0
   188
sl@0
   189
void CWsDynamicResWinBase::CheckAndConnectScreen()
sl@0
   190
	{
sl@0
   191
	if (TGlobalSettings::Instance().iDisconnected) //set from script file to match wsini keyword SIMULATE_STARTUP_DISCONNECTED
sl@0
   192
		{
sl@0
   193
		//Verify that the display really is disconnected
sl@0
   194
		ASSERT_TRUE_X(iScreenDevice != NULL);
sl@0
   195
		MDisplayControl* interface = static_cast<MDisplayControl*>(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
sl@0
   196
		ASSERT_TRUE_X(interface != NULL);
sl@0
   197
		RArray<MDisplayControl::TResolution> resolutions;
sl@0
   198
		const TInt err = interface->GetResolutions(resolutions);
sl@0
   199
		ASSERT_EQUALS_X(err, KErrDisconnected);
sl@0
   200
		resolutions.Close();
sl@0
   201
		}
sl@0
   202
	
sl@0
   203
#ifndef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER
sl@0
   204
	//make sure display is attached to screen (only if I/F is available at compile time...)
sl@0
   205
	TInt displayState = ENormalResolution;
sl@0
   206
	UserSvr::HalFunction(EHalGroupDisplay | (TGlobalSettings::Instance().iScreen<<16), EDisplayHalSetDisplayState, &displayState, NULL);
sl@0
   207
	Pause(200);
sl@0
   208
#endif	
sl@0
   209
	
sl@0
   210
	if (TGlobalSettings::Instance().iDisconnected)
sl@0
   211
		{
sl@0
   212
		//Verify that the display now is connected
sl@0
   213
		MDisplayControl* interface = static_cast<MDisplayControl*>(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
sl@0
   214
		RArray<MDisplayControl::TResolution> resolutions;
sl@0
   215
		const TInt err = interface->GetResolutions(resolutions);
sl@0
   216
		ASSERT_EQUALS_X(err, KErrNone);
sl@0
   217
		const_cast<TGlobalSettings&>(TGlobalSettings::Instance()).iDisconnected = EFalse;
sl@0
   218
		resolutions.Close();
sl@0
   219
		}
sl@0
   220
	}
sl@0
   221
sl@0
   222
/**
sl@0
   223
Common tear down code for all tests.
sl@0
   224
sl@0
   225
Windows, group and session created are closed. Screen device is destroyed.
sl@0
   226
Surfaces, manager and update session are closed.
sl@0
   227
*/
sl@0
   228
void CWsDynamicResWinBase::TearDownL()
sl@0
   229
	{
sl@0
   230
	iDoTearDown=EFalse;
sl@0
   231
	if (iInfoGc!=iGc)
sl@0
   232
		delete iInfoGc;
sl@0
   233
	delete iGc;
sl@0
   234
	if (iInfoScreenDevice!=iScreenDevice)
sl@0
   235
		delete iInfoScreenDevice;
sl@0
   236
	delete iScreenDevice;
sl@0
   237
sl@0
   238
	iGroup.Close();
sl@0
   239
	if (iInfoGroupInstance.WsHandle())
sl@0
   240
		iInfoGroupInstance.Close();
sl@0
   241
	iSession.Flush();
sl@0
   242
	iSession.Close();
sl@0
   243
	}
sl@0
   244
/**
sl@0
   245
 * Note that this is not the ideal mechanism.
sl@0
   246
 * A derived class may thinks its TearDown is safe to do from delete, but in the class it is derived from it may not be safe
sl@0
   247
 **/
sl@0
   248
void CWsDynamicResWinBase::TearDownFromDeleteL()	
sl@0
   249
	{
sl@0
   250
	CWsDynamicResWinBase::TearDownL();	//Explicitly call the non-derived implementation.
sl@0
   251
	}
sl@0
   252
sl@0
   253
CWsDynamicResWinBase::~CWsDynamicResWinBase()
sl@0
   254
{
sl@0
   255
	if (iDoTearDown)
sl@0
   256
		TearDownFromDeleteL();	//This mechanism is not entirely clean to use.
sl@0
   257
}
sl@0
   258
/**
sl@0
   259
Pause for the given number of milliseconds.
sl@0
   260
sl@0
   261
@param aMilliseconds	Time to wait in milliseconds.
sl@0
   262
*/
sl@0
   263
void CWsDynamicResWinBase::Pause(TInt aMilliseconds)
sl@0
   264
	{
sl@0
   265
	User::After(TTimeIntervalMicroSeconds32(aMilliseconds * 1000));
sl@0
   266
	}
sl@0
   267
// This handles any non-member uses of the extended ASSERT_XXX macros
sl@0
   268
void TefUnitFailLeaveL()
sl@0
   269
	{
sl@0
   270
	
sl@0
   271
	User::Leave(KErrTEFUnitFail);
sl@0
   272
	}
sl@0
   273
/**
sl@0
   274
 * side-effect: log the state info just before I leave!
sl@0
   275
 * Note that this only logs intentional assertion failures.
sl@0
   276
 * Fails due to panics or throws won't log this info.
sl@0
   277
 **/
sl@0
   278
void CWsDynamicResWinBase::TefUnitFailLeaveL()
sl@0
   279
	{
sl@0
   280
	for (TInt line=0;line<KMaxInfoLines;line++)
sl@0
   281
		if (iTestInfo[line].Length())
sl@0
   282
			Logger().LogExtra((TText8*)"Test state at fail - line",line, ESevrAll, iTestInfo[line]);
sl@0
   283
	
sl@0
   284
	User::Leave(KErrTEFUnitFail);
sl@0
   285
	}
sl@0
   286
sl@0
   287
/**	Creates the LHS info window, annd a middle window to display a representation of the expected result.
sl@0
   288
 *  Also sets up a rectangle representing the space on the right to be used for the test
sl@0
   289
 * 	@param	aTitle	The title to display on the info window
sl@0
   290
 *  @param	aDetail	Optional text to display on the first line under the title
sl@0
   291
**/
sl@0
   292
void CWsDynamicResWinBase::MakeTitleAndCompareWindowsL(TRefByValue<const TDesC16> aTitle,TRefByValue<const TDesC16> aDetail)
sl@0
   293
	{	
sl@0
   294
	iTestName=aTitle;
sl@0
   295
	iTestInfo[0]=aDetail;
sl@0
   296
	
sl@0
   297
	TRect screenSize(iInfoScreenDevice->SizeInPixels());
sl@0
   298
	TPoint oneThird(screenSize.iBr.iX/3,screenSize.iBr.iY/3);
sl@0
   299
	TRect winSize(0,0,oneThird.iX,oneThird.iY);
sl@0
   300
	
sl@0
   301
	if (oneThird.iX>oneThird.iY)
sl@0
   302
		{
sl@0
   303
		oneThird.iY=0;
sl@0
   304
		winSize.iBr.iY=screenSize.iBr.iY;
sl@0
   305
		}
sl@0
   306
	else
sl@0
   307
		{
sl@0
   308
		oneThird.iX=0;
sl@0
   309
		winSize.iBr.iX=screenSize.iBr.iX;
sl@0
   310
		}
sl@0
   311
	winSize.Shrink(5,5);
sl@0
   312
sl@0
   313
	if (iInfoGc)
sl@0
   314
		{
sl@0
   315
		iTitle=RWindow(iSession);
sl@0
   316
		ASSERT_EQUALS_X(iTitle.Construct(*iInfoGroup, ++iWindowHandle), KErrNone);
sl@0
   317
		iTitle.SetBackgroundColor(iCyan);
sl@0
   318
		iTitle.SetExtent(winSize.iTl,winSize.Size());
sl@0
   319
		iTitle.Activate();
sl@0
   320
		
sl@0
   321
		RepaintTitleWindowL();
sl@0
   322
		iTitle.SetVisible(ETrue);
sl@0
   323
	
sl@0
   324
		winSize.Move(oneThird);
sl@0
   325
		iCompare=RWindow(iSession);
sl@0
   326
		ASSERT_EQUALS_X(iCompare.Construct(*iInfoGroup, ++iWindowHandle), KErrNone);
sl@0
   327
		iCompare.SetBackgroundColor(COMPARE_BACKGROUND);
sl@0
   328
		iCompare.SetExtent(winSize.iTl,winSize.Size());
sl@0
   329
		iCompare.Activate();
sl@0
   330
		iCompare.BeginRedraw();
sl@0
   331
		ActivateWithWipe(iInfoGc,iCompare,COMPARE_BACKGROUND);
sl@0
   332
	
sl@0
   333
		TFontSpec fspec(KMonospaceTestFontTypefaceName,KMaxFontSize);
sl@0
   334
		CFont *font=NULL;
sl@0
   335
		ASSERT_EQUALS(iScreenDevice->GetNearestFontToDesignHeightInTwips(font,fspec),KErrNone);
sl@0
   336
		iInfoGc->UseFont(font);
sl@0
   337
		iInfoGc->DrawText(_L("Simulation"),winSize.Size(),winSize.Size().iHeight-5,iGc->ECenter);
sl@0
   338
	
sl@0
   339
		iInfoGc->Deactivate();
sl@0
   340
		iCompare.EndRedraw();
sl@0
   341
		iCompare.SetVisible(ETrue);
sl@0
   342
		if (iScreenDevice!=iInfoScreenDevice)
sl@0
   343
			{
sl@0
   344
			winSize.Move(-oneThird);
sl@0
   345
			}
sl@0
   346
		else
sl@0
   347
			{
sl@0
   348
			winSize.Move(oneThird);
sl@0
   349
			}
sl@0
   350
		}
sl@0
   351
	else
sl@0
   352
		{
sl@0
   353
		winSize=iScreenDevice->SizeInPixels();
sl@0
   354
		}
sl@0
   355
	
sl@0
   356
	iTestPos=winSize;
sl@0
   357
	iTestPointCentre=winSize.Center();
sl@0
   358
	iCenteredFrontWinRect=winSize;
sl@0
   359
	iCenteredFrontWinRect.Shrink(winSize.Size().iWidth/3,winSize.Size().iHeight/3);
sl@0
   360
sl@0
   361
	}
sl@0
   362
/**	Makes the compare window larger by covering the test window area as well.
sl@0
   363
 * 	Copes with vertically aligned screens, but will be naughty if called multiple times!!!
sl@0
   364
 *  @param aGoLarger	If set false, resets the size back.
sl@0
   365
 **/
sl@0
   366
void CWsDynamicResWinBase::LargerCompareWindow(TBool aGoLarger)
sl@0
   367
	{
sl@0
   368
	TPoint currPos=iCompare.AbsPosition();
sl@0
   369
	TSize currSize=iCompare.Size();
sl@0
   370
	if (currPos.iX<currPos.iY)
sl@0
   371
		{
sl@0
   372
		if (aGoLarger)
sl@0
   373
			currSize.iHeight<<=1;
sl@0
   374
		else
sl@0
   375
			currSize.iHeight>>=1;
sl@0
   376
		}
sl@0
   377
	else
sl@0
   378
		{
sl@0
   379
		if (aGoLarger)
sl@0
   380
			currSize.iWidth<<=1;
sl@0
   381
		else
sl@0
   382
			currSize.iWidth>>=1;
sl@0
   383
		}
sl@0
   384
	iCompare.SetSize(currSize);
sl@0
   385
	}
sl@0
   386
	
sl@0
   387
sl@0
   388
/**	Puts a line of text on the LHS window.
sl@0
   389
 *  Repaints the window. The line of text will also be shown in the log if the test fails.
sl@0
   390
 *	@param	aDetail	The text to display
sl@0
   391
 * 	@param	aIndex	The row number to display at
sl@0
   392
 **/
sl@0
   393
void CWsDynamicResWinBase::UpdateTitleWindowL(TRefByValue<const TDesC16> aDetail,TInt aIndex)
sl@0
   394
	{
sl@0
   395
	ASSERT(aIndex>=0 && aIndex<KMaxInfoLines);
sl@0
   396
	iTestInfo[aIndex]=aDetail;
sl@0
   397
sl@0
   398
	RepaintTitleWindowL();
sl@0
   399
	
sl@0
   400
	}
sl@0
   401
/**	Activate the GC onto the Window.
sl@0
   402
 *  In non-transparent mode it also performs a wipe background as the WServ system does not necessarily do this.
sl@0
   403
 * 	@param	aGc		The GC to associate
sl@0
   404
 * 	@param	aWin	The window to associate
sl@0
   405
 * 	@param	aColor	The color to use as the wipe. Default is transparent, which means no wipe.
sl@0
   406
 **/
sl@0
   407
TBool	CWsDynamicResWinBase::ActivateWithWipe(CWindowGc* aGc,RWindow& aWin,TRgb aColor)
sl@0
   408
	{
sl@0
   409
	aGc->Activate(aWin);
sl@0
   410
	aGc->SetBrushColor(aColor);
sl@0
   411
	aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
   412
	if (aColor!=TRgb(0,0) && !iTransparencyEnabled)	//presume that all redraw-stored windows will draw background
sl@0
   413
		{
sl@0
   414
		aGc->Clear();
sl@0
   415
		return ETrue;	//window was cleared
sl@0
   416
		}
sl@0
   417
	return EFalse;	
sl@0
   418
	}
sl@0
   419
sl@0
   420
CWindowGc*	CWsDynamicResWinBase::GcForWindow(RWindow& aWin)
sl@0
   421
	{
sl@0
   422
	if (aWin.WsHandle()==NULL)
sl@0
   423
		return NULL;	//can't activate uninitialised window.
sl@0
   424
	CWindowGc* gc=iGc;
sl@0
   425
	if (iGc!=iInfoGc)
sl@0
   426
		if (&aWin==&iCompare || &aWin==&iTitle)
sl@0
   427
			gc=iInfoGc;
sl@0
   428
		else if (iInfoGroup && aWin.WindowGroupId()==iInfoGroup->WindowGroupId())
sl@0
   429
			gc=iInfoGc;
sl@0
   430
	return gc;
sl@0
   431
	}
sl@0
   432
/** Activates an appropriate predefined GC on the specified window and wipes the background if necessary. 
sl@0
   433
 *  @param	aWin	The window to wipe
sl@0
   434
 * 	@param	aColor	The colour to wipe with (if necessary)
sl@0
   435
 * 	@return	the GC to use for drawing and deactivate at end. This may be NULL if the window is not "live"
sl@0
   436
 **/
sl@0
   437
CWindowGc*	CWsDynamicResWinBase::BeginActivateWithWipe(TBool aInvalidate,RWindow& aWin,TRgb aColor)
sl@0
   438
	{
sl@0
   439
	CWindowGc* gc=GcForWindow(aWin);
sl@0
   440
	iSession.Flush();
sl@0
   441
	if (gc==NULL)
sl@0
   442
		return gc;	//can't activate uninitialised window.
sl@0
   443
	if (aInvalidate)
sl@0
   444
		aWin.Invalidate();
sl@0
   445
	iSession.Flush();
sl@0
   446
	aWin.BeginRedraw();
sl@0
   447
	iSession.Flush();
sl@0
   448
	ActivateWithWipe(gc,aWin,aColor);
sl@0
   449
	return gc;	
sl@0
   450
	}
sl@0
   451
sl@0
   452
/** Activates an appropriate predefined GC on the specified window and wipes the background if necessary. 
sl@0
   453
 *  @param	aWin	The window to wipe
sl@0
   454
 * 	@param	aColor	The colour to wipe with (if necessary)
sl@0
   455
 * 	@return	the GC to use for drawing and deactivate at end. This may be NULL if the window is not "live"
sl@0
   456
 **/
sl@0
   457
CWindowGc*	CWsDynamicResWinBase::BeginActivateWithWipe(TBool aInvalidate,TRect aRect,RWindow& aWin,TRgb aColor)
sl@0
   458
	{
sl@0
   459
	if (aWin.WsHandle()==NULL)
sl@0
   460
		return NULL;	//can't activate uninitialised window.
sl@0
   461
	if (aInvalidate)
sl@0
   462
		aWin.Invalidate(aRect);
sl@0
   463
	aWin.BeginRedraw(aRect);
sl@0
   464
	CWindowGc* gc=iGc;
sl@0
   465
	if (iGc!=iInfoGc)
sl@0
   466
		if (&aWin==&iCompare || &aWin==&iTitle)
sl@0
   467
			gc=iInfoGc;
sl@0
   468
		else if (aWin.WindowGroupId()==iInfoGroup->WindowGroupId())
sl@0
   469
			gc=iInfoGc;
sl@0
   470
	ActivateWithWipe(gc,aWin,aColor);
sl@0
   471
	return gc;	
sl@0
   472
	}
sl@0
   473
sl@0
   474
TBool		CWsDynamicResWinBase::InvalidateRegion(const TRegion& aRegion,RWindow& aWin)
sl@0
   475
	{
sl@0
   476
	if (aWin.WsHandle()==NULL)
sl@0
   477
		return false;	//can't activate uninitialised window.
sl@0
   478
	for (TInt ii = 0; ii < aRegion.Count(); ii++)
sl@0
   479
		{
sl@0
   480
		aWin.Invalidate(aRegion[ii]);
sl@0
   481
		}
sl@0
   482
	return true;
sl@0
   483
	}
sl@0
   484
sl@0
   485
CWindowGc*	CWsDynamicResWinBase::BeginActivateWithWipe(const TRegion& aRegion,RWindow& aWin,TRgb aColor)
sl@0
   486
	{
sl@0
   487
	if (!InvalidateRegion(aRegion,aWin))
sl@0
   488
		return NULL;	//can't activate uninitialised window.
sl@0
   489
sl@0
   490
	aWin.BeginRedraw();
sl@0
   491
	CWindowGc* gc=iGc;
sl@0
   492
	if (iGc!=iInfoGc)
sl@0
   493
		if (&aWin==&iCompare || &aWin==&iTitle)
sl@0
   494
			gc=iInfoGc;
sl@0
   495
		else if (aWin.WindowGroupId()==iInfoGroup->WindowGroupId())
sl@0
   496
			gc=iInfoGc;
sl@0
   497
	ActivateWithWipe(gc,aWin,aColor);
sl@0
   498
	return gc;	
sl@0
   499
	}
sl@0
   500
sl@0
   501
sl@0
   502
/**	Paints the LHS window with rows of text.
sl@0
   503
 * 
sl@0
   504
 **/
sl@0
   505
void CWsDynamicResWinBase::RepaintTitleWindowL()
sl@0
   506
	{
sl@0
   507
	if (iTitle.WsHandle())
sl@0
   508
		{
sl@0
   509
		iTitle.Invalidate();
sl@0
   510
	
sl@0
   511
		iTitle.BeginRedraw();
sl@0
   512
		ActivateWithWipe(iInfoGc,iTitle,TITLE_BACKGROUND);
sl@0
   513
		iInfoGc->SetUnderlineStyle(EUnderlineOn);
sl@0
   514
		TSize winSize=iTitle.Size();
sl@0
   515
		TRect textRect(winSize);
sl@0
   516
		textRect.iBr.iY/=4;
sl@0
   517
		TFontSpec fspec(KMonospaceTestFontTypefaceName,KMaxFontSize);
sl@0
   518
		CFont *font=NULL;
sl@0
   519
		ASSERT_EQUALS(iInfoScreenDevice->GetNearestFontToDesignHeightInTwips(font,fspec),KErrNone);
sl@0
   520
		iInfoGc->UseFont(font);
sl@0
   521
		iInfoGc->DrawText(iTestName,textRect,textRect.iBr.iY/2,iGc->ECenter);
sl@0
   522
		iInfoGc->SetUnderlineStyle(EUnderlineOff);
sl@0
   523
		textRect.iTl.iY=textRect.iBr.iY;
sl@0
   524
		TInt rowHeight=winSize.iHeight*3/(4*(KMaxInfoLines+1));
sl@0
   525
		textRect.iBr.iY+=rowHeight;
sl@0
   526
		for (TInt index=0;index<KMaxInfoLines;index++)
sl@0
   527
			{
sl@0
   528
			if (iTestInfo[index].Length())
sl@0
   529
			    {
sl@0
   530
				iInfoGc->DrawText(iTestInfo[index],textRect,textRect.Size().iHeight*3/4,iInfoGc->ECenter);
sl@0
   531
			    }
sl@0
   532
			textRect.Move(0,rowHeight);
sl@0
   533
			}
sl@0
   534
		iInfoGc->DiscardFont();
sl@0
   535
		iInfoGc->Deactivate();
sl@0
   536
		iTitle.EndRedraw();
sl@0
   537
		iInfoScreenDevice->ReleaseFont(font);
sl@0
   538
	
sl@0
   539
		iSession.Flush();
sl@0
   540
		iSession.Finish();
sl@0
   541
		}
sl@0
   542
	}
sl@0
   543
sl@0
   544
/** Useful test culled from other GCE test classes.
sl@0
   545
 * 	
sl@0
   546
 * 
sl@0
   547
 * 
sl@0
   548
 **/
sl@0
   549
TBool CWsDynamicResWinBase::DisplayHasAlpha() const
sl@0
   550
	{
sl@0
   551
	return (iDisplayMode == EColor16MA || iDisplayMode == EColor16MAP);
sl@0
   552
	}
sl@0
   553
/**	Test using an indipendent method that GCE version of WServ is running
sl@0
   554
 *  This method can only be called after the testcase is started
sl@0
   555
 * 
sl@0
   556
 * 	@return	true if WServ version is GCE technology, false if legacy technology
sl@0
   557
 **/
sl@0
   558
TBool CWsDynamicResWinBase::GCEIsSupported() const
sl@0
   559
	{
sl@0
   560
	CFbsDrawDevice* screenDevice=NULL;
sl@0
   561
	TDisplayMode displayMode=iScreenDevice->DisplayMode();
sl@0
   562
	TRAPD(err, screenDevice = CFbsDrawDevice::NewScreenDeviceL(TGlobalSettings::Instance().iScreen, displayMode));
sl@0
   563
	TBool rv=EFalse;
sl@0
   564
	if(err == KErrNone)
sl@0
   565
		{
sl@0
   566
		TAny* p=NULL;
sl@0
   567
		rv=(screenDevice->GetInterface(KSurfaceInterfaceID, p)==KErrNone);
sl@0
   568
		delete screenDevice;
sl@0
   569
		}
sl@0
   570
	return rv;
sl@0
   571
	}
sl@0
   572
/**	Test using an indipendent method that GCE version of WServ is running
sl@0
   573
 *  This method can be called at any time, even by external code, but creates temporary window session objects
sl@0
   574
 * 
sl@0
   575
 * 	@return	true if WServ version is GCE technology, false if legacy technology
sl@0
   576
 **/
sl@0
   577
TBool CWsDynamicResWinBase::GCEIsSupportedStatic()
sl@0
   578
	{
sl@0
   579
	CFbsDrawDevice* screenDevice=NULL;
sl@0
   580
	RWsSession session;
sl@0
   581
	if (session.Connect()!=KErrNone)
sl@0
   582
		{
sl@0
   583
		return EFalse;
sl@0
   584
		}
sl@0
   585
	TDisplayMode displayMode=ENone;
sl@0
   586
		{CWsScreenDevice screen(session);
sl@0
   587
		if (screen.Construct(TGlobalSettings::Instance().iScreen)!=KErrNone)
sl@0
   588
			{
sl@0
   589
			return EFalse;
sl@0
   590
			}
sl@0
   591
			displayMode=screen.DisplayMode();
sl@0
   592
		}//screen destroyed
sl@0
   593
		TRAPD(err, screenDevice = CFbsDrawDevice::NewScreenDeviceL(TGlobalSettings::Instance().iScreen, displayMode));
sl@0
   594
		TBool rv=EFalse;
sl@0
   595
		if(err == KErrNone)
sl@0
   596
			{
sl@0
   597
			TAny* p=NULL;
sl@0
   598
			rv=(screenDevice->GetInterface(KSurfaceInterfaceID, p)==KErrNone);
sl@0
   599
			delete screenDevice;
sl@0
   600
			}
sl@0
   601
	return rv;
sl@0
   602
	}//session destroyed
sl@0
   603
/**
sl@0
   604
Use the full-screen background window to select a display mode that doesn't use
sl@0
   605
alpha (anything other than EColor16MA or EColor16MAP). Record the mode for use
sl@0
   606
in setting all other windows.
sl@0
   607
@return ETrue if an appropriate mode was selected, EFalse otherwise.
sl@0
   608
*/
sl@0
   609
TBool CWsDynamicResWinBase::SelectChromaCompositionMode()
sl@0
   610
	{
sl@0
   611
	// Request EColor64K, but as long as the actual mode doesn't use alpha, it
sl@0
   612
	// doesn't matter too much which one is used.
sl@0
   613
	if (iInfoGc==iGc)
sl@0
   614
		{
sl@0
   615
		iDisplayMode = (TDisplayMode)iBackground.SetRequiredDisplayMode(EColor64K);
sl@0
   616
		iSession.Flush();		// Force switching to the display mode.
sl@0
   617
		}
sl@0
   618
	return !DisplayHasAlpha();
sl@0
   619
	}
sl@0
   620
/**	Returns the colour used by WServ to paint holes in UI layer to reveal the GCE behind.
sl@0
   621
 * 	The window should have a surface attached.
sl@0
   622
 * 	If the method is called after the surface has been detached or the window was removed then 
sl@0
   623
 * 	the previous recorded hole color is returned.
sl@0
   624
 **/
sl@0
   625
TRgb  CWsDynamicResWinBase::GceHoleColor( RWindowBase& aWin)const
sl@0
   626
	{
sl@0
   627
	if (aWin.WsHandle()==NULL)
sl@0
   628
		{
sl@0
   629
		return iLastGceHoleColor;
sl@0
   630
		}
sl@0
   631
	TRgb retVal=aWin.KeyColor();
sl@0
   632
	if (retVal==TRgb(0,0))
sl@0
   633
		{
sl@0
   634
		return iLastGceHoleColor;
sl@0
   635
		}
sl@0
   636
	else
sl@0
   637
		{
sl@0
   638
		iLastGceHoleColor=retVal;
sl@0
   639
		return retVal;
sl@0
   640
		}
sl@0
   641
	}
sl@0
   642
sl@0
   643
sl@0
   644
/**
sl@0
   645
Use the full-screen background window to select a display mode that can use
sl@0
   646
alpha (either EColor16MA or EColor16MAP). Record the mode for use in setting all
sl@0
   647
other windows.
sl@0
   648
@return ETrue if an appropriate mode was selected, EFalse otherwise.
sl@0
   649
*/
sl@0
   650
TBool CWsDynamicResWinBase::SelectAlphaCompositionMode(TDisplayMode aMode)
sl@0
   651
	{
sl@0
   652
	// Request EColor16MA, but as long as the actual mode can use alpha, it
sl@0
   653
	// doesn't matter too much which one is used.
sl@0
   654
	if (iInfoGc==iGc)
sl@0
   655
		{
sl@0
   656
		iDisplayMode = (TDisplayMode)iBackground.SetRequiredDisplayMode(aMode);
sl@0
   657
		iSession.Flush();		// Force switching to the display mode.
sl@0
   658
		}
sl@0
   659
	return DisplayHasAlpha();
sl@0
   660
	}
sl@0
   661
sl@0
   662
/**
sl@0
   663
 * 	Interesting UI pattern used by other GCE tests.
sl@0
   664
 * 
sl@0
   665
 * 
sl@0
   666
 **/
sl@0
   667
void CWsDynamicResWinBase::DrawUIContent(RWindow& aWindow)
sl@0
   668
	{
sl@0
   669
	aWindow.BeginRedraw();
sl@0
   670
	CWindowGc* gc=(&aWindow==&iCompare)?iInfoGc:iGc;
sl@0
   671
	
sl@0
   672
	gc->Activate(aWindow);
sl@0
   673
sl@0
   674
	TBool hasAlpha = DisplayHasAlpha();
sl@0
   675
sl@0
   676
	// Draw a red-green graduated box in the central portion of the window,
sl@0
   677
	// with alpha if available.
sl@0
   678
	TPoint start;
sl@0
   679
	TPoint end;
sl@0
   680
	TInt halfW = KSurfaceWidth / 2;
sl@0
   681
	TInt quarterW = halfW / 2;
sl@0
   682
	TInt halfH = KSurfaceHeight / 2;
sl@0
   683
	TInt quarterH = halfH / 2;
sl@0
   684
sl@0
   685
	// Set constant ordinals for non-alpha case.
sl@0
   686
	start.iX = quarterW;
sl@0
   687
	end.iX = quarterW + halfW;
sl@0
   688
sl@0
   689
	for (TInt yy = 0; yy < halfH; yy++)
sl@0
   690
		{
sl@0
   691
		TInt yval = yy * 255 / (halfH - 1);
sl@0
   692
		start.iY = yy + quarterH;
sl@0
   693
		end.iY = start.iY;
sl@0
   694
sl@0
   695
		if (hasAlpha)
sl@0
   696
			{
sl@0
   697
			for (TInt xx = 0; xx < halfW; xx++)
sl@0
   698
				{
sl@0
   699
				TInt xval = xx * 255 / (halfW - 1);
sl@0
   700
				start.iX = xx + quarterW;
sl@0
   701
				end.iX = start.iX + 1;
sl@0
   702
				gc->SetPenColor(TRgb(yval, 255 - yval, 0, xval));
sl@0
   703
				gc->DrawLine(start, end);
sl@0
   704
				}
sl@0
   705
			}
sl@0
   706
		else
sl@0
   707
			{
sl@0
   708
			gc->SetPenColor(TRgb(yval, 255 - yval, 0));
sl@0
   709
			gc->DrawLine(start, end);
sl@0
   710
			}
sl@0
   711
		}
sl@0
   712
sl@0
   713
	gc->Deactivate();
sl@0
   714
	aWindow.EndRedraw();
sl@0
   715
	}
sl@0
   716
sl@0
   717
/**
sl@0
   718
 * 	Causes the given window to be redrawn.
sl@0
   719
 * 	Doesn't draw anything except the background wipe, when the transparency manager hasn't
sl@0
   720
 * 
sl@0
   721
 **/
sl@0
   722
void CWsDynamicResWinBase::DrawPlainUI(RWindow& aWindow,TBool aInvalidate,TRgb aWipeColor)
sl@0
   723
	{
sl@0
   724
	if (CWindowGc* gc=BeginActivateWithWipe(aInvalidate,aWindow,aWipeColor))
sl@0
   725
		{
sl@0
   726
		//actually does nothing!
sl@0
   727
		gc->Deactivate();
sl@0
   728
		aWindow.EndRedraw();
sl@0
   729
		}
sl@0
   730
	}
sl@0
   731
/**
sl@0
   732
 *  	Interesting UI pattern used by other GCE tests.
sl@0
   733
 * 
sl@0
   734
 * 
sl@0
   735
 **/
sl@0
   736
void CWsDynamicResWinBase::DrawCross(RWindow& aWindow, TRgb aColor, TInt aThickness)
sl@0
   737
	{
sl@0
   738
	aWindow.BeginRedraw();
sl@0
   739
	CWindowGc* gc=(&aWindow==&iCompare)?iInfoGc:iGc;
sl@0
   740
	gc->Activate(aWindow);
sl@0
   741
sl@0
   742
	// Draw a red diagonal cross in the window.
sl@0
   743
	gc->SetPenColor(aColor);
sl@0
   744
	gc->SetPenSize(TSize(aThickness, aThickness));
sl@0
   745
	gc->DrawLine(TPoint(0, 0), TPoint(KSurfaceWidth, KSurfaceHeight));
sl@0
   746
	gc->DrawLine(TPoint(KSurfaceWidth, 0), TPoint(0, KSurfaceHeight));
sl@0
   747
sl@0
   748
	gc->Deactivate();
sl@0
   749
	aWindow.EndRedraw();
sl@0
   750
	}
sl@0
   751
sl@0
   752
/**
sl@0
   753
 * 	Checks the RGB value
sl@0
   754
 * 
sl@0
   755
 * 
sl@0
   756
 **/
sl@0
   757
void CWsDynamicResWinBase::TestPixelL(TPoint aPt, TRgb aColor, TBool aMatch)
sl@0
   758
	{
sl@0
   759
	TRect screenArea(iScreenDevice->SizeInPixels());
sl@0
   760
	if (aPt.iX < screenArea.iTl.iX)
sl@0
   761
		{
sl@0
   762
		aPt.iX = screenArea.iTl.iX;
sl@0
   763
		}
sl@0
   764
	else if (aPt.iX >= screenArea.iBr.iX)
sl@0
   765
		{
sl@0
   766
		aPt.iX = screenArea.iBr.iX - 1;
sl@0
   767
		}
sl@0
   768
	if (aPt.iY < screenArea.iTl.iY)
sl@0
   769
		{
sl@0
   770
		aPt.iY = screenArea.iTl.iY;
sl@0
   771
		}
sl@0
   772
	else if (aPt.iY >= screenArea.iBr.iY)
sl@0
   773
		{
sl@0
   774
		aPt.iY = screenArea.iBr.iY - 1;
sl@0
   775
		}
sl@0
   776
sl@0
   777
	TRgb pixel;
sl@0
   778
	iScreenDevice->GetPixel(pixel, aPt);
sl@0
   779
	if (aMatch)
sl@0
   780
		{
sl@0
   781
		ASSERT_EQUALS_X(pixel.Internal(), aColor.Internal());
sl@0
   782
		}
sl@0
   783
	else
sl@0
   784
		{
sl@0
   785
		ASSERT_NOT_EQUALS_X(pixel.Internal(), aColor.Internal());
sl@0
   786
		}
sl@0
   787
	}
sl@0
   788
sl@0
   789
struct CountColour
sl@0
   790
	{
sl@0
   791
	TRgb	iColor;
sl@0
   792
	TInt	iCount;
sl@0
   793
	TBool operator  < (const CountColour& aRhs)const	
sl@0
   794
		{	return iColor.Value()<aRhs.iColor.Value();	}
sl@0
   795
	
sl@0
   796
	CountColour(TRgb	aColor,TInt	aCount=0): 
sl@0
   797
			iColor(aColor),iCount(aCount) {}
sl@0
   798
	
sl@0
   799
	CountColour(const CountColour& aRhs): 
sl@0
   800
			iColor(aRhs.iColor),iCount(aRhs.iCount) {}
sl@0
   801
	};
sl@0
   802
sl@0
   803
void LogColorL(TRgb aPixel,RArray<CountColour>& aColors)
sl@0
   804
	{
sl@0
   805
	//I am sure one of the find methods would do this, but life is too short!
sl@0
   806
	TInt existingIndex;
sl@0
   807
	for (existingIndex=0;existingIndex<aColors.Count();existingIndex++)
sl@0
   808
		if (aColors[existingIndex].iColor==aPixel)
sl@0
   809
			break;
sl@0
   810
	if (existingIndex==aColors.Count())
sl@0
   811
		aColors.AppendL(CountColour(aPixel,1));
sl@0
   812
	else
sl@0
   813
		aColors[existingIndex].iCount++;
sl@0
   814
	}
sl@0
   815
sl@0
   816
/**
sl@0
   817
 * Tests the outline of the given rectangle to verify that it has the expected inner and outer colors
sl@0
   818
 * There may be a limited number of other colors present.
sl@0
   819
 * If the given count of other colors is exceeded then false is returned
sl@0
   820
 * If the majority of inner and outer edge pixels are not the given colors then returns false
sl@0
   821
 * If the  colors are repeated on inside and outside then returns false
sl@0
   822
 * If there are corners then the insides of the corners are also check for outside color
sl@0
   823
 * Note that the right and bottom edge coordinates are outside the rectangle.
sl@0
   824
 * Note that I am not performing any safety clipping at present. The rectangle must be on-screen!
sl@0
   825
 * A negative value for corner size indicates that the window may or may not have corners that size.
sl@0
   826
 * Only leaves if fatal memory condition!
sl@0
   827
**/
sl@0
   828
TBool CWsDynamicResWinBase::TestRectL(TRect aRect,TRgb aInnerColor,TInt aOtherInnerColors,TRgb aOuterColor,TInt aOtherOuterColors,TInt aExpectedCornerSize)
sl@0
   829
	{
sl@0
   830
	if (aRect.iTl.iX<=0 || aRect.iTl.iY<=0)
sl@0
   831
		return ETrue;	//can't perform the test against the outside of the screen
sl@0
   832
	//quantise the expectation based on the current mode.
sl@0
   833
	TDisplayMode displayMode=iScreenDevice->DisplayMode();
sl@0
   834
	switch (displayMode)
sl@0
   835
		{
sl@0
   836
	case EColor4K:
sl@0
   837
		aInnerColor=aInnerColor.Color4K(aInnerColor.Color4K());
sl@0
   838
		aOuterColor=aOuterColor.Color4K(aOuterColor.Color4K());
sl@0
   839
		break;
sl@0
   840
	case EColor64K:
sl@0
   841
		aInnerColor=aInnerColor.Color64K(aInnerColor.Color64K());
sl@0
   842
		aOuterColor=aOuterColor.Color64K(aOuterColor.Color64K());
sl@0
   843
		break;
sl@0
   844
	case EColor16M:
sl@0
   845
	case EColor16MU:
sl@0
   846
	case EColor16MA:
sl@0
   847
	case EColor16MAP:
sl@0
   848
		break;
sl@0
   849
	default:
sl@0
   850
		ASSERT_EQUALS(EColor16MA,displayMode);		//Can't quantise color for this display mode!
sl@0
   851
		}
sl@0
   852
sl@0
   853
	RArray<CountColour> innerColors;
sl@0
   854
	innerColors.AppendL(aInnerColor);
sl@0
   855
	RArray<CountColour> outerColors;
sl@0
   856
	outerColors.AppendL(aOuterColor);
sl@0
   857
	TInt cornerSize=aExpectedCornerSize>=0?aExpectedCornerSize:-aExpectedCornerSize;
sl@0
   858
	//Check outside first!
sl@0
   859
	TRgb pixelVal;
sl@0
   860
	for(TPoint pixelPos(aRect.iTl.iX-1,aRect.iTl.iY-1);pixelPos.iX<aRect.iBr.iX;pixelPos.iX++)
sl@0
   861
		{
sl@0
   862
		iScreenDevice->GetPixel(pixelVal, pixelPos);
sl@0
   863
		LogColorL(pixelVal,outerColors);
sl@0
   864
		}
sl@0
   865
	for(TPoint pixelPos(aRect.iTl.iX,aRect.iBr.iY);pixelPos.iX<=aRect.iBr.iX;pixelPos.iX++)
sl@0
   866
		{
sl@0
   867
		iScreenDevice->GetPixel(pixelVal, pixelPos);
sl@0
   868
		LogColorL(pixelVal,outerColors);
sl@0
   869
		}
sl@0
   870
	for(TPoint pixelPos(aRect.iTl.iX-1,aRect.iTl.iY);pixelPos.iY<=aRect.iBr.iY;pixelPos.iY++)
sl@0
   871
		{
sl@0
   872
		iScreenDevice->GetPixel(pixelVal, pixelPos);
sl@0
   873
		LogColorL(pixelVal,outerColors);
sl@0
   874
		}
sl@0
   875
	for(TPoint pixelPos(aRect.iBr.iX,aRect.iTl.iY-1);pixelPos.iY<aRect.iBr.iY;pixelPos.iY++)
sl@0
   876
		{
sl@0
   877
		iScreenDevice->GetPixel(pixelVal, pixelPos);
sl@0
   878
		LogColorL(pixelVal,outerColors);
sl@0
   879
		}
sl@0
   880
	TInt cornerStart=1;
sl@0
   881
	if (cornerSize)
sl@0
   882
		{
sl@0
   883
		cornerStart=cornerSize;
sl@0
   884
		if (aExpectedCornerSize>0)
sl@0
   885
			{
sl@0
   886
			iScreenDevice->GetPixel(pixelVal, aRect.iTl);
sl@0
   887
			LogColorL(pixelVal,outerColors);
sl@0
   888
			iScreenDevice->GetPixel(pixelVal, TPoint(aRect.iTl.iX,aRect.iBr.iY-1));
sl@0
   889
			LogColorL(pixelVal,outerColors);
sl@0
   890
			iScreenDevice->GetPixel(pixelVal, TPoint(aRect.iBr.iX-1,aRect.iTl.iY));
sl@0
   891
			LogColorL(pixelVal,outerColors);
sl@0
   892
			iScreenDevice->GetPixel(pixelVal, TPoint(aRect.iBr.iX-1,aRect.iBr.iY-1));
sl@0
   893
			LogColorL(pixelVal,outerColors);
sl@0
   894
			}
sl@0
   895
		}
sl@0
   896
	
sl@0
   897
	//test inside edges (excluding 4 corner pixels - do them seperately)
sl@0
   898
	for(TPoint pixelPos(aRect.iTl.iX+cornerStart,aRect.iTl.iY);pixelPos.iX<aRect.iBr.iX-cornerStart;pixelPos.iX++)
sl@0
   899
		{
sl@0
   900
		iScreenDevice->GetPixel(pixelVal, pixelPos);
sl@0
   901
		LogColorL(pixelVal,innerColors);
sl@0
   902
		}
sl@0
   903
	for(TPoint pixelPos(aRect.iTl.iX+cornerStart,aRect.iBr.iY-1);pixelPos.iX<aRect.iBr.iX-cornerStart;pixelPos.iX++)
sl@0
   904
		{
sl@0
   905
		iScreenDevice->GetPixel(pixelVal, pixelPos);
sl@0
   906
		LogColorL(pixelVal,innerColors);
sl@0
   907
		}
sl@0
   908
	for(TPoint pixelPos(aRect.iTl.iX,aRect.iTl.iY+cornerStart);pixelPos.iY<aRect.iBr.iY-cornerStart;pixelPos.iY++)
sl@0
   909
		{
sl@0
   910
		iScreenDevice->GetPixel(pixelVal, pixelPos);
sl@0
   911
		LogColorL(pixelVal,innerColors);
sl@0
   912
		}
sl@0
   913
	for(TPoint pixelPos(aRect.iBr.iX-1,aRect.iTl.iY+cornerStart);pixelPos.iY<aRect.iBr.iY-cornerStart;pixelPos.iY++)
sl@0
   914
		{
sl@0
   915
		iScreenDevice->GetPixel(pixelVal, pixelPos);
sl@0
   916
		LogColorL(pixelVal,innerColors);
sl@0
   917
		}
sl@0
   918
	//the 4 corner cells - not checking the whole corner area...
sl@0
   919
	if (aExpectedCornerSize>=0)
sl@0
   920
		{
sl@0
   921
		iScreenDevice->GetPixel(pixelVal, TPoint(aRect.iTl.iX+cornerSize,aRect.iTl.iY+cornerSize));
sl@0
   922
		LogColorL(pixelVal,innerColors);
sl@0
   923
		iScreenDevice->GetPixel(pixelVal, TPoint(aRect.iTl.iX+cornerSize,aRect.iBr.iY-1-cornerSize));
sl@0
   924
		LogColorL(pixelVal,innerColors);
sl@0
   925
		iScreenDevice->GetPixel(pixelVal, TPoint(aRect.iBr.iX-1-cornerSize,aRect.iBr.iY-1-cornerSize));
sl@0
   926
		LogColorL(pixelVal,innerColors);
sl@0
   927
		iScreenDevice->GetPixel(pixelVal, TPoint(aRect.iBr.iX-1-cornerSize,aRect.iTl.iY+cornerSize));
sl@0
   928
		LogColorL(pixelVal,innerColors);
sl@0
   929
		}
sl@0
   930
	//OK... that has tested all the pixels, now check the result
sl@0
   931
	if (innerColors.Count()>aOtherInnerColors+1)
sl@0
   932
		return EFalse;
sl@0
   933
	if (outerColors.Count()>aOtherOuterColors+1)
sl@0
   934
		return EFalse;
sl@0
   935
	for (TInt index=1;index<innerColors.Count();index++)
sl@0
   936
		if (innerColors[0].iCount<innerColors[index].iCount)
sl@0
   937
			{
sl@0
   938
			return EFalse;
sl@0
   939
			}
sl@0
   940
	for (TInt index=1;index<outerColors.Count();index++)
sl@0
   941
		if (outerColors[0].iCount<outerColors[index].iCount)
sl@0
   942
			{
sl@0
   943
			return EFalse;
sl@0
   944
			}
sl@0
   945
	for (TInt indexIn=1;indexIn<innerColors.Count();indexIn++)
sl@0
   946
		for (TInt indexOut=0;indexOut<outerColors.Count();indexOut++)
sl@0
   947
			if (innerColors[indexIn].iColor.Value()==outerColors[indexOut].iColor.Value())
sl@0
   948
				{
sl@0
   949
				return EFalse;
sl@0
   950
				}
sl@0
   951
	return ETrue;
sl@0
   952
	}
sl@0
   953
sl@0
   954
TRect CWsDynamicResWinBase::PentCellRect(const TRect& aFullRect,char aStartLetter,char aEndLetter)
sl@0
   955
	{
sl@0
   956
	if (aEndLetter==0)
sl@0
   957
		aEndLetter=aStartLetter;
sl@0
   958
	aStartLetter&=0x1f;
sl@0
   959
	aEndLetter&=0x1f;
sl@0
   960
	TInt startx=(aStartLetter-1)%5;
sl@0
   961
	TInt starty=(aStartLetter-1)/5;
sl@0
   962
	TInt endx=(aEndLetter-1)%5;
sl@0
   963
	TInt endy=(aEndLetter-1)/5;
sl@0
   964
	if (starty>endy)
sl@0
   965
		{	//swap			//	s		e
sl@0
   966
		starty-=endy;		//	s-e
sl@0
   967
		endy+=starty;		//			s					
sl@0
   968
		starty=endy-starty;	//	e
sl@0
   969
		}
sl@0
   970
	if (startx>endx)
sl@0
   971
		{	//swap			//	s		e
sl@0
   972
		startx-=endx;		//	s-e
sl@0
   973
		endx+=startx;		//			s					
sl@0
   974
		startx=endx-startx;	//	e
sl@0
   975
		}
sl@0
   976
	TSize fullSize=aFullRect.Size();
sl@0
   977
	return TRect(	aFullRect.iTl.iX+fullSize.iWidth*startx/5,
sl@0
   978
					aFullRect.iTl.iY+fullSize.iHeight*starty/5,
sl@0
   979
					aFullRect.iTl.iX+fullSize.iWidth*(endx+1)/5,
sl@0
   980
					aFullRect.iTl.iY+fullSize.iHeight*(endy+1)/5
sl@0
   981
				);
sl@0
   982
	}