os/graphics/windowing/windowserver/test/tauto/TMULSCREENS.CPP
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// Enable Multiple Displays
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
/**
sl@0
    19
 @file
sl@0
    20
 @test
sl@0
    21
 @internalComponent - Internal Symbian test code
sl@0
    22
*/
sl@0
    23
sl@0
    24
#include "TMULSCREENS.h"
sl@0
    25
sl@0
    26
const TInt KFstScreenNo = 0;
sl@0
    27
const TInt KSndScreenNo = 1;
sl@0
    28
sl@0
    29
CTMulScreens::CTMulScreens(CTestStep* aStep):
sl@0
    30
	CTWsGraphicsBase(aStep)
sl@0
    31
	{
sl@0
    32
	}
sl@0
    33
sl@0
    34
void CTMulScreens::ConstructL()
sl@0
    35
	{
sl@0
    36
	User::LeaveIfError(iRws.Connect());
sl@0
    37
	iFstScreenDevice =new(ELeave) CWsScreenDevice(iRws);
sl@0
    38
	TInt err = iFstScreenDevice->Construct(KFstScreenNo);
sl@0
    39
	iTest->LogLeave(err);
sl@0
    40
	User::LeaveIfError(err);
sl@0
    41
	iNumScreens = iRws.NumberOfScreens();
sl@0
    42
	if(KSndScreenNo<iNumScreens)
sl@0
    43
		{
sl@0
    44
		iSndScreenDevice =new(ELeave) CWsScreenDevice(iRws);
sl@0
    45
		err = iSndScreenDevice->Construct(KSndScreenNo);
sl@0
    46
		iTest->LogLeave(err);
sl@0
    47
		User::LeaveIfError(err);
sl@0
    48
		}
sl@0
    49
	INFO_PRINTF2(_L("The number of screens supported on this device is %d"),iNumScreens);
sl@0
    50
	}
sl@0
    51
sl@0
    52
CTMulScreens::~CTMulScreens()
sl@0
    53
	{
sl@0
    54
	iFstWinGp.Close();
sl@0
    55
	if(KSndScreenNo<iNumScreens)
sl@0
    56
		{
sl@0
    57
		iSndWinGp.Close();
sl@0
    58
		delete iSndScreenDevice;
sl@0
    59
		}
sl@0
    60
	delete iFstScreenDevice;
sl@0
    61
	iRws.Close();
sl@0
    62
	}
sl@0
    63
sl@0
    64
/**
sl@0
    65
   @SYMTestCaseID          GRAPHICS-WSERV-0383
sl@0
    66
sl@0
    67
   @SYMPREQ					PREQ1227
sl@0
    68
sl@0
    69
   @SYMREQ					REQ5541
sl@0
    70
sl@0
    71
   @SYMTestCaseDesc			Create Window Group(s) on each screen.
sl@0
    72
sl@0
    73
   @SYMTestPriority			High
sl@0
    74
sl@0
    75
   @SYMTestStatus			Implemented
sl@0
    76
sl@0
    77
   @SYMTestActions			Call RWsSession::NumWindowGroups() to get the number of window groups of a given window group priority running on a specified screen.
sl@0
    78
   							Test the number of Window Groups on each screen.
sl@0
    79
   							Test the size of the list of window group on each screen.
sl@0
    80
   							Test the Window Group which has the keyboard focus on the second screen.
sl@0
    81
							API Calls:\n
sl@0
    82
							TInt RWsSession::NumWindowGroups(TInt aScreenNumber,TInt aPriority) const
sl@0
    83
							TInt RWsSession::WindowGroupList(CArrayFixFlat<TInt>* aWindowList,TInt aScreenNumber,TInt aPriority)
sl@0
    84
							TInt RWindowGroup::Construct(TUint32 aClientHandle,CWsScreenDevice* aScreenDevice)
sl@0
    85
							TInt RWsSession::GetFocusWindowGroup(TInt aScreenNumber)
sl@0
    86
sl@0
    87
   @SYMTestExpectedResults	Provided that a second screen is configured in the epoc.ini and the wsini.ini, this test case will create one window group on the first screen
sl@0
    88
   							and two window groups on the second screen.
sl@0
    89
							If only one screen is configured, then it will create one group on the primary screen.
sl@0
    90
							Otherwise this function leaves with a system-wide error.
sl@0
    91
*/
sl@0
    92
sl@0
    93
void CTMulScreens::TestCreateGroupWindowsL()
sl@0
    94
	{
sl@0
    95
	const TInt fstNumWinGps = iRws.NumWindowGroups(KFstScreenNo,EAllPriorities);
sl@0
    96
	CArrayFixFlat<TInt>* fstList = new(ELeave) CArrayFixFlat<TInt>(1);
sl@0
    97
	CleanupStack::PushL(fstList);
sl@0
    98
	TInt err = iRws.WindowGroupList(fstList,KFstScreenNo,EAllPriorities);
sl@0
    99
	TEST(err==KErrNone);
sl@0
   100
	TEST(fstList->Count()==fstNumWinGps);
sl@0
   101
	err = iRws.WindowGroupList(fstList); //test existing api
sl@0
   102
	TEST(err==KErrNone);
sl@0
   103
	TEST(fstList->Count()==(iRws.NumWindowGroups())); 
sl@0
   104
	iFstWinGp = RWindowGroup(iRws);
sl@0
   105
	TRAP(err,iFstWinGp.Construct(ENullWsHandle,iFstScreenDevice));
sl@0
   106
	TEST(err==KErrNone);
sl@0
   107
	if(err==KErrNone)
sl@0
   108
		{
sl@0
   109
		TEST(iRws.NumWindowGroups(KFstScreenNo,EAllPriorities) == (fstNumWinGps+1));
sl@0
   110
		}
sl@0
   111
	CleanupStack::PopAndDestroy(fstList);
sl@0
   112
sl@0
   113
	//Second screen has been configured.
sl@0
   114
	if(KSndScreenNo<iNumScreens)
sl@0
   115
		{
sl@0
   116
		TInt winId = iRws.GetFocusWindowGroup(KSndScreenNo);
sl@0
   117
		TEST(winId==KErrGeneral);
sl@0
   118
		iSndWinGp = RWindowGroup(iRws);
sl@0
   119
		TRAP(err,iSndWinGp.Construct(ENullWsHandle,ETrue,iSndScreenDevice));
sl@0
   120
		TEST(err==KErrNone);
sl@0
   121
		if(err==KErrNone)
sl@0
   122
			{
sl@0
   123
			winId = iRws.GetFocusWindowGroup(KSndScreenNo);
sl@0
   124
			TEST(winId==iSndWinGp.Identifier());
sl@0
   125
			TEST(iRws.NumWindowGroups(KFstScreenNo,EAllPriorities) == (fstNumWinGps+1)); //test that the no. of screens unchanged on first screen
sl@0
   126
			CArrayFixFlat<TInt>* sndList =new(ELeave) CArrayFixFlat<TInt>(1);
sl@0
   127
			CleanupStack::PushL(sndList);
sl@0
   128
			TInt sndNumWinGps = iRws.NumWindowGroups(KSndScreenNo,iSndWinGp.OrdinalPriority());
sl@0
   129
			err = iRws.WindowGroupList(sndList,KSndScreenNo,iSndWinGp.OrdinalPriority());
sl@0
   130
			TEST(err==KErrNone);
sl@0
   131
			TEST(sndList->Count()==sndNumWinGps);
sl@0
   132
sl@0
   133
			iSndWinGp.SetOrdinalPosition(iSndWinGp.OrdinalPosition(),EAllPriorities);
sl@0
   134
			TInt allPriNumWinGps= iRws.NumWindowGroups(EAllPriorities);
sl@0
   135
			CArrayFixFlat<TInt>* allPriList =new(ELeave) CArrayFixFlat<TInt>(1);
sl@0
   136
			CleanupStack::PushL(allPriList);
sl@0
   137
			err = iRws.WindowGroupList(EAllPriorities,allPriList);
sl@0
   138
			TEST(err==KErrNone);
sl@0
   139
			TEST(allPriList->Count()==allPriNumWinGps);
sl@0
   140
sl@0
   141
			CleanupStack::PopAndDestroy(2,sndList);
sl@0
   142
			}
sl@0
   143
		RWindowGroup trdWinGp = RWindowGroup(iRws);
sl@0
   144
		TRAP(err,trdWinGp.Construct(ENullWsHandle,ETrue,iSndScreenDevice));
sl@0
   145
		TEST(err==KErrNone);
sl@0
   146
		if(err==KErrNone)
sl@0
   147
			{
sl@0
   148
			winId = iRws.GetFocusWindowGroup(KSndScreenNo);
sl@0
   149
			TEST(winId==trdWinGp.Identifier());
sl@0
   150
			trdWinGp.Close();
sl@0
   151
			}
sl@0
   152
		}
sl@0
   153
	}
sl@0
   154
sl@0
   155
/**
sl@0
   156
   @SYMTestCaseID          GRAPHICS-WSERV-0384
sl@0
   157
sl@0
   158
   @SYMPREQ					PREQ1227
sl@0
   159
sl@0
   160
   @SYMREQ					REQ5541
sl@0
   161
sl@0
   162
   @SYMTestCaseDependencies	SYMTestCaseID GRAPHICS-WSERV-0383
sl@0
   163
sl@0
   164
   @SYMTestCaseDesc			Create a blank window on each screen.
sl@0
   165
sl@0
   166
   @SYMTestPriority			High
sl@0
   167
sl@0
   168
   @SYMTestStatus			Implemented
sl@0
   169
sl@0
   170
   @SYMTestActions			Test that each blank window is created on a different screen.
sl@0
   171
							API Calls:\n
sl@0
   172
							TInt RBlankWindow::Construct(const RWindowTreeNode &parent, TUint32 aClientHandle) where parent is
sl@0
   173
							a Window Group created on each screen.
sl@0
   174
sl@0
   175
   @SYMTestExpectedResults	The background colour of the first screen changes to blue and that of the second one changes to green.
sl@0
   176
   							Otherwise this function leaves with a system-wide error.
sl@0
   177
*/
sl@0
   178
void CTMulScreens::TestCreateBlankWindowsL()
sl@0
   179
	{
sl@0
   180
	RBlankWindow fstBlankWin(iRws);
sl@0
   181
	CleanupClosePushL(fstBlankWin);
sl@0
   182
	TRAPD(err,fstBlankWin.Construct(iFstWinGp,ENullWsHandle));
sl@0
   183
	TEST(err==KErrNone);
sl@0
   184
	if(err==KErrNone)
sl@0
   185
		{
sl@0
   186
		fstBlankWin.SetRequiredDisplayMode(EColor256);
sl@0
   187
		fstBlankWin.SetColor(TRgb(0,0,255)); // paint the screen blue
sl@0
   188
		fstBlankWin.Activate();
sl@0
   189
		iRws.Flush();
sl@0
   190
		TheClient->WaitForRedrawsToFinish();
sl@0
   191
		User::After(6000000);
sl@0
   192
		}
sl@0
   193
	CleanupStack::PopAndDestroy();//fstBlankWin	
sl@0
   194
	
sl@0
   195
	// Second screen
sl@0
   196
	if(KSndScreenNo<iNumScreens)
sl@0
   197
		{
sl@0
   198
		RBlankWindow sndBlankWin(iRws);
sl@0
   199
		CleanupClosePushL(sndBlankWin);
sl@0
   200
		TRAP(err,sndBlankWin.Construct(iSndWinGp,ENullWsHandle));
sl@0
   201
		TEST(err==KErrNone);
sl@0
   202
		if(err==KErrNone)
sl@0
   203
			{
sl@0
   204
			sndBlankWin.SetRequiredDisplayMode(EColor256);
sl@0
   205
			sndBlankWin.SetColor(TRgb(0,255,0));	//paint the screen green
sl@0
   206
			sndBlankWin.Activate(); //there is a defect in Activate() because there is a delay before the second screen turns green
sl@0
   207
			iRws.Flush();
sl@0
   208
			TheClient->WaitForRedrawsToFinish();
sl@0
   209
			User::After(6000000);
sl@0
   210
			}
sl@0
   211
		CleanupStack::PopAndDestroy(); //sndBlankWin
sl@0
   212
		}
sl@0
   213
	}
sl@0
   214
sl@0
   215
sl@0
   216
/**
sl@0
   217
   @SYMTestCaseID          GRAPHICS-WSERV-0385
sl@0
   218
sl@0
   219
   @SYMPREQ					PREQ1227
sl@0
   220
sl@0
   221
   @SYMREQ					REQ5541
sl@0
   222
sl@0
   223
   @SYMTestCaseDependencies	SYMTestCaseID GRAPHICS-WSERV-0383
sl@0
   224
sl@0
   225
   @SYMTestCaseDesc			Test the Window Group that has the keyboard focus for each screen.
sl@0
   226
sl@0
   227
   @SYMTestPriority			High
sl@0
   228
sl@0
   229
   @SYMTestStatus			Implemented
sl@0
   230
sl@0
   231
   @SYMTestActions			Call RWsSession::GetFocusWindowGroup on each screen.
sl@0
   232
							API Calls:\n
sl@0
   233
							TInt RWsSession::GetFocusWindowGroup(TInt aScreenNumber)
sl@0
   234
sl@0
   235
   @SYMTestExpectedResults	The identifier returned by the API for each screen is tested to see if it is the expected Window Group ID; ie the
sl@0
   236
   							ID of the window group created in the first test case.
sl@0
   237
*/
sl@0
   238
void CTMulScreens::TestGetFocusWindow()
sl@0
   239
	{
sl@0
   240
	TInt winId = iRws.GetFocusWindowGroup(KFstScreenNo);
sl@0
   241
	TEST(winId==iFstWinGp.Identifier());
sl@0
   242
	if(KSndScreenNo<iNumScreens)
sl@0
   243
		{
sl@0
   244
		winId = iRws.GetFocusWindowGroup(KSndScreenNo);
sl@0
   245
		TEST(winId==iSndWinGp.Identifier());
sl@0
   246
		TEST(iRws.GetFocusWindowGroup()==iFstWinGp.Identifier());
sl@0
   247
		}
sl@0
   248
	}
sl@0
   249
sl@0
   250
/**
sl@0
   251
   @SYMTestCaseID          GRAPHICS-WSERV-0386
sl@0
   252
sl@0
   253
   @SYMPREQ					PREQ1227
sl@0
   254
sl@0
   255
   @SYMREQ					REQ5541
sl@0
   256
sl@0
   257
   @SYMTestCaseDependencies	SYMTestCaseID GRAPHICS-WSERV-0383
sl@0
   258
sl@0
   259
   @SYMTestCaseDesc			Test the default owning window on each screen.
sl@0
   260
sl@0
   261
   @SYMTestPriority			High
sl@0
   262
sl@0
   263
   @SYMTestStatus			Implemented
sl@0
   264
sl@0
   265
   @SYMTestActions			Call RWsSession::GetDefaultOwningWindow() to return the ID of the default owning window.
sl@0
   266
   							Call RWsSession::DefaultOwningWindow() on the second Window Group to set it as the default owning window on the second screen.
sl@0
   267
   							Call new API RWsSession::GetDefaultOwningWindow(TInt aScreenNumber) to get the default owning window on the second screen.
sl@0
   268
   							API Calls:\n
sl@0
   269
							TInt RWsSession::GetFocusWindowGroup()
sl@0
   270
							TInt RWsSession::GetFocusWindowGroup(TInt aScreenNumber)
sl@0
   271
sl@0
   272
   @SYMTestExpectedResults	The identifier returned by the API for each screen is tested to see that they are not the same.
sl@0
   273
*/
sl@0
   274
void CTMulScreens::TestGetDefaultOwningWindow()
sl@0
   275
	{
sl@0
   276
	if(KSndScreenNo<iNumScreens)
sl@0
   277
		{
sl@0
   278
		TInt prevWinId = iRws.GetDefaultOwningWindow();
sl@0
   279
		iSndWinGp.DefaultOwningWindow();
sl@0
   280
		TInt winId = iRws.GetDefaultOwningWindow(KSndScreenNo);
sl@0
   281
		TEST(winId==iSndWinGp.Identifier());
sl@0
   282
		TEST(prevWinId!=winId);
sl@0
   283
		}
sl@0
   284
	}
sl@0
   285
sl@0
   286
/**
sl@0
   287
   @SYMTestCaseID          GRAPHICS-WSERV-0387
sl@0
   288
sl@0
   289
   @SYMPREQ					PREQ1227
sl@0
   290
sl@0
   291
   @SYMREQ					REQ5541
sl@0
   292
sl@0
   293
   @SYMTestCaseDesc			Test the background colour.
sl@0
   294
sl@0
   295
   @SYMTestPriority			High
sl@0
   296
sl@0
   297
   @SYMTestStatus			Implemented
sl@0
   298
sl@0
   299
   @SYMTestActions			Call RWsSession::GetBackgroundColor() to store the default value;Change the background colour by calling RWsSession::SetBackgroundColor();
sl@0
   300
   							Test that the background has changed; Restore the background colour.
sl@0
   301
   							API Calls:\n
sl@0
   302
   							TRgb RWsSession::GetBackgroundColor() const
sl@0
   303
							void RWsSession::SetBackgroundColor(TRgb colour)
sl@0
   304
sl@0
   305
   @SYMTestExpectedResults	 Background color should change when SetBackgroundColor is called.
sl@0
   306
*/
sl@0
   307
void CTMulScreens::TestSetBackgroundColour()
sl@0
   308
	{
sl@0
   309
	TRgb rgb_b4 = iRws.GetBackgroundColor();
sl@0
   310
	iRws.SetBackgroundColor(KRgbBlack);
sl@0
   311
	TEST(iRws.GetBackgroundColor()==KRgbBlack);
sl@0
   312
	iRws.SetBackgroundColor(rgb_b4);
sl@0
   313
	TEST(iRws.GetBackgroundColor()==rgb_b4);
sl@0
   314
	}
sl@0
   315
sl@0
   316
/**
sl@0
   317
   @SYMTestCaseID          GRAPHICS-WSERV-0388
sl@0
   318
sl@0
   319
   @SYMPREQ					PREQ1227
sl@0
   320
sl@0
   321
   @SYMREQ					REQ5541
sl@0
   322
sl@0
   323
   @SYMTestCaseDesc			Test the shadow vector.
sl@0
   324
sl@0
   325
   @SYMTestPriority			High
sl@0
   326
sl@0
   327
   @SYMTestStatus			Implemented
sl@0
   328
sl@0
   329
   @SYMTestActions			Call RWsSession::ShadowVector() to store the default value;Call RWsSession::SetShadowVector() to change the shadow vector;
sl@0
   330
   							Test that the shadow vector has changed; Restore the shadow vector.
sl@0
   331
   							API Calls:\n
sl@0
   332
   							TPoint RWsSession::ShadowVector() const
sl@0
   333
							void RWsSession::SetShadowVector(const TPoint &aVector);
sl@0
   334
sl@0
   335
   @SYMTestExpectedResults	 The shadow vector should change when SetShadowVector is called.
sl@0
   336
*/
sl@0
   337
void CTMulScreens::TestSetShadowVector()
sl@0
   338
	{
sl@0
   339
	TPoint point_b4 = iRws.ShadowVector();
sl@0
   340
	
sl@0
   341
	iRws.SetShadowVector(TPoint(3,3));
sl@0
   342
	
sl@0
   343
	#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
sl@0
   344
	TEST(iRws.ShadowVector()==TPoint(0,0)); // in NGA SetShadowVector & ShadowVector are deprecated
sl@0
   345
	#else
sl@0
   346
	TEST(iRws.ShadowVector()==TPoint(3,3));
sl@0
   347
	#endif
sl@0
   348
	
sl@0
   349
	iRws.SetShadowVector(point_b4);
sl@0
   350
	
sl@0
   351
	#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
sl@0
   352
	TEST(iRws.ShadowVector()==TPoint(0,0)); // in NGA SetShadowVector & ShadowVector are deprecated
sl@0
   353
	#else
sl@0
   354
	TEST(iRws.ShadowVector()==point_b4);
sl@0
   355
	#endif
sl@0
   356
	}
sl@0
   357
sl@0
   358
/**
sl@0
   359
   @SYMTestCaseID          GRAPHICS-WSERV-0389
sl@0
   360
sl@0
   361
   @SYMPREQ					PREQ1227
sl@0
   362
sl@0
   363
   @SYMREQ					REQ5541
sl@0
   364
sl@0
   365
   @SYMTestCaseDesc			Negative tests for the APIs listed below.
sl@0
   366
sl@0
   367
   @SYMTestPriority			High
sl@0
   368
sl@0
   369
   @SYMTestStatus			Implemented
sl@0
   370
sl@0
   371
   @SYMTestActions			Launch a thread to call TestInvalidScreenNumber. Pass an invalid screen number to the APIs listed below.
sl@0
   372
   							API Calls:\n
sl@0
   373
   							TInt RWsSession::NumWindowGroups(TInt aScreenNumber,TInt aPriority) const
sl@0
   374
							TInt RWsSession::WindowGroupList(CArrayFixFlat<TInt>* aWindowList,TInt aScreenNumber,TInt aPriority)
sl@0
   375
							TInt RWsSession::GetFocusWindowGroup(TInt aScreenNumber)
sl@0
   376
							TInt GetDefaultOwningWindow(TInt aScreenNumber)
sl@0
   377
							TDisplayMode GetDefModeMaxNumColors(TInt aScreenNumber,TInt& aColor,TInt& aGray) const
sl@0
   378
   							TInt GetColorModeList(TInt aScreenNumber,CArrayFixFlat<TInt>* aModeList) const
sl@0
   379
sl@0
   380
   @SYMTestExpectedResults	 The thread panics and exits with reason EWservPanicScreenNumber.
sl@0
   381
*/
sl@0
   382
void CTMulScreens::TestPanicsL()
sl@0
   383
	{
sl@0
   384
	TInt firstTest = 1;
sl@0
   385
	TInt lastTest = 6;
sl@0
   386
	const TInt KInvalidScreenNumber = 2;
sl@0
   387
	for (TInt option=firstTest;option<=lastTest;option++)
sl@0
   388
		{
sl@0
   389
		TEST(iTest->TestWsPanicL(&TestInvalidScreenNumberL,EWservPanicScreenNumber,option,(TAny*)KInvalidScreenNumber));
sl@0
   390
		}
sl@0
   391
	}
sl@0
   392
sl@0
   393
TInt CTMulScreens::TestInvalidScreenNumberL(TInt aOption, TAny *aScreenNumber)
sl@0
   394
	{
sl@0
   395
	RWsSession wsSession;
sl@0
   396
	wsSession.Connect();
sl@0
   397
	switch((TInt)aOption)
sl@0
   398
		{
sl@0
   399
		case 1:
sl@0
   400
			wsSession.NumWindowGroups((TInt)aScreenNumber,EAllPriorities);
sl@0
   401
			break;
sl@0
   402
		case 2:
sl@0
   403
			{
sl@0
   404
			CArrayFixFlat<TInt>* list = new(ELeave) CArrayFixFlat<TInt>(1);
sl@0
   405
			wsSession.WindowGroupList(list,(TInt)aScreenNumber,EAllPriorities);
sl@0
   406
			}
sl@0
   407
			break;
sl@0
   408
		case 3:
sl@0
   409
			wsSession.GetFocusWindowGroup((TInt)aScreenNumber);
sl@0
   410
			break;
sl@0
   411
		case 4:
sl@0
   412
			wsSession.GetDefaultOwningWindow((TInt)aScreenNumber);
sl@0
   413
			break;
sl@0
   414
		case 5:
sl@0
   415
			{
sl@0
   416
			CArrayFixFlat<TInt>* list = new(ELeave) CArrayFixFlat<TInt>(1);
sl@0
   417
			wsSession.GetColorModeList((TInt)aScreenNumber,list);
sl@0
   418
			}
sl@0
   419
			break;
sl@0
   420
		case 6:
sl@0
   421
			{
sl@0
   422
			TInt color,gray;
sl@0
   423
			wsSession.GetDefModeMaxNumColors((TInt)aScreenNumber,color,gray);
sl@0
   424
			}
sl@0
   425
			break;
sl@0
   426
		default:
sl@0
   427
			User::Panic(_L("Default panic"),KErrGeneral);
sl@0
   428
			break;
sl@0
   429
		}
sl@0
   430
	return KErrNone;
sl@0
   431
	}
sl@0
   432
sl@0
   433
sl@0
   434
/**
sl@0
   435
   @SYMTestCaseID          GRAPHICS-WSERV-0390
sl@0
   436
sl@0
   437
   @SYMPREQ					PREQ1227
sl@0
   438
sl@0
   439
   @SYMREQ					REQ5541
sl@0
   440
sl@0
   441
   @SYMTestCaseDependencies	SYMTestCaseID GRAPHICS-WSERV-0383
sl@0
   442
sl@0
   443
   @SYMTestCaseDesc			Test that CWindowGc updates its screendevice each time it is activated on a window.
sl@0
   444
sl@0
   445
   @SYMTestPriority			High
sl@0
   446
sl@0
   447
   @SYMTestStatus			Implemented
sl@0
   448
sl@0
   449
   @SYMTestActions			Activate the gc on both RWindows.CWindowGc::Device() is called after each activation has taken place.
sl@0
   450
   							API Calls:\n
sl@0
   451
   							void CWindowGc::Activate(RDrawableWindow &aDevice);
sl@0
   452
   							void CWindowGc::Deactivate();
sl@0
   453
   							CGraphicsDevice* CWindowGc::Device() const
sl@0
   454
   							TInt RWindow::Construct(const RWindowTreeNode &parent,TUint32 aHandle);
sl@0
   455
sl@0
   456
   @SYMTestExpectedResults	CWindowGc::Device() returns the screendevice on which the gc was last activated.
sl@0
   457
*/
sl@0
   458
void CTMulScreens::TestDeviceL()
sl@0
   459
	{
sl@0
   460
	RWindow fstWin(iRws);
sl@0
   461
	User::LeaveIfError(fstWin.Construct(iFstWinGp,ENullWsHandle));
sl@0
   462
	CleanupClosePushL(fstWin);
sl@0
   463
	fstWin.Activate();
sl@0
   464
sl@0
   465
	CWindowGc* gc=new (ELeave) CWindowGc(iFstScreenDevice);
sl@0
   466
	User::LeaveIfError(gc->Construct());
sl@0
   467
	CleanupStack::PushL(gc);
sl@0
   468
	gc->Activate(fstWin);
sl@0
   469
sl@0
   470
	TEST((CWsScreenDevice*)gc->Device()==iFstScreenDevice);
sl@0
   471
	gc->Deactivate();
sl@0
   472
sl@0
   473
	if(KSndScreenNo<iNumScreens)
sl@0
   474
		{
sl@0
   475
		RWindow sndWin(iRws);
sl@0
   476
		User::LeaveIfError(sndWin.Construct(iSndWinGp,ENullWsHandle));
sl@0
   477
		CleanupClosePushL(sndWin);
sl@0
   478
		sndWin.Activate();
sl@0
   479
sl@0
   480
		gc->Activate(sndWin);
sl@0
   481
		TEST((CWsScreenDevice*)gc->Device()==iSndScreenDevice);
sl@0
   482
		gc->Deactivate();
sl@0
   483
		CleanupStack::PopAndDestroy();
sl@0
   484
		}
sl@0
   485
sl@0
   486
	CleanupStack::PopAndDestroy(2,&fstWin);
sl@0
   487
	}
sl@0
   488
sl@0
   489
/**
sl@0
   490
   @SYMTestCaseID          GRAPHICS-WSERV-0034
sl@0
   491
sl@0
   492
   @SYMPREQ					PREQ1227
sl@0
   493
sl@0
   494
   @SYMREQ					REQ5541
sl@0
   495
sl@0
   496
   @SYMTestCaseDesc			Test that the order of creating a screen device and window group does not matter.
sl@0
   497
sl@0
   498
   @SYMTestPriority			High
sl@0
   499
sl@0
   500
   @SYMTestStatus			Implemented
sl@0
   501
sl@0
   502
   @SYMTestActions			Create a window group before creating the screen device. Create a graphics context and call activate on it.
sl@0
   503
   							API Calls:\n
sl@0
   504
   							TInt RWindowGroup::Construct(TUint32 aClientHandle)
sl@0
   505
   							TInt CWsScreenDevice::Construct()
sl@0
   506
    						void CWindowGc::Activate(RDrawableWindow &aDevice);
sl@0
   507
   							void CWindowGc::Deactivate();
sl@0
   508
   							TInt RWindow::Construct(const RWindowTreeNode &parent,TUint32 aHandle);
sl@0
   509
sl@0
   510
   @SYMTestExpectedResults	 The test code does not panic with EWservPanicGroupWinScreenDeviceDeleted
sl@0
   511
*/
sl@0
   512
void CTMulScreens::TestInitaliseScreenDeviceL()
sl@0
   513
	{
sl@0
   514
	RWsSession rws1;
sl@0
   515
	User::LeaveIfError(rws1.Connect());
sl@0
   516
	CleanupClosePushL(rws1);
sl@0
   517
sl@0
   518
	RWindowGroup gw1(rws1);
sl@0
   519
	User::LeaveIfError(gw1.Construct(ENullWsHandle));
sl@0
   520
	CleanupClosePushL(gw1);
sl@0
   521
sl@0
   522
	CWsScreenDevice* screen1 = new (ELeave) CWsScreenDevice(rws1);
sl@0
   523
	User::LeaveIfError(screen1->Construct());
sl@0
   524
	CleanupStack::PushL(screen1);
sl@0
   525
sl@0
   526
	RWindow win1(rws1);
sl@0
   527
	User::LeaveIfError(win1.Construct(gw1,ETrue));
sl@0
   528
	CleanupClosePushL(win1);
sl@0
   529
	win1.Activate();
sl@0
   530
sl@0
   531
	CWindowGc* gc=new (ELeave) CWindowGc(screen1);
sl@0
   532
	User::LeaveIfError(gc->Construct());
sl@0
   533
	CleanupStack::PushL(gc);
sl@0
   534
	gc->Activate(win1);
sl@0
   535
sl@0
   536
	CleanupStack::PopAndDestroy(5,&rws1);
sl@0
   537
	}
sl@0
   538
sl@0
   539
/**
sl@0
   540
@SYMTestCaseID		GRAPHICS-WSERV-0492
sl@0
   541
sl@0
   542
@SYMDEF             PDEF126432
sl@0
   543
sl@0
   544
@SYMTestCaseDesc    Test the screen number that a window is located on
sl@0
   545
sl@0
   546
@SYMTestPriority    Medium
sl@0
   547
sl@0
   548
@SYMTestStatus      Implemented
sl@0
   549
sl@0
   550
@SYMTestActions     Create two windows on two screens respectively 
sl@0
   551
					and check the screen number that each window is located on
sl@0
   552
sl@0
   553
@SYMTestExpectedResults The screen numbers should match the expected ones
sl@0
   554
*/
sl@0
   555
void CTMulScreens::TestScreenNumbersOfWindowsL()
sl@0
   556
	{
sl@0
   557
	// First screen
sl@0
   558
	RWindow fstWin(iRws);
sl@0
   559
	CleanupClosePushL(fstWin);
sl@0
   560
	TRAPD(err,fstWin.Construct(iFstWinGp,ENullWsHandle));
sl@0
   561
	TEST(err==KErrNone);
sl@0
   562
	if(err==KErrNone)
sl@0
   563
		{
sl@0
   564
		fstWin.Activate();
sl@0
   565
		iRws.Flush();
sl@0
   566
		}
sl@0
   567
	TEST(fstWin.ScreenNumber()==KFstScreenNo);
sl@0
   568
	CleanupStack::PopAndDestroy();//fstWin	
sl@0
   569
	
sl@0
   570
	// Second screen
sl@0
   571
	if(KSndScreenNo<iNumScreens)
sl@0
   572
		{
sl@0
   573
		RWindow sndWin(iRws);
sl@0
   574
		CleanupClosePushL(sndWin);
sl@0
   575
		TRAP(err,sndWin.Construct(iSndWinGp,ENullWsHandle));
sl@0
   576
		TEST(err==KErrNone);
sl@0
   577
		if(err==KErrNone)
sl@0
   578
			{
sl@0
   579
			sndWin.Activate(); 
sl@0
   580
			iRws.Flush();
sl@0
   581
			}
sl@0
   582
		TEST(sndWin.ScreenNumber()==KSndScreenNo);
sl@0
   583
		CleanupStack::PopAndDestroy(); //sndWin
sl@0
   584
		}
sl@0
   585
	}	
sl@0
   586
	
sl@0
   587
void CTMulScreens::RunTestCaseL(TInt aCurTestCase)
sl@0
   588
	{
sl@0
   589
	_LIT(KTest0,"Create a window group on each screen");
sl@0
   590
	_LIT(KTest1,"Create a blank window on each screen");
sl@0
   591
	_LIT(KTest2,"Get focus window");
sl@0
   592
	_LIT(KTest3,"Get default owning window");
sl@0
   593
	_LIT(KTest4,"Change background colour");
sl@0
   594
	_LIT(KTest5,"Change shadow vector");
sl@0
   595
	_LIT(KTest6,"Panic Tests");
sl@0
   596
	_LIT(KTest7,"Test device pointer returned by GC");
sl@0
   597
	_LIT(KTest8,"Initialise ScreenDevice");
sl@0
   598
	_LIT(KTest9,"Test screen numbers that windows are located on");
sl@0
   599
	((CTMulScreensStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
sl@0
   600
sl@0
   601
	switch(aCurTestCase)
sl@0
   602
		{
sl@0
   603
		case 1:
sl@0
   604
			((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0383"));
sl@0
   605
			INFO_PRINTF1(KTest0);
sl@0
   606
			TestCreateGroupWindowsL();
sl@0
   607
			break;
sl@0
   608
		case 2:
sl@0
   609
			((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0384"));
sl@0
   610
			INFO_PRINTF1(KTest1);
sl@0
   611
			TestCreateBlankWindowsL();
sl@0
   612
			break;
sl@0
   613
		case 3:
sl@0
   614
			((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0385"));
sl@0
   615
			INFO_PRINTF1(KTest2);
sl@0
   616
			TestGetFocusWindow();
sl@0
   617
		case 4:
sl@0
   618
			((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0386"));
sl@0
   619
			INFO_PRINTF1(KTest3);
sl@0
   620
			TestGetDefaultOwningWindow();
sl@0
   621
			break;
sl@0
   622
		case 5:
sl@0
   623
			((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0387"));
sl@0
   624
			INFO_PRINTF1(KTest4);
sl@0
   625
			TestSetBackgroundColour();
sl@0
   626
			break;
sl@0
   627
		case 6:
sl@0
   628
			((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0388"));
sl@0
   629
			INFO_PRINTF1(KTest5);
sl@0
   630
			TestSetShadowVector();
sl@0
   631
			break;
sl@0
   632
		case 7:
sl@0
   633
			((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0389"));
sl@0
   634
			INFO_PRINTF1(KTest6);
sl@0
   635
			TestPanicsL();
sl@0
   636
			break;
sl@0
   637
		case 8:
sl@0
   638
			((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0390"));
sl@0
   639
			INFO_PRINTF1(KTest7);
sl@0
   640
			TestDeviceL();
sl@0
   641
			break;
sl@0
   642
		case 9:
sl@0
   643
			((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0034"));
sl@0
   644
			INFO_PRINTF1(KTest8);
sl@0
   645
			TestInitaliseScreenDeviceL();
sl@0
   646
			break;
sl@0
   647
		case 10:
sl@0
   648
			((CTMulScreensStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0492"));
sl@0
   649
			INFO_PRINTF1(KTest9);
sl@0
   650
			TestScreenNumbersOfWindowsL();
sl@0
   651
		case 11:
sl@0
   652
			((CTMulScreensStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
sl@0
   653
			((CTMulScreensStep*)iStep)->CloseTMSGraphicsStep();
sl@0
   654
			INFO_PRINTF1(_L("All tests completed.\n"));
sl@0
   655
			TestComplete();
sl@0
   656
			break;
sl@0
   657
		default:
sl@0
   658
			((CTMulScreensStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
sl@0
   659
			((CTMulScreensStep*)iStep)->CloseTMSGraphicsStep();
sl@0
   660
			INFO_PRINTF1(_L("CTMulScreens::RunTestCaseL default case\n"));
sl@0
   661
			break;
sl@0
   662
		}
sl@0
   663
	((CTMulScreensStep*)iStep)->RecordTestResultL();
sl@0
   664
	}
sl@0
   665
sl@0
   666
__WS_CONSTRUCT_STEP__(MulScreens)