os/graphics/windowing/windowserver/test/tdynamicres/src/wsdynamicresbasic.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
#include "wsdynamicresbasic.h"
sl@0
    20
#include <test/extendtef.h>
sl@0
    21
#include "globalsettings.h"
sl@0
    22
#include <w32debug.h>
sl@0
    23
#include <w32stdgraphic.h>
sl@0
    24
#include "regionextend.h"
sl@0
    25
#include <fbs.h>
sl@0
    26
#include <e32svr.h>
sl@0
    27
#include <u32hal.h>
sl@0
    28
#include <graphics/surfaceconfiguration.h>
sl@0
    29
#include "surfaceutility.h"
sl@0
    30
#include <graphics/testscreencapture.h>
sl@0
    31
sl@0
    32
//verify which base code is available to the test
sl@0
    33
#include <dispchannel.h>
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
sl@0
    39
//#define VISIBLE_PAUSES 1000
sl@0
    40
#define OVERLAPPING_CELL	0	//'m'	//0 indicates cells do not overlap
sl@0
    41
/*
sl@0
    42
 * CWsGceTestPlaceSurfExtra implementation
sl@0
    43
 * 
sl@0
    44
 * 
sl@0
    45
 * 
sl@0
    46
 * 
sl@0
    47
 */
sl@0
    48
CWsDynamicResBasic::CWsDynamicResBasic()
sl@0
    49
{
sl@0
    50
}
sl@0
    51
sl@0
    52
CWsDynamicResBasic::~CWsDynamicResBasic()
sl@0
    53
{
sl@0
    54
}
sl@0
    55
sl@0
    56
void CWsDynamicResBasic::SetupL()
sl@0
    57
	{
sl@0
    58
	MyBase::SetupL();
sl@0
    59
	}
sl@0
    60
void CWsDynamicResBasic::TearDownL()
sl@0
    61
	{
sl@0
    62
	MyBase::TearDownL();
sl@0
    63
	
sl@0
    64
	}
sl@0
    65
void CWsDynamicResBasic::TearDownFromDeleteL()
sl@0
    66
	{
sl@0
    67
	MyBase::TearDownFromDeleteL();
sl@0
    68
	}
sl@0
    69
sl@0
    70
sl@0
    71
CTestSuite* CWsDynamicResBasic::CreateSuiteL( const TDesC& aName )
sl@0
    72
	{
sl@0
    73
	//Create the surface manager here, before the test suite creates additional threads
sl@0
    74
	if (GCEIsSupportedStatic())
sl@0
    75
		{
sl@0
    76
		TRAP_IGNORE(PostTestCleanupInstance().CreateSharedUtilityL());
sl@0
    77
		}
sl@0
    78
	
sl@0
    79
	SUB_SUITE_OPT(CWsDynamicResBasic,NULL);
sl@0
    80
sl@0
    81
		//BASIC
sl@0
    82
		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0001L);
sl@0
    83
		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0002L);
sl@0
    84
		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0003L);
sl@0
    85
		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0004L);
sl@0
    86
		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0005L);
sl@0
    87
		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0006L);
sl@0
    88
		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0007L);
sl@0
    89
		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0008L);
sl@0
    90
		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0009L);
sl@0
    91
		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0010L);	//only run on screen 1
sl@0
    92
		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0011L);
sl@0
    93
		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0012L);	//only run on screen 0
sl@0
    94
		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0013L);
sl@0
    95
		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0014L);	//only run on screen 1
sl@0
    96
		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0015L);	//only run with no scaling
sl@0
    97
		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0016L);	//only run with anisotropic scaling
sl@0
    98
		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0017L);	//only run with integer scaling
sl@0
    99
		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0018L);
sl@0
   100
sl@0
   101
		ADD_TEST_STEP_PARAM_BOOL(GRAPHICS_WSERV_DYNAMICRES_0021L);	//only run on screen 1
sl@0
   102
		
sl@0
   103
		//OOM
sl@0
   104
		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0031L);
sl@0
   105
		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0032L);
sl@0
   106
		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0033L);
sl@0
   107
		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0034L);	//dont run with no scaling on screen 0
sl@0
   108
sl@0
   109
		//SCREEN CAPTURE
sl@0
   110
		ADD_TEST_STEP_PARAM_BOOL(GRAPHICS_WSERV_DYNAMICRES_0041L);
sl@0
   111
		ADD_TEST_STEP_PARAM_BOOL(GRAPHICS_WSERV_DYNAMICRES_0042L);
sl@0
   112
		
sl@0
   113
		//DYNAMIC SCREEN MODE - only run these with no scaling and isotropic scaling
sl@0
   114
		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0051L);	
sl@0
   115
		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0052L);	//only run on screen 1 (multiple resolutions)
sl@0
   116
		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0053L);
sl@0
   117
sl@0
   118
		//DEFECT
sl@0
   119
		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0101L);
sl@0
   120
		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0102L);
sl@0
   121
sl@0
   122
	END_SUITE;
sl@0
   123
	}
sl@0
   124
sl@0
   125
#define LOG_AND_PANIC_IF_NOT_GCE											\
sl@0
   126
		{																	\
sl@0
   127
		if (!GCEIsSupported())												\
sl@0
   128
			{																\
sl@0
   129
			INFO_PRINTF1(_L("Test skipped: GCE support is not loaded"));	\
sl@0
   130
			User::Panic(_L("GCE.Wrong.Mode"),1);							\
sl@0
   131
			return;															\
sl@0
   132
			}																\
sl@0
   133
		}
sl@0
   134
sl@0
   135
CWsDisplayEvent::CWsDisplayEvent(RWsSession *aWs):
sl@0
   136
CActive(EPriorityStandard), iWs(aWs), iConfigSpinner(0), iResListSpinner(0),iReceivedEventCount(0), 
sl@0
   137
iReceivedPointerEventCount(0), iPointerPosTestPass(ETrue) 
sl@0
   138
	{
sl@0
   139
	CActiveScheduler::Add(this);
sl@0
   140
	}
sl@0
   141
CWsDisplayEvent::~CWsDisplayEvent()
sl@0
   142
	{
sl@0
   143
	Cancel();
sl@0
   144
	}
sl@0
   145
sl@0
   146
void CWsDisplayEvent::DoCancel()
sl@0
   147
	{
sl@0
   148
	iWs->EventReadyCancel();
sl@0
   149
	}
sl@0
   150
sl@0
   151
void CWsDisplayEvent::Request()
sl@0
   152
	{
sl@0
   153
	iWs->EventReady(&iStatus);
sl@0
   154
	SetActive();
sl@0
   155
	}
sl@0
   156
sl@0
   157
void CWsDisplayEvent::RunL()
sl@0
   158
	{
sl@0
   159
	TWsEvent event;
sl@0
   160
	iWs->GetEvent(event);
sl@0
   161
	
sl@0
   162
	if(iStatus == KErrNone)
sl@0
   163
		{
sl@0
   164
		switch(event.Type())
sl@0
   165
			{
sl@0
   166
			case EEventScreenDeviceChanged:
sl@0
   167
				{
sl@0
   168
				iReceivedDeviceEventCount++;
sl@0
   169
				}
sl@0
   170
			case EEventPointer:
sl@0
   171
				{
sl@0
   172
				iReceivedPointerEventCount++;
sl@0
   173
				TPointerEvent* ptEvent = event.Pointer();
sl@0
   174
				//make 1 pixels distance allowance, as non integer scalling from composition to app may occur
sl@0
   175
				//1 pixels allowance because we never scale greater than 2 times
sl@0
   176
				if(ptEvent->iPosition.iX < iPointerPos.iX - 1 && ptEvent->iPosition.iX > iPointerPos.iX + 1
sl@0
   177
						&& ptEvent->iPosition.iY < iPointerPos.iY - 1 &&ptEvent->iPosition.iY > iPointerPos.iY + 1)
sl@0
   178
					{
sl@0
   179
					iPointerPosTestPass = EFalse;
sl@0
   180
					}
sl@0
   181
				}
sl@0
   182
			case EEventDisplayChanged:
sl@0
   183
				{
sl@0
   184
				iConfigSpinner = event.DisplayChanged()->iConfigurationChangeId;
sl@0
   185
				iResListSpinner = event.DisplayChanged()->iResolutionListChangeId;
sl@0
   186
				iReceivedEventCount++;
sl@0
   187
				}
sl@0
   188
				break;
sl@0
   189
			default:
sl@0
   190
				break;
sl@0
   191
			}
sl@0
   192
		}
sl@0
   193
	else
sl@0
   194
		User::Leave(iStatus.Int());
sl@0
   195
	
sl@0
   196
	Request();
sl@0
   197
	}
sl@0
   198
sl@0
   199
CEventTimer* CEventTimer::NewL()
sl@0
   200
	{
sl@0
   201
	CEventTimer* self = new (ELeave) CEventTimer;
sl@0
   202
	CleanupStack::PushL(self);
sl@0
   203
	self->ConstructL();
sl@0
   204
	CleanupStack::Pop(self);
sl@0
   205
	return self;
sl@0
   206
	}
sl@0
   207
      
sl@0
   208
void CEventTimer::ConstructL()
sl@0
   209
	{
sl@0
   210
	User::LeaveIfError(iTimer.CreateLocal());
sl@0
   211
	CActiveScheduler::Add(this);
sl@0
   212
	}
sl@0
   213
 
sl@0
   214
CEventTimer::CEventTimer() : CActive(EPriorityStandard)
sl@0
   215
	{
sl@0
   216
	
sl@0
   217
	}
sl@0
   218
sl@0
   219
CEventTimer::~CEventTimer()
sl@0
   220
	{
sl@0
   221
	Cancel();
sl@0
   222
	iTimer.Close();
sl@0
   223
	}
sl@0
   224
sl@0
   225
void CEventTimer::DoCancel()
sl@0
   226
	{
sl@0
   227
	iTimer.Cancel();
sl@0
   228
	CActiveScheduler::Stop();
sl@0
   229
	}
sl@0
   230
sl@0
   231
void CEventTimer::RunL()
sl@0
   232
	{
sl@0
   233
	CActiveScheduler::Stop();
sl@0
   234
	}
sl@0
   235
sl@0
   236
void CEventTimer::Wait(TInt aDelay)
sl@0
   237
	{
sl@0
   238
	iTimer.After(iStatus, aDelay);
sl@0
   239
	SetActive();
sl@0
   240
	CActiveScheduler::Start();
sl@0
   241
	}
sl@0
   242
sl@0
   243
//Set display state to normal and to the first decent resolution
sl@0
   244
//A failed test could leave it in a bad state
sl@0
   245
void CWsDynamicResBasic::ResetScreens()
sl@0
   246
	{
sl@0
   247
	Pause(1000);
sl@0
   248
#ifndef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER
sl@0
   249
	TInt displayState = ENormalResolution; 
sl@0
   250
	UserSvr::HalFunction(EHalGroupDisplay | (iScreenDevice->GetScreenNumber()<<16), EDisplayHalSetDisplayState, &displayState, NULL);
sl@0
   251
#endif
sl@0
   252
	MDisplayControl* interface = static_cast<MDisplayControl*>
sl@0
   253
				(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
sl@0
   254
	ASSERT_TRUE(interface);
sl@0
   255
	
sl@0
   256
	RArray<TInt> appModeIndexList;
sl@0
   257
	TInt currMode=iScreenDevice->CurrentScreenMode();
sl@0
   258
	iScreenDevice->GetScreenSizeModeList(&appModeIndexList);
sl@0
   259
	if (appModeIndexList[0]!=currMode)
sl@0
   260
		{
sl@0
   261
		iScreenDevice->SetAppScreenMode(appModeIndexList[0]);
sl@0
   262
		iScreenDevice->SetScreenMode(appModeIndexList[0]);
sl@0
   263
		}
sl@0
   264
	appModeIndexList.Close();
sl@0
   265
	
sl@0
   266
	TInt resolutions = interface->NumberOfResolutions();
sl@0
   267
	ASSERT_TRUE (resolutions > 0);
sl@0
   268
	RArray<MDisplayControl::TResolution> resolutionList1;
sl@0
   269
	TInt error = interface->GetResolutions(resolutionList1);
sl@0
   270
	ASSERT_EQUALS(error,KErrNone);
sl@0
   271
	ASSERT_EQUALS(resolutionList1.Count(), resolutions);
sl@0
   272
	TDisplayConfiguration config;
sl@0
   273
	TInt goodRes=0;
sl@0
   274
	if (resolutionList1[goodRes].iPixelSize==TSize())
sl@0
   275
		{
sl@0
   276
		goodRes++;
sl@0
   277
		ASSERT_TRUE(resolutions>goodRes);		//First res was blank, and no more to choose!
sl@0
   278
		}
sl@0
   279
	config.SetResolution(resolutionList1[goodRes].iPixelSize);
sl@0
   280
	error=interface->SetConfiguration(config);
sl@0
   281
	ASSERT_EQUALS(error,KErrNone);
sl@0
   282
	resolutionList1.Close();
sl@0
   283
	}
sl@0
   284
sl@0
   285
/**
sl@0
   286
@SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0001L
sl@0
   287
@SYMTestCaseDesc		WSERV Screen Device GetInterface returns known interface
sl@0
   288
@SYMREQ					REQ10325
sl@0
   289
@SYMPREQ				PREQ2102
sl@0
   290
@SYMTestType			CT
sl@0
   291
@SYMTestPriority		1
sl@0
   292
@SYMTestPurpose			Basic classic behaviour
sl@0
   293
@SYMTestActions			
sl@0
   294
	Call GetInterface with a well known GUID
sl@0
   295
@SYMTestExpectedResults	
sl@0
   296
	Returns a pointer
sl@0
   297
*/
sl@0
   298
void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0001L()
sl@0
   299
	{
sl@0
   300
	LOG_AND_PANIC_IF_NOT_GCE;
sl@0
   301
	MakeTitleAndCompareWindowsL(_L("GRAPHICS_WSERV_DYNAMICRES_0001L"),_L("Basic Dynamic Resolution test"));
sl@0
   302
	
sl@0
   303
	MDisplayControlBase* interface1 = static_cast<MDisplayControlBase*>
sl@0
   304
			(iScreenDevice->GetInterface(MDisplayControlBase::ETypeId));
sl@0
   305
	ASSERT_TRUE(interface1);
sl@0
   306
	
sl@0
   307
	MDisplayControl* interface2 = static_cast<MDisplayControl*>
sl@0
   308
			(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
sl@0
   309
	ASSERT_TRUE(interface2);
sl@0
   310
	
sl@0
   311
	MDisplayMappingBase* interface3 = static_cast<MDisplayMappingBase*>
sl@0
   312
			(iScreenDevice->GetInterface(MDisplayMappingBase::ETypeId));
sl@0
   313
	ASSERT_TRUE(interface3);
sl@0
   314
	
sl@0
   315
	MDisplayMapping* interface4 = static_cast<MDisplayMapping*>
sl@0
   316
			(iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
sl@0
   317
	ASSERT_TRUE(interface4);
sl@0
   318
	}
sl@0
   319
sl@0
   320
/**
sl@0
   321
@SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0002L
sl@0
   322
@SYMTestCaseDesc		Basic test for NumberOfResolutions
sl@0
   323
@SYMREQ					REQ10328
sl@0
   324
@SYMPREQ				PREQ2102
sl@0
   325
@SYMTestType			CT
sl@0
   326
@SYMTestPriority		1
sl@0
   327
@SYMTestPurpose			NumberOfResolutions returns correctly
sl@0
   328
@SYMTestActions			
sl@0
   329
	GetInterface
sl@0
   330
	then call NumberOfResolutions.
sl@0
   331
@SYMTestExpectedResults	
sl@0
   332
	It shouldn't return KErrNotSupported
sl@0
   333
*/
sl@0
   334
void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0002L()
sl@0
   335
	{
sl@0
   336
	LOG_AND_PANIC_IF_NOT_GCE;
sl@0
   337
	MDisplayControl* interface = static_cast<MDisplayControl*>
sl@0
   338
				(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
sl@0
   339
	ASSERT_TRUE(interface);
sl@0
   340
	TInt resolutions = interface->NumberOfResolutions();
sl@0
   341
	ASSERT_TRUE (resolutions != KErrNotSupported);
sl@0
   342
	}
sl@0
   343
sl@0
   344
/**
sl@0
   345
@SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0003L
sl@0
   346
@SYMTestCaseDesc		Basic test for GetResolutions
sl@0
   347
@SYMREQ					REQ10328
sl@0
   348
@SYMPREQ				PREQ2102
sl@0
   349
@SYMTestType			CT
sl@0
   350
@SYMTestPriority		
sl@0
   351
@SYMTestPurpose			Check GetResolutions returns a valid TSize RArray
sl@0
   352
@SYMTestActions			
sl@0
   353
	GetInterface
sl@0
   354
	Call NumberOfResolutions
sl@0
   355
	Create an array and garbage fill based on amount of resolutions
sl@0
   356
	Call GetResolutions on this array
sl@0
   357
	Create an array (dont garbage fill)
sl@0
   358
	Call GetResolutions on this empty array
sl@0
   359
	Create an array with smaller size than required
sl@0
   360
	Call GetResolutions on this array
sl@0
   361
	Create an array with larger size than required
sl@0
   362
	Call GetResolutions on this array
sl@0
   363
@SYMTestExpectedResults	
sl@0
   364
	For both GetResolutions calls, it should allocate memory if needed, and fill
sl@0
   365
	with correct sizes
sl@0
   366
*/
sl@0
   367
void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0003L()
sl@0
   368
	{
sl@0
   369
	LOG_AND_PANIC_IF_NOT_GCE;
sl@0
   370
	TInt count;
sl@0
   371
	TInt error;
sl@0
   372
	
sl@0
   373
	MDisplayControl* interface = static_cast<MDisplayControl*>
sl@0
   374
				(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
sl@0
   375
	ASSERT_TRUE(interface);
sl@0
   376
	
sl@0
   377
	TInt resolutions = interface->NumberOfResolutions();
sl@0
   378
	ASSERT_TRUE (resolutions > 0);
sl@0
   379
	
sl@0
   380
	RArray<MDisplayControl::TResolution> resolutionList1;
sl@0
   381
	for (count=0;count<resolutions;count++)
sl@0
   382
		{
sl@0
   383
		resolutionList1.Append(MDisplayControl::TResolution(TSize(),TSize()));
sl@0
   384
		}
sl@0
   385
	error = interface->GetResolutions(resolutionList1);
sl@0
   386
	ASSERT_EQUALS(error,KErrNone);
sl@0
   387
	ASSERT_EQUALS(resolutionList1.Count(), resolutions);
sl@0
   388
	
sl@0
   389
	RArray<MDisplayControl::TResolution> resolutionList2;
sl@0
   390
	error = interface->GetResolutions(resolutionList2);
sl@0
   391
	ASSERT_EQUALS(error,KErrNone);
sl@0
   392
	ASSERT_EQUALS(resolutionList2.Count(), resolutions);
sl@0
   393
	
sl@0
   394
	RArray<MDisplayControl::TResolution> resolutionList3;
sl@0
   395
	for (count=0;count<resolutions-1;count++)
sl@0
   396
		{
sl@0
   397
		resolutionList3.Append(MDisplayControl::TResolution(TSize(),TSize()));
sl@0
   398
		}
sl@0
   399
	error = interface->GetResolutions(resolutionList3);
sl@0
   400
	ASSERT_EQUALS(error,KErrNone);
sl@0
   401
	ASSERT_EQUALS(resolutionList3.Count(), resolutions);
sl@0
   402
	
sl@0
   403
	RArray<MDisplayControl::TResolution> resolutionList4;
sl@0
   404
	for (count=0;count<resolutions+2;count++)
sl@0
   405
		{
sl@0
   406
		resolutionList4.Append(MDisplayControl::TResolution(TSize(),TSize()));
sl@0
   407
		}
sl@0
   408
	error = interface->GetResolutions(resolutionList4);
sl@0
   409
	ASSERT_EQUALS(error,KErrNone);
sl@0
   410
	ASSERT_EQUALS(resolutionList4.Count(), resolutions);
sl@0
   411
	
sl@0
   412
	for (count=0;count<resolutions;count++)
sl@0
   413
		{
sl@0
   414
		ASSERT_EQUALS(resolutionList1[count].iPixelSize,resolutionList2[count].iPixelSize);
sl@0
   415
		ASSERT_EQUALS(resolutionList1[count].iPixelSize,resolutionList3[count].iPixelSize);
sl@0
   416
		ASSERT_EQUALS(resolutionList1[count].iPixelSize,resolutionList4[count].iPixelSize);
sl@0
   417
		
sl@0
   418
		ASSERT_EQUALS(resolutionList1[count].iTwipsSize,resolutionList2[count].iTwipsSize);
sl@0
   419
		ASSERT_EQUALS(resolutionList1[count].iTwipsSize,resolutionList3[count].iTwipsSize);
sl@0
   420
		ASSERT_EQUALS(resolutionList1[count].iTwipsSize,resolutionList4[count].iTwipsSize);
sl@0
   421
		
sl@0
   422
		if (!(resolutionList1[count].iFlags == resolutionList2[count].iFlags))
sl@0
   423
			{
sl@0
   424
			ASSERT_TRUE(EFalse);
sl@0
   425
			}
sl@0
   426
		if (!(resolutionList1[count].iFlags == resolutionList3[count].iFlags))
sl@0
   427
			{
sl@0
   428
			ASSERT_TRUE(EFalse);
sl@0
   429
			}
sl@0
   430
		if (!(resolutionList1[count].iFlags == resolutionList4[count].iFlags))
sl@0
   431
			{
sl@0
   432
			ASSERT_TRUE(EFalse);
sl@0
   433
			}
sl@0
   434
		}
sl@0
   435
	resolutionList1.Close();
sl@0
   436
	resolutionList2.Close();
sl@0
   437
	resolutionList3.Close();
sl@0
   438
	resolutionList4.Close();
sl@0
   439
	}
sl@0
   440
sl@0
   441
/**
sl@0
   442
@SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0004L
sl@0
   443
@SYMTestCaseDesc		Test for GetConfiguration
sl@0
   444
@SYMREQ					REQ10328
sl@0
   445
@SYMPREQ				PREQ2102
sl@0
   446
@SYMTestType			CT
sl@0
   447
@SYMTestPriority		1
sl@0
   448
@SYMTestPurpose			Check GetConfiguration returns a configuration object
sl@0
   449
@SYMTestActions			
sl@0
   450
	GetInterface
sl@0
   451
	GetConfiguration with standard TDisplayConfiguration
sl@0
   452
	GetResolution from the TDisplayConfiguration object
sl@0
   453
	GetConfiguration with TDisplayConfiguration object with a greater version/size
sl@0
   454
	GetResolution from the TDisplayConfiguration object
sl@0
   455
	GetConfiguration with TDisplayConfiguration object with a smaller version/size -- equal to TDisplayConfiguration1
sl@0
   456
	GetResolution from the TDisplayConfiguration object
sl@0
   457
	Check all the resolutions should be same
sl@0
   458
@SYMTestExpectedResults	
sl@0
   459
	
sl@0
   460
*/
sl@0
   461
void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0004L()
sl@0
   462
	{
sl@0
   463
	LOG_AND_PANIC_IF_NOT_GCE;
sl@0
   464
			
sl@0
   465
	MDisplayControl* interface = static_cast<MDisplayControl*>
sl@0
   466
				(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
sl@0
   467
	ASSERT_TRUE(interface);
sl@0
   468
	
sl@0
   469
	TDisplayConfiguration dispConfig;
sl@0
   470
	interface->GetConfiguration(dispConfig);
sl@0
   471
	ASSERT_TRUE(dispConfig.IsDefined(TDisplayConfigurationBase::EResolution));
sl@0
   472
	TSize size;
sl@0
   473
	TSize twips;
sl@0
   474
	ASSERT_TRUE(dispConfig.GetResolution(size));
sl@0
   475
	ASSERT_TRUE(dispConfig.GetResolutionTwips(twips));
sl@0
   476
	
sl@0
   477
	TDisplayConfiguration dispConfig1(TDisplayConfiguration().Version() + 10);
sl@0
   478
	interface->GetConfiguration(dispConfig1);
sl@0
   479
	ASSERT_TRUE(dispConfig1.IsDefined(TDisplayConfigurationBase::EResolution));
sl@0
   480
	TSize size1;
sl@0
   481
	TSize twips1;
sl@0
   482
	ASSERT_TRUE(dispConfig1.GetResolution(size1));
sl@0
   483
	ASSERT_TRUE(dispConfig1.GetResolutionTwips(twips1));
sl@0
   484
	
sl@0
   485
	TDisplayConfiguration dispConfig2(TDisplayConfiguration1().Version());
sl@0
   486
	interface->GetConfiguration(dispConfig2);
sl@0
   487
	ASSERT_TRUE(dispConfig2.IsDefined(TDisplayConfigurationBase::EResolution));
sl@0
   488
	TSize size2;
sl@0
   489
	TSize twips2;
sl@0
   490
	ASSERT_TRUE(dispConfig2.GetResolution(size2));
sl@0
   491
	ASSERT_TRUE(dispConfig2.GetResolutionTwips(twips2));
sl@0
   492
	
sl@0
   493
	ASSERT_EQUALS(size, size1);
sl@0
   494
	ASSERT_EQUALS(size, size2);
sl@0
   495
	ASSERT_EQUALS(twips, twips1);
sl@0
   496
	ASSERT_EQUALS(twips, twips2);
sl@0
   497
	}
sl@0
   498
sl@0
   499
/**
sl@0
   500
@SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0005L
sl@0
   501
@SYMTestCaseDesc		Test getting display change event from event queue
sl@0
   502
@SYMREQ					REQ10329 REQ10330
sl@0
   503
@SYMPREQ				PREQ2102
sl@0
   504
@SYMTestType			CT
sl@0
   505
@SYMTestPriority		1
sl@0
   506
@SYMTestPurpose			Verify the correct behaviour of display change notification
sl@0
   507
@SYMTestActions			
sl@0
   508
	Run through various ways of changing resolution
sl@0
   509
	For each, check if event has been received
sl@0
   510
@SYMTestExpectedResults	
sl@0
   511
	Based on type of change, check event
sl@0
   512
	@note Test uses HAL to simulate display disconnection. Not supported on production platforms.
sl@0
   513
*/
sl@0
   514
void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0005L()
sl@0
   515
	{
sl@0
   516
	LOG_AND_PANIC_IF_NOT_GCE;
sl@0
   517
	ResetScreens();
sl@0
   518
#ifdef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER
sl@0
   519
	ASSERT_FALSE("Display connection test not compiled because MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER");
sl@0
   520
#else
sl@0
   521
	TInt screenNo = iScreenDevice->GetScreenNumber();
sl@0
   522
	
sl@0
   523
	MDisplayControl* interface = static_cast<MDisplayControl*>
sl@0
   524
				(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
sl@0
   525
	ASSERT_TRUE(interface);
sl@0
   526
	interface->EnableDisplayChangeEvents(ETrue);
sl@0
   527
	ASSERT_TRUE(interface->DisplayChangeEventsEnabled());
sl@0
   528
	
sl@0
   529
	CWsDisplayEvent* displayEventAO = new(ELeave) CWsDisplayEvent(&iSession);
sl@0
   530
	CleanupStack::PushL(displayEventAO);
sl@0
   531
	displayEventAO->Request();
sl@0
   532
	CEventTimer *timer = CEventTimer::NewL();
sl@0
   533
	CleanupStack::PushL(timer);
sl@0
   534
	TInt dispSpinnerValue = displayEventAO->ResListSpinner();
sl@0
   535
	TInt configSpinnerValue = displayEventAO->ConfigSpinner();
sl@0
   536
	
sl@0
   537
	iSession.Flush();		
sl@0
   538
	TInt displayState = EDisconnect;
sl@0
   539
	UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
sl@0
   540
	
sl@0
   541
	timer->Wait(100000);
sl@0
   542
	ASSERT_TRUE(displayEventAO->ConfigSpinner() >= configSpinnerValue); //this is also a config change
sl@0
   543
	ASSERT_TRUE(displayEventAO->ResListSpinner() > dispSpinnerValue); //1st display change event
sl@0
   544
	dispSpinnerValue = displayEventAO->ResListSpinner();
sl@0
   545
	configSpinnerValue = displayEventAO->ConfigSpinner();
sl@0
   546
	
sl@0
   547
	
sl@0
   548
	interface->EnableDisplayChangeEvents(ETrue);//enable again
sl@0
   549
	ASSERT_TRUE(interface->DisplayChangeEventsEnabled());
sl@0
   550
	interface->EnableDisplayChangeEvents(EFalse);//disable
sl@0
   551
	ASSERT_FALSE(interface->DisplayChangeEventsEnabled());
sl@0
   552
	interface->EnableDisplayChangeEvents(EFalse);//disable again
sl@0
   553
	interface->EnableDisplayChangeEvents(ETrue);//enable again
sl@0
   554
	iSession.Flush();
sl@0
   555
	
sl@0
   556
	TDisplayConfiguration disconnectedConfig;
sl@0
   557
	disconnectedConfig.SetResolution(TSize(10,11));
sl@0
   558
	disconnectedConfig.SetResolutionTwips(TSize(12,13));
sl@0
   559
	disconnectedConfig.SetRotation(TDisplayConfiguration1::ERotationNormal);
sl@0
   560
	interface->GetConfiguration(disconnectedConfig);
sl@0
   561
	ASSERT_FALSE(disconnectedConfig.IsDefined(disconnectedConfig.EResolution));
sl@0
   562
	ASSERT_FALSE(disconnectedConfig.IsDefined(disconnectedConfig.EResolutionTwips));
sl@0
   563
	ASSERT_FALSE(disconnectedConfig.IsDefined(disconnectedConfig.ERotation));
sl@0
   564
	
sl@0
   565
	displayState = ENormalResolution; 
sl@0
   566
	UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
sl@0
   567
	
sl@0
   568
	timer->Wait(1000000);
sl@0
   569
	ASSERT_TRUE(displayEventAO->ConfigSpinner() >= configSpinnerValue); //this is a config change if display policy is enabled. not a change otherwise
sl@0
   570
	ASSERT_TRUE(displayEventAO->ResListSpinner() > dispSpinnerValue); //display change event	
sl@0
   571
	dispSpinnerValue = displayEventAO->ResListSpinner();
sl@0
   572
	configSpinnerValue = displayEventAO->ConfigSpinner();
sl@0
   573
	
sl@0
   574
	TDisplayConfiguration dispConfig, dispConfig2;
sl@0
   575
	TSize resolution,resolution2;
sl@0
   576
	interface->GetConfiguration(dispConfig2);
sl@0
   577
	dispConfig2.GetResolution(resolution2);
sl@0
   578
	RArray<MDisplayControl::TResolution> resolutions;
sl@0
   579
	TInt err = interface->GetResolutions(resolutions);
sl@0
   580
	ASSERT_EQUALS(err, KErrNone);
sl@0
   581
	dispConfig.SetResolution(resolutions[resolutions.Count()/2].iPixelSize);
sl@0
   582
	err = interface->SetConfiguration(dispConfig);
sl@0
   583
	ASSERT_EQUALS(err, KErrNone);
sl@0
   584
	interface->GetConfiguration(dispConfig);
sl@0
   585
	
sl@0
   586
	timer->Wait(100000);
sl@0
   587
	
sl@0
   588
	if(!(dispConfig2 == dispConfig))
sl@0
   589
		{
sl@0
   590
		ASSERT_TRUE(displayEventAO->ConfigSpinner() > configSpinnerValue); //a config change, but on screen 0 with DP disabled, as we only have 1 resolution when DP disabled
sl@0
   591
		}
sl@0
   592
	else
sl@0
   593
		{
sl@0
   594
		ASSERT_TRUE(displayEventAO->ConfigSpinner() == configSpinnerValue);
sl@0
   595
		}
sl@0
   596
	ASSERT_EQUALS(displayEventAO->ResListSpinner(), dispSpinnerValue); //this is not a display change event	
sl@0
   597
	dispSpinnerValue = displayEventAO->ResListSpinner();
sl@0
   598
	configSpinnerValue = displayEventAO->ConfigSpinner();
sl@0
   599
	resolutions.Close();
sl@0
   600
	
sl@0
   601
	//here we flood the event queue with key events, so the next display change
sl@0
   602
	//can't put event and queue and force the retry AO on server side to kick off
sl@0
   603
	iSession.SetFocusScreen(TGlobalSettings::Instance().iScreen);
sl@0
   604
	for(TInt scanCode = 'a'; scanCode < 't'; scanCode ++)
sl@0
   605
		{
sl@0
   606
		TRawEvent rawEvent;
sl@0
   607
		rawEvent.Set(TRawEvent::EKeyDown,scanCode);
sl@0
   608
		iSession.SimulateRawEvent(rawEvent);
sl@0
   609
		rawEvent.Set(TRawEvent::EKeyUp,scanCode);
sl@0
   610
		iSession.SimulateRawEvent(rawEvent);
sl@0
   611
		}
sl@0
   612
	iSession.Flush();
sl@0
   613
sl@0
   614
	TInt eventCount1 = displayEventAO->ReceivedEventCount(); 
sl@0
   615
	//we should still receive this
sl@0
   616
	displayState = EDisconnect; 
sl@0
   617
	UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
sl@0
   618
	//let retry AO retry more times before we try to get it
sl@0
   619
	User::After(1000000);
sl@0
   620
	
sl@0
   621
	timer->Wait(10000000);
sl@0
   622
	ASSERT_TRUE(displayEventAO->ConfigSpinner()> configSpinnerValue ); //4th config change
sl@0
   623
	ASSERT_TRUE(displayEventAO->ResListSpinner() > dispSpinnerValue); //4th display change event
sl@0
   624
	
sl@0
   625
	//This part is doomed as well. Now the received event count includes all the pointer, device and display change event
sl@0
   626
	/*
sl@0
   627
	TInt eventCount2 = displayEventAO->ReceivedEventCount();
sl@0
   628
	//make sure retry AO is stopped - we only receive 1 display event
sl@0
   629
	ASSERT_EQUALS(eventCount1 + 1, eventCount2);
sl@0
   630
	*/
sl@0
   631
	displayState = ENormalResolution; 
sl@0
   632
	UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
sl@0
   633
	
sl@0
   634
	CleanupStack::PopAndDestroy(2, displayEventAO);
sl@0
   635
#endif
sl@0
   636
	}
sl@0
   637
sl@0
   638
//Adds the first rotation defined in the TResolution to the display configuration
sl@0
   639
void CWsDynamicResBasic::SetRotation (TDisplayConfiguration& aConfig, const MDisplayControl::TResolution& aResolution)
sl@0
   640
	{
sl@0
   641
	if (aResolution.iFlags.IsSet(MDisplayControlBase::TResolution::ERotationNormalSupported))
sl@0
   642
		{
sl@0
   643
		aConfig.SetRotation(TDisplayConfiguration1::ERotationNormal);
sl@0
   644
		}
sl@0
   645
	else if (aResolution.iFlags.IsSet(MDisplayControlBase::TResolution::ERotation90Supported))
sl@0
   646
		{
sl@0
   647
		aConfig.SetRotation(TDisplayConfiguration1::ERotation90CW);
sl@0
   648
		}
sl@0
   649
	else if (aResolution.iFlags.IsSet(MDisplayControlBase::TResolution::ERotation180Supported))
sl@0
   650
		{
sl@0
   651
		aConfig.SetRotation(TDisplayConfiguration1::ERotation180);
sl@0
   652
		}
sl@0
   653
	else if (aResolution.iFlags.IsSet(MDisplayControlBase::TResolution::ERotation270Supported))
sl@0
   654
		{
sl@0
   655
		aConfig.SetRotation(TDisplayConfiguration1::ERotation270CW);
sl@0
   656
		}
sl@0
   657
	ASSERT_TRUE(aConfig.IsDefined(aConfig.ERotation));
sl@0
   658
	}
sl@0
   659
	
sl@0
   660
/**
sl@0
   661
@SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0006L
sl@0
   662
@SYMTestCaseDesc		Set Screen display res
sl@0
   663
@SYMREQ					REQ10326
sl@0
   664
@SYMPREQ				PREQ2102
sl@0
   665
@SYMTestType			CT
sl@0
   666
@SYMTestPriority		
sl@0
   667
@SYMTestPurpose			Checking window and layer extents continue working
sl@0
   668
@SYMTestActions			
sl@0
   669
	Get resolution list
sl@0
   670
	For every resolution
sl@0
   671
		Set resolution
sl@0
   672
		Draw many rectangles that shrink to demonstrate scaling issues
sl@0
   673
		Draw surface
sl@0
   674
		Move window around
sl@0
   675
@SYMTestExpectedResults	
sl@0
   676
	Every resolution that is supported by current app mode should successfully be set
sl@0
   677
	All rectangles and surface should be visible
sl@0
   678
	As the window moves, the rectangles and surface should move with it, keeping visible
sl@0
   679
*/
sl@0
   680
void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0006L()
sl@0
   681
	{
sl@0
   682
	LOG_AND_PANIC_IF_NOT_GCE;
sl@0
   683
	ResetScreens();
sl@0
   684
	TInt error;
sl@0
   685
	MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0006L"),_L("Change Resolution"));
sl@0
   686
sl@0
   687
	iTestBack=RBlankWindow(iSession);
sl@0
   688
	ASSERT_EQUALS(iTestBack.Construct(iGroup, ++iWindowHandle), KErrNone);
sl@0
   689
	iTestBack.SetRequiredDisplayMode(iDisplayMode);
sl@0
   690
	iTestBack.SetColor(TRgb(255,0,0));
sl@0
   691
	iTestBack.SetExtent(iTestPos.iTl,iTestPos.Size());
sl@0
   692
	iTestBack.Activate();
sl@0
   693
	iTestBack.SetVisible(ETrue);
sl@0
   694
	
sl@0
   695
	struct DrawCompare
sl@0
   696
		{
sl@0
   697
		static void Draw(CWindowGc*	aGc)
sl@0
   698
			{
sl@0
   699
			aGc->SetPenStyle(aGc->ESolidPen);
sl@0
   700
			aGc->SetPenColor(TRgb(255,255,255));
sl@0
   701
			aGc->SetBrushColor(TRgb(0,0,0));
sl@0
   702
			TRect r(2,2,82,82);
sl@0
   703
			while(r.Width()>0)
sl@0
   704
				{
sl@0
   705
				aGc->DrawRect(r);
sl@0
   706
				r.Shrink(2,2);
sl@0
   707
				}
sl@0
   708
			}
sl@0
   709
		};
sl@0
   710
	TSurfaceId surfaceID;
sl@0
   711
	TRAPD(err, surfaceID = iUtility->CreateSurfaceL(TSize(200,200), 
sl@0
   712
			KSurfaceFormat, 200 * KBytesPerPixel));
sl@0
   713
	ASSERT_EQUALS(err,KErrNone);
sl@0
   714
	TRAP(err,iUtility->FanFillSurfaceL(surfaceID,iYellow,iRed,iMagenta));
sl@0
   715
	ASSERT_EQUALS(err,KErrNone);
sl@0
   716
	TSurfaceConfiguration surfConf;
sl@0
   717
	surfConf.SetSurfaceId(surfaceID);
sl@0
   718
	
sl@0
   719
	surfConf.SetExtent(TRect(2,84,82,166));
sl@0
   720
	iCompare.SetBackgroundSurface(surfConf,EFalse);
sl@0
   721
	
sl@0
   722
	if (CWindowGc*	gc=BeginActivateWithWipe(ETrue,iCompare,TRgb(128,128,128)))
sl@0
   723
		{
sl@0
   724
		DrawCompare::Draw(gc);
sl@0
   725
		gc->Deactivate();
sl@0
   726
		iCompare.EndRedraw();
sl@0
   727
		
sl@0
   728
		}
sl@0
   729
	iSession.Finish(ETrue);
sl@0
   730
	Pause(1000);
sl@0
   731
	
sl@0
   732
	MDisplayControl* interface = static_cast<MDisplayControl*>
sl@0
   733
				(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
sl@0
   734
	ASSERT_TRUE(interface);
sl@0
   735
	
sl@0
   736
	TInt resolutions = interface->NumberOfResolutions();
sl@0
   737
	ASSERT_TRUE (resolutions > 0);
sl@0
   738
	
sl@0
   739
	RArray<MDisplayControl::TResolution> resolutionList1;
sl@0
   740
	error = interface->GetResolutions(resolutionList1);
sl@0
   741
	ASSERT_EQUALS(error,KErrNone);
sl@0
   742
	ASSERT_EQUALS(resolutionList1.Count(), resolutions);
sl@0
   743
	
sl@0
   744
	TDisplayConfiguration dispConfigBefore;
sl@0
   745
	interface->GetConfiguration(dispConfigBefore);
sl@0
   746
	ASSERT_TRUE(dispConfigBefore.IsDefined(dispConfigBefore.EResolution))
sl@0
   747
	if (resolutions>1)
sl@0
   748
		{
sl@0
   749
		//Got a mode to change to!
sl@0
   750
		TSize resBefore;
sl@0
   751
		TBool ok=dispConfigBefore.GetResolution(resBefore);
sl@0
   752
		ASSERT_TRUE(ok);	//we "know" this should be ok, as we just asserted the flag
sl@0
   753
		TBool foundBeforeRes=EFalse;
sl@0
   754
		for (TInt res=0;res<resolutionList1.Count();res++)
sl@0
   755
			{
sl@0
   756
//			if (resolutionList1[res].iPixelSize!=resBefore)
sl@0
   757
				{
sl@0
   758
				if (resolutionList1[res].iPixelSize!=TSize(0,0))	//this test is not about turning the display off
sl@0
   759
					{
sl@0
   760
					TDisplayConfiguration dispConfigReq;
sl@0
   761
					dispConfigReq.SetResolution(resolutionList1[res].iPixelSize);
sl@0
   762
					ASSERT_TRUE(dispConfigReq.IsDefined(dispConfigReq.EResolution));
sl@0
   763
					
sl@0
   764
					SetRotation(dispConfigReq,resolutionList1[res]);	//set rotation to first defined in res list
sl@0
   765
					
sl@0
   766
					TInt errCode=interface->SetConfiguration(dispConfigReq);
sl@0
   767
					//ASSERT_EQUALS(errCode,KErrNone);
sl@0
   768
					if (errCode != KErrNone)
sl@0
   769
						{
sl@0
   770
						//Probably current size mode does not support the rotation of the passed in configuration
sl@0
   771
						
sl@0
   772
						ASSERT_EQUALS(errCode,KErrArgument);	//failed to find compatible res in the policy
sl@0
   773
						continue;
sl@0
   774
						}
sl@0
   775
					Pause(300);
sl@0
   776
					TRect outerrect(iTestPos.iTl,resolutionList1[res].iPixelSize.AsPoint());
sl@0
   777
					iTestBack.SetExtent(outerrect.iTl,outerrect.Size());
sl@0
   778
					iSession.Finish(ETrue);
sl@0
   779
					Pause(300);
sl@0
   780
					if (CWindowGc*	gc=BeginActivateWithWipe(ETrue,iCompare,TRgb(128,128,128)))
sl@0
   781
						{
sl@0
   782
						DrawCompare::Draw(gc);
sl@0
   783
						gc->Deactivate();
sl@0
   784
						iCompare.EndRedraw();
sl@0
   785
						}
sl@0
   786
					TBuf16<20> s;
sl@0
   787
					s.AppendNum(res);
sl@0
   788
					UpdateTitleWindowL(s,2);
sl@0
   789
					s.Zero();
sl@0
   790
					s.AppendNum(resolutionList1[res].iPixelSize.iWidth);
sl@0
   791
					s.Append('x');
sl@0
   792
					s.AppendNum(resolutionList1[res].iPixelSize.iHeight);
sl@0
   793
					UpdateTitleWindowL(s,3);
sl@0
   794
					
sl@0
   795
					iSession.Finish(ETrue);
sl@0
   796
					Pause(300);
sl@0
   797
					outerrect.iBr.iX-=5;
sl@0
   798
					outerrect.iBr.iY-=5;
sl@0
   799
					iTestBack.SetExtent(outerrect.iTl,outerrect.Size());
sl@0
   800
					iSession.Finish(ETrue);
sl@0
   801
					Pause(300);
sl@0
   802
					TPoint winpos=iCompare.AbsPosition();
sl@0
   803
					TSize winsize=iCompare.Size();
sl@0
   804
//					iInfoScreenDevice->ReleaseTwipsCache();
sl@0
   805
					RepaintTitleWindowL();
sl@0
   806
					for (TSize z=TSize(1,1);z!=TSize(-1,-1);)
sl@0
   807
						{
sl@0
   808
						for (TInt i=0;i<15;i++)
sl@0
   809
							{
sl@0
   810
							winpos+=z;
sl@0
   811
							iCompare.SetExtent(winpos,winsize);
sl@0
   812
							iSession.Finish(ETrue);
sl@0
   813
							Pause(100);
sl@0
   814
							}
sl@0
   815
						if (z.iHeight && z.iWidth)
sl@0
   816
							z=TSize(0,-1);
sl@0
   817
						else
sl@0
   818
						if (z.iHeight)
sl@0
   819
							z=TSize(-1,0);
sl@0
   820
						else
sl@0
   821
							z=TSize(-1,-1);
sl@0
   822
						}
sl@0
   823
					TDisplayConfiguration dispConfigAfter;
sl@0
   824
					interface->GetConfiguration(dispConfigAfter);
sl@0
   825
					TSize resAfter;
sl@0
   826
					TBool ok=dispConfigAfter.GetResolution(resAfter);
sl@0
   827
					ASSERT_TRUE(ok);
sl@0
   828
					if (resolutionList1[res].iPixelSize!=resAfter)
sl@0
   829
						{
sl@0
   830
						INFO_PRINTF3(_L("Did not receive expected resolution %ix%i"),resolutionList1[res].iPixelSize.iWidth,resolutionList1[res].iPixelSize.iHeight);
sl@0
   831
						INFO_PRINTF3(_L("Instead got %ix%i"),resAfter.iWidth,resAfter.iHeight);
sl@0
   832
						}
sl@0
   833
					}
sl@0
   834
				}
sl@0
   835
			if (resolutionList1[res].iPixelSize==resBefore)
sl@0
   836
				{
sl@0
   837
				foundBeforeRes=ETrue;
sl@0
   838
				}
sl@0
   839
			}
sl@0
   840
		ASSERT_TRUE(foundBeforeRes);
sl@0
   841
		//restore initial res
sl@0
   842
		interface->SetConfiguration(dispConfigBefore);
sl@0
   843
		Pause(1000);
sl@0
   844
		TDisplayConfiguration dispConfigAfter;
sl@0
   845
		interface->GetConfiguration(dispConfigAfter);
sl@0
   846
		TSize resAfter;
sl@0
   847
		ok=dispConfigAfter.GetResolution(resAfter);
sl@0
   848
		ASSERT_TRUE(ok);	
sl@0
   849
		ASSERT_EQUALS(resBefore,resAfter);
sl@0
   850
		}
sl@0
   851
	else
sl@0
   852
		{
sl@0
   853
		INFO_PRINTF1(_L("Only 1 resolution configured on this screen - res change test skipped."));
sl@0
   854
		}
sl@0
   855
	resolutionList1.Close();
sl@0
   856
	}
sl@0
   857
sl@0
   858
/**
sl@0
   859
@SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0007L
sl@0
   860
@SYMTestCaseDesc		Coordinates Mapping
sl@0
   861
@SYMREQ					REQ10336
sl@0
   862
@SYMPREQ				PREQ2102
sl@0
   863
@SYMTestType			CT
sl@0
   864
@SYMTestPurpose			Basic call to mapcoordinates
sl@0
   865
@SYMTestActions			
sl@0
   866
	Call mapCoordinates
sl@0
   867
@SYMTestExpectedResults	
sl@0
   868
	targetRect should be correctly filled in with same rect as sourceRect
sl@0
   869
*/
sl@0
   870
void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0007L()
sl@0
   871
	{
sl@0
   872
	MDisplayMapping* interface = static_cast<MDisplayMapping*>
sl@0
   873
			(iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
sl@0
   874
	ASSERT_TRUE(interface);
sl@0
   875
	TRect sourceRect(10, 10, 30, 50);
sl@0
   876
	TRect targetRect(5,5,10,10);
sl@0
   877
	TInt err = interface->MapCoordinates(EApplicationSpace, sourceRect, EApplicationSpace, targetRect);
sl@0
   878
	ASSERT_EQUALS(err, KErrNone);
sl@0
   879
	ASSERT_EQUALS(sourceRect, targetRect);
sl@0
   880
	}
sl@0
   881
sl@0
   882
/**
sl@0
   883
@SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0008L
sl@0
   884
@SYMTestCaseDesc		SetModes and mapCoordinates
sl@0
   885
@SYMREQ					REQ10336
sl@0
   886
@SYMPREQ				PREQ2102
sl@0
   887
@SYMTestType			CT
sl@0
   888
@SYMTestPurpose			Basic SetSizeMode and complex MapCoordinates function
sl@0
   889
@SYMTestActions			
sl@0
   890
	Set a new size mode
sl@0
   891
	Perform many rect conversions using MapCoordinates
sl@0
   892
@SYMTestExpectedResults	
sl@0
   893
	Ensure that through multiple conversions, accuracy is not lost
sl@0
   894
*/
sl@0
   895
void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0008L()
sl@0
   896
	{
sl@0
   897
	LOG_AND_PANIC_IF_NOT_GCE;
sl@0
   898
	ResetScreens();
sl@0
   899
	TInt error;
sl@0
   900
	MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0008L"),_L("Change Size Mode"));
sl@0
   901
sl@0
   902
    iTestBack=RBlankWindow(iSession);
sl@0
   903
    ASSERT_EQUALS(iTestBack.Construct(iGroup, ++iWindowHandle), KErrNone);
sl@0
   904
    iTestBack.SetRequiredDisplayMode(iDisplayMode);
sl@0
   905
    iTestBack.SetColor(TRgb(255,0,0));
sl@0
   906
    iTestBack.SetExtent(iTestPos.iTl,iTestPos.Size());
sl@0
   907
    iTestBack.Activate();
sl@0
   908
    iTestBack.SetVisible(ETrue);
sl@0
   909
    iSession.Finish(ETrue);
sl@0
   910
	
sl@0
   911
	
sl@0
   912
	if (CWindowGc*	gc=BeginActivateWithWipe(ETrue,iCompare,TRgb(128,128,128)))
sl@0
   913
		{
sl@0
   914
		gc->SetPenStyle(gc->ESolidPen);
sl@0
   915
		gc->SetPenColor(TRgb(255,255,255));
sl@0
   916
		gc->SetBrushColor(TRgb(0,0,0));
sl@0
   917
		TRect r(2,2,22,22);
sl@0
   918
		while(r.Width()>0)
sl@0
   919
			{
sl@0
   920
			gc->DrawRect(r);
sl@0
   921
			r.Shrink(2,2);
sl@0
   922
			}
sl@0
   923
		gc->Deactivate();
sl@0
   924
		iCompare.EndRedraw();
sl@0
   925
		
sl@0
   926
		}
sl@0
   927
	iSession.Finish(ETrue);
sl@0
   928
	Pause(1000);
sl@0
   929
	
sl@0
   930
	MDisplayControl* interface = static_cast<MDisplayControl*>
sl@0
   931
				(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
sl@0
   932
	ASSERT_TRUE(interface);
sl@0
   933
	
sl@0
   934
	TInt resolutions = interface->NumberOfResolutions();
sl@0
   935
	ASSERT_TRUE (resolutions > 0);
sl@0
   936
	
sl@0
   937
	RArray<MDisplayControl::TResolution> resolutionList1;
sl@0
   938
	error = interface->GetResolutions(resolutionList1);
sl@0
   939
	ASSERT_EQUALS(error,KErrNone);
sl@0
   940
	ASSERT_EQUALS(resolutionList1.Count(), resolutions);
sl@0
   941
	
sl@0
   942
	TDisplayConfiguration dispConfigBefore;
sl@0
   943
	interface->GetConfiguration(dispConfigBefore);
sl@0
   944
	ASSERT_TRUE(dispConfigBefore.IsDefined(dispConfigBefore.EResolution));
sl@0
   945
	
sl@0
   946
	RArray<TInt> screenModeList;
sl@0
   947
	iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
sl@0
   948
	ASSERT_TRUE (screenModeList.Count() > 1);
sl@0
   949
	iScreenDevice->SetAppScreenMode(screenModeList[1]);
sl@0
   950
	iScreenDevice->SetScreenMode(screenModeList[1]);
sl@0
   951
	iSession.Finish(ETrue);
sl@0
   952
	Pause(1000);
sl@0
   953
	
sl@0
   954
	MDisplayMapping* interfaceM = static_cast<MDisplayMapping*>
sl@0
   955
			(iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
sl@0
   956
	TRect appRect(20, 40, 193, 110);
sl@0
   957
	TRect uiRect(1,2,3,4);
sl@0
   958
	TRect compRect(5,6,7,8);
sl@0
   959
	TRect tempRect(10,11,12,13);
sl@0
   960
	TInt err;
sl@0
   961
	while (ETrue)
sl@0
   962
		{
sl@0
   963
		//quick get for a print
sl@0
   964
		err = interfaceM->MapCoordinates(EApplicationSpace, appRect, EFullScreenSpace, uiRect);
sl@0
   965
		err = interfaceM->MapCoordinates(EApplicationSpace, appRect, ECompositionSpace, compRect);
sl@0
   966
		
sl@0
   967
//		print
sl@0
   968
//		INFO_PRINTF5(_L("appRect : %d , %d - %d , %d"),appRect.iTl.iX,appRect.iTl.iY,appRect.iBr.iX,appRect.iBr.iY);
sl@0
   969
//		INFO_PRINTF5(_L("uiRect : %d , %d - %d , %d"),uiRect.iTl.iX,uiRect.iTl.iY,uiRect.iBr.iX,uiRect.iBr.iY);
sl@0
   970
//		INFO_PRINTF5(_L("compRect : %d , %d - %d , %d"),compRect.iTl.iX,compRect.iTl.iY,compRect.iBr.iX,compRect.iBr.iY);
sl@0
   971
//		INFO_PRINTF1(_L("  "));
sl@0
   972
		
sl@0
   973
		//longer process to insure conversions both ways dont lose accuracy
sl@0
   974
		err = interfaceM->MapCoordinates(EApplicationSpace, appRect, EFullScreenSpace, uiRect);
sl@0
   975
		err = interfaceM->MapCoordinates(EFullScreenSpace, uiRect, EApplicationSpace, tempRect);
sl@0
   976
		ASSERT_EQUALS(tempRect,appRect);
sl@0
   977
		
sl@0
   978
		err = interfaceM->MapCoordinates(EApplicationSpace, appRect, ECompositionSpace, compRect);
sl@0
   979
		err = interfaceM->MapCoordinates(ECompositionSpace, compRect, EApplicationSpace, tempRect);
sl@0
   980
		ASSERT_EQUALS(tempRect,appRect);
sl@0
   981
		
sl@0
   982
		err = interfaceM->MapCoordinates(EApplicationSpace, appRect, EFullScreenSpace, uiRect);
sl@0
   983
		err = interfaceM->MapCoordinates(EFullScreenSpace, uiRect, ECompositionSpace, compRect);
sl@0
   984
		err = interfaceM->MapCoordinates(ECompositionSpace, compRect, EFullScreenSpace, tempRect);
sl@0
   985
		ASSERT_EQUALS(tempRect,uiRect);
sl@0
   986
		
sl@0
   987
		appRect.iBr.iX--;
sl@0
   988
		appRect.iBr.iY--;
sl@0
   989
		if (appRect.IsEmpty())
sl@0
   990
			{
sl@0
   991
			break;
sl@0
   992
			}
sl@0
   993
		}
sl@0
   994
	
sl@0
   995
	TRect rect1(5,5,10,10);
sl@0
   996
	TRect rect2(15,15,20,20);
sl@0
   997
	TRect rect3(50,50,50,50);
sl@0
   998
	//1
sl@0
   999
	err = interfaceM->MapCoordinates(ECompositionSpace, rect1, ECompositionSpace, rect2);
sl@0
  1000
	err = interfaceM->MapCoordinates(EFullScreenSpace, rect2, ECompositionSpace, rect3);
sl@0
  1001
	ASSERT_EQUALS(rect1,rect2);
sl@0
  1002
	
sl@0
  1003
	err = interfaceM->MapCoordinates(ECompositionSpace, rect1, EFullScreenSpace, rect2);
sl@0
  1004
	err = interfaceM->MapCoordinates(EFullScreenSpace, rect2, ECompositionSpace, rect3);
sl@0
  1005
	ASSERT_EQUALS(rect1,rect3);
sl@0
  1006
sl@0
  1007
	err = interfaceM->MapCoordinates(ECompositionSpace, rect1, EApplicationSpace, rect2);
sl@0
  1008
	err = interfaceM->MapCoordinates(EApplicationSpace, rect2, ECompositionSpace, rect3);
sl@0
  1009
	ASSERT_EQUALS(rect1,rect3);
sl@0
  1010
	
sl@0
  1011
	err = interfaceM->MapCoordinates(ECompositionSpace, rect1, EDirectScreenAccessSpace, rect2);
sl@0
  1012
	err = interfaceM->MapCoordinates(EDirectScreenAccessSpace, rect2, ECompositionSpace, rect3);
sl@0
  1013
	ASSERT_EQUALS(rect1,rect3);
sl@0
  1014
	
sl@0
  1015
	//2
sl@0
  1016
	err = interfaceM->MapCoordinates(EFullScreenSpace, rect1, EFullScreenSpace, rect2);
sl@0
  1017
	ASSERT_EQUALS(rect1,rect2);
sl@0
  1018
	
sl@0
  1019
	err = interfaceM->MapCoordinates(EFullScreenSpace, rect1, EApplicationSpace, rect2);
sl@0
  1020
	err = interfaceM->MapCoordinates(EApplicationSpace, rect2, EFullScreenSpace, rect3);
sl@0
  1021
	ASSERT_EQUALS(rect1,rect3);
sl@0
  1022
	
sl@0
  1023
	err = interfaceM->MapCoordinates(EFullScreenSpace, rect1, EDirectScreenAccessSpace, rect2);
sl@0
  1024
	err = interfaceM->MapCoordinates(EDirectScreenAccessSpace, rect2, EFullScreenSpace, rect3);
sl@0
  1025
	ASSERT_EQUALS(rect1,rect3);
sl@0
  1026
	
sl@0
  1027
	//3
sl@0
  1028
	err = interfaceM->MapCoordinates(EApplicationSpace, rect1, EApplicationSpace, rect2);
sl@0
  1029
	ASSERT_EQUALS(rect1,rect2);
sl@0
  1030
	
sl@0
  1031
	err = interfaceM->MapCoordinates(EApplicationSpace, rect1, EDirectScreenAccessSpace, rect2);
sl@0
  1032
	err = interfaceM->MapCoordinates(EDirectScreenAccessSpace, rect2, EApplicationSpace, rect3);
sl@0
  1033
	ASSERT_EQUALS(rect1,rect3);
sl@0
  1034
	
sl@0
  1035
	//4
sl@0
  1036
	err = interfaceM->MapCoordinates(EDirectScreenAccessSpace, rect1, EDirectScreenAccessSpace, rect2);
sl@0
  1037
	ASSERT_EQUALS(rect1,rect2);
sl@0
  1038
	
sl@0
  1039
	//invalid
sl@0
  1040
	err = interfaceM->MapCoordinates(ECompositionSpace, rect1, (TCoordinateSpace)0, rect2);
sl@0
  1041
	ASSERT_EQUALS(err,KErrNotSupported);
sl@0
  1042
	err = interfaceM->MapCoordinates(EFullScreenSpace, rect1, (TCoordinateSpace)0, rect2);
sl@0
  1043
	ASSERT_EQUALS(err,KErrNotSupported);
sl@0
  1044
	err = interfaceM->MapCoordinates(EApplicationSpace, rect1, (TCoordinateSpace)0, rect2);
sl@0
  1045
	ASSERT_EQUALS(err,KErrNotSupported);
sl@0
  1046
	err = interfaceM->MapCoordinates(EDirectScreenAccessSpace, rect1, (TCoordinateSpace)0, rect2);
sl@0
  1047
	ASSERT_EQUALS(err,KErrNotSupported);
sl@0
  1048
	err = interfaceM->MapCoordinates((TCoordinateSpace)0, rect1, EDirectScreenAccessSpace, rect2);
sl@0
  1049
	ASSERT_EQUALS(err,KErrNotSupported);
sl@0
  1050
	
sl@0
  1051
	TDisplayConfiguration dispConfigAfter;
sl@0
  1052
	interface->GetConfiguration(dispConfigAfter);
sl@0
  1053
sl@0
  1054
	screenModeList.Close();
sl@0
  1055
	resolutionList1.Close();
sl@0
  1056
	iScreenDevice->SetAppScreenMode(0);
sl@0
  1057
	iScreenDevice->SetScreenMode(0);
sl@0
  1058
	}
sl@0
  1059
sl@0
  1060
/**
sl@0
  1061
@SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0009L
sl@0
  1062
@SYMTestCaseDesc		Set Screen display res using app mode
sl@0
  1063
@SYMREQ					REQ10336
sl@0
  1064
@SYMPREQ				PREQ2102
sl@0
  1065
@SYMTestType			CT
sl@0
  1066
@SYMTestPurpose			SetScreenMode functions correctly
sl@0
  1067
@SYMTestActions			
sl@0
  1068
	Similar to 0006, but setting every available screen mode instead of resolution
sl@0
  1069
@SYMTestExpectedResults	
sl@0
  1070
	Every set should work, including modes that involve a rotation!
sl@0
  1071
*/
sl@0
  1072
void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0009L()
sl@0
  1073
	{
sl@0
  1074
	LOG_AND_PANIC_IF_NOT_GCE;
sl@0
  1075
	ResetScreens();
sl@0
  1076
	TInt error;
sl@0
  1077
	iSession.Finish(ETrue);
sl@0
  1078
	MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0009L"),_L("Change Size Mode"));
sl@0
  1079
	iSession.Finish(ETrue);
sl@0
  1080
sl@0
  1081
    iTestBack=RBlankWindow(iSession);
sl@0
  1082
    ASSERT_EQUALS(iTestBack.Construct(iGroup, ++iWindowHandle), KErrNone);
sl@0
  1083
    iTestBack.SetRequiredDisplayMode(iDisplayMode);
sl@0
  1084
    iTestBack.SetColor(TRgb(255,0,0));
sl@0
  1085
    iTestBack.SetExtent(iTestPos.iTl,iTestPos.Size());
sl@0
  1086
    iTestBack.Activate();
sl@0
  1087
    iTestBack.SetVisible(ETrue);
sl@0
  1088
	iSession.Finish(ETrue);
sl@0
  1089
	
sl@0
  1090
	struct DrawCompare
sl@0
  1091
		{
sl@0
  1092
		static void Draw(CWindowGc*	aGc)
sl@0
  1093
			{
sl@0
  1094
			aGc->SetPenStyle(aGc->ESolidPen);
sl@0
  1095
			aGc->SetPenColor(TRgb(255,255,255));
sl@0
  1096
			aGc->SetBrushColor(TRgb(0,0,0));
sl@0
  1097
			TRect r(2,2,82,82);
sl@0
  1098
			while(r.Width()>0)
sl@0
  1099
				{
sl@0
  1100
				aGc->DrawRect(r);
sl@0
  1101
				r.Shrink(2,2);
sl@0
  1102
				}
sl@0
  1103
			}
sl@0
  1104
		};
sl@0
  1105
	TSurfaceId surfaceID;
sl@0
  1106
	TRAPD(err, surfaceID = iUtility->CreateSurfaceL(TSize(200,200), 
sl@0
  1107
			KSurfaceFormat, 200 * KBytesPerPixel));
sl@0
  1108
	ASSERT_EQUALS(err,KErrNone);
sl@0
  1109
	TRAP(err,iUtility->FanFillSurfaceL(surfaceID,iYellow,iRed,iMagenta));
sl@0
  1110
	ASSERT_EQUALS(err,KErrNone);
sl@0
  1111
	TSurfaceConfiguration surfConf;
sl@0
  1112
	surfConf.SetSurfaceId(surfaceID);
sl@0
  1113
	
sl@0
  1114
	surfConf.SetExtent(TRect(2,84,82,166));
sl@0
  1115
	iCompare.SetBackgroundSurface(surfConf,EFalse);
sl@0
  1116
	
sl@0
  1117
	if (CWindowGc*	gc=BeginActivateWithWipe(ETrue,iCompare,TRgb(128,128,128)))
sl@0
  1118
		{
sl@0
  1119
		DrawCompare::Draw(gc);
sl@0
  1120
		gc->Deactivate();
sl@0
  1121
		iCompare.EndRedraw();
sl@0
  1122
		
sl@0
  1123
		}
sl@0
  1124
	iSession.Finish(ETrue);
sl@0
  1125
	Pause(1000);
sl@0
  1126
	RArray<TInt> screenModeList;
sl@0
  1127
	iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
sl@0
  1128
	MDisplayControl* interface = static_cast<MDisplayControl*>
sl@0
  1129
				(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
sl@0
  1130
	ASSERT_TRUE(interface);
sl@0
  1131
	
sl@0
  1132
	TInt resolutions = interface->NumberOfResolutions();
sl@0
  1133
	ASSERT_TRUE (resolutions > 0);
sl@0
  1134
	
sl@0
  1135
	RArray<MDisplayControl::TResolution> resolutionList1;
sl@0
  1136
	error = interface->GetResolutions(resolutionList1);
sl@0
  1137
	ASSERT_EQUALS(error,KErrNone);
sl@0
  1138
	ASSERT_EQUALS(resolutionList1.Count(), resolutions);
sl@0
  1139
	
sl@0
  1140
	TDisplayConfiguration dispConfigBefore;
sl@0
  1141
	interface->GetConfiguration(dispConfigBefore);
sl@0
  1142
	ASSERT_TRUE(dispConfigBefore.IsDefined(dispConfigBefore.EResolution))
sl@0
  1143
	if (screenModeList.Count()>1)
sl@0
  1144
		{
sl@0
  1145
		//Got a mode to change to!
sl@0
  1146
		TSize resBefore;
sl@0
  1147
		TBool ok=dispConfigBefore.GetResolution(resBefore);
sl@0
  1148
		ASSERT_TRUE(ok);	//we "know" this should be ok, as we just asserted the flag
sl@0
  1149
		for (TInt res=0;res<screenModeList.Count();res++)
sl@0
  1150
			{
sl@0
  1151
				{
sl@0
  1152
					{
sl@0
  1153
					TDisplayConfiguration dispConfigReq;
sl@0
  1154
					iInfoScreenDevice->SetAppScreenMode(screenModeList[res]);
sl@0
  1155
					iInfoScreenDevice->SetScreenMode(screenModeList[res]);
sl@0
  1156
					iSession.Finish(ETrue);
sl@0
  1157
					Pause(300);
sl@0
  1158
					
sl@0
  1159
					TPixelsAndRotation pr;
sl@0
  1160
					iInfoScreenDevice->GetDefaultScreenSizeAndRotation(pr);
sl@0
  1161
					TPoint 	origin=iInfoScreenDevice->GetDefaultScreenModeOrigin();
sl@0
  1162
					Pause(300);
sl@0
  1163
					
sl@0
  1164
					if (CWindowGc*	gc=BeginActivateWithWipe(ETrue,iCompare,TRgb(128,128,128)))
sl@0
  1165
						{
sl@0
  1166
						DrawCompare::Draw(gc);
sl@0
  1167
						gc->Deactivate();
sl@0
  1168
						iCompare.EndRedraw();
sl@0
  1169
						}
sl@0
  1170
					if (iTitle.WsHandle())
sl@0
  1171
						{
sl@0
  1172
						TPoint	infoWinPos;
sl@0
  1173
						TSize	infoWinSize;
sl@0
  1174
						infoWinPos=iTitle.AbsPosition();
sl@0
  1175
						infoWinSize=iTitle.Size();
sl@0
  1176
						infoWinSize.iHeight=pr.iPixelSize.iHeight-2*infoWinPos.iY;
sl@0
  1177
						iTitle.SetSize(infoWinSize);
sl@0
  1178
						}
sl@0
  1179
					TBuf16<20> s;
sl@0
  1180
					s.AppendNum(res);
sl@0
  1181
					UpdateTitleWindowL(s,1);
sl@0
  1182
					s.Zero();
sl@0
  1183
					s.AppendNum(pr.iPixelSize.iWidth);
sl@0
  1184
					s.Append('x');
sl@0
  1185
					s.AppendNum(pr.iPixelSize.iHeight);
sl@0
  1186
					UpdateTitleWindowL(s,2);
sl@0
  1187
					s.Zero();
sl@0
  1188
					s.AppendNum(origin.iX);
sl@0
  1189
					s.Append(',');
sl@0
  1190
					s.AppendNum(origin.iY);
sl@0
  1191
					UpdateTitleWindowL(s,3);
sl@0
  1192
					
sl@0
  1193
					iSession.Finish(ETrue);
sl@0
  1194
					Pause(300);
sl@0
  1195
					
sl@0
  1196
					TPoint winpos=iCompare.AbsPosition();
sl@0
  1197
					TSize winsize=iCompare.Size();
sl@0
  1198
sl@0
  1199
					for (TSize z=TSize(1,1);z!=TSize(-1,-1);)
sl@0
  1200
						{
sl@0
  1201
						for (TInt i=0;i<15;i++)
sl@0
  1202
							{
sl@0
  1203
							winpos+=z;
sl@0
  1204
							iCompare.SetExtent(winpos,winsize);
sl@0
  1205
							iSession.Finish(ETrue);
sl@0
  1206
							Pause(100);
sl@0
  1207
							}
sl@0
  1208
						if (z.iHeight && z.iWidth)
sl@0
  1209
							z=TSize(0,-1);
sl@0
  1210
						else
sl@0
  1211
						if (z.iHeight)
sl@0
  1212
							z=TSize(-1,0);
sl@0
  1213
						else
sl@0
  1214
							z=TSize(-1,-1);
sl@0
  1215
						}
sl@0
  1216
					}
sl@0
  1217
				}
sl@0
  1218
			}
sl@0
  1219
		//restore initial res
sl@0
  1220
		if (screenModeList.Count() > 1)
sl@0
  1221
            {   //set back to basics
sl@0
  1222
            iInfoScreenDevice->SetAppScreenMode(screenModeList[0]);
sl@0
  1223
            iInfoScreenDevice->SetScreenMode(screenModeList[0]);
sl@0
  1224
            Pause(300);
sl@0
  1225
            }
sl@0
  1226
		
sl@0
  1227
		interface->SetConfiguration(dispConfigBefore);
sl@0
  1228
		Pause(1000);
sl@0
  1229
		TDisplayConfiguration dispConfigAfter;
sl@0
  1230
		interface->GetConfiguration(dispConfigAfter);
sl@0
  1231
		TSize resAfter;
sl@0
  1232
		ok=dispConfigAfter.GetResolution(resAfter);
sl@0
  1233
		ASSERT_TRUE(ok);	
sl@0
  1234
		ASSERT_EQUALS(resBefore,resAfter);
sl@0
  1235
		}
sl@0
  1236
	else
sl@0
  1237
		{
sl@0
  1238
		INFO_PRINTF1(_L("Only 1 screen size mode configured on this screen - res change test skipped."));
sl@0
  1239
		}
sl@0
  1240
sl@0
  1241
	screenModeList.Close();
sl@0
  1242
	resolutionList1.Close();
sl@0
  1243
	}
sl@0
  1244
sl@0
  1245
/**
sl@0
  1246
@SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0010L
sl@0
  1247
@SYMTestCaseDesc		Test app mode setting during attach/detach
sl@0
  1248
@SYMREQ					REQ10330
sl@0
  1249
@SYMPREQ				PREQ2102
sl@0
  1250
@SYMTestType			CT
sl@0
  1251
@SYMTestPurpose			Make sure display resumes last app mode when reattached
sl@0
  1252
@SYMTestActions			
sl@0
  1253
	Save app mode and display configuration before detach and compare it with those after reattach.
sl@0
  1254
	Repeat for a second app mode
sl@0
  1255
	If available, repeat with dynamic app mode
sl@0
  1256
@SYMTestExpectedResults	
sl@0
  1257
	For normal app mode, on reconnect it should re apply the old configuration
sl@0
  1258
	For dynamic app mode, on reconnect it should be 0x0	
sl@0
  1259
*/
sl@0
  1260
void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0010L()
sl@0
  1261
	{
sl@0
  1262
	LOG_AND_PANIC_IF_NOT_GCE;
sl@0
  1263
	ResetScreens();
sl@0
  1264
#ifdef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER
sl@0
  1265
	ASSERT_FALSE("Test not compiled because MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER");
sl@0
  1266
#else
sl@0
  1267
	TInt error;
sl@0
  1268
	iSession.Finish(ETrue);
sl@0
  1269
	MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0010L"),_L("detach/attach"));
sl@0
  1270
	iSession.Finish(ETrue);
sl@0
  1271
sl@0
  1272
	Pause(1000);
sl@0
  1273
	TInt screenNo = iScreenDevice->GetScreenNumber();
sl@0
  1274
	RArray<TInt> screenModeList;
sl@0
  1275
	iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
sl@0
  1276
	
sl@0
  1277
	//Find 2 real app modes and 1 dynamic app mode
sl@0
  1278
	TInt firstAvailableAppMode = -1;
sl@0
  1279
	TInt secondAvailableAppMode = -1;
sl@0
  1280
	TInt dynamicAppMode = -1;
sl@0
  1281
	for (TInt ii = 0; ii < screenModeList.Count(); ii++)
sl@0
  1282
		{
sl@0
  1283
		TBool dynamic = iInfoScreenDevice->IsModeDynamic(screenModeList[ii]);
sl@0
  1284
		if (dynamic && dynamicAppMode == -1)
sl@0
  1285
			{
sl@0
  1286
			dynamicAppMode = screenModeList[ii];
sl@0
  1287
			}
sl@0
  1288
		if (!dynamic)
sl@0
  1289
			{
sl@0
  1290
			if (firstAvailableAppMode == -1)
sl@0
  1291
				{
sl@0
  1292
				firstAvailableAppMode = screenModeList[ii];
sl@0
  1293
				}
sl@0
  1294
			else if (secondAvailableAppMode == -1)
sl@0
  1295
				{
sl@0
  1296
				secondAvailableAppMode = screenModeList[ii];
sl@0
  1297
				}
sl@0
  1298
			}
sl@0
  1299
		}
sl@0
  1300
	ASSERT_TRUE(firstAvailableAppMode!=-1);
sl@0
  1301
	ASSERT_TRUE(secondAvailableAppMode!=-1);
sl@0
  1302
	
sl@0
  1303
	MDisplayControl* interface = static_cast<MDisplayControl*>
sl@0
  1304
				(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
sl@0
  1305
	ASSERT_TRUE(interface);
sl@0
  1306
	
sl@0
  1307
	MDisplayMapping* mappingInterface = static_cast<MDisplayMapping*>
sl@0
  1308
				(iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
sl@0
  1309
	ASSERT_TRUE(mappingInterface);
sl@0
  1310
	
sl@0
  1311
	TInt resolutions = interface->NumberOfResolutions();
sl@0
  1312
	ASSERT_TRUE (resolutions > 0);
sl@0
  1313
	
sl@0
  1314
	RArray<MDisplayControl::TResolution> resolutionList1;
sl@0
  1315
	error = interface->GetResolutions(resolutionList1);
sl@0
  1316
	ASSERT_EQUALS(error,KErrNone);
sl@0
  1317
	ASSERT_EQUALS(resolutionList1.Count(), resolutions);
sl@0
  1318
	
sl@0
  1319
	TDisplayConfiguration configBeforeDetach, configAfterReattach;
sl@0
  1320
	TInt appModeBeforeDetach, appModeAfterReattach;
sl@0
  1321
sl@0
  1322
	//
sl@0
  1323
	//1st detach - attach sequence
sl@0
  1324
	appModeBeforeDetach = firstAvailableAppMode;
sl@0
  1325
	iScreenDevice->SetAppScreenMode(appModeBeforeDetach );
sl@0
  1326
	iScreenDevice->SetScreenMode(appModeBeforeDetach );
sl@0
  1327
	Pause(200);
sl@0
  1328
	interface->GetConfiguration(configBeforeDetach);
sl@0
  1329
	
sl@0
  1330
	TInt displayState = EDisconnect;
sl@0
  1331
	UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
sl@0
  1332
	Pause(300);
sl@0
  1333
	
sl@0
  1334
	//dummy mapping should return KErrNotReady if display is disconnected
sl@0
  1335
	TRect dummyRect(1,2,5,8);
sl@0
  1336
	error = mappingInterface->MapCoordinates(ECompositionSpace, dummyRect, EFullScreenSpace, dummyRect);
sl@0
  1337
	ASSERT_EQUALS(error, KErrNotReady);
sl@0
  1338
	
sl@0
  1339
	displayState = ENormalResolution;
sl@0
  1340
	UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
sl@0
  1341
	Pause(300);
sl@0
  1342
	
sl@0
  1343
	interface->GetConfiguration(configAfterReattach);
sl@0
  1344
	ASSERT_TRUE(configBeforeDetach==configAfterReattach);
sl@0
  1345
	appModeAfterReattach = iScreenDevice->CurrentScreenMode();
sl@0
  1346
	ASSERT_EQUALS(appModeBeforeDetach, appModeAfterReattach);
sl@0
  1347
	//1st detach - attach sequence ends here
sl@0
  1348
	//
sl@0
  1349
	
sl@0
  1350
	configBeforeDetach.ClearAll();
sl@0
  1351
	configAfterReattach.ClearAll();
sl@0
  1352
	
sl@0
  1353
	//
sl@0
  1354
	//2nd detach-attach sequence - non dynamic app mode
sl@0
  1355
	iScreenDevice->SetAppScreenMode(secondAvailableAppMode);
sl@0
  1356
	iScreenDevice->SetScreenMode(secondAvailableAppMode);
sl@0
  1357
	Pause(200);
sl@0
  1358
	appModeBeforeDetach = iScreenDevice->CurrentScreenMode();
sl@0
  1359
	interface->GetConfiguration(configBeforeDetach);
sl@0
  1360
	displayState = EDisconnect;
sl@0
  1361
	UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
sl@0
  1362
	Pause(300);
sl@0
  1363
	//dummy mapping should return KErrNotReady if display is disconnected
sl@0
  1364
	error = mappingInterface->MapCoordinates(ECompositionSpace, dummyRect, EFullScreenSpace, dummyRect);
sl@0
  1365
	ASSERT_EQUALS(error, KErrNotReady);
sl@0
  1366
	
sl@0
  1367
	displayState = ENoResolution;
sl@0
  1368
	UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
sl@0
  1369
	Pause(300);
sl@0
  1370
	//dummy mapping should return KErrNotReady if display is disconnected
sl@0
  1371
	error = mappingInterface->MapCoordinates(ECompositionSpace, dummyRect, EFullScreenSpace, dummyRect);
sl@0
  1372
	ASSERT_EQUALS(error, KErrNotReady);
sl@0
  1373
	
sl@0
  1374
	displayState = ENormalResolution;
sl@0
  1375
	UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
sl@0
  1376
	Pause(300);
sl@0
  1377
	
sl@0
  1378
	interface->GetConfiguration(configAfterReattach);
sl@0
  1379
	ASSERT_TRUE(configBeforeDetach==configAfterReattach);
sl@0
  1380
	appModeAfterReattach = iScreenDevice->CurrentScreenMode();
sl@0
  1381
	ASSERT_EQUALS(appModeBeforeDetach, appModeAfterReattach);
sl@0
  1382
	//2nd detach-attach sequence ends here
sl@0
  1383
	//
sl@0
  1384
	
sl@0
  1385
	configBeforeDetach.ClearAll();
sl@0
  1386
	configAfterReattach.ClearAll();
sl@0
  1387
	
sl@0
  1388
	//
sl@0
  1389
	//3rd detach-attach sequence - dynamic app mode
sl@0
  1390
	if (dynamicAppMode == -1)
sl@0
  1391
		{
sl@0
  1392
		screenModeList.Close();
sl@0
  1393
		resolutionList1.Close();
sl@0
  1394
		INFO_PRINTF1(_L("No dynamic app mode, end test"));	//not a fail if there isn't a dynamic app mode
sl@0
  1395
		return;
sl@0
  1396
		}
sl@0
  1397
	
sl@0
  1398
	iScreenDevice->SetAppScreenMode(dynamicAppMode);
sl@0
  1399
	iScreenDevice->SetScreenMode(dynamicAppMode);
sl@0
  1400
	Pause(200);
sl@0
  1401
	appModeBeforeDetach = iScreenDevice->CurrentScreenMode();
sl@0
  1402
	interface->GetConfiguration(configBeforeDetach);
sl@0
  1403
	displayState = EDisconnect;
sl@0
  1404
	UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
sl@0
  1405
	Pause(300);
sl@0
  1406
	//dummy mapping should return KErrNotReady if display is disconnected
sl@0
  1407
	error = mappingInterface->MapCoordinates(ECompositionSpace, dummyRect, EFullScreenSpace, dummyRect);
sl@0
  1408
	ASSERT_EQUALS(error, KErrNotReady);
sl@0
  1409
	
sl@0
  1410
	displayState = ENoResolution;
sl@0
  1411
	UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
sl@0
  1412
	Pause(300);
sl@0
  1413
	//dummy mapping should return KErrNotReady if display is disconnected
sl@0
  1414
	error = mappingInterface->MapCoordinates(ECompositionSpace, dummyRect, EFullScreenSpace, dummyRect);
sl@0
  1415
	ASSERT_EQUALS(error, KErrNotReady);
sl@0
  1416
	
sl@0
  1417
	displayState = ENormalResolution;
sl@0
  1418
	UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
sl@0
  1419
	Pause(300);
sl@0
  1420
	
sl@0
  1421
	interface->GetConfiguration(configAfterReattach);
sl@0
  1422
	ASSERT_FALSE(configBeforeDetach==configAfterReattach);
sl@0
  1423
	TSize afterReattachSize;
sl@0
  1424
	ASSERT_TRUE(configAfterReattach.GetResolution(afterReattachSize));
sl@0
  1425
	ASSERT_EQUALS(afterReattachSize,TSize(0,0));
sl@0
  1426
	ASSERT_TRUE(configAfterReattach.GetResolutionTwips(afterReattachSize));
sl@0
  1427
	ASSERT_EQUALS(afterReattachSize,TSize(0,0));
sl@0
  1428
	
sl@0
  1429
	appModeAfterReattach = iScreenDevice->CurrentScreenMode();
sl@0
  1430
	ASSERT_EQUALS(appModeBeforeDetach, appModeAfterReattach);
sl@0
  1431
	//3rd detach-attach sequence ends here
sl@0
  1432
	//
sl@0
  1433
	
sl@0
  1434
	screenModeList.Close();
sl@0
  1435
	resolutionList1.Close();
sl@0
  1436
#endif
sl@0
  1437
	}
sl@0
  1438
sl@0
  1439
sl@0
  1440
CDSATestDrawing::CDSATestDrawing():CTimer(EPriorityStandard)
sl@0
  1441
	{}
sl@0
  1442
sl@0
  1443
CDSATestDrawing::~CDSATestDrawing()
sl@0
  1444
	{
sl@0
  1445
	Cancel();
sl@0
  1446
	}
sl@0
  1447
CDSATestDrawing* CDSATestDrawing::NewL()
sl@0
  1448
	{
sl@0
  1449
	CDSATestDrawing *self = new(ELeave) CDSATestDrawing();
sl@0
  1450
	CleanupStack::PushL(self);
sl@0
  1451
	self->ConstructL();
sl@0
  1452
	CleanupStack::Pop(self);
sl@0
  1453
	return self;
sl@0
  1454
	}
sl@0
  1455
sl@0
  1456
void CDSATestDrawing::ConstructL()
sl@0
  1457
	{
sl@0
  1458
	CTimer::ConstructL();
sl@0
  1459
	CActiveScheduler::Add(this);
sl@0
  1460
	}
sl@0
  1461
sl@0
  1462
void CDSATestDrawing::StartDrawingL(CDirectScreenAccess *aDSA)
sl@0
  1463
	{
sl@0
  1464
	
sl@0
  1465
	if(aDSA)
sl@0
  1466
		{
sl@0
  1467
		iDSA = aDSA;
sl@0
  1468
		}
sl@0
  1469
	
sl@0
  1470
	if(iDSA)
sl@0
  1471
		{
sl@0
  1472
		iDSA->StartL();
sl@0
  1473
		
sl@0
  1474
		iRect = TRect(TPoint(0,0), iDSA->DrawingRegion()->BoundingRect().Size());
sl@0
  1475
		
sl@0
  1476
		iWin->Invalidate();
sl@0
  1477
		iWin->BeginRedraw();
sl@0
  1478
		CFbsBitGc* gc = iDSA->Gc();
sl@0
  1479
		gc->SetBrushColor(TRgb(220,220,220));
sl@0
  1480
		gc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
  1481
		gc->Clear();
sl@0
  1482
		iWin->EndRedraw();
sl@0
  1483
		After(500000);
sl@0
  1484
		}
sl@0
  1485
	
sl@0
  1486
	}
sl@0
  1487
sl@0
  1488
void CDSATestDrawing::RunL()
sl@0
  1489
	{
sl@0
  1490
	Draw();
sl@0
  1491
	After(500000);
sl@0
  1492
	}
sl@0
  1493
sl@0
  1494
void CDSATestDrawing::Draw()
sl@0
  1495
	{
sl@0
  1496
	//Should not invalidate the window containing DSA drawing. That's the whole point!
sl@0
  1497
	CFbsBitGc* gc = iDSA->Gc();
sl@0
  1498
	gc->SetPenStyle(gc->ESolidPen);
sl@0
  1499
	gc->SetPenColor(TRgb(255,0,0));
sl@0
  1500
	gc->SetBrushStyle(gc->ENullBrush);
sl@0
  1501
	iRect.Shrink(1, 1);
sl@0
  1502
	gc->DrawRect(iRect);
sl@0
  1503
	iDSA->ScreenDevice()->Update();
sl@0
  1504
	
sl@0
  1505
	}
sl@0
  1506
void CDSATestDrawing::Restart(RDirectScreenAccess::TTerminationReasons /*aReason*/) 
sl@0
  1507
	{
sl@0
  1508
	
sl@0
  1509
	StartDrawingL(NULL);
sl@0
  1510
	}
sl@0
  1511
sl@0
  1512
void CDSATestDrawing::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/)
sl@0
  1513
	{
sl@0
  1514
	Cancel();
sl@0
  1515
	}
sl@0
  1516
sl@0
  1517
/**
sl@0
  1518
@SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0011L
sl@0
  1519
@SYMTestCaseDesc		Test DSA drawing in different App Mode
sl@0
  1520
@SYMREQ					REQ10332 REQ10336
sl@0
  1521
@SYMPREQ				PREQ2102
sl@0
  1522
@SYMTestType			CT
sl@0
  1523
@SYMTestPurpose			Test DSA can restart and draw at correct place when screen mode changes
sl@0
  1524
@SYMTestActions			
sl@0
  1525
	A rectangle will be drawn 1 pixel inside the DSA drawing region, and continue to shrink before the drawing
sl@0
  1526
	time runs out. when screen mode changes, DSA should restart and the rectangle should be reset to 1 pixel inside
sl@0
  1527
	the new drawing region.
sl@0
  1528
	
sl@0
  1529
	note: DSA drawing region is clipped by DSA buffer, App Size and the visible area of the window which it drawns in
sl@0
  1530
@SYMTestExpectedResults	
sl@0
  1531
	All tests should pass.
sl@0
  1532
	
sl@0
  1533
*/
sl@0
  1534
void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0011L()
sl@0
  1535
	{
sl@0
  1536
	LOG_AND_PANIC_IF_NOT_GCE;
sl@0
  1537
	ResetScreens();
sl@0
  1538
sl@0
  1539
	Pause(1000);
sl@0
  1540
	MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0011L"),_L("DSA drawing"));
sl@0
  1541
	CDSATestDrawing *dsaDraw = CDSATestDrawing::NewL();
sl@0
  1542
	CleanupStack::PushL(dsaDraw);
sl@0
  1543
	CDirectScreenAccess *dsa = CDirectScreenAccess::NewL(iSession, *iScreenDevice, iCompare, *dsaDraw);
sl@0
  1544
	CleanupStack::PushL(dsa);
sl@0
  1545
	dsaDraw->SetWindow(iCompare);
sl@0
  1546
	dsaDraw->StartDrawingL(dsa);
sl@0
  1547
	
sl@0
  1548
	CEventTimer *timer = CEventTimer::NewL();
sl@0
  1549
	CleanupStack::PushL(timer);
sl@0
  1550
	
sl@0
  1551
	RArray<TInt> screenModeList;
sl@0
  1552
	iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
sl@0
  1553
	MDisplayControl* interface = static_cast<MDisplayControl*>
sl@0
  1554
				(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
sl@0
  1555
	ASSERT_TRUE(interface);
sl@0
  1556
	
sl@0
  1557
	MDisplayMapping* mappingInterface = static_cast<MDisplayMapping*>
sl@0
  1558
				(iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
sl@0
  1559
	ASSERT_TRUE(mappingInterface);
sl@0
  1560
	
sl@0
  1561
	CFbsScreenDevice *pixelReadBackDevice = CFbsScreenDevice::NewL(iScreenDevice->GetScreenNumber(), iScreenDevice->DisplayMode());
sl@0
  1562
	CleanupStack::PushL(pixelReadBackDevice);
sl@0
  1563
	
sl@0
  1564
	for (TInt res=0;res<screenModeList.Count();res++)
sl@0
  1565
		{
sl@0
  1566
		iScreenDevice->SetAppScreenMode(screenModeList[res]);
sl@0
  1567
		iScreenDevice->SetScreenMode(screenModeList[res]);
sl@0
  1568
		dsa->ScreenDevice()->Update();
sl@0
  1569
		Pause(300);
sl@0
  1570
		//wait for DSA to restart
sl@0
  1571
		timer->Wait(500000);
sl@0
  1572
		TRect regionRect(dsa->DrawingRegion()->BoundingRect());
sl@0
  1573
sl@0
  1574
		TPoint winpos = iCompare.AbsPosition();
sl@0
  1575
		TSize winsize = iCompare.Size();
sl@0
  1576
		
sl@0
  1577
		TPixelsAndRotation pr;
sl@0
  1578
		iInfoScreenDevice->GetDefaultScreenSizeAndRotation(pr);
sl@0
  1579
		TPoint 	origin=iInfoScreenDevice->GetDefaultScreenModeOrigin();
sl@0
  1580
		Pause(300);
sl@0
  1581
		if (iTitle.WsHandle())
sl@0
  1582
			{
sl@0
  1583
			TPoint	infoWinPos;
sl@0
  1584
			TSize	infoWinSize;
sl@0
  1585
			infoWinPos=iTitle.AbsPosition();
sl@0
  1586
			infoWinSize=iTitle.Size();
sl@0
  1587
			infoWinSize.iHeight=pr.iPixelSize.iHeight-2*infoWinPos.iY;
sl@0
  1588
			iTitle.SetSize(infoWinSize);
sl@0
  1589
			}
sl@0
  1590
		TBuf16<20> s;
sl@0
  1591
		s.AppendNum(res);
sl@0
  1592
		UpdateTitleWindowL(s,1);
sl@0
  1593
		s.Zero();
sl@0
  1594
		s.AppendNum(pr.iPixelSize.iWidth);
sl@0
  1595
		s.Append('x');
sl@0
  1596
		s.AppendNum(pr.iPixelSize.iHeight);
sl@0
  1597
		UpdateTitleWindowL(s,2);
sl@0
  1598
		s.Zero();
sl@0
  1599
		s.AppendNum(origin.iX);
sl@0
  1600
		s.Append(',');
sl@0
  1601
		s.AppendNum(origin.iY);
sl@0
  1602
		UpdateTitleWindowL(s,3);
sl@0
  1603
		
sl@0
  1604
		INFO_PRINTF2(_L("---------test %i---------"), res);
sl@0
  1605
		INFO_PRINTF3(_L("resolution %i x %i"), pr.iPixelSize.iWidth, pr.iPixelSize.iHeight);
sl@0
  1606
		INFO_PRINTF3(_L("Origin (%i, %i)"), origin.iX, origin.iY);
sl@0
  1607
		//INFO_PRINTF3(_L("Test Window Origin (%i, %i)"), iCompare.AbsPosition().iX, iCompare.AbsPosition().iY);
sl@0
  1608
		INFO_PRINTF3(_L("DSA drawing region bounding rect origin (%i, %i)"), dsa->DrawingRegion()->BoundingRect().iTl.iX,
sl@0
  1609
				dsa->DrawingRegion()->BoundingRect().iTl.iY);
sl@0
  1610
		INFO_PRINTF3(_L("DSA drawing region bounding rect size (%i x %i)"), dsa->DrawingRegion()->BoundingRect().Width(),
sl@0
  1611
						dsa->DrawingRegion()->BoundingRect().Height());
sl@0
  1612
		//give time so DSA AO can start drawing
sl@0
  1613
		timer->Wait(5000000);
sl@0
  1614
		
sl@0
  1615
sl@0
  1616
		TRect readBackRect;
sl@0
  1617
		mappingInterface->MapCoordinates(EApplicationSpace, TRect(0,0,1,1), EDirectScreenAccessSpace, readBackRect);
sl@0
  1618
		pixelReadBackDevice->SetDrawDeviceOffset(readBackRect.iTl);
sl@0
  1619
		pixelReadBackDevice->SetDeviceOrientation((TDeviceOrientation)(1 << pr.iRotation));
sl@0
  1620
		readBackRect.SetRect(dsa->DrawingRegion()->BoundingRect().iTl, dsa->DrawingRegion()->BoundingRect().iBr);
sl@0
  1621
		
sl@0
  1622
		if(readBackRect.IsEmpty())
sl@0
  1623
			{
sl@0
  1624
			INFO_PRINTF1(_L("DSA drawing region is empty, skip checking pixel colour"));
sl@0
  1625
			continue;
sl@0
  1626
			}
sl@0
  1627
		
sl@0
  1628
		//Ruo: Oh I almost believe iBr is exclusive now
sl@0
  1629
		TDisplayConfiguration dispConfigAfter2;
sl@0
  1630
		interface->GetConfiguration(dispConfigAfter2);
sl@0
  1631
		TSize theSize;
sl@0
  1632
		dispConfigAfter2.GetResolution(theSize);
sl@0
  1633
		TDisplayConfiguration1::TRotation orient;
sl@0
  1634
		dispConfigAfter2.GetRotation(orient);
sl@0
  1635
		if (orient == TDisplayConfiguration1::ERotation90CW || orient == TDisplayConfiguration1::ERotation270CW)
sl@0
  1636
			{
sl@0
  1637
			TInt temp = theSize.iHeight;
sl@0
  1638
			theSize.iHeight = theSize.iWidth;
sl@0
  1639
			theSize.iWidth = temp;
sl@0
  1640
			}
sl@0
  1641
		TRect uiSize(TPoint(0,0), theSize);
sl@0
  1642
		MDisplayMapping* mappingInterface = static_cast<MDisplayMapping*>
sl@0
  1643
					(iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
sl@0
  1644
		ASSERT_TRUE(mappingInterface);
sl@0
  1645
		TRect finalSize;
sl@0
  1646
		mappingInterface->MapCoordinates(EApplicationSpace, uiSize, ECompositionSpace, finalSize);
sl@0
  1647
				
sl@0
  1648
		CFbsBitmap* bmp2 = new (ELeave) CFbsBitmap;
sl@0
  1649
		CleanupStack::PushL(bmp2);
sl@0
  1650
		User::LeaveIfError(bmp2->Create(finalSize.Size(), EColor16MU));
sl@0
  1651
		MTestScreenCapture
sl@0
  1652
				* csc =
sl@0
  1653
						static_cast<MTestScreenCapture*> (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf));
sl@0
  1654
	
sl@0
  1655
		if (csc)
sl@0
  1656
			{
sl@0
  1657
			TInt errr = csc->ComposeScreen(*bmp2);
sl@0
  1658
			ASSERT_TRUE(errr == KErrNone);
sl@0
  1659
			}
sl@0
  1660
		else
sl@0
  1661
			{
sl@0
  1662
			if (!cSCLogged)
sl@0
  1663
				{
sl@0
  1664
				cSCLogged = ETrue;
sl@0
  1665
				_LIT(KNoCSC, "CSC testing not enabled as CSC render stage not defined");
sl@0
  1666
				Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrAll, KNoCSC);
sl@0
  1667
				}
sl@0
  1668
			}
sl@0
  1669
sl@0
  1670
		readBackRect.iBr = readBackRect.iBr - TPoint(1,1);
sl@0
  1671
		//check 4 outter corners
sl@0
  1672
		TRgb pixelRgb;
sl@0
  1673
		TRgb cornerRgb(220, 220, 220);
sl@0
  1674
		TRgb innerRgb(255, 0, 0);
sl@0
  1675
		readBackRect.Grow(1, 1);
sl@0
  1676
		TRect compSpaceReadBackRect;
sl@0
  1677
		mappingInterface->MapCoordinates(EApplicationSpace, readBackRect, ECompositionSpace, compSpaceReadBackRect);
sl@0
  1678
sl@0
  1679
			
sl@0
  1680
		if (csc)
sl@0
  1681
			{
sl@0
  1682
			if (finalSize.Contains(compSpaceReadBackRect.iTl))
sl@0
  1683
				{
sl@0
  1684
				bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iTl);
sl@0
  1685
				if(!(pixelRgb != cornerRgb))
sl@0
  1686
					{
sl@0
  1687
					_LIT(KCompareFailed, "Corner check failed on app mode: %d");
sl@0
  1688
					TBuf<256> x;
sl@0
  1689
					x.Format(KCompareFailed, res+1);
sl@0
  1690
					Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
sl@0
  1691
					CleanupStack::PopAndDestroy(bmp2);
sl@0
  1692
					continue;
sl@0
  1693
					}
sl@0
  1694
				}
sl@0
  1695
			if (finalSize.Contains(TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY)))
sl@0
  1696
				{
sl@0
  1697
				bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY));
sl@0
  1698
				if(!(pixelRgb != cornerRgb))
sl@0
  1699
					{
sl@0
  1700
					_LIT(KCompareFailed, "Corner check failed on app mode: %d");
sl@0
  1701
					TBuf<256> x;
sl@0
  1702
					x.Format(KCompareFailed, res+1);
sl@0
  1703
					Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
sl@0
  1704
					CleanupStack::PopAndDestroy(bmp2);
sl@0
  1705
					continue;
sl@0
  1706
					}
sl@0
  1707
				}
sl@0
  1708
			if (finalSize.Contains(compSpaceReadBackRect.iBr))
sl@0
  1709
				{
sl@0
  1710
				bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iBr);
sl@0
  1711
				if(!(pixelRgb != cornerRgb))
sl@0
  1712
					{
sl@0
  1713
					_LIT(KCompareFailed, "Corner check failed on app mode: %d");
sl@0
  1714
					TBuf<256> x;
sl@0
  1715
					x.Format(KCompareFailed, res+1);
sl@0
  1716
					Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
sl@0
  1717
					CleanupStack::PopAndDestroy(bmp2);
sl@0
  1718
					continue;
sl@0
  1719
					}
sl@0
  1720
				}
sl@0
  1721
			if (finalSize.Contains(TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY)))
sl@0
  1722
				{
sl@0
  1723
				bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY));
sl@0
  1724
				if(!(pixelRgb != cornerRgb))
sl@0
  1725
					{
sl@0
  1726
					_LIT(KCompareFailed, "Corner check failed on app mode: %d");
sl@0
  1727
					TBuf<256> x;
sl@0
  1728
					x.Format(KCompareFailed, res+1);
sl@0
  1729
					Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
sl@0
  1730
					CleanupStack::PopAndDestroy(bmp2);
sl@0
  1731
					continue;
sl@0
  1732
					}
sl@0
  1733
				}
sl@0
  1734
			}
sl@0
  1735
		
sl@0
  1736
		pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iTl);
sl@0
  1737
		ASSERT_TRUE(pixelRgb != cornerRgb);
sl@0
  1738
		pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iBr.iX, readBackRect.iTl.iY));
sl@0
  1739
		ASSERT_TRUE(pixelRgb != cornerRgb);
sl@0
  1740
		pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iBr);
sl@0
  1741
		ASSERT_TRUE(pixelRgb != cornerRgb);
sl@0
  1742
		pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iTl.iX, readBackRect.iBr.iY));
sl@0
  1743
		ASSERT_TRUE(pixelRgb != cornerRgb);
sl@0
  1744
		
sl@0
  1745
		//check 4 inner corners
sl@0
  1746
		readBackRect.Shrink(1,1);
sl@0
  1747
		mappingInterface->MapCoordinates(EApplicationSpace, readBackRect, ECompositionSpace, compSpaceReadBackRect);
sl@0
  1748
	
sl@0
  1749
		if (csc)
sl@0
  1750
			{
sl@0
  1751
			if (finalSize.Contains(compSpaceReadBackRect.iTl))
sl@0
  1752
				{
sl@0
  1753
				bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iTl);
sl@0
  1754
				if(!(pixelRgb == cornerRgb))
sl@0
  1755
					{
sl@0
  1756
					_LIT(KCompareFailed, "Corner check failed on app mode: %d");
sl@0
  1757
					TBuf<256> x;
sl@0
  1758
					x.Format(KCompareFailed, res+1);
sl@0
  1759
					Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
sl@0
  1760
					CleanupStack::PopAndDestroy(bmp2);
sl@0
  1761
					continue;
sl@0
  1762
					}
sl@0
  1763
				}
sl@0
  1764
			if (finalSize.Contains(TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY)))
sl@0
  1765
				{
sl@0
  1766
				bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY));
sl@0
  1767
				if(!(pixelRgb == cornerRgb))
sl@0
  1768
					{
sl@0
  1769
					_LIT(KCompareFailed, "Corner check failed on app mode: %d");
sl@0
  1770
					TBuf<256> x;
sl@0
  1771
					x.Format(KCompareFailed, res+1);
sl@0
  1772
					Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
sl@0
  1773
					CleanupStack::PopAndDestroy(bmp2);
sl@0
  1774
					continue;
sl@0
  1775
					}
sl@0
  1776
				}
sl@0
  1777
			if (finalSize.Contains(compSpaceReadBackRect.iBr))
sl@0
  1778
				{
sl@0
  1779
				bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iBr);
sl@0
  1780
				if(!(pixelRgb == cornerRgb))
sl@0
  1781
					{
sl@0
  1782
					_LIT(KCompareFailed, "Corner check failed on app mode: %d");
sl@0
  1783
					TBuf<256> x;
sl@0
  1784
					x.Format(KCompareFailed, res+1);
sl@0
  1785
					Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
sl@0
  1786
					CleanupStack::PopAndDestroy(bmp2);
sl@0
  1787
					continue;
sl@0
  1788
					}
sl@0
  1789
				}
sl@0
  1790
			if (finalSize.Contains(TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY)))
sl@0
  1791
				{
sl@0
  1792
				bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY));
sl@0
  1793
				if(!(pixelRgb == cornerRgb))
sl@0
  1794
					{
sl@0
  1795
					_LIT(KCompareFailed, "Corner check failed on app mode: %d");
sl@0
  1796
					TBuf<256> x;
sl@0
  1797
					x.Format(KCompareFailed, res+1);
sl@0
  1798
					Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
sl@0
  1799
					CleanupStack::PopAndDestroy(bmp2);
sl@0
  1800
					continue;
sl@0
  1801
					}
sl@0
  1802
				}
sl@0
  1803
			}
sl@0
  1804
		
sl@0
  1805
		pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iTl);
sl@0
  1806
		ASSERT_TRUE(pixelRgb == cornerRgb);
sl@0
  1807
		pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iBr.iX, readBackRect.iTl.iY));
sl@0
  1808
		ASSERT_TRUE(pixelRgb == cornerRgb);
sl@0
  1809
		pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iBr);
sl@0
  1810
		ASSERT_TRUE(pixelRgb == cornerRgb);
sl@0
  1811
		pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iTl.iX, readBackRect.iBr.iY));
sl@0
  1812
		ASSERT_TRUE(pixelRgb == cornerRgb);
sl@0
  1813
		//check inner colour
sl@0
  1814
		if(readBackRect.Width() < 3 || readBackRect.Height() < 3)
sl@0
  1815
			{
sl@0
  1816
			INFO_PRINTF1(_L("DSA drawing region is too small for drawing inner rectangle skip checking inner colour"));
sl@0
  1817
			CleanupStack::PopAndDestroy(bmp2);
sl@0
  1818
			continue;
sl@0
  1819
			}
sl@0
  1820
		
sl@0
  1821
		readBackRect.Shrink(1,1);
sl@0
  1822
		mappingInterface->MapCoordinates(EApplicationSpace, readBackRect, ECompositionSpace, compSpaceReadBackRect);
sl@0
  1823
		
sl@0
  1824
		if (csc)
sl@0
  1825
			{
sl@0
  1826
			if (finalSize.Contains(compSpaceReadBackRect.iTl))
sl@0
  1827
				{
sl@0
  1828
				bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iTl);
sl@0
  1829
				if(!(pixelRgb == innerRgb))
sl@0
  1830
					{
sl@0
  1831
					_LIT(KCompareFailed, "Corner check failed on app mode: %d");
sl@0
  1832
					TBuf<256> x;
sl@0
  1833
					x.Format(KCompareFailed, res+1);
sl@0
  1834
					Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
sl@0
  1835
					CleanupStack::PopAndDestroy(bmp2);
sl@0
  1836
					continue;
sl@0
  1837
					}
sl@0
  1838
				}
sl@0
  1839
			if (finalSize.Contains(TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY)))
sl@0
  1840
				{
sl@0
  1841
				bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY));
sl@0
  1842
				if(!(pixelRgb == innerRgb))
sl@0
  1843
					{
sl@0
  1844
					_LIT(KCompareFailed, "Corner check failed on app mode: %d");
sl@0
  1845
					TBuf<256> x;
sl@0
  1846
					x.Format(KCompareFailed, res+1);
sl@0
  1847
					Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
sl@0
  1848
					CleanupStack::PopAndDestroy(bmp2);
sl@0
  1849
					continue;
sl@0
  1850
					}
sl@0
  1851
				}
sl@0
  1852
			if (finalSize.Contains(compSpaceReadBackRect.iBr))
sl@0
  1853
				{
sl@0
  1854
				bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iBr);
sl@0
  1855
				if(!(pixelRgb == innerRgb))
sl@0
  1856
					{
sl@0
  1857
					_LIT(KCompareFailed, "Corner check failed on app mode: %d");
sl@0
  1858
					TBuf<256> x;
sl@0
  1859
					x.Format(KCompareFailed, res+1);
sl@0
  1860
					Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
sl@0
  1861
					CleanupStack::PopAndDestroy(bmp2);
sl@0
  1862
					continue;
sl@0
  1863
					}
sl@0
  1864
				}
sl@0
  1865
			if (finalSize.Contains(TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY)))
sl@0
  1866
				{
sl@0
  1867
				bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY));
sl@0
  1868
				if(!(pixelRgb == innerRgb))
sl@0
  1869
					{
sl@0
  1870
					_LIT(KCompareFailed, "Corner check failed on app mode: %d");
sl@0
  1871
					TBuf<256> x;
sl@0
  1872
					x.Format(KCompareFailed, res+1);
sl@0
  1873
					Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
sl@0
  1874
					CleanupStack::PopAndDestroy(bmp2);
sl@0
  1875
					continue;
sl@0
  1876
					}
sl@0
  1877
				}
sl@0
  1878
			}
sl@0
  1879
		
sl@0
  1880
		pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iTl);
sl@0
  1881
		ASSERT_TRUE(pixelRgb == innerRgb);
sl@0
  1882
		pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iBr.iX, readBackRect.iTl.iY));
sl@0
  1883
		ASSERT_TRUE(pixelRgb == innerRgb);
sl@0
  1884
		pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iBr);
sl@0
  1885
		ASSERT_TRUE(pixelRgb == innerRgb);
sl@0
  1886
		pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iTl.iX, readBackRect.iBr.iY));
sl@0
  1887
		ASSERT_TRUE(pixelRgb == innerRgb);
sl@0
  1888
sl@0
  1889
		CleanupStack::PopAndDestroy(bmp2);
sl@0
  1890
		}
sl@0
  1891
	screenModeList.Close();
sl@0
  1892
	CleanupStack::PopAndDestroy(4, dsaDraw);
sl@0
  1893
	}
sl@0
  1894
sl@0
  1895
/**
sl@0
  1896
@SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0012L
sl@0
  1897
@SYMTestCaseDesc		Test Pointer event coordinates are correct in different screen modes.
sl@0
  1898
@SYMREQ					REQ10336
sl@0
  1899
@SYMPREQ				PREQ2102
sl@0
  1900
@SYMTestType			CT
sl@0
  1901
@SYMTestPriority		1
sl@0
  1902
@SYMTestPurpose			Test Pointer event coordinates are correct in different screen mode
sl@0
  1903
@SYMTestActions			
sl@0
  1904
	In each screen mode, the simulated pointer event should always at the same relative position
sl@0
  1905
	inside iCompare window
sl@0
  1906
@SYMTestExpectedResults	
sl@0
  1907
	All test should pass
sl@0
  1908
	**NOTE  Can only be tested in screen 0 **
sl@0
  1909
*/
sl@0
  1910
void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0012L()
sl@0
  1911
	{
sl@0
  1912
	LOG_AND_PANIC_IF_NOT_GCE;
sl@0
  1913
	ResetScreens();
sl@0
  1914
	MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0012L"),_L("Pointer coordinates"));		
sl@0
  1915
	Pause(300);
sl@0
  1916
sl@0
  1917
	CWsDisplayEvent* displayEventAO = new(ELeave) CWsDisplayEvent(&iSession);
sl@0
  1918
	CleanupStack::PushL(displayEventAO);
sl@0
  1919
	displayEventAO->Request();
sl@0
  1920
	CEventTimer *timer = CEventTimer::NewL();
sl@0
  1921
	CleanupStack::PushL(timer);
sl@0
  1922
	
sl@0
  1923
	MDisplayMapping* mappingInterface = static_cast<MDisplayMapping*>
sl@0
  1924
				(iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
sl@0
  1925
	ASSERT_TRUE(mappingInterface);
sl@0
  1926
	
sl@0
  1927
	RArray<TInt> screenModeList;
sl@0
  1928
	iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
sl@0
  1929
	iSession.SetFocusScreen(TGlobalSettings::Instance().iScreen);
sl@0
  1930
	
sl@0
  1931
	for (TInt res=0;res<screenModeList.Count();res++)
sl@0
  1932
		{
sl@0
  1933
		iScreenDevice->SetAppScreenMode(screenModeList[res]);
sl@0
  1934
		iScreenDevice->SetScreenMode(screenModeList[res]);
sl@0
  1935
		Pause(300);
sl@0
  1936
		
sl@0
  1937
		//win position in app space
sl@0
  1938
		TPoint winPos = iCompare.AbsPosition();
sl@0
  1939
		TSize winSize = iCompare.Size();
sl@0
  1940
		
sl@0
  1941
		//pointer event at the origin of window
sl@0
  1942
		TRect rectNearWinOrigin(winPos+TPoint(1,1), TSize(1,1));
sl@0
  1943
		//the expected pointer position received by client to compare with the actual point received.
sl@0
  1944
		//it's (1,1) because it's relative to window
sl@0
  1945
		displayEventAO->SetExpectedPointPos(TPoint(1, 1)); 
sl@0
  1946
		TRect rectInComp, rectBackInApp;
sl@0
  1947
		mappingInterface->MapCoordinates(EApplicationSpace, rectNearWinOrigin, ECompositionSpace, rectInComp);
sl@0
  1948
		//as we got the physical coordinates at where we simulate pointer event
sl@0
  1949
		TRawEvent rawEvent;
sl@0
  1950
		rawEvent.Set(TRawEvent::EButton1Down, rectInComp.iTl.iX, rectInComp.iTl.iY);
sl@0
  1951
		iSession.SimulateRawEvent(rawEvent);
sl@0
  1952
		rawEvent.Set(TRawEvent::EButton1Up, rectInComp.iTl.iX, rectInComp.iTl.iY);
sl@0
  1953
		iSession.SimulateRawEvent(rawEvent);
sl@0
  1954
		iSession.Flush();
sl@0
  1955
		timer->Wait(1000);
sl@0
  1956
		
sl@0
  1957
		ASSERT_EQUALS(displayEventAO->ReceivedPointerEventCount(), res*4+2);
sl@0
  1958
		ASSERT_TRUE(displayEventAO->PointerTestPassed());
sl@0
  1959
		
sl@0
  1960
		//pointer event at 1/2 width and height inside the window
sl@0
  1961
		TRect rectAtWinCenter(winPos+TPoint(winSize.iWidth/2, winSize.iHeight/2), TSize(1,1));
sl@0
  1962
		displayEventAO->SetExpectedPointPos(rectAtWinCenter.iTl - winPos);
sl@0
  1963
		mappingInterface->MapCoordinates(EApplicationSpace, rectAtWinCenter, ECompositionSpace, rectInComp);
sl@0
  1964
		//as we got the physical coordinates at where we simulate pointer event
sl@0
  1965
		rawEvent.Set(TRawEvent::EButton1Down, rectInComp.iTl.iX, rectInComp.iTl.iY);
sl@0
  1966
		iSession.SimulateRawEvent(rawEvent);
sl@0
  1967
		rawEvent.Set(TRawEvent::EButton1Up, rectInComp.iTl.iX, rectInComp.iTl.iY);
sl@0
  1968
		iSession.SimulateRawEvent(rawEvent);
sl@0
  1969
		iSession.Flush();
sl@0
  1970
		timer->Wait(1000);
sl@0
  1971
		
sl@0
  1972
		ASSERT_EQUALS(displayEventAO->ReceivedPointerEventCount(), res*4 + 4);
sl@0
  1973
		ASSERT_TRUE(displayEventAO->PointerTestPassed());
sl@0
  1974
		}
sl@0
  1975
	screenModeList.Close();
sl@0
  1976
	CleanupStack::PopAndDestroy(2, displayEventAO);
sl@0
  1977
	}
sl@0
  1978
sl@0
  1979
/**
sl@0
  1980
@SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0013L
sl@0
  1981
@SYMTestCaseDesc		Test the twips size after detach
sl@0
  1982
@SYMREQ					REQ10329
sl@0
  1983
@SYMPREQ				PREQ2102
sl@0
  1984
@SYMTestType			CT
sl@0
  1985
@SYMTestPurpose			Make sure the twips size is undefined after detach.
sl@0
  1986
@SYMTestActions			
sl@0
  1987
	Save display configuration before detach and compare it with the display configuration after detach.
sl@0
  1988
@SYMTestExpectedResults	
sl@0
  1989
	all tests should pass
sl@0
  1990
*/
sl@0
  1991
void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0013L()
sl@0
  1992
	{
sl@0
  1993
	LOG_AND_PANIC_IF_NOT_GCE;
sl@0
  1994
	ResetScreens();
sl@0
  1995
#ifdef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER
sl@0
  1996
	ASSERT_FALSE("Test not compiled because MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER");
sl@0
  1997
#else
sl@0
  1998
	TInt error;
sl@0
  1999
	iSession.Finish(ETrue);
sl@0
  2000
	MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0013L"),_L("detach/attach - twips size"));
sl@0
  2001
	iSession.Finish(ETrue);
sl@0
  2002
sl@0
  2003
	Pause(1000);
sl@0
  2004
	TInt screenNo = iScreenDevice->GetScreenNumber();
sl@0
  2005
	RArray<TInt> screenModeList;
sl@0
  2006
	iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
sl@0
  2007
	MDisplayControl* interface = static_cast<MDisplayControl*>
sl@0
  2008
				(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
sl@0
  2009
	ASSERT_TRUE(interface);
sl@0
  2010
	
sl@0
  2011
	MDisplayMapping* mappingInterface = static_cast<MDisplayMapping*>
sl@0
  2012
				(iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
sl@0
  2013
	ASSERT_TRUE(mappingInterface);
sl@0
  2014
	
sl@0
  2015
	TInt resolutions = interface->NumberOfResolutions();
sl@0
  2016
	ASSERT_TRUE (resolutions > 0);
sl@0
  2017
	
sl@0
  2018
	RArray<MDisplayControl::TResolution> resolutionList1;
sl@0
  2019
	error = interface->GetResolutions(resolutionList1);
sl@0
  2020
	ASSERT_EQUALS(error,KErrNone);
sl@0
  2021
	ASSERT_EQUALS(resolutionList1.Count(), resolutions);
sl@0
  2022
	
sl@0
  2023
	TDisplayConfiguration configBeforeDetach;
sl@0
  2024
	
sl@0
  2025
	// detach the display
sl@0
  2026
	interface->GetConfiguration(configBeforeDetach);
sl@0
  2027
	TInt displayState = EDisconnect;
sl@0
  2028
	UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
sl@0
  2029
	Pause(300);
sl@0
  2030
	
sl@0
  2031
	// retrieve the display configuration
sl@0
  2032
	interface->GetConfiguration(configBeforeDetach);
sl@0
  2033
	ASSERT_FALSE(configBeforeDetach.IsDefined(TDisplayConfiguration::EResolutionTwips));
sl@0
  2034
	
sl@0
  2035
	error = interface->GetResolutions(resolutionList1);
sl@0
  2036
	ASSERT_EQUALS(error,KErrDisconnected);
sl@0
  2037
	
sl@0
  2038
	configBeforeDetach.ClearAll();
sl@0
  2039
	
sl@0
  2040
	screenModeList.Close();
sl@0
  2041
	resolutionList1.Close();
sl@0
  2042
	
sl@0
  2043
	displayState = ENormalResolution;
sl@0
  2044
	UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
sl@0
  2045
#endif
sl@0
  2046
	}
sl@0
  2047
sl@0
  2048
/**
sl@0
  2049
@SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0014L
sl@0
  2050
@SYMTestCaseDesc		Test GetConfiguration immediatly after SetConfiguration
sl@0
  2051
@SYMREQ					REQ10328
sl@0
  2052
@SYMPREQ				PREQ2102
sl@0
  2053
@SYMTestType			CT
sl@0
  2054
@SYMTestPurpose			Make sure the twips size is buffered so immediate GetConfiguration can get correct twip size
sl@0
  2055
@SYMTestActions			
sl@0
  2056
	successive SetConfiguration/GetConfiguration pair 
sl@0
  2057
@SYMTestExpectedResults	
sl@0
  2058
	all tests should pass
sl@0
  2059
*/
sl@0
  2060
void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0014L()
sl@0
  2061
	{
sl@0
  2062
	MDisplayControl* interface = static_cast<MDisplayControl*>
sl@0
  2063
					(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
sl@0
  2064
	ASSERT_TRUE(interface);
sl@0
  2065
	
sl@0
  2066
	RArray<MDisplayControl::TResolution> resolutions;
sl@0
  2067
	TInt err = interface->GetResolutions(resolutions);
sl@0
  2068
	ASSERT_EQUALS(err, KErrNone);
sl@0
  2069
	TDisplayConfiguration configSet, configGet;
sl@0
  2070
	TSize twipsGet, resolutionGet;
sl@0
  2071
	
sl@0
  2072
	TInt screenNo = iScreenDevice->GetScreenNumber();
sl@0
  2073
	iSession.SetFocusScreen(TGlobalSettings::Instance().iScreen);
sl@0
  2074
	for(TInt testIndex = 0; testIndex < 2; testIndex++)
sl@0
  2075
		{//run twice
sl@0
  2076
#ifdef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER
sl@0
  2077
	INFO_PRINTF1(_L("Test not compiled because MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER"));
sl@0
  2078
#else
sl@0
  2079
		TInt displayState;
sl@0
  2080
		displayState = ENormalResolution;
sl@0
  2081
		UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
sl@0
  2082
#endif
sl@0
  2083
		for (TInt i=0;i<resolutions.Count();i++)
sl@0
  2084
			{
sl@0
  2085
			INFO_PRINTF2(_L("i = %i"), i);
sl@0
  2086
			INFO_PRINTF3(_L("resolutions: %i x %i"), resolutions[i].iPixelSize.iWidth, resolutions[i].iPixelSize.iHeight);
sl@0
  2087
			INFO_PRINTF3(_L("twips: %i x %i"), resolutions[i].iTwipsSize.iWidth, resolutions[i].iTwipsSize.iHeight);
sl@0
  2088
			configSet.ClearAll();
sl@0
  2089
			configGet.ClearAll();
sl@0
  2090
			configSet.SetResolution(resolutions[i].iPixelSize);
sl@0
  2091
			err = interface->SetConfiguration(configSet);
sl@0
  2092
			if(err != KErrNone)
sl@0
  2093
				{
sl@0
  2094
				//with scaling, KErrArgument means current config is not compatible with appmode. 
sl@0
  2095
				//In none scaling, it does mean an error,
sl@0
  2096
				//but the purpose of this test is to see if twips size is buffered so we can read it back instantly
sl@0
  2097
				//let other tests test the functionality of SetConfiguration.
sl@0
  2098
				ASSERT_EQUALS(err, KErrArgument); 
sl@0
  2099
												
sl@0
  2100
				INFO_PRINTF1(_L("this configuration is not compatible with current appmode, skip"));
sl@0
  2101
				continue;
sl@0
  2102
				}
sl@0
  2103
			interface->GetConfiguration(configGet);
sl@0
  2104
			ASSERT_TRUE(configGet.IsDefined(TDisplayConfigurationBase::EResolutionTwips));
sl@0
  2105
			ASSERT_TRUE(configGet.IsDefined(TDisplayConfigurationBase::EResolution));
sl@0
  2106
			configGet.GetResolutionTwips(twipsGet);
sl@0
  2107
			configGet.GetResolution(resolutionGet);
sl@0
  2108
			INFO_PRINTF3(_L("resolution readback: %i x %i"), resolutionGet.iWidth, resolutionGet.iHeight);
sl@0
  2109
			INFO_PRINTF3(_L("twips readback: %i x %i"), twipsGet.iWidth, twipsGet.iHeight);
sl@0
  2110
			ASSERT_EQUALS(twipsGet, resolutions[i].iTwipsSize);
sl@0
  2111
			Pause(300);
sl@0
  2112
			}
sl@0
  2113
#ifdef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER
sl@0
  2114
	INFO_PRINTF1(_L("Test not compiled because MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER"));
sl@0
  2115
#else
sl@0
  2116
		displayState = EDisconnect;
sl@0
  2117
		UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
sl@0
  2118
#endif		
sl@0
  2119
		}
sl@0
  2120
	resolutions.Close();
sl@0
  2121
	
sl@0
  2122
	}
sl@0
  2123
sl@0
  2124
/**
sl@0
  2125
@SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0015L
sl@0
  2126
@SYMTestCaseDesc		No Scaling doesnt return virtual resolutions
sl@0
  2127
@SYMREQ					REQ10336
sl@0
  2128
@SYMPREQ				PREQ2102
sl@0
  2129
@SYMTestType			CT
sl@0
  2130
@SYMTestPriority		1
sl@0
  2131
@SYMTestPurpose			no scaling should mean basic resolution selection
sl@0
  2132
@SYMTestActions			
sl@0
  2133
	Get resolution list
sl@0
  2134
	Should not contain virtual resolutions
sl@0
  2135
	Set every app mode
sl@0
  2136
	Should not change resolution
sl@0
  2137
@SYMTestExpectedResults	
sl@0
  2138
	All test should pass
sl@0
  2139
	**SENSITIVE TO CHANGES IN EPOC.INI and WSINI.INI**
sl@0
  2140
*/
sl@0
  2141
void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0015L()
sl@0
  2142
	{	//ONLY RUN WITH 'NO SCALING' WSINI.INI, can be found in resources
sl@0
  2143
	MDisplayControl* interface = static_cast<MDisplayControl*>
sl@0
  2144
			(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
sl@0
  2145
	ASSERT_TRUE(interface);
sl@0
  2146
	
sl@0
  2147
	TInt resolutions = interface->NumberOfResolutions();
sl@0
  2148
	TInt screenNumber = iScreenDevice->GetScreenNumber();
sl@0
  2149
	if (screenNumber == 0)
sl@0
  2150
		{
sl@0
  2151
		ASSERT_EQUALS(resolutions,1);
sl@0
  2152
		}
sl@0
  2153
	else if (screenNumber == 1)
sl@0
  2154
		{
sl@0
  2155
		ASSERT_EQUALS(resolutions,4);
sl@0
  2156
		}	
sl@0
  2157
	
sl@0
  2158
	RArray<MDisplayControl::TResolution> resolutionList1;
sl@0
  2159
	TInt error = interface->GetResolutions(resolutionList1);
sl@0
  2160
	ASSERT_EQUALS(error,KErrNone);
sl@0
  2161
	ASSERT_EQUALS(resolutionList1.Count(), resolutions);
sl@0
  2162
	
sl@0
  2163
	RArray<TInt> screenModeList;
sl@0
  2164
	iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
sl@0
  2165
	
sl@0
  2166
	TDisplayConfiguration dispConfig1;
sl@0
  2167
	interface->GetConfiguration(dispConfig1);
sl@0
  2168
	TSize size1;
sl@0
  2169
	ASSERT_TRUE(dispConfig1.GetResolution(size1));
sl@0
  2170
	
sl@0
  2171
	for (TInt ii = 0; ii < screenModeList.Count(); ii++)
sl@0
  2172
		{
sl@0
  2173
		iInfoScreenDevice->SetAppScreenMode(screenModeList[ii]);
sl@0
  2174
		iInfoScreenDevice->SetScreenMode(screenModeList[ii]);
sl@0
  2175
		iSession.Finish(ETrue);
sl@0
  2176
		Pause(300);
sl@0
  2177
		
sl@0
  2178
		TDisplayConfiguration newConfig;
sl@0
  2179
		interface->GetConfiguration(newConfig);
sl@0
  2180
		TSize newSize;
sl@0
  2181
		ASSERT_TRUE(dispConfig1.GetResolution(newSize));
sl@0
  2182
		ASSERT_EQUALS(size1,newSize);
sl@0
  2183
		}
sl@0
  2184
	iInfoScreenDevice->SetAppScreenMode(screenModeList[0]);
sl@0
  2185
	iInfoScreenDevice->SetScreenMode(screenModeList[0]);
sl@0
  2186
	iSession.Finish(ETrue);
sl@0
  2187
	Pause(300);
sl@0
  2188
	
sl@0
  2189
	screenModeList.Close();
sl@0
  2190
	resolutionList1.Close();
sl@0
  2191
	}
sl@0
  2192
sl@0
  2193
/**
sl@0
  2194
@SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0016L
sl@0
  2195
@SYMTestCaseDesc		Anisotropic scaling
sl@0
  2196
@SYMREQ					REQ10336
sl@0
  2197
@SYMPREQ				PREQ2102
sl@0
  2198
@SYMTestType			CT
sl@0
  2199
@SYMTestPriority		1
sl@0
  2200
@SYMTestPurpose			Check using twips will cause virtual resolutions to possibly be different
sl@0
  2201
@SYMTestActions			
sl@0
  2202
	Check the virtual resolution for XXX is correctly XXX
sl@0
  2203
	Check when setting the appmode, it choses the correct resolution
sl@0
  2204
@SYMTestExpectedResults	
sl@0
  2205
	Tests should pass
sl@0
  2206
	**SENSITIVE TO CHANGES IN EPOC.INI and WSINI.INI**
sl@0
  2207
*/
sl@0
  2208
void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0016L()
sl@0
  2209
	{	//ONLY RUN WITH ANISOTROPIC WSINI.INI
sl@0
  2210
sl@0
  2211
	}
sl@0
  2212
sl@0
  2213
/**
sl@0
  2214
@SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0017L
sl@0
  2215
@SYMTestCaseDesc		Integer scales correctly in policy
sl@0
  2216
@SYMREQ					REQ10336
sl@0
  2217
@SYMPREQ				PREQ2102
sl@0
  2218
@SYMTestType			CT
sl@0
  2219
@SYMTestPriority		1
sl@0
  2220
@SYMTestPurpose			Integer scaling should not create resolutions of non integer value!
sl@0
  2221
@SYMTestActions			
sl@0
  2222
	For every virtual resolution
sl@0
  2223
		Check its an integer size of a real resolution
sl@0
  2224
@SYMTestExpectedResults	
sl@0
  2225
	All should be integers (1:1 , 1:2 , 1:3 or 1:4 in current policy)
sl@0
  2226
	**NOTE ONLY RUN WITH INTEGER WSINI.INI**
sl@0
  2227
*/
sl@0
  2228
void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0017L()
sl@0
  2229
	{	//ONLY RUN WITH INTEGER WSINI.INI
sl@0
  2230
	MDisplayControl* interface = static_cast<MDisplayControl*>
sl@0
  2231
			(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
sl@0
  2232
	ASSERT_TRUE(interface);
sl@0
  2233
	
sl@0
  2234
	TInt resolutions = interface->NumberOfResolutions();
sl@0
  2235
	ASSERT_TRUE(resolutions>1);
sl@0
  2236
	
sl@0
  2237
	RArray<MDisplayControl::TResolution> resolutionList1;
sl@0
  2238
	TInt error = interface->GetResolutions(resolutionList1);
sl@0
  2239
	ASSERT_EQUALS(error,KErrNone);
sl@0
  2240
	ASSERT_EQUALS(resolutionList1.Count(), resolutions);
sl@0
  2241
	
sl@0
  2242
	TInt index;
sl@0
  2243
	for (index=0;index<resolutions;index++)
sl@0
  2244
		{
sl@0
  2245
		if (resolutionList1[index].iFlags.IsSet(MDisplayControlBase::TResolution::EIsVirtual))
sl@0
  2246
			{
sl@0
  2247
			TBool foundMatch = EFalse;
sl@0
  2248
			for (TInt index2=0;index2<resolutions;index2++)
sl@0
  2249
				{
sl@0
  2250
				if (resolutionList1[index2].iFlags.IsClear(MDisplayControlBase::TResolution::EIsVirtual))
sl@0
  2251
					{
sl@0
  2252
					for (TInt scale=1;scale<=4;scale++)
sl@0
  2253
						{
sl@0
  2254
						TSize compare;
sl@0
  2255
						compare.iWidth=resolutionList1[index].iPixelSize.iWidth/scale;
sl@0
  2256
						compare.iHeight=resolutionList1[index].iPixelSize.iHeight/scale;
sl@0
  2257
						if (resolutionList1[index2].iPixelSize == compare)
sl@0
  2258
							{
sl@0
  2259
							foundMatch = ETrue;
sl@0
  2260
							break;
sl@0
  2261
							}
sl@0
  2262
						}
sl@0
  2263
					}
sl@0
  2264
				if (foundMatch)
sl@0
  2265
					{
sl@0
  2266
					break;
sl@0
  2267
					}
sl@0
  2268
				}
sl@0
  2269
			ASSERT_TRUE(foundMatch);
sl@0
  2270
			}
sl@0
  2271
		}
sl@0
  2272
	resolutionList1.Close();
sl@0
  2273
	}
sl@0
  2274
sl@0
  2275
/**
sl@0
  2276
@SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0018L
sl@0
  2277
@SYMTestCaseDesc		MDisplayMapping interface function test
sl@0
  2278
@SYMREQ					REQ10336
sl@0
  2279
@SYMPREQ				PREQ2102
sl@0
  2280
@SYMTestType			CT
sl@0
  2281
@SYMTestPriority		1
sl@0
  2282
@SYMTestPurpose			All the MDisplayMapping interface functions are consistent
sl@0
  2283
@SYMTestActions			
sl@0
  2284
	Check different mapping functions are consistent
sl@0
  2285
@SYMTestExpectedResults	
sl@0
  2286
	All test should pass
sl@0
  2287
*/
sl@0
  2288
void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0018L()
sl@0
  2289
	{
sl@0
  2290
	
sl@0
  2291
	LOG_AND_PANIC_IF_NOT_GCE;
sl@0
  2292
	ResetScreens();
sl@0
  2293
	TInt error;
sl@0
  2294
	iSession.Finish(ETrue);
sl@0
  2295
	MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0020L"),_L("Mapping function consistency"));
sl@0
  2296
	iSession.Finish(ETrue);
sl@0
  2297
	
sl@0
  2298
	MDisplayControl* interface = static_cast<MDisplayControl*>
sl@0
  2299
			(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
sl@0
  2300
	ASSERT_TRUE(interface);
sl@0
  2301
	
sl@0
  2302
	MDisplayMapping* mapInterface = static_cast<MDisplayMapping*>
sl@0
  2303
			(iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
sl@0
  2304
	ASSERT_TRUE(mapInterface);
sl@0
  2305
	
sl@0
  2306
	RArray<TInt> screenModeList;
sl@0
  2307
	iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
sl@0
  2308
	
sl@0
  2309
	TRect maxWinExtent, refMaxWinExtent;
sl@0
  2310
	TSize surfaceSize, surfaceTwips, refSurfaceSize, refSurfaceTwips;
sl@0
  2311
	TRect displayWinExtent, refDisplayWinExtent;
sl@0
  2312
	for (TInt i = 0; i < screenModeList.Count(); i++)
sl@0
  2313
		{
sl@0
  2314
		iInfoScreenDevice->SetAppScreenMode(screenModeList[i]);
sl@0
  2315
		iInfoScreenDevice->SetScreenMode(screenModeList[i]);
sl@0
  2316
		iSession.Finish(ETrue);
sl@0
  2317
		Pause(300);
sl@0
  2318
		
sl@0
  2319
		INFO_PRINTF1(_L("---------------"));
sl@0
  2320
		INFO_PRINTF2(_L("screen mode : %i"), screenModeList[i]);
sl@0
  2321
		
sl@0
  2322
		mapInterface->GetMaximumWindowExtent(maxWinExtent);
sl@0
  2323
		INFO_PRINTF3(_L("MaximumWindowExtent Origin: (%i, %i)"), maxWinExtent.iTl.iX, maxWinExtent.iTl.iY);
sl@0
  2324
		INFO_PRINTF3(_L("MaximumWindowExtent Size: %i x %i"), maxWinExtent.Width(), maxWinExtent.Height());
sl@0
  2325
		
sl@0
  2326
		
sl@0
  2327
		TDisplayConfiguration config;
sl@0
  2328
		interface->GetConfiguration(config);
sl@0
  2329
		ASSERT_TRUE(config.IsDefined(TDisplayConfigurationBase::EResolution));
sl@0
  2330
		TSize fullUiSize;
sl@0
  2331
		config.GetResolution(fullUiSize);
sl@0
  2332
		error = mapInterface->MapCoordinates(EFullScreenSpace, fullUiSize, EApplicationSpace, refMaxWinExtent);
sl@0
  2333
		ASSERT_EQUALS(error, KErrNone);
sl@0
  2334
		INFO_PRINTF3(_L("ref MaximumWindowExtent Origin: (%i, %i)"), refMaxWinExtent.iTl.iX, refMaxWinExtent.iTl.iY);
sl@0
  2335
		INFO_PRINTF3(_L("ref MaximumWindowExtent Size: %i x %i"), refMaxWinExtent.Width(), refMaxWinExtent.Height());
sl@0
  2336
		ASSERT_EQUALS(maxWinExtent, refMaxWinExtent);
sl@0
  2337
		INFO_PRINTF1(_L("Match"));
sl@0
  2338
		
sl@0
  2339
		mapInterface->GetMaximumSurfaceSize(surfaceSize, surfaceTwips);
sl@0
  2340
		INFO_PRINTF3(_L("MaxSurfaceSize: %i x %i"), surfaceSize.iWidth, surfaceSize.iHeight);
sl@0
  2341
		INFO_PRINTF3(_L("MaxSurfaceTwips: %i x %i"), surfaceTwips.iWidth, surfaceSize.iHeight);
sl@0
  2342
		TRect compositionRect;
sl@0
  2343
		error = mapInterface->MapCoordinates(EFullScreenSpace, fullUiSize, ECompositionSpace, compositionRect);
sl@0
  2344
		ASSERT_EQUALS(error, KErrNone);
sl@0
  2345
		refSurfaceSize = compositionRect.Size();
sl@0
  2346
		INFO_PRINTF3(_L("RefSurfaceSize: %i x %i"), refSurfaceSize.iWidth, refSurfaceSize.iHeight);
sl@0
  2347
		ASSERT_TRUE(config.IsDefined(TDisplayConfigurationBase::EResolutionTwips));
sl@0
  2348
		config.GetResolutionTwips(refSurfaceTwips);
sl@0
  2349
		INFO_PRINTF3(_L("RefSurfaceTwips: %i x %i"), refSurfaceTwips.iWidth, refSurfaceTwips.iHeight);
sl@0
  2350
		ASSERT_EQUALS(surfaceSize, refSurfaceSize);
sl@0
  2351
		ASSERT_EQUALS(surfaceTwips, refSurfaceTwips);
sl@0
  2352
		INFO_PRINTF1(_L("Match"));
sl@0
  2353
		
sl@0
  2354
		mapInterface->GetDisplayExtentOfWindow(iCompare, displayWinExtent);
sl@0
  2355
		INFO_PRINTF3(_L("DisplayWin origin: (%i, %i)"), displayWinExtent.iTl.iX, displayWinExtent.iTl.iY);
sl@0
  2356
		INFO_PRINTF3(_L("DisplayWin Size: (%i x %i"), displayWinExtent.Width(), displayWinExtent.Height());
sl@0
  2357
		error = mapInterface->MapCoordinates(EApplicationSpace, TRect(TPoint(iCompare.AbsPosition()),iCompare.Size()), ECompositionSpace, refDisplayWinExtent);
sl@0
  2358
		ASSERT_EQUALS(error, KErrNone);
sl@0
  2359
		INFO_PRINTF3(_L("RefDisplayWin origin: (%i, %i)"), refDisplayWinExtent.iTl.iX, refDisplayWinExtent.iTl.iY);
sl@0
  2360
		INFO_PRINTF3(_L("RefDisplayWin Size: (%i x %i"), refDisplayWinExtent.Width(), refDisplayWinExtent.Height());
sl@0
  2361
		ASSERT_EQUALS(displayWinExtent, refDisplayWinExtent);
sl@0
  2362
		INFO_PRINTF1(_L("Match"));
sl@0
  2363
		}
sl@0
  2364
	iInfoScreenDevice->SetAppScreenMode(screenModeList[0]);
sl@0
  2365
	iInfoScreenDevice->SetScreenMode(screenModeList[0]);
sl@0
  2366
	screenModeList.Close();
sl@0
  2367
	}
sl@0
  2368
sl@0
  2369
/*
sl@0
  2370
@SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0021L
sl@0
  2371
@SYMTestCaseDesc		SetResolution negative test
sl@0
  2372
@SYMREQ					REQ10326
sl@0
  2373
@SYMPREQ				PREQ2102
sl@0
  2374
@SYMTestType			CT
sl@0
  2375
@SYMTestPriority		1
sl@0
  2376
@SYMTestPurpose			Invalid configurations should return error and change nothing!
sl@0
  2377
@SYMTestActions			
sl@0
  2378
	Set config with rubbish resolution
sl@0
  2379
	Set config with rubbish twips
sl@0
  2380
	Set config with valid resolution, rubbish twips
sl@0
  2381
	Set config with valid twips, rubbish resolution
sl@0
  2382
	Set config with nothing defined
sl@0
  2383
@SYMTestExpectedResults	
sl@0
  2384
	Should all fail safely and not change any settings.
sl@0
  2385
	Config with nothing defined in a scaled mode will reset the resolution to current modes
sl@0
  2386
	equivilent virtual resolution
sl@0
  2387
	**NOTE ONLY RUN IN SCREEN 1 - we need multiple resolutions available**
sl@0
  2388
*/
sl@0
  2389
void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0021L(TBool aScaleMode)
sl@0
  2390
	{	//aScaleMode 0 = no scaling, 1 = integer,isotropic or anisotropic
sl@0
  2391
	MDisplayControl* interface = static_cast<MDisplayControl*>
sl@0
  2392
			(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
sl@0
  2393
	ASSERT_TRUE(interface);
sl@0
  2394
	
sl@0
  2395
	TInt resolutions = interface->NumberOfResolutions();
sl@0
  2396
	ASSERT_TRUE (resolutions > 1);
sl@0
  2397
		
sl@0
  2398
	RArray<MDisplayControl::TResolution> resolutionList1;
sl@0
  2399
	TInt error = interface->GetResolutions(resolutionList1);
sl@0
  2400
	ASSERT_EQUALS(resolutionList1.Count(), resolutions);
sl@0
  2401
	
sl@0
  2402
	TDisplayConfiguration original;
sl@0
  2403
	original.SetResolution(resolutionList1[0].iPixelSize);
sl@0
  2404
	error = interface->SetConfiguration(original);
sl@0
  2405
	ASSERT_EQUALS(error,KErrNone);
sl@0
  2406
	
sl@0
  2407
	TDisplayConfiguration beforeConfig;
sl@0
  2408
	TDisplayConfiguration afterConfig;
sl@0
  2409
	interface->GetConfiguration(beforeConfig);
sl@0
  2410
	
sl@0
  2411
	TInt differentRes;
sl@0
  2412
	for (differentRes = 1; differentRes < resolutions; differentRes++)
sl@0
  2413
		{
sl@0
  2414
		if (!(resolutionList1[differentRes].iPixelSize == resolutionList1[0].iPixelSize))
sl@0
  2415
			{
sl@0
  2416
			break;
sl@0
  2417
			}
sl@0
  2418
		}
sl@0
  2419
	ASSERT_TRUE(differentRes < resolutions);	//otherwise it didnt find a resolution different to the one set
sl@0
  2420
	
sl@0
  2421
	TDisplayConfiguration test1;
sl@0
  2422
	test1.SetResolution(TSize(5,6));	//rubbish resolution!
sl@0
  2423
	error = interface->SetConfiguration(test1);
sl@0
  2424
sl@0
  2425
	ASSERT_EQUALS(error,KErrArgument);
sl@0
  2426
sl@0
  2427
	ASSERT_EQUALS(error,KErrArgument);
sl@0
  2428
	iSession.Flush();
sl@0
  2429
	interface->GetConfiguration(afterConfig);
sl@0
  2430
	ASSERT_TRUE(beforeConfig == afterConfig);
sl@0
  2431
	
sl@0
  2432
	TDisplayConfiguration test2;
sl@0
  2433
	test2.SetResolutionTwips(TSize(7,8));	//rubbish twips!
sl@0
  2434
	error = interface->SetConfiguration(test2);
sl@0
  2435
	ASSERT_EQUALS(error,KErrArgument);
sl@0
  2436
	iSession.Flush();
sl@0
  2437
	interface->GetConfiguration(afterConfig);
sl@0
  2438
	ASSERT_TRUE(beforeConfig == afterConfig);
sl@0
  2439
	
sl@0
  2440
	TDisplayConfiguration test3;
sl@0
  2441
	test3.SetResolution(resolutionList1[differentRes].iPixelSize);	//ok resolution!
sl@0
  2442
	test3.SetResolutionTwips(TSize(9,10));	//rubbish twips!
sl@0
  2443
	error = interface->SetConfiguration(test3);
sl@0
  2444
	//ASSERT_EQUALS(error,KErrArgument);
sl@0
  2445
	if (error != KErrArgument)
sl@0
  2446
		{
sl@0
  2447
		ASSERT_EQUALS (aScaleMode,0);	//if no policy, we currently have issue with confing not being validated
sl@0
  2448
		INFO_PRINTF1(_L("config was not honoured!"));
sl@0
  2449
		error = interface->SetConfiguration(original);
sl@0
  2450
		ASSERT_EQUALS(error,KErrNone);
sl@0
  2451
		iSession.Flush();
sl@0
  2452
		Pause(200);
sl@0
  2453
		}
sl@0
  2454
	else
sl@0
  2455
		{
sl@0
  2456
		iSession.Flush();
sl@0
  2457
		Pause(200);
sl@0
  2458
		interface->GetConfiguration(afterConfig);
sl@0
  2459
		ASSERT_TRUE(beforeConfig == afterConfig);
sl@0
  2460
		}
sl@0
  2461
sl@0
  2462
	TDisplayConfiguration test4;
sl@0
  2463
	test4.SetResolution(TSize(11,12));	//rubbish resolution!
sl@0
  2464
	test4.SetResolutionTwips(resolutionList1[differentRes].iTwipsSize);	//ok twips!
sl@0
  2465
	error = interface->SetConfiguration(test4);
sl@0
  2466
	if (error != KErrArgument)
sl@0
  2467
		{
sl@0
  2468
		ASSERT_EQUALS (aScaleMode,0);	//if no policy, we currently have issue with config not being validated
sl@0
  2469
		INFO_PRINTF1(_L("config was not honoured!"));
sl@0
  2470
		error = interface->SetConfiguration(original);
sl@0
  2471
		ASSERT_EQUALS(error,KErrNone);
sl@0
  2472
		iSession.Flush();
sl@0
  2473
		Pause(200);
sl@0
  2474
		}
sl@0
  2475
	else
sl@0
  2476
		{
sl@0
  2477
		iSession.Flush();
sl@0
  2478
		Pause(200);
sl@0
  2479
		interface->GetConfiguration(afterConfig);
sl@0
  2480
		ASSERT_TRUE(beforeConfig == afterConfig);
sl@0
  2481
		}
sl@0
  2482
	
sl@0
  2483
	if (aScaleMode)
sl@0
  2484
		{
sl@0
  2485
		RArray<TInt> screenModeList;
sl@0
  2486
		iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
sl@0
  2487
		ASSERT_TRUE(screenModeList.Count()>1);
sl@0
  2488
		//set default screen mode, sets resolution to best fit for this mode
sl@0
  2489
		iInfoScreenDevice->SetAppScreenMode(screenModeList[0]);
sl@0
  2490
		iInfoScreenDevice->SetScreenMode(screenModeList[0]);	//also sets its best resolution
sl@0
  2491
		iSession.Finish(ETrue);
sl@0
  2492
		Pause(200);
sl@0
  2493
		
sl@0
  2494
		TDisplayConfiguration newModeConfig;
sl@0
  2495
		interface->GetConfiguration(newModeConfig);
sl@0
  2496
		//get best fit resolution
sl@0
  2497
		TSize newModeRes;
sl@0
  2498
		ASSERT_TRUE(newModeConfig.GetResolution(newModeRes));
sl@0
  2499
		
sl@0
  2500
		//find a different resolution
sl@0
  2501
		TInt i;
sl@0
  2502
		for (i = 0; i < resolutions; i++)
sl@0
  2503
			{
sl@0
  2504
			if (!(resolutionList1[i].iPixelSize == newModeRes))
sl@0
  2505
				{
sl@0
  2506
				break;
sl@0
  2507
				}
sl@0
  2508
			}
sl@0
  2509
		ASSERT_TRUE(i < resolutions);	//otherwise it didnt find a resolution different to the one set
sl@0
  2510
		TDisplayConfiguration newSetConfig;
sl@0
  2511
		
sl@0
  2512
		//set the different resolution
sl@0
  2513
		newSetConfig.SetResolution(resolutionList1[i].iPixelSize);
sl@0
  2514
		error = interface->SetConfiguration(newSetConfig);
sl@0
  2515
		ASSERT_TRUE(error == KErrNone);
sl@0
  2516
		iSession.Flush();
sl@0
  2517
		Pause(200);
sl@0
  2518
		TDisplayConfiguration checkConfig;
sl@0
  2519
		
sl@0
  2520
		//check its set this new resolution
sl@0
  2521
		interface->GetConfiguration(checkConfig);
sl@0
  2522
		TSize checkSize;
sl@0
  2523
		checkConfig.GetResolution(checkSize);
sl@0
  2524
		ASSERT_TRUE (checkSize == resolutionList1[i].iPixelSize);
sl@0
  2525
		
sl@0
  2526
		TDisplayConfiguration emptyConfig;
sl@0
  2527
		TDisplayConfiguration newModeConfig2(newModeConfig);
sl@0
  2528
		newModeConfig2.Clear(newModeConfig2.EResolutionTwips);
sl@0
  2529
		//set empty config, which should reset resolution to current modes default
sl@0
  2530
		error = interface->SetConfiguration(emptyConfig);//emptyConfig);
sl@0
  2531
		ASSERT_TRUE(error == KErrNone);
sl@0
  2532
		iSession.Finish();
sl@0
  2533
		Pause(200);
sl@0
  2534
	
sl@0
  2535
		interface->GetConfiguration(checkConfig);
sl@0
  2536
		ASSERT_TRUE (newModeConfig == checkConfig);	//empty config reset res to modes default res
sl@0
  2537
sl@0
  2538
		screenModeList.Close();
sl@0
  2539
		}
sl@0
  2540
	else
sl@0
  2541
		{
sl@0
  2542
		TDisplayConfiguration test5;
sl@0
  2543
		error = interface->SetConfiguration(test5);
sl@0
  2544
		ASSERT_EQUALS(error,KErrArgument);
sl@0
  2545
		}
sl@0
  2546
	resolutionList1.Close();	
sl@0
  2547
	}
sl@0
  2548
sl@0
  2549
/**
sl@0
  2550
@SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0031L
sl@0
  2551
@SYMTestCaseDesc		SetConfiguration in OOM (changing resolution)
sl@0
  2552
@SYMREQ					REQ10326
sl@0
  2553
@SYMPREQ				PREQ2102
sl@0
  2554
@SYMTestType			CT
sl@0
  2555
@SYMTestPriority		1
sl@0
  2556
@SYMTestPurpose			Safety check against OOM
sl@0
  2557
@SYMTestActions			
sl@0
  2558
	Set OOM failure
sl@0
  2559
	Set a resolution that will definately cause a change of resolution
sl@0
  2560
	Increase length of time to failure, repeat
sl@0
  2561
	Finish after 5 successful changes of resolution
sl@0
  2562
@SYMTestExpectedResults	
sl@0
  2563
	Set resolution should either return a fail and not have cause a change in resolution,
sl@0
  2564
	or it should have returned no fail and have set the new resolution
sl@0
  2565
*/
sl@0
  2566
void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0031L()
sl@0
  2567
	{
sl@0
  2568
	MDisplayControl* interface = static_cast<MDisplayControl*>
sl@0
  2569
			(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
sl@0
  2570
	ASSERT_TRUE(interface);
sl@0
  2571
	INFO_PRINTF1(_L("Interface obtained sucessfully."));
sl@0
  2572
	
sl@0
  2573
	TInt resolutions = interface->NumberOfResolutions();
sl@0
  2574
	ASSERT_TRUE (resolutions > 0);
sl@0
  2575
	INFO_PRINTF1(_L("NumberOfResolutions obtained sucessfully."));
sl@0
  2576
	
sl@0
  2577
	RArray<MDisplayControl::TResolution> resolutionList1;
sl@0
  2578
	TInt error = interface->GetResolutions(resolutionList1);
sl@0
  2579
	ASSERT_EQUALS(error,KErrNone);
sl@0
  2580
	ASSERT_EQUALS(resolutionList1.Count(), resolutions);
sl@0
  2581
	INFO_PRINTF1(_L("resolutionList1 has correct number of resolutions."));
sl@0
  2582
	
sl@0
  2583
	TInt index;
sl@0
  2584
	TDisplayConfiguration dispConfigBefore;
sl@0
  2585
	TDisplayConfiguration dispConfigAfter;
sl@0
  2586
	
sl@0
  2587
	dispConfigBefore.SetResolution(resolutionList1[0].iPixelSize);
sl@0
  2588
	interface->SetConfiguration(dispConfigBefore);
sl@0
  2589
	interface->GetConfiguration(dispConfigBefore);
sl@0
  2590
	ASSERT_TRUE(dispConfigBefore.IsDefined(dispConfigBefore.EResolution));
sl@0
  2591
	INFO_PRINTF1(_L("dispConfigBefore is defined."));
sl@0
  2592
	TSize dispResBefore;
sl@0
  2593
	TSize dispResAfter;
sl@0
  2594
	dispConfigBefore.GetResolution(dispResBefore);
sl@0
  2595
	TDisplayConfiguration::TRotation dispRotBefore;
sl@0
  2596
	TDisplayConfiguration::TRotation dispRotReq;
sl@0
  2597
	dispConfigBefore.GetRotation(dispRotBefore);
sl@0
  2598
sl@0
  2599
	for (index = 0; index < resolutionList1.Count(); index++)
sl@0
  2600
		{
sl@0
  2601
		INFO_PRINTF2(_L("Starting resolution %d."), index);
sl@0
  2602
		if (resolutionList1[index].iPixelSize.iWidth == 0)
sl@0
  2603
			{
sl@0
  2604
			continue;
sl@0
  2605
			}
sl@0
  2606
		TInt heapFail = 1;
sl@0
  2607
		TBool notComplete = ETrue;
sl@0
  2608
		TInt completeCount = 0;
sl@0
  2609
		while (notComplete)
sl@0
  2610
			{
sl@0
  2611
			TDisplayConfiguration dispConfigReq;
sl@0
  2612
			dispConfigReq.SetResolution(resolutionList1[index].iPixelSize);
sl@0
  2613
			ASSERT_TRUE(dispConfigReq.IsDefined(dispConfigReq.EResolution));
sl@0
  2614
			SetRotation(dispConfigReq,resolutionList1[index]);	//set rotation to first defined in res list
sl@0
  2615
			dispConfigReq.GetRotation(dispRotReq);
sl@0
  2616
			INFO_PRINTF2(_L("Before heap failure, value of heapfail is %d."), heapFail);
sl@0
  2617
			
sl@0
  2618
			iSession.Finish(ETrue);
sl@0
  2619
			iSession.HeapSetFail(RHeap::EDeterministic,heapFail);
sl@0
  2620
			TInt errCode=interface->SetConfiguration(dispConfigReq);
sl@0
  2621
			iSession.HeapSetFail(RHeap::ENone,0);
sl@0
  2622
			INFO_PRINTF1(_L("After Heap Failure."));
sl@0
  2623
			iSession.Finish(ETrue);
sl@0
  2624
			Pause (100);
sl@0
  2625
			INFO_PRINTF1(_L("After Session Finish."));
sl@0
  2626
			
sl@0
  2627
			interface->GetConfiguration(dispConfigAfter);
sl@0
  2628
			ASSERT_TRUE(dispConfigAfter.IsDefined(dispConfigAfter.EResolution));
sl@0
  2629
			dispConfigAfter.GetResolution(dispResAfter);
sl@0
  2630
			
sl@0
  2631
			TBool worked = ETrue;
sl@0
  2632
			if (errCode < KErrNone)
sl@0
  2633
				{			
sl@0
  2634
				worked = EFalse;
sl@0
  2635
				ASSERT_EQUALS(dispResAfter,dispResBefore);
sl@0
  2636
				if (dispRotReq != dispRotBefore)
sl@0
  2637
					{	//didnt expect it work-KErrGeneral can mean a memory allocation fail
sl@0
  2638
					if (errCode == KErrArgument)
sl@0
  2639
						{	//if it didnt panic, that is a good enough pass in this instance
sl@0
  2640
						worked = ETrue;
sl@0
  2641
						}
sl@0
  2642
					}
sl@0
  2643
				}
sl@0
  2644
			else
sl@0
  2645
				{				
sl@0
  2646
				ASSERT_EQUALS(dispResAfter,resolutionList1[index].iPixelSize);
sl@0
  2647
				}
sl@0
  2648
			if (worked)
sl@0
  2649
				{	
sl@0
  2650
				completeCount++;
sl@0
  2651
				if (completeCount == 5)
sl@0
  2652
					{
sl@0
  2653
					notComplete = EFalse;
sl@0
  2654
					}
sl@0
  2655
				}
sl@0
  2656
			else
sl@0
  2657
				{
sl@0
  2658
				completeCount = 0;
sl@0
  2659
				}
sl@0
  2660
			interface->SetConfiguration(dispConfigBefore);
sl@0
  2661
			INFO_PRINTF1(_L("After Setting Original Configuration."));
sl@0
  2662
			heapFail++;
sl@0
  2663
			if (heapFail == 80)
sl@0
  2664
				{
sl@0
  2665
				ASSERT_TRUE(0);	//worrying amount of fails
sl@0
  2666
				}
sl@0
  2667
			}
sl@0
  2668
		}
sl@0
  2669
	resolutionList1.Close();
sl@0
  2670
	}
sl@0
  2671
sl@0
  2672
/**
sl@0
  2673
@SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0032L
sl@0
  2674
@SYMTestCaseDesc		SetAppMode in OOM
sl@0
  2675
@SYMREQ					REQ10326 REQ10336
sl@0
  2676
@SYMPREQ				PREQ2102
sl@0
  2677
@SYMTestType			CT
sl@0
  2678
@SYMTestPriority		1
sl@0
  2679
@SYMTestPurpose			Safety check against OOM
sl@0
  2680
@SYMTestActions			
sl@0
  2681
	Set OOM failure
sl@0
  2682
	Set new app mode
sl@0
  2683
	Increase length of time to failure, repeat
sl@0
  2684
	Finish after 5 successful changes of mode
sl@0
  2685
@SYMTestExpectedResults	
sl@0
  2686
	SetAppMode should either return a fail and not have cause a change in resolution,
sl@0
  2687
	or it should have returned no fail and have set the new resolution
sl@0
  2688
*/
sl@0
  2689
void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0032L()
sl@0
  2690
	{
sl@0
  2691
	MDisplayControl* interface = static_cast<MDisplayControl*>
sl@0
  2692
			(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
sl@0
  2693
	ASSERT_TRUE(interface);
sl@0
  2694
	
sl@0
  2695
	TInt resolutions = interface->NumberOfResolutions();
sl@0
  2696
	ASSERT_TRUE (resolutions > 0);
sl@0
  2697
	RArray<TInt> screenModeList;
sl@0
  2698
	iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
sl@0
  2699
	ASSERT_TRUE (screenModeList.Count()>0);
sl@0
  2700
	
sl@0
  2701
	iInfoScreenDevice->SetAppScreenMode(screenModeList[0]);
sl@0
  2702
	iInfoScreenDevice->SetScreenMode(screenModeList[0]);
sl@0
  2703
	
sl@0
  2704
	for (TInt index = 1; index < screenModeList.Count(); index++)
sl@0
  2705
		{	//skip index 0, as that wouldn't be changing mode
sl@0
  2706
		TInt heapFail = 1;
sl@0
  2707
		TBool notComplete = ETrue;
sl@0
  2708
		TInt completeCount = 0;
sl@0
  2709
		while (notComplete)
sl@0
  2710
			{
sl@0
  2711
            RDebug::Printf("iInfoScreenDevice->SetAppScreenMode");
sl@0
  2712
			iInfoScreenDevice->SetAppScreenMode(screenModeList[index]);
sl@0
  2713
			iSession.Finish(ETrue);
sl@0
  2714
			iSession.HeapSetFail(RHeap::EDeterministic,heapFail);
sl@0
  2715
            RDebug::Printf("iInfoScreenDevice->SetAppScreenMode");
sl@0
  2716
			iInfoScreenDevice->SetScreenMode(screenModeList[index]);
sl@0
  2717
            RDebug::Printf("SetScreenMode done");
sl@0
  2718
			iSession.HeapSetFail(RHeap::ENone,0);
sl@0
  2719
			iSession.Finish(ETrue);
sl@0
  2720
            RDebug::Printf("Finish done");
sl@0
  2721
			Pause(50);
sl@0
  2722
			TInt newMode = iInfoScreenDevice->CurrentScreenMode();
sl@0
  2723
sl@0
  2724
			if (screenModeList[index] == newMode)
sl@0
  2725
				{
sl@0
  2726
				completeCount++;
sl@0
  2727
				if (completeCount == 5)
sl@0
  2728
					{
sl@0
  2729
					INFO_PRINTF3(_L("Mode %i Succeeded with heapFail = %d"),index, heapFail);
sl@0
  2730
					notComplete = EFalse;
sl@0
  2731
					}
sl@0
  2732
				iInfoScreenDevice->SetAppScreenMode(screenModeList[0]);
sl@0
  2733
				iInfoScreenDevice->SetScreenMode(screenModeList[0]);
sl@0
  2734
				iSession.Finish(ETrue);
sl@0
  2735
				Pause(50);
sl@0
  2736
				}
sl@0
  2737
			else
sl@0
  2738
				{
sl@0
  2739
				completeCount = 0;
sl@0
  2740
				}
sl@0
  2741
			heapFail++;
sl@0
  2742
			if (heapFail == 80)
sl@0
  2743
				{
sl@0
  2744
				ASSERT_TRUE(0);	//worrying amount of fails
sl@0
  2745
				}
sl@0
  2746
			}
sl@0
  2747
		}
sl@0
  2748
	screenModeList.Close();
sl@0
  2749
	}
sl@0
  2750
sl@0
  2751
/**
sl@0
  2752
@SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0033L
sl@0
  2753
@SYMTestCaseDesc		GetConfiguration in OOM
sl@0
  2754
@SYMREQ					REQ10328
sl@0
  2755
@SYMPREQ				PREQ2102
sl@0
  2756
@SYMTestType			CT
sl@0
  2757
@SYMTestPriority		1
sl@0
  2758
@SYMTestPurpose			Safety check against OOM
sl@0
  2759
@SYMTestActions			
sl@0
  2760
	Set OOM failure
sl@0
  2761
	GetConfiguration
sl@0
  2762
	Check config
sl@0
  2763
	Increase time till failure
sl@0
  2764
	Success after 5 completed gets
sl@0
  2765
@SYMTestExpectedResults	
sl@0
  2766
	Should always succeed
sl@0
  2767
*/
sl@0
  2768
void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0033L()
sl@0
  2769
	{
sl@0
  2770
	MDisplayControl* interface = static_cast<MDisplayControl*>
sl@0
  2771
			(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
sl@0
  2772
	ASSERT_TRUE(interface);
sl@0
  2773
	
sl@0
  2774
	TInt heapFail = 1;
sl@0
  2775
	for (TInt i=0;i<5;i++)
sl@0
  2776
		{
sl@0
  2777
		TDisplayConfiguration config;
sl@0
  2778
		iSession.Finish(ETrue);
sl@0
  2779
		iSession.HeapSetFail(RHeap::EDeterministic,heapFail);
sl@0
  2780
		interface->GetConfiguration(config);
sl@0
  2781
		iSession.HeapSetFail(RHeap::ENone,0);
sl@0
  2782
		iSession.Finish(ETrue);
sl@0
  2783
		ASSERT_TRUE(config.IsDefined(config.ERotation));
sl@0
  2784
		ASSERT_TRUE(config.IsDefined(config.EResolution));
sl@0
  2785
		ASSERT_TRUE(config.IsDefined(config.EResolutionTwips));
sl@0
  2786
		heapFail++;
sl@0
  2787
		}
sl@0
  2788
	}
sl@0
  2789
sl@0
  2790
/**
sl@0
  2791
@SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0034L
sl@0
  2792
@SYMTestCaseDesc		GetResolutions in OOM
sl@0
  2793
@SYMREQ					REQ10328
sl@0
  2794
@SYMPREQ				PREQ2102
sl@0
  2795
@SYMTestType			CT
sl@0
  2796
@SYMTestPriority		1
sl@0
  2797
@SYMTestPurpose			Safety check against OOM
sl@0
  2798
@SYMTestActions			
sl@0
  2799
	Set OOM failure
sl@0
  2800
	GetResolutions
sl@0
  2801
	Check resolutions filled in
sl@0
  2802
	Success after 5 completed gets
sl@0
  2803
@SYMTestExpectedResults	
sl@0
  2804
	Should never panic!
sl@0
  2805
*/
sl@0
  2806
void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0034L()
sl@0
  2807
	{
sl@0
  2808
	MDisplayControl* interface = static_cast<MDisplayControl*>
sl@0
  2809
			(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
sl@0
  2810
	ASSERT_TRUE(interface);
sl@0
  2811
	
sl@0
  2812
	TInt resolutions = interface->NumberOfResolutions();
sl@0
  2813
	ASSERT_TRUE(resolutions>1);
sl@0
  2814
	
sl@0
  2815
	RArray<MDisplayControl::TResolution> resolutionList1;
sl@0
  2816
	TInt error = interface->GetResolutions(resolutionList1);
sl@0
  2817
	ASSERT_EQUALS(error,KErrNone);
sl@0
  2818
	ASSERT_TRUE(resolutionList1.Count() > 0);
sl@0
  2819
sl@0
  2820
	TInt heapFail = 1;
sl@0
  2821
	TInt completeCount = 0;
sl@0
  2822
	TBool notComplete = ETrue;
sl@0
  2823
	while (notComplete)
sl@0
  2824
		{
sl@0
  2825
		RArray<MDisplayControl::TResolution> resolutionList2;
sl@0
  2826
		iSession.Finish(ETrue);
sl@0
  2827
		iSession.HeapSetFail(RHeap::EDeterministic,heapFail);
sl@0
  2828
		error = interface->GetResolutions(resolutionList2);
sl@0
  2829
		iSession.HeapSetFail(RHeap::ENone,0);
sl@0
  2830
		iSession.Finish(ETrue);
sl@0
  2831
		if (error<KErrNone)
sl@0
  2832
			{
sl@0
  2833
			ASSERT_EQUALS(error,KErrNoMemory);
sl@0
  2834
			completeCount = 0;
sl@0
  2835
			}
sl@0
  2836
		else
sl@0
  2837
			{
sl@0
  2838
			ASSERT_EQUALS(resolutionList2.Count(),resolutionList1.Count());
sl@0
  2839
			for (TInt i=0;i<resolutionList2.Count();i++)
sl@0
  2840
				{
sl@0
  2841
				ASSERT_EQUALS(resolutionList1[i].iPixelSize,resolutionList2[i].iPixelSize);
sl@0
  2842
				ASSERT_EQUALS(resolutionList1[i].iTwipsSize,resolutionList2[i].iTwipsSize);
sl@0
  2843
				if (!(resolutionList1[i].iFlags==resolutionList2[i].iFlags))
sl@0
  2844
					{
sl@0
  2845
					ASSERT_TRUE(0);
sl@0
  2846
					}
sl@0
  2847
				}
sl@0
  2848
			completeCount++;
sl@0
  2849
			}
sl@0
  2850
		heapFail++;
sl@0
  2851
		resolutionList2.Close();
sl@0
  2852
		if (completeCount == 5)
sl@0
  2853
			{
sl@0
  2854
			notComplete = EFalse;
sl@0
  2855
			}
sl@0
  2856
		if (heapFail == 20)
sl@0
  2857
			{
sl@0
  2858
			ASSERT_TRUE(0);	//worrying amount of fails
sl@0
  2859
			}
sl@0
  2860
		}
sl@0
  2861
	resolutionList1.Close();
sl@0
  2862
	}
sl@0
  2863
sl@0
  2864
/**
sl@0
  2865
@SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0041L
sl@0
  2866
@SYMTestCaseDesc		Test Drawing of bitmaps (case 0) and surfaces (case 1) in all different AppModes
sl@0
  2867
@SYMREQ					REQ10332 REQ10336
sl@0
  2868
@SYMPREQ				PREQ2102
sl@0
  2869
@SYMTestType			CT
sl@0
  2870
@SYMTestPurpose			Check to see if Bitmaps and Surfaces are drawn correctly in different app modes
sl@0
  2871
@SYMTestActions			
sl@0
  2872
	A Simple pattern will be drawn by a bitmap on the left and a surface on the right, about half the window size each. The Composited Screen Capture code will be used to compare the drawing to a unchanged copy of the bitmap to see if they are drawn correctly
sl@0
  2873
	
sl@0
  2874
	Note, add .0 to test name to test bitmap drawing and .1 to test surface drawing
sl@0
  2875
@SYMTestExpectedResults	
sl@0
  2876
	All tests should pass.
sl@0
  2877
	
sl@0
  2878
*/
sl@0
  2879
void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0041L(TBool aIsSurface)
sl@0
  2880
	{
sl@0
  2881
	LOG_AND_PANIC_IF_NOT_GCE;
sl@0
  2882
	ResetScreens();
sl@0
  2883
	TInt error;
sl@0
  2884
	iSession.Finish(ETrue);
sl@0
  2885
	
sl@0
  2886
	TRect screenSize(iInfoScreenDevice->SizeInPixels());
sl@0
  2887
	screenSize.Shrink(5,5);
sl@0
  2888
	
sl@0
  2889
	RBlankWindow testWindow;
sl@0
  2890
	if (iInfoGc)
sl@0
  2891
		{
sl@0
  2892
		testWindow=RBlankWindow(iSession);
sl@0
  2893
		ASSERT_EQUALS(testWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone);
sl@0
  2894
		testWindow.SetColor(iBlue);
sl@0
  2895
		testWindow.SetExtent(screenSize.iTl,screenSize.Size());
sl@0
  2896
		testWindow.Activate();
sl@0
  2897
		
sl@0
  2898
		if (testWindow.WsHandle())
sl@0
  2899
			{		
sl@0
  2900
			iSession.Flush();
sl@0
  2901
			iSession.Finish();
sl@0
  2902
			}
sl@0
  2903
		testWindow.SetVisible(ETrue);
sl@0
  2904
		}
sl@0
  2905
	
sl@0
  2906
	iSession.Finish(ETrue);
sl@0
  2907
	
sl@0
  2908
	RArray<TInt> screenModeList;
sl@0
  2909
	iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
sl@0
  2910
	MDisplayControl* interface = static_cast<MDisplayControl*>
sl@0
  2911
				(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
sl@0
  2912
	ASSERT_TRUE(interface);
sl@0
  2913
	
sl@0
  2914
	TInt resolutions = interface->NumberOfResolutions();
sl@0
  2915
	ASSERT_TRUE (resolutions > 0);
sl@0
  2916
	
sl@0
  2917
	RArray<MDisplayControl::TResolution> resolutionList1;
sl@0
  2918
	error = interface->GetResolutions(resolutionList1);
sl@0
  2919
	ASSERT_EQUALS(error,KErrNone);
sl@0
  2920
	ASSERT_EQUALS(resolutionList1.Count(), resolutions);
sl@0
  2921
	
sl@0
  2922
	TDisplayConfiguration dispConfigBefore;
sl@0
  2923
	interface->GetConfiguration(dispConfigBefore);
sl@0
  2924
	ASSERT_TRUE(dispConfigBefore.IsDefined(dispConfigBefore.EResolution))
sl@0
  2925
	if (screenModeList.Count()>1)
sl@0
  2926
		{
sl@0
  2927
		//Got a mode to change to!
sl@0
  2928
		TSize resBefore;
sl@0
  2929
		TBool ok=dispConfigBefore.GetResolution(resBefore);
sl@0
  2930
		ASSERT_TRUE(ok);	//we "know" this should be ok, as we just asserted the flag
sl@0
  2931
		for (TInt res=0;res<screenModeList.Count();res++)
sl@0
  2932
			{
sl@0
  2933
				{
sl@0
  2934
					{
sl@0
  2935
					TDisplayConfiguration dispConfigReq;
sl@0
  2936
					iInfoScreenDevice->SetAppScreenMode(screenModeList[res]);
sl@0
  2937
					iInfoScreenDevice->SetScreenMode(screenModeList[res]);
sl@0
  2938
					iSession.Finish(ETrue);
sl@0
  2939
					Pause(300);
sl@0
  2940
					
sl@0
  2941
sl@0
  2942
					TSize pr = iInfoScreenDevice->SizeInPixels();
sl@0
  2943
					TPoint 	origin=iInfoScreenDevice->GetDefaultScreenModeOrigin();					
sl@0
  2944
					Pause(300);
sl@0
  2945
					TSize winpos;
sl@0
  2946
					
sl@0
  2947
					TSize surfaceSize = pr;
sl@0
  2948
					surfaceSize.iWidth /= 2;
sl@0
  2949
					surfaceSize.iWidth -= 20;
sl@0
  2950
					surfaceSize.iHeight -= 20;
sl@0
  2951
					TSurfaceId surfaceID;
sl@0
  2952
					TRAPD(err, surfaceID = iUtility->CreateSurfaceL(surfaceSize, 
sl@0
  2953
								KSurfaceFormat, surfaceSize.iWidth * KBytesPerPixel));
sl@0
  2954
					ASSERT_EQUALS(err,KErrNone);
sl@0
  2955
					TRAP(err,iUtility->PatternFillSurfaceL(surfaceID));
sl@0
  2956
					ASSERT_EQUALS(err,KErrNone);
sl@0
  2957
								
sl@0
  2958
					CFbsBitmap* equivalentBitmap=NULL;
sl@0
  2959
					TRAP(err,equivalentBitmap=iUtility->EquivalentBitmapL(surfaceID));
sl@0
  2960
					CleanupStack::PushL(equivalentBitmap);
sl@0
  2961
					ASSERT_EQUALS(err,KErrNone);
sl@0
  2962
					
sl@0
  2963
					screenSize = iInfoScreenDevice->SizeInPixels();
sl@0
  2964
					TSize testSize = iScreenDevice->SizeInPixels();
sl@0
  2965
					screenSize.Shrink(5,5);
sl@0
  2966
					
sl@0
  2967
					if (iInfoGc)
sl@0
  2968
						{
sl@0
  2969
						testWindow.SetExtent(screenSize.iTl,screenSize.Size());
sl@0
  2970
						
sl@0
  2971
						if (testWindow.WsHandle())
sl@0
  2972
							{
sl@0
  2973
							
sl@0
  2974
							iSession.Flush();
sl@0
  2975
							iSession.Finish();
sl@0
  2976
							}
sl@0
  2977
						testWindow.SetVisible(ETrue);
sl@0
  2978
						}
sl@0
  2979
					Pause(200);			
sl@0
  2980
					iSession.Finish(ETrue);
sl@0
  2981
					
sl@0
  2982
					RWindow surfWindow;
sl@0
  2983
					if (iInfoGc)
sl@0
  2984
						{
sl@0
  2985
						surfWindow=RWindow(iSession);
sl@0
  2986
						ASSERT_EQUALS(surfWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone);
sl@0
  2987
						surfWindow.SetBackgroundSurface(surfaceID);
sl@0
  2988
						surfWindow.SetExtent(screenSize.iTl+TPoint( screenSize.Width()/2 +5,5),surfaceSize);
sl@0
  2989
						surfWindow.Activate();
sl@0
  2990
						
sl@0
  2991
						if (surfWindow.WsHandle())
sl@0
  2992
							{
sl@0
  2993
							surfWindow.Invalidate();
sl@0
  2994
						
sl@0
  2995
							surfWindow.BeginRedraw();
sl@0
  2996
							ActivateWithWipe(iInfoGc,surfWindow,iRed);
sl@0
  2997
							surfWindow.EndRedraw();
sl@0
  2998
						
sl@0
  2999
							iSession.Flush();
sl@0
  3000
							iSession.Finish();
sl@0
  3001
							}
sl@0
  3002
						surfWindow.SetVisible(ETrue);
sl@0
  3003
						iInfoGc->Deactivate();
sl@0
  3004
						}
sl@0
  3005
					
sl@0
  3006
					iSession.Finish(ETrue);
sl@0
  3007
					
sl@0
  3008
					TRect bitmapDrawRect;
sl@0
  3009
					bitmapDrawRect = surfaceSize;
sl@0
  3010
					
sl@0
  3011
					RWindow bmpWindow;
sl@0
  3012
					if (iInfoGc)
sl@0
  3013
						{
sl@0
  3014
						bmpWindow=RWindow(iSession);
sl@0
  3015
						ASSERT_EQUALS(bmpWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone);
sl@0
  3016
						bmpWindow.SetBackgroundColor(iRed);
sl@0
  3017
						bmpWindow.SetExtent(screenSize.iTl+TPoint(5,5),surfaceSize);
sl@0
  3018
						bmpWindow.Activate();
sl@0
  3019
						
sl@0
  3020
						if (bmpWindow.WsHandle())
sl@0
  3021
							{
sl@0
  3022
							bmpWindow.Invalidate();
sl@0
  3023
						
sl@0
  3024
							bmpWindow.BeginRedraw();
sl@0
  3025
							ActivateWithWipe(iInfoGc,bmpWindow,iRed);
sl@0
  3026
							// Not drawing, draw twice??
sl@0
  3027
							iInfoGc->DrawBitmap(bitmapDrawRect, equivalentBitmap);
sl@0
  3028
							bmpWindow.EndRedraw();
sl@0
  3029
						
sl@0
  3030
							iSession.Flush();
sl@0
  3031
							iSession.Finish();
sl@0
  3032
							}
sl@0
  3033
						bmpWindow.SetVisible(ETrue);
sl@0
  3034
						iInfoGc->Deactivate();
sl@0
  3035
						}
sl@0
  3036
					Pause(200);			
sl@0
  3037
					iSession.Finish(ETrue);
sl@0
  3038
sl@0
  3039
					
sl@0
  3040
					if (iInfoGc)
sl@0
  3041
						{
sl@0
  3042
						
sl@0
  3043
						if (bmpWindow.WsHandle())
sl@0
  3044
							{
sl@0
  3045
							bmpWindow.Invalidate();
sl@0
  3046
						
sl@0
  3047
							bmpWindow.BeginRedraw();
sl@0
  3048
							ActivateWithWipe(iInfoGc,bmpWindow,iRed);
sl@0
  3049
							// Not drawing, draw twice??
sl@0
  3050
							iInfoGc->DrawBitmap(bitmapDrawRect, equivalentBitmap);
sl@0
  3051
							bmpWindow.EndRedraw();
sl@0
  3052
							
sl@0
  3053
							iSession.Flush();
sl@0
  3054
							iSession.Finish();
sl@0
  3055
							}
sl@0
  3056
						bmpWindow.SetVisible(ETrue);
sl@0
  3057
						iInfoGc->Deactivate();
sl@0
  3058
						}
sl@0
  3059
					Pause(200);			
sl@0
  3060
					iSession.Finish(ETrue);
sl@0
  3061
					
sl@0
  3062
					if (iInfoGc)
sl@0
  3063
						{
sl@0
  3064
								
sl@0
  3065
						if (bmpWindow.WsHandle())
sl@0
  3066
							{
sl@0
  3067
							bmpWindow.Invalidate();
sl@0
  3068
											
sl@0
  3069
							bmpWindow.BeginRedraw();
sl@0
  3070
							ActivateWithWipe(iInfoGc,bmpWindow,iRed);
sl@0
  3071
							// Not drawing, draw twice??
sl@0
  3072
							iInfoGc->DrawBitmap(bitmapDrawRect, equivalentBitmap);
sl@0
  3073
							bmpWindow.EndRedraw();
sl@0
  3074
							iSession.Flush();
sl@0
  3075
							iSession.Finish();
sl@0
  3076
							}
sl@0
  3077
						bmpWindow.SetVisible(ETrue);
sl@0
  3078
						iInfoGc->Deactivate();
sl@0
  3079
						}
sl@0
  3080
					Pause(200);			
sl@0
  3081
					iSession.Finish(ETrue);
sl@0
  3082
sl@0
  3083
					RArray<TBitmapRegionPair> regionArray;					
sl@0
  3084
sl@0
  3085
					RRegion equivRegion;
sl@0
  3086
					TBitmapRegionPair bitmap1Region;
sl@0
  3087
					bitmap1Region.bitmap = equivalentBitmap;
sl@0
  3088
					bitmap1Region.drawRect = TRect(TPoint(0,0),surfaceSize);
sl@0
  3089
					equivRegion.AddRect(TRect(TPoint(0,0),surfaceSize));
sl@0
  3090
					bitmap1Region.region = &equivRegion;
sl@0
  3091
sl@0
  3092
					regionArray.Append(bitmap1Region);
sl@0
  3093
sl@0
  3094
sl@0
  3095
					TDisplayConfiguration dispConfigAfter2;
sl@0
  3096
					interface->GetConfiguration(dispConfigAfter2);
sl@0
  3097
					TSize theSize;
sl@0
  3098
					dispConfigAfter2.GetResolution(theSize);
sl@0
  3099
					TDisplayConfiguration1::TRotation orient;
sl@0
  3100
					dispConfigAfter2.GetRotation(orient);
sl@0
  3101
					if (orient == TDisplayConfiguration1::ERotation90CW || orient == TDisplayConfiguration1::ERotation270CW)
sl@0
  3102
						{
sl@0
  3103
						TInt temp = theSize.iHeight;
sl@0
  3104
						theSize.iHeight = theSize.iWidth;
sl@0
  3105
						theSize.iWidth = temp;
sl@0
  3106
						}
sl@0
  3107
					TRect uiSize(TPoint(0,0), theSize);
sl@0
  3108
					MDisplayMapping* mappingInterface = static_cast<MDisplayMapping*>
sl@0
  3109
								(iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
sl@0
  3110
					ASSERT_TRUE(mappingInterface);
sl@0
  3111
					TRect finalSize;
sl@0
  3112
					mappingInterface->MapCoordinates(EApplicationSpace, uiSize, ECompositionSpace, finalSize);
sl@0
  3113
						
sl@0
  3114
sl@0
  3115
					CFbsBitmap* bmp2 = new (ELeave) CFbsBitmap;
sl@0
  3116
					CleanupStack::PushL(bmp2);
sl@0
  3117
					User::LeaveIfError(bmp2->Create(finalSize.Size(), EColor16MU));
sl@0
  3118
sl@0
  3119
					MTestScreenCapture
sl@0
  3120
							* csc =
sl@0
  3121
									static_cast<MTestScreenCapture*> (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf));
sl@0
  3122
					if (csc)
sl@0
  3123
						{
sl@0
  3124
						TInt errr = csc->ComposeScreen(*bmp2);
sl@0
  3125
						ASSERT_TRUE(errr == KErrNone);
sl@0
  3126
						}
sl@0
  3127
					else
sl@0
  3128
						{
sl@0
  3129
						if (!cSCLogged)
sl@0
  3130
							{
sl@0
  3131
							cSCLogged = ETrue;
sl@0
  3132
							_LIT(KNoCSC, "CSC testing not enabled as CSC render stage not defined");
sl@0
  3133
							Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrAll, KNoCSC);
sl@0
  3134
							}
sl@0
  3135
						}
sl@0
  3136
					
sl@0
  3137
					
sl@0
  3138
					TRect compareRect(bmpWindow.AbsPosition(), bmpWindow.Size());
sl@0
  3139
					TRect testRect(surfWindow.AbsPosition(), surfWindow.Size());
sl@0
  3140
sl@0
  3141
					if (csc)
sl@0
  3142
						{
sl@0
  3143
						if(!Compare(*bmp2, compareRect, testRect, regionArray, aIsSurface))
sl@0
  3144
							{
sl@0
  3145
							_LIT(KCompareFailed, "Compare Failed on app mode: %d");
sl@0
  3146
							TBuf<256> x;
sl@0
  3147
							x.Format(KCompareFailed, res+1);
sl@0
  3148
							Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
sl@0
  3149
							}
sl@0
  3150
						}
sl@0
  3151
sl@0
  3152
					CleanupStack::PopAndDestroy(bmp2);
sl@0
  3153
sl@0
  3154
					equivRegion.Close();
sl@0
  3155
					regionArray.Close();
sl@0
  3156
					
sl@0
  3157
					CleanupStack::PopAndDestroy(equivalentBitmap);
sl@0
  3158
					surfWindow.Close();
sl@0
  3159
					bmpWindow.Close();
sl@0
  3160
					}
sl@0
  3161
				}
sl@0
  3162
			}
sl@0
  3163
		//restore initial res
sl@0
  3164
		if (screenModeList.Count() > 1)
sl@0
  3165
            {   //set back to basics
sl@0
  3166
            iInfoScreenDevice->SetAppScreenMode(screenModeList[0]);
sl@0
  3167
            iInfoScreenDevice->SetScreenMode(screenModeList[0]);
sl@0
  3168
            Pause(300);
sl@0
  3169
            }
sl@0
  3170
		
sl@0
  3171
		interface->SetConfiguration(dispConfigBefore);
sl@0
  3172
		Pause(1000);
sl@0
  3173
		TDisplayConfiguration dispConfigAfter;
sl@0
  3174
		interface->GetConfiguration(dispConfigAfter);
sl@0
  3175
		TSize resAfter;
sl@0
  3176
		ok=dispConfigAfter.GetResolution(resAfter);
sl@0
  3177
		ASSERT_TRUE(ok);	
sl@0
  3178
		ASSERT_EQUALS(resBefore,resAfter);
sl@0
  3179
		}
sl@0
  3180
	else
sl@0
  3181
		{
sl@0
  3182
		INFO_PRINTF1(_L("Only 1 screen size mode configured on this screen - res change test skipped."));
sl@0
  3183
		}
sl@0
  3184
	testWindow.Close();
sl@0
  3185
	screenModeList.Close();
sl@0
  3186
	resolutionList1.Close();
sl@0
  3187
	}
sl@0
  3188
	
sl@0
  3189
sl@0
  3190
/**
sl@0
  3191
@SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0042L
sl@0
  3192
@SYMTestCaseDesc		Test Drawing of bitmaps (case 0) and surfaces (case 1) in all different resolutions
sl@0
  3193
@SYMREQ					REQ10332
sl@0
  3194
@SYMPREQ				PREQ2102
sl@0
  3195
@SYMTestType			CT
sl@0
  3196
@SYMTestPurpose			Check to see if Bitmaps and Surfaces are drawn correctly in different resolutions
sl@0
  3197
@SYMTestActions			
sl@0
  3198
	A Simple pattern will be drawn by a bitmap on the left and a surface on the right, about half the window size each. The Composited Screen Capture code will be used to compare the drawing to a unchanged copy of the bitmap to see if they are drawn correctly
sl@0
  3199
	
sl@0
  3200
	Note, add .0 to test name to test bitmap drawing and .1 to test surface drawing
sl@0
  3201
@SYMTestExpectedResults	
sl@0
  3202
	All tests should pass.
sl@0
  3203
	
sl@0
  3204
*/
sl@0
  3205
void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0042L(TBool aIsSurface)
sl@0
  3206
	{
sl@0
  3207
	LOG_AND_PANIC_IF_NOT_GCE;
sl@0
  3208
	ResetScreens();
sl@0
  3209
	TInt error;
sl@0
  3210
	iSession.Finish(ETrue);
sl@0
  3211
	
sl@0
  3212
	TRect screenSize(iInfoScreenDevice->SizeInPixels());
sl@0
  3213
	screenSize.Shrink(5,5);
sl@0
  3214
	
sl@0
  3215
	RBlankWindow testWindow;
sl@0
  3216
	if (iInfoGc)
sl@0
  3217
		{
sl@0
  3218
		testWindow=RBlankWindow(iSession);
sl@0
  3219
		ASSERT_EQUALS(testWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone);
sl@0
  3220
		testWindow.SetColor(iBlue);
sl@0
  3221
		testWindow.SetExtent(screenSize.iTl,screenSize.Size());
sl@0
  3222
		testWindow.Activate();
sl@0
  3223
		
sl@0
  3224
		if (testWindow.WsHandle())
sl@0
  3225
			{		
sl@0
  3226
			iSession.Flush();
sl@0
  3227
			iSession.Finish();
sl@0
  3228
			}
sl@0
  3229
		testWindow.SetVisible(ETrue);
sl@0
  3230
		}
sl@0
  3231
	
sl@0
  3232
	iSession.Finish(ETrue);
sl@0
  3233
	
sl@0
  3234
	RArray<TInt> screenModeList;
sl@0
  3235
	iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
sl@0
  3236
	MDisplayControl* interface = static_cast<MDisplayControl*>
sl@0
  3237
				(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
sl@0
  3238
	ASSERT_TRUE(interface);
sl@0
  3239
	
sl@0
  3240
	TInt resolutions = interface->NumberOfResolutions();
sl@0
  3241
	ASSERT_TRUE (resolutions > 0);
sl@0
  3242
	
sl@0
  3243
	RArray<MDisplayControl::TResolution> resolutionList1;
sl@0
  3244
	error = interface->GetResolutions(resolutionList1);
sl@0
  3245
	ASSERT_EQUALS(error,KErrNone);
sl@0
  3246
	ASSERT_EQUALS(resolutionList1.Count(), resolutions);
sl@0
  3247
	
sl@0
  3248
	TDisplayConfiguration dispConfigBefore;
sl@0
  3249
	interface->GetConfiguration(dispConfigBefore);
sl@0
  3250
sl@0
  3251
	iInfoScreenDevice->SetAppScreenMode(screenModeList[1]);
sl@0
  3252
	iInfoScreenDevice->SetScreenMode(screenModeList[1]);
sl@0
  3253
	iSession.Finish();
sl@0
  3254
	Pause(50);
sl@0
  3255
	
sl@0
  3256
	if (resolutions>1)
sl@0
  3257
		{
sl@0
  3258
		//Got a mode to change to!
sl@0
  3259
		TSize resBefore;
sl@0
  3260
		TBool ok=dispConfigBefore.GetResolution(resBefore);
sl@0
  3261
		ASSERT_TRUE(ok);	//we "know" this should be ok, as we just asserted the flag
sl@0
  3262
		for (TInt res=0;res<resolutionList1.Count();res++)
sl@0
  3263
			{
sl@0
  3264
			if (resolutionList1[res].iPixelSize!=TSize(0,0))	//this test is not about turning the display off
sl@0
  3265
				{
sl@0
  3266
				TDisplayConfiguration dispConfigReq;
sl@0
  3267
				dispConfigReq.SetResolution(resolutionList1[res].iPixelSize);
sl@0
  3268
				ASSERT_TRUE(dispConfigReq.IsDefined(dispConfigReq.EResolution));
sl@0
  3269
				
sl@0
  3270
				SetRotation(dispConfigReq,resolutionList1[res]);	//set rotation to first defined in res list
sl@0
  3271
				
sl@0
  3272
				
sl@0
  3273
				
sl@0
  3274
sl@0
  3275
				TInt errCode=interface->SetConfiguration(dispConfigReq);
sl@0
  3276
				//ASSERT_EQUALS(errCode,KErrNone);
sl@0
  3277
				if (errCode != KErrNone)
sl@0
  3278
					{
sl@0
  3279
					//Probably current size mode does not support the rotation of the passed in configuration
sl@0
  3280
					
sl@0
  3281
					ASSERT_EQUALS(errCode,KErrArgument);	//failed to find compatible res in the policy
sl@0
  3282
					continue;
sl@0
  3283
					}
sl@0
  3284
				
sl@0
  3285
				
sl@0
  3286
				TSize pr = iInfoScreenDevice->SizeInPixels();
sl@0
  3287
				TPoint 	origin=iInfoScreenDevice->GetDefaultScreenModeOrigin();					
sl@0
  3288
				Pause(300);
sl@0
  3289
				TSize winpos;
sl@0
  3290
				
sl@0
  3291
				TSize surfaceSize = pr;
sl@0
  3292
				surfaceSize.iWidth /= 2;
sl@0
  3293
				surfaceSize.iWidth -= 20;
sl@0
  3294
				surfaceSize.iHeight -= 20;
sl@0
  3295
				TSurfaceId surfaceID;
sl@0
  3296
				TRAPD(err, surfaceID = iUtility->CreateSurfaceL(surfaceSize, 
sl@0
  3297
							KSurfaceFormat, surfaceSize.iWidth * KBytesPerPixel));
sl@0
  3298
				ASSERT_EQUALS(err,KErrNone);
sl@0
  3299
				TRAP(err,iUtility->PatternFillSurfaceL(surfaceID));
sl@0
  3300
				ASSERT_EQUALS(err,KErrNone);
sl@0
  3301
							
sl@0
  3302
				CFbsBitmap* equivalentBitmap=NULL;
sl@0
  3303
				TRAP(err,equivalentBitmap=iUtility->EquivalentBitmapL(surfaceID));
sl@0
  3304
				CleanupStack::PushL(equivalentBitmap);
sl@0
  3305
				ASSERT_EQUALS(err,KErrNone);
sl@0
  3306
				
sl@0
  3307
				screenSize = iInfoScreenDevice->SizeInPixels();
sl@0
  3308
				screenSize.Shrink(5,5);
sl@0
  3309
				
sl@0
  3310
				if (iInfoGc)
sl@0
  3311
					{
sl@0
  3312
					testWindow.SetExtent(screenSize.iTl,screenSize.Size());
sl@0
  3313
					
sl@0
  3314
					if (testWindow.WsHandle())
sl@0
  3315
						{
sl@0
  3316
						
sl@0
  3317
						iSession.Flush();
sl@0
  3318
						iSession.Finish();
sl@0
  3319
						}
sl@0
  3320
					testWindow.SetVisible(ETrue);
sl@0
  3321
					}
sl@0
  3322
				Pause(200);			
sl@0
  3323
				iSession.Finish(ETrue);
sl@0
  3324
				
sl@0
  3325
				RWindow surfWindow;
sl@0
  3326
				if (iInfoGc)
sl@0
  3327
					{
sl@0
  3328
					surfWindow=RWindow(iSession);
sl@0
  3329
					ASSERT_EQUALS(surfWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone);
sl@0
  3330
					surfWindow.SetBackgroundSurface(surfaceID);
sl@0
  3331
					surfWindow.SetExtent(screenSize.iTl+TPoint( screenSize.Width()/2 +5,5),surfaceSize);
sl@0
  3332
					surfWindow.Activate();
sl@0
  3333
					
sl@0
  3334
					if (surfWindow.WsHandle())
sl@0
  3335
						{
sl@0
  3336
						surfWindow.Invalidate();
sl@0
  3337
					
sl@0
  3338
						surfWindow.BeginRedraw();
sl@0
  3339
						ActivateWithWipe(iInfoGc,surfWindow,iRed);
sl@0
  3340
						surfWindow.EndRedraw();
sl@0
  3341
					
sl@0
  3342
						iSession.Flush();
sl@0
  3343
						iSession.Finish();
sl@0
  3344
						}
sl@0
  3345
					surfWindow.SetVisible(ETrue);
sl@0
  3346
					iInfoGc->Deactivate();
sl@0
  3347
					}
sl@0
  3348
				
sl@0
  3349
				iSession.Finish(ETrue);
sl@0
  3350
				
sl@0
  3351
				TRect bitmapDrawRect;
sl@0
  3352
				bitmapDrawRect = surfaceSize;
sl@0
  3353
				
sl@0
  3354
				RWindow bmpWindow;
sl@0
  3355
				if (iInfoGc)
sl@0
  3356
					{
sl@0
  3357
					bmpWindow=RWindow(iSession);
sl@0
  3358
					ASSERT_EQUALS(bmpWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone);
sl@0
  3359
					bmpWindow.SetBackgroundColor(iRed);
sl@0
  3360
					bmpWindow.SetExtent(screenSize.iTl+TPoint(5,5),surfaceSize);
sl@0
  3361
					bmpWindow.Activate();
sl@0
  3362
					
sl@0
  3363
					if (bmpWindow.WsHandle())
sl@0
  3364
						{
sl@0
  3365
						bmpWindow.Invalidate();
sl@0
  3366
					
sl@0
  3367
						bmpWindow.BeginRedraw();
sl@0
  3368
						ActivateWithWipe(iInfoGc,bmpWindow,iRed);
sl@0
  3369
						// Not drawing, draw twice??
sl@0
  3370
						iInfoGc->DrawBitmap(bitmapDrawRect, equivalentBitmap);
sl@0
  3371
						bmpWindow.EndRedraw();
sl@0
  3372
					
sl@0
  3373
						iSession.Flush();
sl@0
  3374
						iSession.Finish();
sl@0
  3375
						}
sl@0
  3376
					bmpWindow.SetVisible(ETrue);
sl@0
  3377
					iInfoGc->Deactivate();
sl@0
  3378
					}
sl@0
  3379
				Pause(200);			
sl@0
  3380
				iSession.Finish(ETrue);
sl@0
  3381
				
sl@0
  3382
				
sl@0
  3383
				if (iInfoGc)
sl@0
  3384
					{
sl@0
  3385
					
sl@0
  3386
					if (bmpWindow.WsHandle())
sl@0
  3387
						{
sl@0
  3388
						bmpWindow.Invalidate();
sl@0
  3389
							
sl@0
  3390
						bmpWindow.BeginRedraw();
sl@0
  3391
						ActivateWithWipe(iInfoGc,bmpWindow,iRed);
sl@0
  3392
						// Not drawing, draw twice??
sl@0
  3393
						iInfoGc->DrawBitmap(bitmapDrawRect, equivalentBitmap);
sl@0
  3394
						bmpWindow.EndRedraw();
sl@0
  3395
											
sl@0
  3396
						iSession.Flush();
sl@0
  3397
						iSession.Finish();
sl@0
  3398
						}
sl@0
  3399
					bmpWindow.SetVisible(ETrue);
sl@0
  3400
					iInfoGc->Deactivate();
sl@0
  3401
					}
sl@0
  3402
				Pause(200);			
sl@0
  3403
				iSession.Finish(ETrue);
sl@0
  3404
									
sl@0
  3405
sl@0
  3406
				
sl@0
  3407
sl@0
  3408
				RArray<TBitmapRegionPair> regionArray;					
sl@0
  3409
sl@0
  3410
				RRegion equivRegion;
sl@0
  3411
				TBitmapRegionPair bitmap1Region;
sl@0
  3412
				bitmap1Region.bitmap = equivalentBitmap;
sl@0
  3413
				bitmap1Region.drawRect = TRect(TPoint(0,0),surfaceSize);
sl@0
  3414
				equivRegion.AddRect(TRect(TPoint(0,0),surfaceSize));
sl@0
  3415
				bitmap1Region.region = &equivRegion;
sl@0
  3416
sl@0
  3417
				regionArray.Append(bitmap1Region);
sl@0
  3418
sl@0
  3419
sl@0
  3420
				TDisplayConfiguration dispConfigAfter2;
sl@0
  3421
				interface->GetConfiguration(dispConfigAfter2);
sl@0
  3422
				TSize theSize;
sl@0
  3423
				dispConfigAfter2.GetResolution(theSize);
sl@0
  3424
				TDisplayConfiguration1::TRotation orient;
sl@0
  3425
				dispConfigAfter2.GetRotation(orient);
sl@0
  3426
				if (orient & 0x1)
sl@0
  3427
					{
sl@0
  3428
					TInt temp = theSize.iHeight;
sl@0
  3429
					theSize.iHeight = theSize.iWidth;
sl@0
  3430
					theSize.iWidth = temp;
sl@0
  3431
					}
sl@0
  3432
				TRect uiSize(TPoint(0,0), theSize);
sl@0
  3433
				MDisplayMapping* mappingInterface = static_cast<MDisplayMapping*>
sl@0
  3434
							(iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
sl@0
  3435
				ASSERT_TRUE(mappingInterface);
sl@0
  3436
				TRect finalSize;
sl@0
  3437
				mappingInterface->MapCoordinates(EApplicationSpace, uiSize, ECompositionSpace, finalSize);
sl@0
  3438
sl@0
  3439
				
sl@0
  3440
				
sl@0
  3441
sl@0
  3442
				CFbsBitmap* bmp2 = new (ELeave) CFbsBitmap;
sl@0
  3443
				CleanupStack::PushL(bmp2);
sl@0
  3444
				TInt bmpErr = bmp2->Create(finalSize.Size(), EColor16MU);
sl@0
  3445
				ASSERT_EQUALS(bmpErr, KErrNone);
sl@0
  3446
sl@0
  3447
				MTestScreenCapture
sl@0
  3448
						* csc =
sl@0
  3449
								static_cast<MTestScreenCapture*> (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf));
sl@0
  3450
				if (csc)
sl@0
  3451
					{
sl@0
  3452
					TInt errr = csc->ComposeScreen(*bmp2);
sl@0
  3453
					}
sl@0
  3454
				else
sl@0
  3455
					{
sl@0
  3456
					if (!cSCLogged)
sl@0
  3457
						{
sl@0
  3458
						cSCLogged = ETrue;
sl@0
  3459
						_LIT(KNoCSC, "CSC testing not enabled as CSC render stage not defined");
sl@0
  3460
						Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrAll, KNoCSC);
sl@0
  3461
						}
sl@0
  3462
					}
sl@0
  3463
				TRect compareRect(bmpWindow.AbsPosition(), bmpWindow.Size());
sl@0
  3464
				TRect testRect(surfWindow.AbsPosition(), surfWindow.Size());
sl@0
  3465
sl@0
  3466
				if (csc)
sl@0
  3467
					{
sl@0
  3468
					if(!Compare(*bmp2, compareRect, testRect, regionArray, aIsSurface))
sl@0
  3469
						{
sl@0
  3470
						_LIT(KCompareFailed, "Compare Failed on resolution: %d");
sl@0
  3471
						TBuf<256> x;
sl@0
  3472
						x.Format(KCompareFailed, res+1);
sl@0
  3473
						Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
sl@0
  3474
						}
sl@0
  3475
					}
sl@0
  3476
				CleanupStack::PopAndDestroy(bmp2);
sl@0
  3477
sl@0
  3478
				equivRegion.Close();
sl@0
  3479
				regionArray.Close();
sl@0
  3480
				
sl@0
  3481
				CleanupStack::PopAndDestroy(equivalentBitmap);
sl@0
  3482
				surfWindow.Close();
sl@0
  3483
				bmpWindow.Close();
sl@0
  3484
				}
sl@0
  3485
			}
sl@0
  3486
			//restore initial res
sl@0
  3487
			iInfoScreenDevice->SetAppScreenMode(0);
sl@0
  3488
			iInfoScreenDevice->SetScreenMode(0);
sl@0
  3489
			}
sl@0
  3490
		else
sl@0
  3491
			{
sl@0
  3492
			INFO_PRINTF1(_L("Only 1 screen size mode configured on this screen - res change test skipped."));
sl@0
  3493
			}
sl@0
  3494
		testWindow.Close();
sl@0
  3495
		screenModeList.Close();
sl@0
  3496
		resolutionList1.Close();
sl@0
  3497
	}
sl@0
  3498
sl@0
  3499
sl@0
  3500
/**
sl@0
  3501
 Tests to see if the pixels in the bitmap match what should be drawn with regards to the bitmaps and regions in aBitmapRegionPairArray
sl@0
  3502
 It does this by in the case of non-scaled bitmaps, performing a pixel by pixel comparison between what has been drawn to the CSC created bitmap and either the pixels of the bitmap if they are contained within the related region or the pixels of the simulation screen. In the case of scalingm only certain pixels are compared from the CSC bitmap to the comparison drawing as the scaling algorithm is hard to replicate.
sl@0
  3503
sl@0
  3504
sl@0
  3505
 @param aBitmap a bitmap of the entire screen which should be generated using the Composited Screen Capture code
sl@0
  3506
 @param aRect1 A rectangle representing the middle window in the comparison triple
sl@0
  3507
 @param aRect2 A rectangle represneting the right window in the comparison triple
sl@0
  3508
 @param aBitmapRegionPairArray An array of the different regions that are being drawn on the screen. They should be placed in order such that the closest to the foreground is first and the furthest away is last in the queue. Each member of the array is a misleadingly titled TBitmapRegion pair, the bitmap member of this should be the bitmap that is being drawn to the region of the screen, if the region is just a blank color then a blank color bitmap should be drawn. The region should be the region that the bitmap is being drawn to and should be the same as the clipping region which is set jsut before the bitmap is drawn to screen. Finally the draw rect is the basic rectangle the bitmap is being drawn to and is mainly used to test if the bitmap is being scaled
sl@0
  3509
 @return True
sl@0
  3510
 */
sl@0
  3511
TBool CWsDynamicResBasic::Compare(const CFbsBitmap& aBitmap,
sl@0
  3512
		const TRect& aRect1, const TRect& aRect2,
sl@0
  3513
		RArray<TBitmapRegionPair>& aBitmapRegionPairArray, TBool aIsSurface)
sl@0
  3514
	{
sl@0
  3515
	MDisplayMapping* mappingInterface = static_cast<MDisplayMapping*>
sl@0
  3516
				(iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
sl@0
  3517
	ASSERT_TRUE(mappingInterface);
sl@0
  3518
		
sl@0
  3519
	
sl@0
  3520
	TRgb color1;
sl@0
  3521
	TRgb color2;
sl@0
  3522
sl@0
  3523
	TInt errorPixels =0;
sl@0
  3524
	TInt diffPixels = 0;
sl@0
  3525
	RRegion ignoreDueToResizing;
sl@0
  3526
	TInt regionCount = aBitmapRegionPairArray.Count();
sl@0
  3527
	for (TInt i=regionCount-1; i>=0; i--)
sl@0
  3528
		{
sl@0
  3529
		if (aBitmapRegionPairArray[i].bitmap->SizeInPixels()
sl@0
  3530
				!= aBitmapRegionPairArray[i].drawRect.Size())
sl@0
  3531
			{
sl@0
  3532
			RArray<TPoint> corners;
sl@0
  3533
			corners.Append(aBitmapRegionPairArray[i].drawRect.iTl);
sl@0
  3534
			corners.Append(TPoint(aBitmapRegionPairArray[i].drawRect.iBr.iX-1,
sl@0
  3535
					aBitmapRegionPairArray[i].drawRect.iTl.iY));
sl@0
  3536
			corners.Append(TPoint(aBitmapRegionPairArray[i].drawRect.iTl.iX,
sl@0
  3537
					aBitmapRegionPairArray[i].drawRect.iBr.iY-1));
sl@0
  3538
			corners.Append(aBitmapRegionPairArray[i].drawRect.iBr- TPoint(1,1));
sl@0
  3539
			for (TInt j=0; j<corners.Count(); j++)
sl@0
  3540
				{
sl@0
  3541
				TBool inOther=EFalse;
sl@0
  3542
				for (TInt k=0; k<i; k++)
sl@0
  3543
					{
sl@0
  3544
					if (aBitmapRegionPairArray[k].region->Contains(corners[j]))
sl@0
  3545
						{
sl@0
  3546
						inOther = ETrue;
sl@0
  3547
						}
sl@0
  3548
					}
sl@0
  3549
				if (inOther)
sl@0
  3550
					{
sl@0
  3551
					continue;
sl@0
  3552
					}
sl@0
  3553
				aBitmap.GetPixel(color1, aRect2.iTl + corners[j]);
sl@0
  3554
				aBitmap.GetPixel(color2, aRect1.iTl + corners[j]);
sl@0
  3555
				TRgb color3 = GreatestColor(color1);
sl@0
  3556
				TRgb color4 = GreatestColor(color2);
sl@0
  3557
				if (color3 != color4)
sl@0
  3558
					{
sl@0
  3559
					// Bitmap copy can be off by a pixel on grid filled surface so allow for green and yellow to be treated equally as they are the background colours, this may allow a misfunctioning gce to pass the test though.
sl@0
  3560
					if (color4 == TRgb(0, 1, 0) && color3 == TRgb(1, 1, 0))
sl@0
  3561
						{
sl@0
  3562
						}
sl@0
  3563
					else
sl@0
  3564
						if (color4 == TRgb(1, 1, 0) && color3 == TRgb(0, 1, 0))
sl@0
  3565
							{
sl@0
  3566
							}
sl@0
  3567
						else
sl@0
  3568
							{
sl@0
  3569
							corners.Close();
sl@0
  3570
							return EFalse;
sl@0
  3571
							}
sl@0
  3572
					}
sl@0
  3573
sl@0
  3574
				}
sl@0
  3575
			// testPoints contains first the pixel within the destRect followed by the pixel in the original position for comparison to
sl@0
  3576
			RArray<TPoint> testPoints;
sl@0
  3577
			testPoints.Append(aBitmapRegionPairArray[i].drawRect.Center());
sl@0
  3578
			testPoints.Append(TPoint(
sl@0
  3579
					aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth/2,
sl@0
  3580
					aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight/2));
sl@0
  3581
			testPoints.Append(TPoint(aBitmapRegionPairArray[i].drawRect.iTl.iX,
sl@0
  3582
					aBitmapRegionPairArray[i].drawRect.Center().iY));
sl@0
  3583
			testPoints.Append(TPoint(0,
sl@0
  3584
					aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight/2));
sl@0
  3585
			testPoints.Append(TPoint(aBitmapRegionPairArray[i].drawRect.iBr.iX
sl@0
  3586
					-1, aBitmapRegionPairArray[i].drawRect.Center().iY));
sl@0
  3587
			testPoints.Append(TPoint(
sl@0
  3588
					aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth-1,
sl@0
  3589
					aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight/2));
sl@0
  3590
			TSize sizeee = aBitmapRegionPairArray[i].drawRect.Size();
sl@0
  3591
			if (aBitmapRegionPairArray[i].drawRect.Size().iWidth > 11 && aBitmapRegionPairArray[i].drawRect.Size().iHeight > 20)
sl@0
  3592
				{
sl@0
  3593
				testPoints.Append(TPoint(
sl@0
  3594
						aBitmapRegionPairArray[i].drawRect.Center().iX, aBitmapRegionPairArray[i].drawRect.iTl.iY));
sl@0
  3595
				testPoints.Append(TPoint(
sl@0
  3596
						aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth/2, 0));
sl@0
  3597
sl@0
  3598
				testPoints.Append(TPoint(
sl@0
  3599
						aBitmapRegionPairArray[i].drawRect.Center().iX, aBitmapRegionPairArray[i].drawRect.iBr.iY-1));
sl@0
  3600
				testPoints.Append(TPoint(
sl@0
  3601
						aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth/2,
sl@0
  3602
						aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight-1));
sl@0
  3603
sl@0
  3604
				if (aBitmapRegionPairArray[i].drawRect.Size().iWidth > 34
sl@0
  3605
						&& aBitmapRegionPairArray[i].drawRect.Size().iHeight > 43)
sl@0
  3606
					{
sl@0
  3607
					testPoints.Append(aBitmapRegionPairArray[i].drawRect.iTl
sl@0
  3608
							+ TPoint(5, 5));
sl@0
  3609
					testPoints.Append(TPoint(5, 5));
sl@0
  3610
					testPoints.Append(TPoint(
sl@0
  3611
							aBitmapRegionPairArray[i].drawRect.iBr.iX - 6,
sl@0
  3612
							aBitmapRegionPairArray[i].drawRect.iTl.iY + 5));
sl@0
  3613
					testPoints.Append(TPoint(
sl@0
  3614
							aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth-6, 5));
sl@0
  3615
					testPoints.Append(TPoint(
sl@0
  3616
							aBitmapRegionPairArray[i].drawRect.iTl.iX + 5,
sl@0
  3617
							aBitmapRegionPairArray[i].drawRect.iBr.iY -6));
sl@0
  3618
					testPoints.Append(TPoint(5,
sl@0
  3619
							aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight - 6));
sl@0
  3620
					testPoints.Append(aBitmapRegionPairArray[i].drawRect.iBr
sl@0
  3621
							- TPoint(6, 6));
sl@0
  3622
					testPoints.Append(TPoint(
sl@0
  3623
							aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth-6,
sl@0
  3624
							aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight-6));
sl@0
  3625
					}
sl@0
  3626
				else
sl@0
  3627
					{
sl@0
  3628
					testPoints.Append(aBitmapRegionPairArray[i].drawRect.iTl
sl@0
  3629
							+ TPoint(2, 3));
sl@0
  3630
					testPoints.Append(TPoint(5, 5));
sl@0
  3631
					testPoints.Append(TPoint(
sl@0
  3632
							aBitmapRegionPairArray[i].drawRect.iBr.iX - 3,
sl@0
  3633
							aBitmapRegionPairArray[i].drawRect.iTl.iY + 3));
sl@0
  3634
					testPoints.Append(TPoint(
sl@0
  3635
							aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth-6, 5));
sl@0
  3636
					testPoints.Append(TPoint(
sl@0
  3637
							aBitmapRegionPairArray[i].drawRect.iTl.iX + 2,
sl@0
  3638
							aBitmapRegionPairArray[i].drawRect.iBr.iY -4));
sl@0
  3639
					testPoints.Append(TPoint(5,
sl@0
  3640
							aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight - 6));
sl@0
  3641
					testPoints.Append(aBitmapRegionPairArray[i].drawRect.iBr
sl@0
  3642
							- TPoint(3, 4));
sl@0
  3643
					testPoints.Append(TPoint(
sl@0
  3644
							aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth-6,
sl@0
  3645
							aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight-6));
sl@0
  3646
					}
sl@0
  3647
				}
sl@0
  3648
			for (int jj=0; jj<testPoints.Count(); jj+=2)
sl@0
  3649
				{
sl@0
  3650
				TBool inOther=EFalse;
sl@0
  3651
				if (!aBitmapRegionPairArray[i].region->Contains(testPoints[jj]))
sl@0
  3652
					{
sl@0
  3653
					continue;
sl@0
  3654
					}
sl@0
  3655
				for (TInt k=0; k<i; k++)
sl@0
  3656
					{
sl@0
  3657
					if (aBitmapRegionPairArray[k].region->Contains(testPoints[jj]))
sl@0
  3658
						{
sl@0
  3659
						inOther = ETrue;
sl@0
  3660
						}
sl@0
  3661
					}
sl@0
  3662
				if (inOther)
sl@0
  3663
					{
sl@0
  3664
					continue;
sl@0
  3665
					}
sl@0
  3666
				TPoint currentPoint = testPoints[jj];
sl@0
  3667
				TRect bound = aBitmapRegionPairArray[i].region->BoundingRect();
sl@0
  3668
				TBool
sl@0
  3669
						contat =
sl@0
  3670
								aBitmapRegionPairArray[i].region->Contains(testPoints[jj]);
sl@0
  3671
				aBitmap.GetPixel(color1, aRect2.iTl + testPoints[jj]);
sl@0
  3672
				aBitmapRegionPairArray[i].bitmap->GetPixel(color2,
sl@0
  3673
						testPoints[jj+1]);
sl@0
  3674
				TRgb color5 = GreatestColor(color1);
sl@0
  3675
				TRgb color6 = GreatestColor(color2);
sl@0
  3676
				if (color5 != color6)
sl@0
  3677
					{
sl@0
  3678
					// Bitmap copy can be off by a pixel on grid filled surface so allow for green and yellow to be treated equally as they are the background colours, this may allow a misfunctioning gce to pass the test though.
sl@0
  3679
					if (color6 == TRgb(0, 1, 0) && color5 == TRgb(1, 1, 0))
sl@0
  3680
						{
sl@0
  3681
						}
sl@0
  3682
					else
sl@0
  3683
						if (color6 == TRgb(1, 1, 0) && color5 == TRgb(0, 1, 0))
sl@0
  3684
							{
sl@0
  3685
							}
sl@0
  3686
						else
sl@0
  3687
							{
sl@0
  3688
							testPoints.Close();
sl@0
  3689
							return EFalse;
sl@0
  3690
							}
sl@0
  3691
					}
sl@0
  3692
				}
sl@0
  3693
sl@0
  3694
			testPoints.Close();
sl@0
  3695
			corners.Close();
sl@0
  3696
			ignoreDueToResizing.Union(*aBitmapRegionPairArray[i].region);
sl@0
  3697
			aBitmapRegionPairArray.Remove(i);
sl@0
  3698
			}
sl@0
  3699
		}
sl@0
  3700
sl@0
  3701
	RRegion superRegion;
sl@0
  3702
sl@0
  3703
	regionCount = aBitmapRegionPairArray.Count();
sl@0
  3704
sl@0
  3705
	for (TInt i=0; i<regionCount; i++)
sl@0
  3706
		{
sl@0
  3707
		superRegion.Union(*(aBitmapRegionPairArray[i].region));
sl@0
  3708
		}
sl@0
  3709
	TRect boundingRect = superRegion.BoundingRect();
sl@0
  3710
	superRegion.Close();
sl@0
  3711
	TInt width = boundingRect.Width();
sl@0
  3712
	TInt height = boundingRect.Height();
sl@0
  3713
	TInt xStart = boundingRect.iTl.iX;
sl@0
  3714
	TInt yStart = boundingRect.iTl.iY;
sl@0
  3715
	
sl@0
  3716
	TSize superSize = aBitmap.SizeInPixels();
sl@0
  3717
	TRgb HHH1;
sl@0
  3718
	TInt nonWhiteCount = 0;
sl@0
  3719
	for (TInt iii = 0; iii<superSize.iWidth; iii++)
sl@0
  3720
		{
sl@0
  3721
		for (TInt jjj=0; jjj<superSize.iHeight; jjj++)
sl@0
  3722
			{
sl@0
  3723
			aBitmap.GetPixel(HHH1, TPoint(iii,jjj));
sl@0
  3724
			if (HHH1 != TRgb (255, 255, 255))
sl@0
  3725
				{
sl@0
  3726
				nonWhiteCount++;
sl@0
  3727
				}
sl@0
  3728
			}
sl@0
  3729
		}
sl@0
  3730
sl@0
  3731
	if (aBitmapRegionPairArray.Count()>0)
sl@0
  3732
		{
sl@0
  3733
        RDebug::Printf("Checking");
sl@0
  3734
        TInt countchecks=0;
sl@0
  3735
		for (TInt i=0; i<width; i++)
sl@0
  3736
			{
sl@0
  3737
			for (TInt j=0; j<height; j++)
sl@0
  3738
				{
sl@0
  3739
				TInt arrayIndex = 0;
sl@0
  3740
				TBool pointInArray= EFalse;
sl@0
  3741
				TPoint currentPoint(xStart + i, yStart + j);
sl@0
  3742
				if (!ignoreDueToResizing.Contains(currentPoint))
sl@0
  3743
					{
sl@0
  3744
					do
sl@0
  3745
						{
sl@0
  3746
						if (aBitmapRegionPairArray[arrayIndex].region->Contains(currentPoint))
sl@0
  3747
							{							
sl@0
  3748
							if (aIsSurface)
sl@0
  3749
								{
sl@0
  3750
								TPoint checkPoint = currentPoint + aRect2.iTl;
sl@0
  3751
								TRect readBackRect;
sl@0
  3752
								mappingInterface->MapCoordinates(EApplicationSpace, TRect(checkPoint, TSize(1,1)), ECompositionSpace, readBackRect);
sl@0
  3753
								aBitmap.GetPixel(color1, readBackRect.iTl);
sl@0
  3754
								}
sl@0
  3755
							else 
sl@0
  3756
								{
sl@0
  3757
								TPoint checkPoint = currentPoint + aRect1.iTl;
sl@0
  3758
								TRect readBackRect;
sl@0
  3759
								mappingInterface->MapCoordinates(EApplicationSpace, TRect(checkPoint, TSize(1,1)), ECompositionSpace, readBackRect);
sl@0
  3760
								aBitmap.GetPixel(color1, readBackRect.iTl);
sl@0
  3761
								}
sl@0
  3762
sl@0
  3763
							aBitmapRegionPairArray[arrayIndex].bitmap->GetPixel(color2,	currentPoint
sl@0
  3764
																		- aBitmapRegionPairArray[arrayIndex].drawRect.iTl);
sl@0
  3765
							
sl@0
  3766
							TRgb color7 = GreatestColor(color1);
sl@0
  3767
							TRgb color8 = GreatestColor(color2);
sl@0
  3768
sl@0
  3769
							if (color7 != color8)
sl@0
  3770
								{
sl@0
  3771
								diffPixels++;
sl@0
  3772
								//return EFalse;
sl@0
  3773
								}
sl@0
  3774
							pointInArray = ETrue;
sl@0
  3775
							}
sl@0
  3776
						arrayIndex++;
sl@0
  3777
						}
sl@0
  3778
					while (!pointInArray && !(arrayIndex
sl@0
  3779
							>= aBitmapRegionPairArray.Count()));
sl@0
  3780
sl@0
  3781
					if (!pointInArray)
sl@0
  3782
						{
sl@0
  3783
						aBitmap.GetPixel(color1, TPoint(i + aRect2.iTl.iX
sl@0
  3784
								+ xStart, j +aRect2.iTl.iY +yStart));
sl@0
  3785
						aBitmap.GetPixel(color2, TPoint(i + aRect1.iTl.iX
sl@0
  3786
								+xStart, j +aRect1.iTl.iY+yStart));
sl@0
  3787
						// Bitmap copy is duller on first few iterations so just pick the greatest color or two colors and see if they match
sl@0
  3788
						TRgb color3 = GreatestColor(color1);
sl@0
  3789
						TRgb color4 = GreatestColor(color2);
sl@0
  3790
sl@0
  3791
						if (color3 != color4)
sl@0
  3792
							{
sl@0
  3793
							// Bitmap copy can be off by a pixel on grid filled surface so allow for green and yellow to be treated equally as they are the background colours, this may allow a misfunctioning gce to pass the test though.
sl@0
  3794
							if (GreatestColor(color2) == TRgb(0, 1, 0)
sl@0
  3795
									&& GreatestColor(color1) == TRgb(1, 1, 0))
sl@0
  3796
								{
sl@0
  3797
								continue;
sl@0
  3798
								}
sl@0
  3799
							else
sl@0
  3800
								if (GreatestColor(color2) == TRgb(1, 1, 0)
sl@0
  3801
										&& GreatestColor(color1) == TRgb(0, 1,
sl@0
  3802
												0))
sl@0
  3803
									{
sl@0
  3804
									continue;
sl@0
  3805
									}
sl@0
  3806
								else
sl@0
  3807
									{
sl@0
  3808
									errorPixels++;
sl@0
  3809
									//return EFalse;
sl@0
  3810
									}
sl@0
  3811
							}
sl@0
  3812
						}
sl@0
  3813
					}
sl@0
  3814
				}
sl@0
  3815
			}
sl@0
  3816
		}
sl@0
  3817
	
sl@0
  3818
	ignoreDueToResizing.Close();
sl@0
  3819
	if (errorPixels+diffPixels < 2)
sl@0
  3820
		{
sl@0
  3821
		return ETrue;
sl@0
  3822
		}
sl@0
  3823
	else
sl@0
  3824
		{
sl@0
  3825
		return EFalse;
sl@0
  3826
		}
sl@0
  3827
sl@0
  3828
	}
sl@0
  3829
sl@0
  3830
sl@0
  3831
/*
sl@0
  3832
  Creates a rough apprxoiamtion to the color pass in. This is used because of issues with the bitmap drwaing in the comparison window. If these issues are fixed then this method can be changed to simply return aColor.
sl@0
  3833
sl@0
  3834
 @param aColor the color to be approximated
sl@0
  3835
 @return an approximation of aColor.
sl@0
  3836
 */
sl@0
  3837
TRgb CWsDynamicResBasic::GreatestColor(TRgb& aColor) const
sl@0
  3838
	{
sl@0
  3839
	TInt test = aColor.Difference(TRgb(0, 0, 0));
sl@0
  3840
	// Accounts for a case when Rgb = 20,20,20 due to poor bitmap drawing
sl@0
  3841
	if (aColor == TRgb(32, 32, 32))
sl@0
  3842
		{
sl@0
  3843
		return TRgb(0, 0, 0);
sl@0
  3844
		}
sl@0
  3845
	if (aColor == TRgb(0, 0, 0))
sl@0
  3846
		{
sl@0
  3847
		return TRgb(0, 0, 0);
sl@0
  3848
		}
sl@0
  3849
	TRgb test2;
sl@0
  3850
	test2.SetInternal(0xFFFEDF01);
sl@0
  3851
	if (aColor == test2)
sl@0
  3852
		{
sl@0
  3853
		return TRgb(1, 1, 0);
sl@0
  3854
		}
sl@0
  3855
sl@0
  3856
	if (test < 70)
sl@0
  3857
		{
sl@0
  3858
		return TRgb(0, 0, 0);
sl@0
  3859
		}
sl@0
  3860
	if (aColor.Green() > aColor.Blue())
sl@0
  3861
		{
sl@0
  3862
		if (aColor.Green() > aColor.Red())
sl@0
  3863
			{
sl@0
  3864
			return TRgb(0, 1, 0);
sl@0
  3865
			}
sl@0
  3866
		else
sl@0
  3867
			if (aColor.Green() == aColor.Red())
sl@0
  3868
				{
sl@0
  3869
				return TRgb(1, 1, 0);
sl@0
  3870
				}
sl@0
  3871
		}
sl@0
  3872
	if (aColor.Green() > aColor.Red())
sl@0
  3873
		{
sl@0
  3874
		if (aColor.Green() > aColor.Blue())
sl@0
  3875
			{
sl@0
  3876
			return TRgb(0, 1, 0);
sl@0
  3877
			}
sl@0
  3878
		else
sl@0
  3879
			if (aColor.Green() == aColor.Blue())
sl@0
  3880
				{
sl@0
  3881
				return TRgb(0, 1, 1);
sl@0
  3882
				}
sl@0
  3883
		}
sl@0
  3884
sl@0
  3885
	if (aColor.Red() > aColor.Green())
sl@0
  3886
		{
sl@0
  3887
		if (aColor.Red() > aColor.Blue())
sl@0
  3888
			{
sl@0
  3889
			return TRgb(1, 0, 0);
sl@0
  3890
			}
sl@0
  3891
		else
sl@0
  3892
			if (aColor.Red() == aColor.Blue())
sl@0
  3893
				{
sl@0
  3894
				return TRgb(1, 0, 1);
sl@0
  3895
				}
sl@0
  3896
		}
sl@0
  3897
	if (aColor.Red() > aColor.Blue())
sl@0
  3898
		{
sl@0
  3899
		if (aColor.Red() > aColor.Green())
sl@0
  3900
			{
sl@0
  3901
			return TRgb(1, 0, 0);
sl@0
  3902
			}
sl@0
  3903
		else
sl@0
  3904
			if (aColor.Red() == aColor.Green())
sl@0
  3905
				{
sl@0
  3906
				return TRgb(1, 1, 0);
sl@0
  3907
				}
sl@0
  3908
		}
sl@0
  3909
sl@0
  3910
	if (aColor.Blue() > aColor.Red())
sl@0
  3911
		{
sl@0
  3912
		if (aColor.Blue() > aColor.Green())
sl@0
  3913
			{
sl@0
  3914
			return TRgb(0, 0, 1);
sl@0
  3915
			}
sl@0
  3916
		else
sl@0
  3917
			if (aColor.Blue() == aColor.Green())
sl@0
  3918
				{
sl@0
  3919
				return TRgb(0, 1, 1);
sl@0
  3920
				}
sl@0
  3921
		}
sl@0
  3922
	if (aColor.Blue() > aColor.Green())
sl@0
  3923
		{
sl@0
  3924
		if (aColor.Blue() > aColor.Red())
sl@0
  3925
			{
sl@0
  3926
			return TRgb(0, 0, 1);
sl@0
  3927
			}
sl@0
  3928
		else
sl@0
  3929
			if (aColor.Blue() == aColor.Red())
sl@0
  3930
				{
sl@0
  3931
				return TRgb(1, 0, 1);
sl@0
  3932
				}
sl@0
  3933
		}
sl@0
  3934
sl@0
  3935
	// Should never reach here, but the compiler cannot be sure
sl@0
  3936
	return TRgb(0, 0, 0);
sl@0
  3937
	}
sl@0
  3938
sl@0
  3939
/*
sl@0
  3940
@SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0051L
sl@0
  3941
@SYMTestCaseDesc		Getting if a mode is dynamic
sl@0
  3942
@SYMREQ					REQ11554
sl@0
  3943
@SYMPREQ				PREQ2102
sl@0
  3944
@SYMTestType			CT
sl@0
  3945
@SYMTestPriority		1
sl@0
  3946
@SYMTestPurpose			Check functions work correctly
sl@0
  3947
@SYMTestActions			
sl@0
  3948
	Do IsModeDynamic for a wrong mode number
sl@0
  3949
	Do IsModeDynamic for a mode that isnt dynamic
sl@0
  3950
	Do IsModeDynamic for a mode that is dynamic
sl@0
  3951
	Do IsCurrentModeDynamic when current mode is not dynamic
sl@0
  3952
	Do IsCurrentModeDynamic when current mode is dynamic
sl@0
  3953
	MODE 10 must be dynamic
sl@0
  3954
@SYMTestExpectedResults	
sl@0
  3955
	All should return as expected.
sl@0
  3956
*/
sl@0
  3957
void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0051L()
sl@0
  3958
	{
sl@0
  3959
	RArray<TInt> screenModeList;
sl@0
  3960
	iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
sl@0
  3961
	iInfoScreenDevice->SetAppScreenMode(0);
sl@0
  3962
	iInfoScreenDevice->SetScreenMode(0);
sl@0
  3963
	iSession.Flush();
sl@0
  3964
	Pause(50);
sl@0
  3965
	ASSERT_FALSE(iInfoScreenDevice->IsModeDynamic(25));
sl@0
  3966
	ASSERT_FALSE(iInfoScreenDevice->IsModeDynamic(1));
sl@0
  3967
	ASSERT_TRUE(iInfoScreenDevice->IsModeDynamic(10));
sl@0
  3968
	ASSERT_FALSE(iInfoScreenDevice->IsCurrentModeDynamic());
sl@0
  3969
	iInfoScreenDevice->SetAppScreenMode(10);
sl@0
  3970
	iInfoScreenDevice->SetScreenMode(10);
sl@0
  3971
	iSession.Flush();
sl@0
  3972
	Pause(50);
sl@0
  3973
	ASSERT_TRUE(iInfoScreenDevice->IsCurrentModeDynamic());
sl@0
  3974
	screenModeList.Close();
sl@0
  3975
	iInfoScreenDevice->SetAppScreenMode(0);
sl@0
  3976
	iInfoScreenDevice->SetScreenMode(0);
sl@0
  3977
	}
sl@0
  3978
sl@0
  3979
/* Takes any 0x0 resolutions out of the res list, useful for some tests
sl@0
  3980
*/
sl@0
  3981
void ResListCleanup(RArray<MDisplayControl::TResolution>& aResList)
sl@0
  3982
	{
sl@0
  3983
	for (TInt ii=0; ii<aResList.Count(); ii++)
sl@0
  3984
		{
sl@0
  3985
		if (aResList[ii].iPixelSize.iWidth == 0 ||
sl@0
  3986
				aResList[ii].iPixelSize.iHeight == 0)
sl@0
  3987
			{
sl@0
  3988
			aResList.Remove(ii);
sl@0
  3989
			ii--;
sl@0
  3990
			}
sl@0
  3991
		}
sl@0
  3992
	}
sl@0
  3993
sl@0
  3994
/*
sl@0
  3995
@SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0052L
sl@0
  3996
@SYMTestCaseDesc		Getting if a mode is dynamic
sl@0
  3997
@SYMREQ					REQ11554
sl@0
  3998
@SYMPREQ				PREQ2102
sl@0
  3999
@SYMTestType			CT
sl@0
  4000
@SYMTestPriority		1
sl@0
  4001
@SYMTestPurpose			Check functions work correctly
sl@0
  4002
@SYMTestActions			
sl@0
  4003
	For every standard screen mode
sl@0
  4004
		Check twips and pixel conversions are correct based on screen mode values
sl@0
  4005
	Set dynamic app mode
sl@0
  4006
	For every resolution
sl@0
  4007
		Check twips and pixel conversions are correct based on physical screen values
sl@0
  4008
@SYMTestExpectedResults	
sl@0
  4009
	All should return as expected.
sl@0
  4010
	NOTE- there must be a dynamic screen mode available
sl@0
  4011
	NOTE- only run on a screen with multiple resolutions available
sl@0
  4012
*/
sl@0
  4013
void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0052L()
sl@0
  4014
	{
sl@0
  4015
	MDisplayControl* interface = static_cast<MDisplayControl*>
sl@0
  4016
			(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
sl@0
  4017
	ASSERT_TRUE(interface);
sl@0
  4018
	
sl@0
  4019
	TInt resolutions = interface->NumberOfResolutions();
sl@0
  4020
	ASSERT_TRUE (resolutions > 1);
sl@0
  4021
		
sl@0
  4022
	RArray<MDisplayControl::TResolution> resolutionList1;
sl@0
  4023
	TInt error = interface->GetResolutions(resolutionList1);
sl@0
  4024
	ASSERT_EQUALS(resolutionList1.Count(), resolutions);
sl@0
  4025
	ResListCleanup(resolutionList1);	//remove any 0x0
sl@0
  4026
	ASSERT_TRUE (resolutionList1.Count() > 1);	//without multiple proper res this test is pointless
sl@0
  4027
	
sl@0
  4028
	TDisplayConfiguration newResolution;
sl@0
  4029
	newResolution.SetResolution(resolutionList1[0].iPixelSize);
sl@0
  4030
	error = interface->SetConfiguration(newResolution);
sl@0
  4031
	ASSERT_EQUALS(error,KErrNone);
sl@0
  4032
	
sl@0
  4033
	TSizeMode info;
sl@0
  4034
	RArray<TInt> screenModes;
sl@0
  4035
	error = iInfoScreenDevice->GetScreenSizeModeList(&screenModes);
sl@0
  4036
	ASSERT_TRUE(error>KErrNone);
sl@0
  4037
	TInt dynamicMode1 = -1;
sl@0
  4038
	TInt dynamicMode2 = -1;
sl@0
  4039
	TPixelsTwipsAndRotation modeAttributes;
sl@0
  4040
	
sl@0
  4041
	//for every app mode, check calculations update correctly
sl@0
  4042
	for (TInt ii=0;ii<screenModes.Count();ii++)
sl@0
  4043
		{
sl@0
  4044
		TInt screenMode = screenModes[ii];
sl@0
  4045
		if (iInfoScreenDevice->IsModeDynamic(screenMode))
sl@0
  4046
			{
sl@0
  4047
			CArrayFixFlat<TInt>* rotations=new(ELeave) CArrayFixFlat<TInt>(1);
sl@0
  4048
			CleanupStack::PushL(rotations);
sl@0
  4049
			TInt error = iInfoScreenDevice->GetRotationsList(screenMode,rotations);
sl@0
  4050
			ASSERT_EQUALS(error,KErrNone);
sl@0
  4051
			ASSERT_TRUE(rotations->Count()>0);
sl@0
  4052
			for (TInt jj = 0; jj < rotations->Count(); jj++)
sl@0
  4053
			    {
sl@0
  4054
			    if ((*rotations)[jj] == (TInt)CFbsBitGc::EGraphicsOrientationNormal ||
sl@0
  4055
			            (*rotations)[jj] == (TInt)CFbsBitGc::EGraphicsOrientationRotated180)
sl@0
  4056
                    {
sl@0
  4057
                    dynamicMode1 = screenMode;
sl@0
  4058
                    }
sl@0
  4059
			    else if ((*rotations)[jj] == (TInt)CFbsBitGc::EGraphicsOrientationRotated90 ||
sl@0
  4060
			            (*rotations)[jj] == (TInt)CFbsBitGc::EGraphicsOrientationRotated270)
sl@0
  4061
                    {
sl@0
  4062
                    dynamicMode2 = screenMode;
sl@0
  4063
                    }
sl@0
  4064
			    }
sl@0
  4065
			CleanupStack::PopAndDestroy(rotations);
sl@0
  4066
			continue;	//dont want to test dynamic modes
sl@0
  4067
			}
sl@0
  4068
		
sl@0
  4069
		INFO_PRINTF2(_L("ScreenMode %d"),screenMode);
sl@0
  4070
		newResolution.ClearAll();
sl@0
  4071
		
sl@0
  4072
		iInfoScreenDevice->SetAppScreenMode(screenMode);
sl@0
  4073
		iInfoScreenDevice->SetScreenMode(screenMode);
sl@0
  4074
		iSession.Flush();
sl@0
  4075
		Pause(50);
sl@0
  4076
		
sl@0
  4077
		info = iInfoScreenDevice->GetCurrentScreenModeAttributes();
sl@0
  4078
		//These 2 asserts relate to DEF136304 - disconnect on startup causes invalid
sl@0
  4079
		//twips values.  They need to be calculated when the screen is connected
sl@0
  4080
		ASSERT_TRUE(info.iScreenTwipsSize.iWidth < 40000);
sl@0
  4081
		ASSERT_TRUE(info.iScreenTwipsSize.iHeight < 40000);
sl@0
  4082
		
sl@0
  4083
		//test that conversions correlate to values reported by config
sl@0
  4084
		TInt test = iInfoScreenDevice->HorizontalTwipsToPixels(
sl@0
  4085
				info.iScreenTwipsSize.iWidth);
sl@0
  4086
		ASSERT_EQUALS (test,info.iScreenSize.iWidth);
sl@0
  4087
		
sl@0
  4088
		test = iInfoScreenDevice->VerticalTwipsToPixels(
sl@0
  4089
				info.iScreenTwipsSize.iHeight);
sl@0
  4090
		ASSERT_EQUALS (test,info.iScreenSize.iHeight);
sl@0
  4091
		
sl@0
  4092
		test = iInfoScreenDevice->HorizontalPixelsToTwips(
sl@0
  4093
				info.iScreenSize.iWidth);
sl@0
  4094
		ASSERT_EQUALS (test,info.iScreenTwipsSize.iWidth);
sl@0
  4095
		
sl@0
  4096
		test = iInfoScreenDevice->VerticalPixelsToTwips(
sl@0
  4097
				info.iScreenSize.iHeight);
sl@0
  4098
		ASSERT_EQUALS (test,info.iScreenTwipsSize.iHeight);
sl@0
  4099
		}
sl@0
  4100
sl@0
  4101
	if (dynamicMode1 == -1 && dynamicMode2 == -1)	//expected to find at least 1 dynamic mode
sl@0
  4102
		{
sl@0
  4103
		ASSERT_TRUE(0);
sl@0
  4104
		}
sl@0
  4105
sl@0
  4106
	for (TInt jj=0;jj<2;jj++)  //for dynamic mode 1 and 2
sl@0
  4107
	    {
sl@0
  4108
	    TInt dynMode = (jj == 0) ? dynamicMode1 : dynamicMode2;
sl@0
  4109
	    if (dynMode == -1)
sl@0
  4110
	        continue;
sl@0
  4111
        //set dynamic app mode
sl@0
  4112
	    iInfoScreenDevice->SetAppScreenMode(dynMode);
sl@0
  4113
	    iInfoScreenDevice->SetScreenMode(dynMode);
sl@0
  4114
	    iSession.Flush();
sl@0
  4115
	    Pause(50);
sl@0
  4116
	    ASSERT_TRUE(iInfoScreenDevice->IsModeDynamic(dynMode));
sl@0
  4117
	    ASSERT_TRUE(iInfoScreenDevice->IsCurrentModeDynamic());
sl@0
  4118
	    ASSERT_EQUALS(dynMode,iInfoScreenDevice->CurrentScreenMode());
sl@0
  4119
        for (TInt ii=0;ii<resolutionList1.Count();ii++)
sl@0
  4120
            {
sl@0
  4121
            INFO_PRINTF2(_L("ResIndex %d"),ii);
sl@0
  4122
            newResolution.ClearAll();
sl@0
  4123
            //set config
sl@0
  4124
            newResolution.SetResolution(resolutionList1[ii].iPixelSize);
sl@0
  4125
            newResolution.SetResolutionTwips(resolutionList1[ii].iTwipsSize);
sl@0
  4126
            SetRotation(newResolution,resolutionList1[ii]);
sl@0
  4127
            TDisplayConfiguration1::TRotation tempSetRot;
sl@0
  4128
            newResolution.GetRotation(tempSetRot);
sl@0
  4129
            
sl@0
  4130
            error = interface->SetConfiguration(newResolution);
sl@0
  4131
sl@0
  4132
            if (jj == 0)
sl@0
  4133
                {
sl@0
  4134
                if (tempSetRot == TDisplayConfiguration1::ERotation90CW ||
sl@0
  4135
                        tempSetRot == TDisplayConfiguration1::ERotation270CW) //mode rotation will not work with config rotation
sl@0
  4136
                    {
sl@0
  4137
                    ASSERT_EQUALS(error,KErrArgument);
sl@0
  4138
                    continue;
sl@0
  4139
                    }
sl@0
  4140
                }
sl@0
  4141
            else    //jj == 1
sl@0
  4142
                {
sl@0
  4143
                if (tempSetRot == TDisplayConfiguration1::ERotationNormal ||
sl@0
  4144
                        tempSetRot == TDisplayConfiguration1::ERotation180) //mode rotation will not work with config rotation
sl@0
  4145
                    {
sl@0
  4146
                    ASSERT_EQUALS(error,KErrArgument);
sl@0
  4147
                    continue;
sl@0
  4148
                    }
sl@0
  4149
                }
sl@0
  4150
            ASSERT_EQUALS(error,KErrNone);
sl@0
  4151
            interface->GetConfiguration(newResolution);
sl@0
  4152
            iSession.Flush();
sl@0
  4153
            Pause(50);
sl@0
  4154
            
sl@0
  4155
            //test that conversions correlate to values reported by config
sl@0
  4156
            TInt test = iInfoScreenDevice->HorizontalTwipsToPixels(
sl@0
  4157
                    resolutionList1[ii].iTwipsSize.iWidth);
sl@0
  4158
            ASSERT_EQUALS (test,resolutionList1[ii].iPixelSize.iWidth);
sl@0
  4159
            
sl@0
  4160
            test = iInfoScreenDevice->VerticalTwipsToPixels(
sl@0
  4161
                    resolutionList1[ii].iTwipsSize.iHeight);
sl@0
  4162
            ASSERT_EQUALS (test,resolutionList1[ii].iPixelSize.iHeight);
sl@0
  4163
            
sl@0
  4164
            test = iInfoScreenDevice->HorizontalPixelsToTwips(
sl@0
  4165
                    resolutionList1[ii].iPixelSize.iWidth);
sl@0
  4166
            ASSERT_EQUALS (test,resolutionList1[ii].iTwipsSize.iWidth);
sl@0
  4167
            
sl@0
  4168
            test = iInfoScreenDevice->VerticalPixelsToTwips(
sl@0
  4169
                    resolutionList1[ii].iPixelSize.iHeight);
sl@0
  4170
            ASSERT_EQUALS (test,resolutionList1[ii].iTwipsSize.iHeight);
sl@0
  4171
            }
sl@0
  4172
	    }
sl@0
  4173
sl@0
  4174
	resolutionList1.Close();
sl@0
  4175
	screenModes.Close();
sl@0
  4176
	}
sl@0
  4177
sl@0
  4178
/*
sl@0
  4179
@SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0053L
sl@0
  4180
@SYMTestCaseDesc		SetScreenSizeAndRotation
sl@0
  4181
@SYMREQ					REQ11554
sl@0
  4182
@SYMPREQ				PREQ2102
sl@0
  4183
@SYMTestType			CT
sl@0
  4184
@SYMTestPriority		1
sl@0
  4185
@SYMTestPurpose			Check functions work correctly
sl@0
  4186
@SYMTestActions			
sl@0
  4187
	Perform calls to SetScreenSizeAndRotation with the various structure types
sl@0
  4188
	MODE 10 must be dynamic
sl@0
  4189
@SYMTestExpectedResults	
sl@0
  4190
	Cannt fail, used for debugging and coverage.
sl@0
  4191
*/
sl@0
  4192
void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0053L()
sl@0
  4193
	{
sl@0
  4194
	MDisplayControl* interface = static_cast<MDisplayControl*>
sl@0
  4195
			(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
sl@0
  4196
	ASSERT_TRUE(interface);
sl@0
  4197
	
sl@0
  4198
	TInt resolutions = interface->NumberOfResolutions();
sl@0
  4199
	ASSERT_TRUE (resolutions > 1);
sl@0
  4200
		
sl@0
  4201
	RArray<MDisplayControl::TResolution> resolutionList1;
sl@0
  4202
	TInt error = interface->GetResolutions(resolutionList1);
sl@0
  4203
	ASSERT_EQUALS(resolutionList1.Count(), resolutions);
sl@0
  4204
	
sl@0
  4205
	//set default app mode and default resolution
sl@0
  4206
	iInfoScreenDevice->SetAppScreenMode(0);
sl@0
  4207
	iInfoScreenDevice->SetScreenMode(0);
sl@0
  4208
	iSession.Flush();
sl@0
  4209
	Pause(50);
sl@0
  4210
	TDisplayConfiguration original;
sl@0
  4211
	original.SetResolution(resolutionList1[0].iPixelSize);
sl@0
  4212
	interface->SetConfiguration(original);
sl@0
  4213
	iSession.Flush();
sl@0
  4214
	Pause(50);
sl@0
  4215
	
sl@0
  4216
	TPixelsAndRotation setup0;
sl@0
  4217
	setup0.iPixelSize = TSize(30,40);
sl@0
  4218
	setup0.iRotation = CFbsBitGc::EGraphicsOrientationNormal;
sl@0
  4219
	
sl@0
  4220
	TPixelsTwipsAndRotation setup1;
sl@0
  4221
	setup1.iPixelSize = TSize(50,60);
sl@0
  4222
	setup1.iTwipsSize = TSize(70,80);
sl@0
  4223
	setup1.iRotation = CFbsBitGc::EGraphicsOrientationNormal;
sl@0
  4224
	
sl@0
  4225
	iInfoScreenDevice->SetScreenSizeAndRotation(setup0);
sl@0
  4226
	iInfoScreenDevice->SetScreenSizeAndRotation(setup1);
sl@0
  4227
	
sl@0
  4228
	//set dynamic app mode
sl@0
  4229
	iInfoScreenDevice->SetAppScreenMode(10);
sl@0
  4230
	iInfoScreenDevice->SetScreenMode(10);
sl@0
  4231
	iSession.Flush();
sl@0
  4232
	Pause(50);
sl@0
  4233
	
sl@0
  4234
	iInfoScreenDevice->SetScreenSizeAndRotation(setup0);
sl@0
  4235
	iInfoScreenDevice->SetScreenSizeAndRotation(setup1);
sl@0
  4236
sl@0
  4237
	const CWsScreenDevice* newDevice = iScreenDevice;
sl@0
  4238
	const MDisplayControl* interface2 = (MDisplayControl*)
sl@0
  4239
			newDevice->GetInterface(MDisplayControl::ETypeId);
sl@0
  4240
	TInt version = interface2->PreferredDisplayVersion();	//for coverage!
sl@0
  4241
	(void)version;
sl@0
  4242
sl@0
  4243
	//set default app mode and default resolution
sl@0
  4244
	iInfoScreenDevice->SetAppScreenMode(1);
sl@0
  4245
	iInfoScreenDevice->SetScreenMode(1);
sl@0
  4246
	iSession.Flush();
sl@0
  4247
	Pause(50);
sl@0
  4248
	interface->SetConfiguration(original);
sl@0
  4249
	iSession.Flush();
sl@0
  4250
	Pause(50);
sl@0
  4251
	
sl@0
  4252
	resolutionList1.Close();
sl@0
  4253
	}
sl@0
  4254
sl@0
  4255
/**
sl@0
  4256
@SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0101L
sl@0
  4257
@SYMTestCaseDesc		Quick demonstration of app modes sizes and positions on screen
sl@0
  4258
@SYMREQ					
sl@0
  4259
@SYMPREQ				PREQ2102
sl@0
  4260
@SYMTestType			CT (manual visual test)
sl@0
  4261
@SYMTestPurpose			To show app modes
sl@0
  4262
@SYMTestActions			
sl@0
  4263
	For every app mode
sl@0
  4264
	Draw a blue box showing the full size and position of the app mode.
sl@0
  4265
	Draw thin red lines demonstrating a window can be drawn outside of the app area to fill
sl@0
  4266
	the screen.
sl@0
  4267
	Green borders at the edge of the appmode, to show we are drawing up to the edges of the
sl@0
  4268
	appmode.
sl@0
  4269
@SYMTestExpectedResults	
sl@0
  4270
	Blue window should represent appmode (with offset and size)
sl@0
  4271
	Red windows should be visible across screen
sl@0
  4272
	Green border (made of windows) around the appmode (blue window)
sl@0
  4273
*/
sl@0
  4274
void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0101L()
sl@0
  4275
	{
sl@0
  4276
	RArray<TInt> screenModeList;
sl@0
  4277
	iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
sl@0
  4278
sl@0
  4279
	if (screenModeList.Count()>1)
sl@0
  4280
		{
sl@0
  4281
		//Got modes to change between!
sl@0
  4282
		TSize resBefore;
sl@0
  4283
		for (TInt res=0;res<screenModeList.Count();res++)
sl@0
  4284
			{
sl@0
  4285
			TDisplayConfiguration dispConfigReq;
sl@0
  4286
			iInfoScreenDevice->SetAppScreenMode(screenModeList[res]);
sl@0
  4287
			iInfoScreenDevice->SetScreenMode(screenModeList[res]);
sl@0
  4288
			iSession.Flush();
sl@0
  4289
			Pause(50);
sl@0
  4290
sl@0
  4291
			TSize appSize = iInfoScreenDevice->SizeInPixels();
sl@0
  4292
			RWindow backWindow(iSession);
sl@0
  4293
			ASSERT_EQUALS(backWindow.Construct(iGroup, 123455), KErrNone);
sl@0
  4294
			backWindow.SetRequiredDisplayMode(iDisplayMode);
sl@0
  4295
			backWindow.SetBackgroundColor(iCyan);
sl@0
  4296
			backWindow.SetExtent(TPoint(40,40),appSize-TSize(40,40));	//shows size of the apparea
sl@0
  4297
			backWindow.Activate();
sl@0
  4298
		
sl@0
  4299
			TSurfaceId surfaceID;
sl@0
  4300
			TRAPD(err, surfaceID = iUtility->CreateSurfaceL(TSize(200,200), 
sl@0
  4301
					KSurfaceFormat, 200 * KBytesPerPixel));
sl@0
  4302
			ASSERT_EQUALS(err,KErrNone);
sl@0
  4303
			TRAP(err,iUtility->FanFillSurfaceL(surfaceID,iYellow,iRed,iMagenta));
sl@0
  4304
			ASSERT_EQUALS(err,KErrNone);
sl@0
  4305
			TSurfaceConfiguration surfConf;
sl@0
  4306
			surfConf.SetSurfaceId(surfaceID);
sl@0
  4307
			
sl@0
  4308
			backWindow.SetBackgroundSurface(surfaceID);
sl@0
  4309
			
sl@0
  4310
			DrawPlainUI(backWindow,ETrue,iBlue);
sl@0
  4311
			iSession.Flush();
sl@0
  4312
			Pause(200);
sl@0
  4313
sl@0
  4314
			RWindow longWindow1(iSession);
sl@0
  4315
			ASSERT_EQUALS(longWindow1.Construct(iGroup, 123456), KErrNone);
sl@0
  4316
			longWindow1.SetRequiredDisplayMode(iDisplayMode);
sl@0
  4317
			longWindow1.SetBackgroundColor(iRed);
sl@0
  4318
			longWindow1.SetExtent(TPoint(-2000,10),TSize(5000,5));	//shows you can draw outside the apparea
sl@0
  4319
			longWindow1.Activate();
sl@0
  4320
			DrawPlainUI(longWindow1,ETrue,iRed);
sl@0
  4321
sl@0
  4322
			iBackground.SetColor(TRgb(0x001000*res|0x800000));
sl@0
  4323
			iSession.SetBackgroundColor(TRgb(0x001000*res+0x40));
sl@0
  4324
			iSession.Flush();
sl@0
  4325
			Pause(100);
sl@0
  4326
			
sl@0
  4327
			RWindow longWindow2(iSession);
sl@0
  4328
			ASSERT_EQUALS(longWindow2.Construct(iGroup, 123457), KErrNone);
sl@0
  4329
			longWindow2.SetRequiredDisplayMode(iDisplayMode);
sl@0
  4330
			longWindow2.SetBackgroundColor(iRed);
sl@0
  4331
			longWindow2.SetExtent(TPoint(20,-2000),TSize(5,5000));	//shows you can draw outside the apparea
sl@0
  4332
			longWindow2.Activate();
sl@0
  4333
			DrawPlainUI(longWindow2,ETrue,iRed);
sl@0
  4334
			
sl@0
  4335
			//borders
sl@0
  4336
			RWindow borderTop(iSession);
sl@0
  4337
			ASSERT_EQUALS(borderTop.Construct(iGroup, 123460), KErrNone);
sl@0
  4338
			borderTop.SetRequiredDisplayMode(iDisplayMode);
sl@0
  4339
			borderTop.SetBackgroundColor(iGreen);
sl@0
  4340
			borderTop.SetExtent(TPoint(0,0),TSize(appSize.iWidth,5));	//border
sl@0
  4341
			borderTop.Activate();
sl@0
  4342
			DrawPlainUI(borderTop,ETrue,iGreen);
sl@0
  4343
			
sl@0
  4344
			RWindow borderLeft(iSession);
sl@0
  4345
			ASSERT_EQUALS(borderLeft.Construct(iGroup, 123461), KErrNone);
sl@0
  4346
			borderLeft.SetRequiredDisplayMode(iDisplayMode);
sl@0
  4347
			borderLeft.SetBackgroundColor(iGreen);
sl@0
  4348
			borderLeft.SetExtent(TPoint(0,0),TSize(5,appSize.iHeight));	//border
sl@0
  4349
			borderLeft.Activate();
sl@0
  4350
			DrawPlainUI(borderLeft,ETrue,iGreen);
sl@0
  4351
						
sl@0
  4352
			RWindow borderRight(iSession);
sl@0
  4353
			ASSERT_EQUALS(borderRight.Construct(iGroup, 123462), KErrNone);
sl@0
  4354
			borderRight.SetRequiredDisplayMode(iDisplayMode);
sl@0
  4355
			borderRight.SetBackgroundColor(iGreen);
sl@0
  4356
			borderRight.SetExtent(TPoint(appSize.iWidth-5,0),TSize(5,appSize.iHeight));	//border
sl@0
  4357
			borderRight.Activate();
sl@0
  4358
			DrawPlainUI(borderRight,ETrue,iGreen);
sl@0
  4359
									
sl@0
  4360
			RWindow borderBottom(iSession);
sl@0
  4361
			ASSERT_EQUALS(borderBottom.Construct(iGroup, 123463), KErrNone);
sl@0
  4362
			borderBottom.SetRequiredDisplayMode(iDisplayMode);
sl@0
  4363
			borderBottom.SetBackgroundColor(iGreen);
sl@0
  4364
			borderBottom.SetExtent(TPoint(0,appSize.iHeight-5),TSize(appSize.iWidth,5));	//border
sl@0
  4365
			borderBottom.Activate();
sl@0
  4366
			DrawPlainUI(borderBottom,ETrue,iGreen);
sl@0
  4367
sl@0
  4368
			iSession.Flush();
sl@0
  4369
			Pause(100);
sl@0
  4370
sl@0
  4371
			backWindow.Close();
sl@0
  4372
			longWindow1.Close();
sl@0
  4373
			longWindow2.Close();
sl@0
  4374
			borderTop.Close();
sl@0
  4375
			borderLeft.Close();
sl@0
  4376
			borderRight.Close();
sl@0
  4377
			borderBottom.Close();
sl@0
  4378
			
sl@0
  4379
			iSession.Finish();
sl@0
  4380
			Pause(50);
sl@0
  4381
			}
sl@0
  4382
		}
sl@0
  4383
	else
sl@0
  4384
		{
sl@0
  4385
		INFO_PRINTF1(_L("Only 1 screen size mode configured on this screen - test skipped."));
sl@0
  4386
		}
sl@0
  4387
sl@0
  4388
	screenModeList.Close();
sl@0
  4389
	iInfoScreenDevice->SetAppScreenMode(0);
sl@0
  4390
	iInfoScreenDevice->SetScreenMode(0);
sl@0
  4391
	iSession.Finish(ETrue);
sl@0
  4392
	Pause(100);
sl@0
  4393
	INFO_PRINTF1(_L("Drawing to borderBottom completed."));
sl@0
  4394
	}
sl@0
  4395
sl@0
  4396
/**
sl@0
  4397
@SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0102L
sl@0
  4398
@SYMTestCaseDesc		Quick demonstration of square app modes in all 4 rotations
sl@0
  4399
@SYMREQ					
sl@0
  4400
@SYMPREQ				PREQ2102
sl@0
  4401
@SYMTestType			CT (manual visual test)
sl@0
  4402
@SYMTestPurpose			To show square app mode in all 4 rotations
sl@0
  4403
@SYMTestActions			
sl@0
  4404
	Draw a blue box showing the full size and position of the app mode.
sl@0
  4405
	Draw thin red lines demonstrating a window can be drawn outside of the app area to fill
sl@0
  4406
	the screen.
sl@0
  4407
	Green borders at the edge of the appmode, to show we are drawing up to the edges of the
sl@0
  4408
	appmode.
sl@0
  4409
@SYMTestExpectedResults	
sl@0
  4410
	Blue window should represent appmode (with offset and size)
sl@0
  4411
	Red windows should be visible across screen
sl@0
  4412
	Green border (made of windows) around the appmode (blue window)
sl@0
  4413
*/
sl@0
  4414
void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0102L()
sl@0
  4415
	{
sl@0
  4416
	RArray<TInt> screenModeList;
sl@0
  4417
	iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
sl@0
  4418
sl@0
  4419
sl@0
  4420
	TSize resBefore;
sl@0
  4421
	TInt res;
sl@0
  4422
	for (res=0;res<screenModeList.Count();res++)
sl@0
  4423
		{
sl@0
  4424
		iInfoScreenDevice->SetAppScreenMode(screenModeList[res]);
sl@0
  4425
		iInfoScreenDevice->SetScreenMode(screenModeList[res]);
sl@0
  4426
sl@0
  4427
		iSession.Finish(ETrue);
sl@0
  4428
		iSession.Flush();
sl@0
  4429
		Pause(50);
sl@0
  4430
		
sl@0
  4431
		TPixelsAndRotation pr;
sl@0
  4432
		iInfoScreenDevice->GetDefaultScreenSizeAndRotation(pr);
sl@0
  4433
		if(pr.iPixelSize.iHeight == pr.iPixelSize.iWidth)
sl@0
  4434
			{
sl@0
  4435
			//found square appmode
sl@0
  4436
			break;
sl@0
  4437
			}
sl@0
  4438
		}
sl@0
  4439
	
sl@0
  4440
	for(TInt rotation = CFbsBitGc::EGraphicsOrientationNormal; rotation <= CFbsBitGc::EGraphicsOrientationRotated270; rotation++)
sl@0
  4441
		{
sl@0
  4442
		iScreenDevice->SetCurrentRotations(screenModeList[res], (CFbsBitGc::TGraphicsOrientation)rotation);
sl@0
  4443
		iSession.Flush();
sl@0
  4444
		Pause(50);
sl@0
  4445
		TDisplayConfiguration dispConfigReq;
sl@0
  4446
		TSize appSize = iInfoScreenDevice->SizeInPixels();
sl@0
  4447
		RWindow backWindow(iSession);
sl@0
  4448
		ASSERT_EQUALS(backWindow.Construct(iGroup, 123455), KErrNone);
sl@0
  4449
		backWindow.SetRequiredDisplayMode(iDisplayMode);
sl@0
  4450
		backWindow.SetBackgroundColor(iBlue);
sl@0
  4451
		backWindow.SetExtent(TPoint(0,0),appSize);	//shows size of the apparea
sl@0
  4452
		backWindow.Activate();
sl@0
  4453
		DrawPlainUI(backWindow,ETrue,iBlue);
sl@0
  4454
		iSession.Flush();
sl@0
  4455
		Pause(200);
sl@0
  4456
sl@0
  4457
		RWindow longWindow1(iSession);
sl@0
  4458
		ASSERT_EQUALS(longWindow1.Construct(iGroup, 123456), KErrNone);
sl@0
  4459
		longWindow1.SetRequiredDisplayMode(iDisplayMode);
sl@0
  4460
		longWindow1.SetBackgroundColor(iRed);
sl@0
  4461
		longWindow1.SetExtent(TPoint(-2000,10),TSize(5000,5));	//shows you can draw outside the apparea
sl@0
  4462
		longWindow1.Activate();
sl@0
  4463
		DrawPlainUI(longWindow1,ETrue,iRed);
sl@0
  4464
sl@0
  4465
		iBackground.SetColor(TRgb(0x001000*res|0x800000));
sl@0
  4466
		iSession.SetBackgroundColor(TRgb(0x001000*res+0x40));
sl@0
  4467
		iSession.Flush();
sl@0
  4468
		Pause(100);
sl@0
  4469
		
sl@0
  4470
		RWindow longWindow2(iSession);
sl@0
  4471
		ASSERT_EQUALS(longWindow2.Construct(iGroup, 123457), KErrNone);
sl@0
  4472
		longWindow2.SetRequiredDisplayMode(iDisplayMode);
sl@0
  4473
		longWindow2.SetBackgroundColor(iRed);
sl@0
  4474
		longWindow2.SetExtent(TPoint(20,-2000),TSize(5,5000));	//shows you can draw outside the apparea
sl@0
  4475
		longWindow2.Activate();
sl@0
  4476
		DrawPlainUI(longWindow2,ETrue,iRed);
sl@0
  4477
		
sl@0
  4478
		//borders
sl@0
  4479
		RWindow borderTop(iSession);
sl@0
  4480
		ASSERT_EQUALS(borderTop.Construct(iGroup, 123460), KErrNone);
sl@0
  4481
		borderTop.SetRequiredDisplayMode(iDisplayMode);
sl@0
  4482
		borderTop.SetBackgroundColor(iGreen);
sl@0
  4483
		borderTop.SetExtent(TPoint(0,0),TSize(appSize.iWidth,5));	//border
sl@0
  4484
		borderTop.Activate();
sl@0
  4485
		DrawPlainUI(borderTop,ETrue,iGreen);
sl@0
  4486
		
sl@0
  4487
		RWindow borderLeft(iSession);
sl@0
  4488
		ASSERT_EQUALS(borderLeft.Construct(iGroup, 123461), KErrNone);
sl@0
  4489
		borderLeft.SetRequiredDisplayMode(iDisplayMode);
sl@0
  4490
		borderLeft.SetBackgroundColor(iGreen);
sl@0
  4491
		borderLeft.SetExtent(TPoint(0,0),TSize(5,appSize.iHeight));	//border
sl@0
  4492
		borderLeft.Activate();
sl@0
  4493
		DrawPlainUI(borderLeft,ETrue,iGreen);
sl@0
  4494
					
sl@0
  4495
		RWindow borderRight(iSession);
sl@0
  4496
		ASSERT_EQUALS(borderRight.Construct(iGroup, 123462), KErrNone);
sl@0
  4497
		borderRight.SetRequiredDisplayMode(iDisplayMode);
sl@0
  4498
		borderRight.SetBackgroundColor(iGreen);
sl@0
  4499
		borderRight.SetExtent(TPoint(appSize.iWidth-5,0),TSize(5,appSize.iHeight));	//border
sl@0
  4500
		borderRight.Activate();
sl@0
  4501
		DrawPlainUI(borderRight,ETrue,iGreen);
sl@0
  4502
								
sl@0
  4503
		RWindow borderBottom(iSession);
sl@0
  4504
		ASSERT_EQUALS(borderBottom.Construct(iGroup, 123463), KErrNone);
sl@0
  4505
		borderBottom.SetRequiredDisplayMode(iDisplayMode);
sl@0
  4506
		borderBottom.SetBackgroundColor(iGreen);
sl@0
  4507
		borderBottom.SetExtent(TPoint(0,appSize.iHeight-5),TSize(appSize.iWidth,5));	//border
sl@0
  4508
		borderBottom.Activate();
sl@0
  4509
		DrawPlainUI(borderBottom,ETrue,iGreen);
sl@0
  4510
sl@0
  4511
		iSession.Flush();
sl@0
  4512
		Pause(100);
sl@0
  4513
sl@0
  4514
		backWindow.Close();
sl@0
  4515
		longWindow1.Close();
sl@0
  4516
		longWindow2.Close();
sl@0
  4517
		borderTop.Close();
sl@0
  4518
		borderLeft.Close();
sl@0
  4519
		borderRight.Close();
sl@0
  4520
		borderBottom.Close();
sl@0
  4521
		
sl@0
  4522
		iSession.Finish();
sl@0
  4523
		Pause(50);
sl@0
  4524
		
sl@0
  4525
		}
sl@0
  4526
sl@0
  4527
sl@0
  4528
	screenModeList.Close();
sl@0
  4529
	iInfoScreenDevice->SetAppScreenMode(0);
sl@0
  4530
	iInfoScreenDevice->SetScreenMode(0);
sl@0
  4531
	iSession.Finish(ETrue);
sl@0
  4532
	Pause(100);
sl@0
  4533
	}