os/graphics/windowing/windowserver/test/tauto/TWINDOW.CPP
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// General window tests
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 "TWINDOW.H"
sl@0
    25
sl@0
    26
const TInt ENumCornerInsets=6;
sl@0
    27
const TInt corner0[ENumCornerInsets]={0,0,0,0,0,0};
sl@0
    28
const TInt corner1[ENumCornerInsets]={1,0,0,0,0,0};
sl@0
    29
const TInt corner2[ENumCornerInsets]={2,1,0,0,0,0};
sl@0
    30
const TInt corner3[ENumCornerInsets]={3,1,1,0,0,0};
sl@0
    31
const TInt corner5[ENumCornerInsets]={5,3,2,1,1,0};
sl@0
    32
const TInt KBaseUserEvent=61750;		//0xF136 - a random number that is unlikely to be used by other applicaions for user event sending
sl@0
    33
sl@0
    34
//
sl@0
    35
sl@0
    36
CWinTestWindow::CWinTestWindow(TRgb aCol) : CBlankWindow(aCol)
sl@0
    37
	{
sl@0
    38
	}
sl@0
    39
sl@0
    40
CWinTestWindow::~CWinTestWindow()
sl@0
    41
	{
sl@0
    42
	delete iChild;
sl@0
    43
	}
sl@0
    44
sl@0
    45
void CWinTestWindow::ConstructL(TPoint pos,TSize size,CTWinBase *aParent, CWindowGc &aGc, TInt aDepth)
sl@0
    46
	{
sl@0
    47
	iWin=RWindow(TheClient->iWs);
sl@0
    48
	User::LeaveIfError(iWin.Construct(*(aParent->WinTreeNode()),ENullWsHandle));
sl@0
    49
	SetExt(pos,size);
sl@0
    50
	if (aDepth<3)
sl@0
    51
		{
sl@0
    52
		iChild=new(ELeave) CWinTestWindow(TRgb::Gray256(iCol.Gray256()+34));
sl@0
    53
		size.iWidth-=8;
sl@0
    54
		size.iHeight-=8;
sl@0
    55
		iChild->ConstructL(TPoint(4,4),size,this,aGc,aDepth+1);
sl@0
    56
		}
sl@0
    57
	Activate();
sl@0
    58
	AssignGC(aGc);
sl@0
    59
	}
sl@0
    60
sl@0
    61
//
sl@0
    62
sl@0
    63
CEvWindowGroup* CEvWindowGroup::NewLC(CTClient* aClient,CTWsGraphicsBase* aTest)
sl@0
    64
	{
sl@0
    65
	CEvWindowGroup* self=new(ELeave) CEvWindowGroup(aClient,aTest);
sl@0
    66
	CleanupStack::PushL(self);
sl@0
    67
	self->ConstructL();
sl@0
    68
	return self;
sl@0
    69
	}
sl@0
    70
sl@0
    71
CEvWindowGroup::CEvWindowGroup(CTClient* aClient,CTWsGraphicsBase* aTest) : CTWindowGroup(aClient), iTest(aTest)
sl@0
    72
	{}
sl@0
    73
sl@0
    74
void CEvWindowGroup::ConstructL()
sl@0
    75
	{
sl@0
    76
	CTWindowGroup::ConstructL();
sl@0
    77
	iGroupWin.EnableReceiptOfFocus(EFalse);
sl@0
    78
	}
sl@0
    79
sl@0
    80
void CEvWindowGroup::SetExpectedEvent(TInt aType)
sl@0
    81
	{
sl@0
    82
	iTest->TEST(!iExpectingEvent);
sl@0
    83
	if (iExpectingEvent)
sl@0
    84
		{
sl@0
    85
		_LIT(KLog,"Setting expected event of type %d, when previouse event of type %d has not arrived (GpWinId=%d).");
sl@0
    86
		iTest->LOG_MESSAGE4(KLog,aType,iExpectedEvent,iGroupWin.Identifier());
sl@0
    87
		}
sl@0
    88
	iExpectedEvent=aType;
sl@0
    89
	iExpectingEvent=ETrue;
sl@0
    90
	}
sl@0
    91
sl@0
    92
void CEvWindowGroup::SendEvent(TInt aType)
sl@0
    93
	{
sl@0
    94
	TWsEvent event;
sl@0
    95
	event.SetType(aType);
sl@0
    96
	iClient->iWs.SendEventToWindowGroup(iGroupWin.Identifier(),event);
sl@0
    97
	SetExpectedEvent(aType);
sl@0
    98
	iClient->Flush();
sl@0
    99
	}
sl@0
   100
sl@0
   101
void CEvWindowGroup::UserEvent(TInt aEventType)
sl@0
   102
	{
sl@0
   103
	iTest->TEST(iExpectingEvent && iExpectedEvent==aEventType);
sl@0
   104
	if (!iExpectingEvent || iExpectedEvent!=aEventType)
sl@0
   105
		{
sl@0
   106
		TInt id=iGroupWin.Identifier();
sl@0
   107
		if (!iExpectingEvent)
sl@0
   108
			{
sl@0
   109
			_LIT(KLog,"Event of type %d recieved when not expecting an event (GpWinId=%d).");
sl@0
   110
			iTest->LOG_MESSAGE3(KLog,aEventType,id);
sl@0
   111
			}
sl@0
   112
		else
sl@0
   113
			{
sl@0
   114
			_LIT(KLog,"Event of type %d when expecting an event of type %d (GpWinId=%d).");
sl@0
   115
			iTest->LOG_MESSAGE4(KLog,aEventType,iExpectingEvent,id);
sl@0
   116
			}
sl@0
   117
		}
sl@0
   118
	iExpectingEvent=EFalse;
sl@0
   119
	}
sl@0
   120
sl@0
   121
//
sl@0
   122
sl@0
   123
CTWindowTest::CTWindowTest(CTestStep* aStep) : CTWsGraphicsBase(aStep)
sl@0
   124
	{}
sl@0
   125
sl@0
   126
CTWindowTest::~CTWindowTest()
sl@0
   127
	{
sl@0
   128
	delete iWin;
sl@0
   129
	}
sl@0
   130
sl@0
   131
void CTWindowTest::ConstructL()
sl@0
   132
	{}
sl@0
   133
sl@0
   134
TInt CTWindowTest::MoveGroup(TAny* aParam)
sl@0
   135
	{
sl@0
   136
	RWsSession ws;
sl@0
   137
	TInt err=ws.Connect();
sl@0
   138
	if (err==KErrNone)
sl@0
   139
		{
sl@0
   140
		TInt command=static_cast<TWindowThreadParam*>(aParam)->iCommand;
sl@0
   141
		err=ws.SetWindowGroupOrdinalPosition(command&EIdMask,(command&EPosMask)>>EPosShift);
sl@0
   142
		ws.Finish();
sl@0
   143
		ws.Close();
sl@0
   144
		}
sl@0
   145
	return err;
sl@0
   146
	}
sl@0
   147
sl@0
   148
void CTWindowTest::CreateTestWindowL()
sl@0
   149
	{
sl@0
   150
	iWin=new(ELeave) CWinTestWindow(TRgb(0,0,0));
sl@0
   151
	iWin->ConstructL(TPoint(1,1),TSize(TestWin->Size().iWidth/2,TestWin->Size().iHeight/2),TheClient->iGroup,*TheClient->iGc,0);
sl@0
   152
	}
sl@0
   153
sl@0
   154
void CTWindowTest::DrawWindows(CWinTestWindow *aWin)
sl@0
   155
	{
sl@0
   156
	if (aWin->iChild)
sl@0
   157
		DrawWindows(aWin->iChild);
sl@0
   158
	aWin->Win()->BeginRedraw();
sl@0
   159
	TheGc->Activate(*aWin->Win());
sl@0
   160
	TheGc->DrawRect(TRect(aWin->Win()->Size()));
sl@0
   161
	TheGc->Deactivate();
sl@0
   162
	aWin->Win()->EndRedraw();
sl@0
   163
	TheClient->iWs.Flush();
sl@0
   164
	}
sl@0
   165
sl@0
   166
void CTWindowTest::CheckAndDestroyWindows()
sl@0
   167
	{
sl@0
   168
	DrawWindows(iWin);
sl@0
   169
	delete iWin;
sl@0
   170
	iWin=NULL;
sl@0
   171
	}
sl@0
   172
sl@0
   173
void CTWindowTest::DestroyWindowWithActiveGc()
sl@0
   174
	{
sl@0
   175
	iWin->Win()->BeginRedraw();
sl@0
   176
	TheGc->Activate(*iWin->Win());
sl@0
   177
	delete iWin;
sl@0
   178
	TheGc->Deactivate();
sl@0
   179
	iWin=NULL;
sl@0
   180
	}
sl@0
   181
sl@0
   182
void CTWindowTest::DestroyWindowWithActiveGc2L()
sl@0
   183
	{
sl@0
   184
	iWin->Win()->BeginRedraw();
sl@0
   185
	TheGc->Activate(*iWin->Win());
sl@0
   186
	CWindowGc *gc1=new(ELeave) CWindowGc(TheClient->iScreen);
sl@0
   187
	CWindowGc *gc2=new(ELeave) CWindowGc(TheClient->iScreen);
sl@0
   188
	CWindowGc *gc3=new(ELeave) CWindowGc(TheClient->iScreen);
sl@0
   189
	gc1->Construct();
sl@0
   190
	gc2->Construct();
sl@0
   191
	gc3->Construct();
sl@0
   192
	gc1->Activate(*iWin->Win());
sl@0
   193
	gc2->Activate(*iWin->Win());
sl@0
   194
	gc3->Activate(*iWin->Win());
sl@0
   195
	delete iWin;
sl@0
   196
	TheGc->Deactivate();
sl@0
   197
	delete gc1;
sl@0
   198
	delete gc2;
sl@0
   199
	delete gc3;
sl@0
   200
	iWin=NULL;
sl@0
   201
	}
sl@0
   202
sl@0
   203
LOCAL_C TInt DoPanicTest(TInt aInt, TAny *aScreenNumber)
sl@0
   204
	{
sl@0
   205
	RWsSession ws;
sl@0
   206
	User::LeaveIfError(ws.Connect());
sl@0
   207
	// use correct screen
sl@0
   208
	//
sl@0
   209
	CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
sl@0
   210
	User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
sl@0
   211
sl@0
   212
	RWindowGroup group(ws);
sl@0
   213
	group.Construct(888);
sl@0
   214
	group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
sl@0
   215
sl@0
   216
	RWindow redraw(ws);
sl@0
   217
	redraw.Construct(group,88);
sl@0
   218
sl@0
   219
	RBackedUpWindow backedUp(ws);
sl@0
   220
	backedUp.Construct(group,EGray16,99);
sl@0
   221
sl@0
   222
	RBlankWindow blank(ws);
sl@0
   223
	blank.Construct(group,111);
sl@0
   224
sl@0
   225
	RWindowBase *base=NULL;
sl@0
   226
	TInt source=aInt/10000;
sl@0
   227
	TInt target=(aInt%10000)/100;
sl@0
   228
	TInt panic=aInt%100;
sl@0
   229
	switch(source)
sl@0
   230
		{
sl@0
   231
		case 0:
sl@0
   232
			base= &redraw;
sl@0
   233
			break;
sl@0
   234
		case 1:
sl@0
   235
			base= &backedUp;
sl@0
   236
			break;
sl@0
   237
		case 2:
sl@0
   238
			base= &blank;
sl@0
   239
			break;
sl@0
   240
		}
sl@0
   241
	switch(target)
sl@0
   242
		{
sl@0
   243
		case 0:
sl@0
   244
			{
sl@0
   245
			RWindow *win=(RWindow *)base;
sl@0
   246
			switch(panic)
sl@0
   247
				{
sl@0
   248
				case 0:
sl@0
   249
					win->BeginRedraw();
sl@0
   250
					break;
sl@0
   251
				case 1:
sl@0
   252
					ws.SetAutoFlush(ETrue);
sl@0
   253
					win->BeginRedraw(TRect(0,0,1,1));
sl@0
   254
					ws.SetAutoFlush(EFalse);
sl@0
   255
					break;
sl@0
   256
				case 2:
sl@0
   257
					ws.SetAutoFlush(ETrue);
sl@0
   258
					win->EndRedraw();
sl@0
   259
					ws.SetAutoFlush(EFalse);
sl@0
   260
					break;
sl@0
   261
				case 3:
sl@0
   262
					win->Invalidate();
sl@0
   263
					break;
sl@0
   264
				case 4:
sl@0
   265
					win->Invalidate(TRect(0,0,1,1));
sl@0
   266
					break;
sl@0
   267
				case 5:
sl@0
   268
					{
sl@0
   269
					RRegion region;
sl@0
   270
					win->GetInvalidRegion(region);
sl@0
   271
					}
sl@0
   272
					break;
sl@0
   273
				case 6:
sl@0
   274
					win->SetBackgroundColor(TRgb(0,0,0));
sl@0
   275
					break;
sl@0
   276
				case 7:
sl@0
   277
					return(EWsExitReasonFinished);
sl@0
   278
				}
sl@0
   279
			break;
sl@0
   280
			}
sl@0
   281
		case 1:
sl@0
   282
			{
sl@0
   283
			RBackedUpWindow *win=(RBackedUpWindow *)base;
sl@0
   284
			switch(panic)
sl@0
   285
				{
sl@0
   286
				case 0:
sl@0
   287
					win->BitmapHandle();
sl@0
   288
					break;
sl@0
   289
				case 1:
sl@0
   290
					win->UpdateScreen();
sl@0
   291
					break;
sl@0
   292
				case 2:
sl@0
   293
					win->UpdateScreen(TRegionFix<1>(TRect(10,10,20,20)));
sl@0
   294
					break;
sl@0
   295
				case 3:
sl@0
   296
					win->UpdateBackupBitmap();
sl@0
   297
					break;
sl@0
   298
				case 4:
sl@0
   299
					win->MaintainBackup();
sl@0
   300
					break;
sl@0
   301
				case 5:
sl@0
   302
					return(EWsExitReasonFinished);
sl@0
   303
				}
sl@0
   304
			break;
sl@0
   305
			}
sl@0
   306
		case 2:
sl@0
   307
			{
sl@0
   308
			RBlankWindow *win=(RBlankWindow *)base;
sl@0
   309
			switch(panic)
sl@0
   310
				{
sl@0
   311
				case 0:
sl@0
   312
					win->SetColor(TRgb(0));
sl@0
   313
					break;
sl@0
   314
				case 1:
sl@0
   315
					return(EWsExitReasonFinished);
sl@0
   316
				}
sl@0
   317
			break;
sl@0
   318
			}
sl@0
   319
		}
sl@0
   320
	ws.Flush();
sl@0
   321
	return(EWsExitReasonBad);	// Should never get here, but it's baaddd if it does
sl@0
   322
	}
sl@0
   323
sl@0
   324
struct TWsLocalStructure
sl@0
   325
	{
sl@0
   326
	TInt xPos;
sl@0
   327
	TInt yPos;
sl@0
   328
	TInt Length;
sl@0
   329
	TAny *ptr;
sl@0
   330
	};
sl@0
   331
sl@0
   332
LOCAL_C TInt DoPanicTest2(TInt aInt, TAny *aScreenNumber)
sl@0
   333
	{
sl@0
   334
	RWsSession ws;
sl@0
   335
	User::LeaveIfError(ws.Connect());
sl@0
   336
//
sl@0
   337
	CWsScreenDevice *screen=new(ELeave) CWsScreenDevice(ws);
sl@0
   338
	screen->Construct((TInt)aScreenNumber);
sl@0
   339
//
sl@0
   340
	RWindowGroup group(ws);
sl@0
   341
	group.Construct(999);
sl@0
   342
	group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
sl@0
   343
sl@0
   344
	RWindow win(ws);
sl@0
   345
	win.Construct(group,122);
sl@0
   346
	win.Activate();
sl@0
   347
sl@0
   348
	switch(aInt)
sl@0
   349
		{
sl@0
   350
		case 0:
sl@0
   351
			{
sl@0
   352
			win.BeginRedraw();
sl@0
   353
			CWindowGc *gc;
sl@0
   354
			screen->CreateContext(gc);
sl@0
   355
			gc->Activate(win);
sl@0
   356
			CFbsFont *font;
sl@0
   357
			screen->GetNearestFontToDesignHeightInTwips((CFont *&)font,TFontSpec());
sl@0
   358
			gc->UseFont(font);
sl@0
   359
			TWsLocalStructure params;
sl@0
   360
			params.xPos=0;
sl@0
   361
			params.yPos=0;
sl@0
   362
			params.Length=1;
sl@0
   363
			TPckgC<TWsLocalStructure> pkg(params);
sl@0
   364
			TPtr8 ptr(NULL,10,10);
sl@0
   365
			ws.TestWriteReplyByProvidingRemoteReadAccess(gc->WsHandle(),EWsGcOpDrawTextPtr,pkg,ptr); // Bad source descriptor
sl@0
   366
			}
sl@0
   367
			break;
sl@0
   368
		case 1:
sl@0
   369
			{
sl@0
   370
			TPtr8 bad(NULL,0); // Bad descriptor
sl@0
   371
			ws.TestWriteReplyP(win.WsHandle(),EWsWinOpSize,NULL,0,&bad); // Bad descriptor
sl@0
   372
			}
sl@0
   373
			break;
sl@0
   374
		case 2:
sl@0
   375
			{
sl@0
   376
			TSize size;
sl@0
   377
			TPtr8 bad((TUint8 *)&size,4,4); // Short descriptor
sl@0
   378
			ws.TestWriteReplyP(win.WsHandle(),EWsWinOpSize,NULL,0,&bad); // Short descriptor
sl@0
   379
			}
sl@0
   380
			break;
sl@0
   381
		case 3:
sl@0
   382
			win.EnablePointerMoveBuffer();
sl@0
   383
			break;
sl@0
   384
		case 4:
sl@0
   385
			{
sl@0
   386
			RBackedUpWindow backup(ws);
sl@0
   387
			backup.Construct(group,EGray16,123);
sl@0
   388
			backup.Activate();
sl@0
   389
			backup.SetRequiredDisplayMode(EGray16);
sl@0
   390
			}
sl@0
   391
			break;
sl@0
   392
		default:
sl@0
   393
			return(EWsExitReasonFinished);
sl@0
   394
		}
sl@0
   395
	ws.Flush();
sl@0
   396
	return(EWsExitReasonBad);	// Should never get here, but it's baaddd if it does
sl@0
   397
	}
sl@0
   398
sl@0
   399
LOCAL_C TInt CallWindowFuction(RWindowTreeNode* aWin,TInt aWinType,TInt aFunc,RWsSession aWs)
sl@0
   400
	{
sl@0
   401
	switch(aWinType)
sl@0
   402
		{
sl@0
   403
	case 0:		//Call functions from RWindowTreeNode
sl@0
   404
		{
sl@0
   405
		RWindowTreeNode* win=aWin;
sl@0
   406
		switch(aFunc)
sl@0
   407
			{
sl@0
   408
		case 0:
sl@0
   409
			win->OrdinalPosition();
sl@0
   410
			break;
sl@0
   411
		case 1:
sl@0
   412
			win->SetOrdinalPosition(1);
sl@0
   413
			break;
sl@0
   414
		case 2:
sl@0
   415
			win->SetOrdinalPosition(1,2);
sl@0
   416
			break;
sl@0
   417
		case 3:
sl@0
   418
			win->FullOrdinalPosition();
sl@0
   419
			break;
sl@0
   420
		case 4:
sl@0
   421
			win->Parent();
sl@0
   422
			break;
sl@0
   423
		case 5:
sl@0
   424
			win->PrevSibling();
sl@0
   425
			break;
sl@0
   426
		case 6:
sl@0
   427
			win->SetFaded(0,RWindowTreeNode::EFadeIncludeChildren);
sl@0
   428
			break;
sl@0
   429
		case 7:
sl@0
   430
			win->WindowGroupId();
sl@0
   431
			break;
sl@0
   432
		//The following can be called on a window with no parent without panicking
sl@0
   433
		case 8:
sl@0
   434
			win->ClearPointerCursor();
sl@0
   435
			break;
sl@0
   436
		case 9:
sl@0
   437
			win->ClientHandle();
sl@0
   438
			break;
sl@0
   439
		case 10:
sl@0
   440
			win->DisableErrorMessages();
sl@0
   441
			break;
sl@0
   442
		case 11:
sl@0
   443
			win->DisableFocusChangeEvents();
sl@0
   444
			break;
sl@0
   445
		case 12:
sl@0
   446
			win->DisableGroupChangeEvents();
sl@0
   447
			break;
sl@0
   448
		case 13:
sl@0
   449
			win->DisableGroupListChangeEvents();
sl@0
   450
			break;
sl@0
   451
		case 14:
sl@0
   452
			win->DisableModifierChangedEvents();
sl@0
   453
			break;
sl@0
   454
		case 15:
sl@0
   455
			win->DisableOnEvents();
sl@0
   456
			break;
sl@0
   457
		case 16:
sl@0
   458
			win->DisableVisibilityChangeEvents();
sl@0
   459
			break;
sl@0
   460
		case 17:
sl@0
   461
			win->EnableErrorMessages(EEventControlAlways);
sl@0
   462
			break;
sl@0
   463
		case 18:
sl@0
   464
			win->EnableFocusChangeEvents();
sl@0
   465
			break;
sl@0
   466
		case 19:
sl@0
   467
			win->EnableGroupChangeEvents();
sl@0
   468
			break;
sl@0
   469
		case 20:
sl@0
   470
			win->EnableGroupListChangeEvents();
sl@0
   471
			break;
sl@0
   472
		case 21:
sl@0
   473
			win->EnableModifierChangedEvents(0,EEventControlAlways);
sl@0
   474
			break;
sl@0
   475
		case 22:
sl@0
   476
			win->EnableVisibilityChangeEvents();
sl@0
   477
			break;
sl@0
   478
		case 23:
sl@0
   479
			win->NextSibling();
sl@0
   480
			break;
sl@0
   481
		case 24:
sl@0
   482
			win->OrdinalPriority();
sl@0
   483
			break;
sl@0
   484
		case 25:
sl@0
   485
			win->SetNonFading(0);
sl@0
   486
			break;
sl@0
   487
		case 26:
sl@0
   488
			win->SetPointerCursor(0);
sl@0
   489
			break;
sl@0
   490
		case 27:
sl@0
   491
			win->Child();
sl@0
   492
			break;
sl@0
   493
		case 28:
sl@0
   494
			return(EWsExitReasonFinished);
sl@0
   495
		default:;
sl@0
   496
			}
sl@0
   497
		}
sl@0
   498
		break;
sl@0
   499
	case 1:		//Call functions from RWindowGroup
sl@0
   500
		{
sl@0
   501
		RWindowGroup* win=(RWindowGroup*)aWin;
sl@0
   502
		switch(aFunc)
sl@0
   503
			{
sl@0
   504
		case 0:
sl@0
   505
			win->EnableReceiptOfFocus(ETrue);
sl@0
   506
			break;
sl@0
   507
		case 1:
sl@0
   508
			win->AutoForeground(ETrue);
sl@0
   509
			break;
sl@0
   510
		case 2:
sl@0
   511
			win->SetOrdinalPriorityAdjust(5);
sl@0
   512
			break;
sl@0
   513
		case 3:
sl@0
   514
			win->CaptureKey(20,0,0);
sl@0
   515
			break;
sl@0
   516
		case 4:
sl@0
   517
			win->CaptureKeyUpAndDowns(20,0,0);
sl@0
   518
			break;
sl@0
   519
		case 5:
sl@0
   520
		case 6:
sl@0
   521
			{
sl@0
   522
			RWindowGroup group(aWs);
sl@0
   523
			group.Construct(876);
sl@0
   524
			group.EnableReceiptOfFocus(EFalse);		// Stop auto group switching on close
sl@0
   525
			if (aFunc==5)
sl@0
   526
				win->CancelCaptureKey(group.CaptureKey(20,0,0));
sl@0
   527
			else
sl@0
   528
				win->CancelCaptureKeyUpAndDowns(group.CaptureKeyUpAndDowns(20,0,0));
sl@0
   529
			}
sl@0
   530
			break;
sl@0
   531
		case 7:
sl@0
   532
			win->AddPriorityKey(20,0,0);
sl@0
   533
			break;
sl@0
   534
		case 8:
sl@0
   535
			win->RemovePriorityKey(20,0,0);
sl@0
   536
			break;
sl@0
   537
		case 9:
sl@0
   538
		case 10:
sl@0
   539
			{
sl@0
   540
			RWindowGroup group(aWs);
sl@0
   541
			group.Construct(765);
sl@0
   542
			group.EnableReceiptOfFocus(EFalse);		// Stop auto group switching on close
sl@0
   543
 			RWindow window(aWs);
sl@0
   544
			window.Construct(group,79);
sl@0
   545
			if (aFunc==9)
sl@0
   546
				win->SetTextCursor(window,TPoint(45,46),TTextCursor());
sl@0
   547
			else
sl@0
   548
				win->SetTextCursor(window,TPoint(55,66),TTextCursor(),TRect(TSize(5,8)));
sl@0
   549
			}
sl@0
   550
			break;
sl@0
   551
		case 11:
sl@0
   552
			win->CancelTextCursor();
sl@0
   553
			break;
sl@0
   554
		case 12:
sl@0
   555
			win->SetOwningWindowGroup(456);
sl@0
   556
			break;
sl@0
   557
		case 13:
sl@0
   558
			win->DefaultOwningWindow();
sl@0
   559
			break;
sl@0
   560
		case 14:
sl@0
   561
			{
sl@0
   562
			TBufC<8> text(_L("abcdef"));
sl@0
   563
			win->SetName(text);
sl@0
   564
			}
sl@0
   565
			break;
sl@0
   566
		case 15:
sl@0
   567
			{
sl@0
   568
			TBuf<16> text;
sl@0
   569
			User::LeaveIfError(win->Name(text));
sl@0
   570
			}
sl@0
   571
			break;
sl@0
   572
		case 16:
sl@0
   573
			win->Identifier();
sl@0
   574
			break;
sl@0
   575
		case 17:
sl@0
   576
			win->DisableKeyClick(ETrue);
sl@0
   577
			break;
sl@0
   578
		case 18:
sl@0
   579
			/*{
sl@0
   580
			TPtr8 text(NULL,0);
sl@0
   581
			TUid uid;
sl@0
   582
			User::LeaveIfError(win->FetchMessage(uid,text));
sl@0
   583
			}*/
sl@0
   584
			win->Identifier();
sl@0
   585
			break;
sl@0
   586
		case 19:
sl@0
   587
			User::LeaveIfError(win->EnableScreenChangeEvents());
sl@0
   588
			break;
sl@0
   589
		case 20:
sl@0
   590
			win->EnableScreenChangeEvents();
sl@0
   591
			break;
sl@0
   592
		case 21:
sl@0
   593
			win->DisableScreenChangeEvents();
sl@0
   594
			break;
sl@0
   595
		case 22:
sl@0
   596
			win->SimulatePointerEvent(TRawEvent());
sl@0
   597
			break;
sl@0
   598
#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
sl@0
   599
        case 23: 	
sl@0
   600
        	win->SimulateAdvancedPointerEvent(TRawEvent());
sl@0
   601
  	  		break;
sl@0
   602
        case 24:	
sl@0
   603
			return(EWsExitReasonFinished);
sl@0
   604
#else
sl@0
   605
		case 23:	
sl@0
   606
			return(EWsExitReasonFinished);
sl@0
   607
#endif			
sl@0
   608
		default:;
sl@0
   609
			}
sl@0
   610
		}
sl@0
   611
		break;
sl@0
   612
	case 2:					//Call functions from RWindowBase
sl@0
   613
		{
sl@0
   614
		RWindowBase* win=(RWindowBase*)aWin;
sl@0
   615
		switch(aFunc)
sl@0
   616
			{
sl@0
   617
		case 0:
sl@0
   618
			win->SetPosition(TPoint(7,8));
sl@0
   619
			break;
sl@0
   620
		case 1:
sl@0
   621
			User::LeaveIfError(win->SetSizeErr(TSize(21,22)));
sl@0
   622
			break;
sl@0
   623
		case 2:
sl@0
   624
			User::LeaveIfError(win->SetExtentErr(TPoint(8,9),TSize(21,22)));
sl@0
   625
			break;
sl@0
   626
		case 3:
sl@0
   627
			win->ClaimPointerGrab();
sl@0
   628
			break;
sl@0
   629
		case 4:
sl@0
   630
			win->SetVisible(ETrue);
sl@0
   631
			break;
sl@0
   632
		case 5:
sl@0
   633
			win->EnableBackup();
sl@0
   634
			break;
sl@0
   635
		case 6:
sl@0
   636
			win->RequestPointerRepeatEvent(TTimeIntervalMicroSeconds32(100000),TRect());
sl@0
   637
			break;
sl@0
   638
		case 7:
sl@0
   639
			win->PasswordWindow(EPasswordCancel);
sl@0
   640
			break;
sl@0
   641
		case 8:
sl@0
   642
			win->FadeBehind(ETrue);
sl@0
   643
			break;
sl@0
   644
		//These can all be called on a window with no parent without panicking
sl@0
   645
		case 9:
sl@0
   646
			win->SetVisible(EFalse);
sl@0
   647
			break;
sl@0
   648
		case 10:
sl@0
   649
			{
sl@0
   650
			RWindowGroup group(aWs);
sl@0
   651
			group.Construct(567);
sl@0
   652
			group.EnableReceiptOfFocus(EFalse);		// Stop auto group switching on close
sl@0
   653
 			RWindow window(aWs);
sl@0
   654
			window.Construct(group,97);
sl@0
   655
			win->InquireOffset(window);
sl@0
   656
			}
sl@0
   657
			break;
sl@0
   658
		case 11:
sl@0
   659
			win->PointerFilter(0,0);
sl@0
   660
			break;
sl@0
   661
		case 12:
sl@0
   662
			win->SetPointerGrab(ETrue);
sl@0
   663
			break;
sl@0
   664
		case 13:
sl@0
   665
			win->SetPointerCapture(0);
sl@0
   666
			break;
sl@0
   667
		case 14:
sl@0
   668
			win->Size();
sl@0
   669
			break;
sl@0
   670
		case 15:
sl@0
   671
			win->Position();
sl@0
   672
			break;
sl@0
   673
		case 16:
sl@0
   674
			User::LeaveIfError(win->SetCornerType(EWindowCorner5,0));
sl@0
   675
			break;
sl@0
   676
		case 17:
sl@0
   677
			{
sl@0
   678
			TRegionFix<3> region;
sl@0
   679
			User::LeaveIfError(win->SetShape(region));
sl@0
   680
			}
sl@0
   681
			break;
sl@0
   682
		case 18:
sl@0
   683
			User::LeaveIfError(win->SetRequiredDisplayMode(EColor16));
sl@0
   684
			break;
sl@0
   685
		case 19:
sl@0
   686
			win->DisplayMode();
sl@0
   687
			break;
sl@0
   688
		case 20:
sl@0
   689
			win->CancelPointerRepeatEventRequest();
sl@0
   690
			break;
sl@0
   691
		case 21:
sl@0
   692
			win->AllocPointerMoveBuffer(10,0);
sl@0
   693
			break;
sl@0
   694
		case 22:
sl@0
   695
			win->FreePointerMoveBuffer();
sl@0
   696
			break;
sl@0
   697
		case 23:
sl@0
   698
			win->DisablePointerMoveBuffer();
sl@0
   699
			break;
sl@0
   700
		case 24:
sl@0
   701
			{
sl@0
   702
			TBuf8<16> buf;
sl@0
   703
			win->RetrievePointerMoveBuffer(buf);
sl@0
   704
			}
sl@0
   705
			break;
sl@0
   706
		case 25:
sl@0
   707
			win->DiscardPointerMoveBuffer();
sl@0
   708
			break;
sl@0
   709
		case 26:
sl@0
   710
			User::LeaveIfError(win->AddKeyRect(TRect(TSize(10,10)),20,ETrue));
sl@0
   711
			break;
sl@0
   712
		case 27:
sl@0
   713
			win->RemoveAllKeyRects();
sl@0
   714
			break;
sl@0
   715
		case 28:
sl@0
   716
			win->EnablePointerMoveBuffer();
sl@0
   717
			break;
sl@0
   718
		case 29:
sl@0
   719
			return(EWsExitReasonFinished);
sl@0
   720
		default:;
sl@0
   721
			}
sl@0
   722
		}
sl@0
   723
		break;
sl@0
   724
	case 3:					//Call functions from RDrawableWindow
sl@0
   725
		{
sl@0
   726
		RDrawableWindow* win=(RDrawableWindow*)aWin;
sl@0
   727
		switch(aFunc)
sl@0
   728
			{
sl@0
   729
		//The following can be called on a window with no parent without panicking
sl@0
   730
		case 0:
sl@0
   731
			win->Scroll(TPoint(7,8));
sl@0
   732
			break;
sl@0
   733
		case 1:
sl@0
   734
			win->Scroll(TRect(9,10,11,12),TPoint(13,14));
sl@0
   735
			break;
sl@0
   736
		case 2:
sl@0
   737
			win->Scroll(TPoint(15,16),TRect(17,18,19,20));
sl@0
   738
			break;
sl@0
   739
		case 3:
sl@0
   740
			win->Scroll(TRect(21,22,23,24),TPoint(25,26),TRect(27,28,29,30));
sl@0
   741
			break;
sl@0
   742
		case 4:
sl@0
   743
			return(EWsExitReasonFinished);
sl@0
   744
		default:;
sl@0
   745
			}
sl@0
   746
		}
sl@0
   747
		break;
sl@0
   748
	case 4:					//Call functions from RBlankWindow
sl@0
   749
		{
sl@0
   750
		RBlankWindow* win=(RBlankWindow*)aWin;
sl@0
   751
		switch(aFunc)
sl@0
   752
			{
sl@0
   753
		case 0:
sl@0
   754
			win->SetSize(TSize(7,8));
sl@0
   755
			break;
sl@0
   756
		case 1:
sl@0
   757
			win->SetExtent(TPoint(27,28),TSize(17,18));
sl@0
   758
			break;
sl@0
   759
		//The following function can be called on a window with no parent without panicking
sl@0
   760
		case 2:
sl@0
   761
			win->SetColor(TRgb::Gray4(2));
sl@0
   762
			break;
sl@0
   763
		case 3:
sl@0
   764
			return(EWsExitReasonFinished);
sl@0
   765
		default:;
sl@0
   766
			}
sl@0
   767
		}
sl@0
   768
		break;
sl@0
   769
	case 5:					//Call functions from RWindow
sl@0
   770
		{
sl@0
   771
		RWindow* win=(RWindow*)aWin;
sl@0
   772
		switch(aFunc)
sl@0
   773
			{
sl@0
   774
		case 0:
sl@0
   775
			win->BeginRedraw();
sl@0
   776
			break;
sl@0
   777
		case 1:
sl@0
   778
			aWs.SetAutoFlush(ETrue);
sl@0
   779
			win->BeginRedraw(TRect(31,32,43,44));
sl@0
   780
			aWs.SetAutoFlush(EFalse);
sl@0
   781
			break;
sl@0
   782
		case 2:
sl@0
   783
			win->SetSize(TSize(5,6));
sl@0
   784
			break;
sl@0
   785
		case 3:
sl@0
   786
			win->SetExtent(TPoint(25,26),TSize(15,16));
sl@0
   787
			break;
sl@0
   788
		//The following can be called on a window with no parent without panicking
sl@0
   789
		case 4:
sl@0
   790
			win->Invalidate();
sl@0
   791
			break;
sl@0
   792
		case 5:
sl@0
   793
			win->Invalidate(TRect(51,52,63,64));
sl@0
   794
			break;
sl@0
   795
		case 6:			//These ones don't panic
sl@0
   796
			aWs.SetAutoFlush(ETrue);
sl@0
   797
			win->EndRedraw();
sl@0
   798
			aWs.SetAutoFlush(EFalse);
sl@0
   799
			break;
sl@0
   800
		case 7:
sl@0
   801
			{
sl@0
   802
			RRegion region;
sl@0
   803
			win->GetInvalidRegion(region);
sl@0
   804
			}
sl@0
   805
			break;
sl@0
   806
		case 8:
sl@0
   807
			win->SetBackgroundColor(TRgb::Gray4(1));
sl@0
   808
			break;
sl@0
   809
		case 9:
sl@0
   810
			win->SetBackgroundColor();
sl@0
   811
			break;
sl@0
   812
		case 10:
sl@0
   813
			return(EWsExitReasonFinished);
sl@0
   814
		default:;
sl@0
   815
			}
sl@0
   816
		}
sl@0
   817
		break;
sl@0
   818
	case 6:					//Call functions from RBackedUpWindow
sl@0
   819
		{
sl@0
   820
		RBackedUpWindow* win=(RBackedUpWindow*)aWin;
sl@0
   821
		switch(aFunc)			//None of these functions panic
sl@0
   822
			{
sl@0
   823
		//The following can be called on a window with no parent without panicking
sl@0
   824
		case 0:
sl@0
   825
			win->BitmapHandle();
sl@0
   826
			break;
sl@0
   827
		case 1:
sl@0
   828
			win->UpdateBackupBitmap();
sl@0
   829
			break;
sl@0
   830
		case 2:
sl@0
   831
			win->MaintainBackup();
sl@0
   832
			break;
sl@0
   833
		case 3:
sl@0
   834
			win->UpdateScreen();
sl@0
   835
			break;
sl@0
   836
		case 4:
sl@0
   837
			win->UpdateScreen(TRegionFix<1>(TRect(1,1,22,22)));
sl@0
   838
			break;
sl@0
   839
		case 5:
sl@0
   840
			return(EWsExitReasonFinished);
sl@0
   841
		default:;
sl@0
   842
			}
sl@0
   843
		}
sl@0
   844
		break;
sl@0
   845
		}
sl@0
   846
	aWs.Flush();
sl@0
   847
	return(EWsExitReasonBad);	// Should never get here, but it's baaddd if it does
sl@0
   848
	}
sl@0
   849
sl@0
   850
LOCAL_C TInt DoPanicTest3(TInt aInt, TAny *aScreenNumber)
sl@0
   851
	{
sl@0
   852
	TInt winType=aInt/CTWindowTest::EWinTypeFactor;
sl@0
   853
	TInt func=aInt%CTWindowTest::EWinTypeFactor;
sl@0
   854
	RWsSession ws;
sl@0
   855
	User::LeaveIfError(ws.Connect());
sl@0
   856
	// use correct screen
sl@0
   857
	//
sl@0
   858
	CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
sl@0
   859
	User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
sl@0
   860
sl@0
   861
	RWindowGroup group(ws);
sl@0
   862
	group.Construct(888);
sl@0
   863
	group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
sl@0
   864
 	RWindow window(ws);
sl@0
   865
	window.Construct(group,789);
sl@0
   866
	RWindowTreeNode* win;
sl@0
   867
	if (winType==1)
sl@0
   868
		win=&window;
sl@0
   869
	else
sl@0
   870
		win=&group;
sl@0
   871
sl@0
   872
	return CallWindowFuction(win,winType,func,ws);
sl@0
   873
	}
sl@0
   874
sl@0
   875
//PanicTestNoPanic
sl@0
   876
//This function is called from DoPanicTest4 for window functions that should run without
sl@0
   877
//panicking the user thread if its parent has been deleted.
sl@0
   878
TInt PanicTestNoPanic(RWindowTreeNode* aWin,TInt aWinType,TInt aFunc,RWsSession aWs,const TInt* const aFuncToSkip)
sl@0
   879
	{
sl@0
   880
	TInt funcReturn;
sl@0
   881
	for(;;)
sl@0
   882
		{
sl@0
   883
		if (aFuncToSkip && *aFuncToSkip == aFunc)
sl@0
   884
			{
sl@0
   885
			aFunc++;
sl@0
   886
			}
sl@0
   887
		funcReturn = CallWindowFuction(aWin,aWinType,aFunc,aWs);
sl@0
   888
		if (funcReturn==EWsExitReasonBad)
sl@0
   889
			{
sl@0
   890
			aFunc++;
sl@0
   891
			}
sl@0
   892
		else if (funcReturn==EWsExitReasonFinished)
sl@0
   893
			{
sl@0
   894
			return EWsExitReasonFinished;
sl@0
   895
			}
sl@0
   896
		else
sl@0
   897
			{
sl@0
   898
			return EWsExitReasonBad;
sl@0
   899
			}
sl@0
   900
		}
sl@0
   901
	}
sl@0
   902
sl@0
   903
LOCAL_C TInt DoPanicTest4(TInt aInt, TAny *aScreenNumber)
sl@0
   904
	{
sl@0
   905
 	TInt winType=aInt/CTWindowTest::EWinTypeFactor;
sl@0
   906
	TInt func=aInt%CTWindowTest::EWinTypeFactor;
sl@0
   907
	RWsSession ws;
sl@0
   908
	User::LeaveIfError(ws.Connect());
sl@0
   909
	// use correct screen
sl@0
   910
	//
sl@0
   911
	CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
sl@0
   912
	User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
sl@0
   913
sl@0
   914
	RWindowGroup group(ws);
sl@0
   915
	group.Construct(234);
sl@0
   916
	group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
sl@0
   917
 	RWindow window(ws);
sl@0
   918
	window.Construct(group,897);
sl@0
   919
	RBackedUpWindow backedUp(ws);
sl@0
   920
	backedUp.Construct(group,EGray16,98);
sl@0
   921
	RBlankWindow blank(ws);
sl@0
   922
	blank.Construct(group,169);
sl@0
   923
	RWindowTreeNode* win=&window;
sl@0
   924
	switch (winType)
sl@0
   925
		{
sl@0
   926
	case 0:
sl@0
   927
		{
sl@0
   928
		if (func > 8)			//if a func 8+ had panicked, fail the test
sl@0
   929
			{
sl@0
   930
			return EWsExitReasonBad;
sl@0
   931
			}
sl@0
   932
		else if (func==8)
sl@0
   933
			{
sl@0
   934
			group.Close();
sl@0
   935
			return PanicTestNoPanic(win,winType,func,ws,NULL);
sl@0
   936
			}
sl@0
   937
		}
sl@0
   938
		break;
sl@0
   939
	case 2:
sl@0
   940
		{
sl@0
   941
		if (func>9)			//if a func 9+ had panicked, fail the test
sl@0
   942
			{
sl@0
   943
			return EWsExitReasonBad;
sl@0
   944
			}
sl@0
   945
		else if (func==9)	//set window visible so that SetVisible(EFalse) (func 9) would crash before fix
sl@0
   946
			{
sl@0
   947
			window.SetVisible(ETrue);
sl@0
   948
			ws.Flush();
sl@0
   949
			group.Close();
sl@0
   950
			TInt funcToSkip = 28;	//this call needs to have already successfully allocated a pointer cursor
sl@0
   951
			return PanicTestNoPanic(win,winType,func,ws,&funcToSkip);
sl@0
   952
			}
sl@0
   953
		}
sl@0
   954
		break;
sl@0
   955
	case 4:
sl@0
   956
		{
sl@0
   957
		win=&blank;
sl@0
   958
		if (func>2)			//if a func 2+ had panicked, fail the test
sl@0
   959
			{
sl@0
   960
			return EWsExitReasonBad;
sl@0
   961
			}
sl@0
   962
		else if (func==2)
sl@0
   963
			{
sl@0
   964
			group.Close();
sl@0
   965
			return PanicTestNoPanic(win,winType,func,ws,NULL);
sl@0
   966
			}
sl@0
   967
		}
sl@0
   968
		break;
sl@0
   969
	case 5:
sl@0
   970
		{
sl@0
   971
		if (func>6)			//if a func 4+ had panicked, fail the test
sl@0
   972
			{
sl@0
   973
			return EWsExitReasonBad;
sl@0
   974
			}
sl@0
   975
		else if (func==4 || func==5)
sl@0
   976
			{
sl@0
   977
			if (CallWindowFuction(win,winType,func,ws)==EWsExitReasonBad)
sl@0
   978
				{
sl@0
   979
				func = 1;
sl@0
   980
				}
sl@0
   981
			else
sl@0
   982
				{
sl@0
   983
				return EWsExitReasonBad;
sl@0
   984
				}
sl@0
   985
			}
sl@0
   986
		else if (func==6)
sl@0
   987
			{
sl@0
   988
			group.Close();
sl@0
   989
			TInt funcToSkip = 6;	//Skip the call to EndRedraw in CallWindowFunction, it is not safe to call it on Window casts.
sl@0
   990
			return PanicTestNoPanic(win,winType,func,ws,&funcToSkip);
sl@0
   991
			}
sl@0
   992
		}
sl@0
   993
		break;
sl@0
   994
	case 6:
sl@0
   995
		{
sl@0
   996
		win=&backedUp;
sl@0
   997
		if (func>0)
sl@0
   998
			return EWsExitReasonBad;
sl@0
   999
		else		//if (func==0)
sl@0
  1000
			{
sl@0
  1001
			TInt end=2;
sl@0
  1002
			while (func==0)
sl@0
  1003
				{
sl@0
  1004
				group.Close();
sl@0
  1005
				while (CallWindowFuction(win,winType,func,ws)==EWsExitReasonBad && ++func<end)
sl@0
  1006
					{}
sl@0
  1007
				if (func==end && end==2)
sl@0
  1008
					{
sl@0
  1009
					func=0;
sl@0
  1010
					end=4;
sl@0
  1011
					}
sl@0
  1012
				}
sl@0
  1013
			if (func==end)
sl@0
  1014
				return EWsExitReasonFinished;
sl@0
  1015
			else
sl@0
  1016
				return EWsExitReasonBad;
sl@0
  1017
			}
sl@0
  1018
		}
sl@0
  1019
		/*break;*/
sl@0
  1020
	default:;
sl@0
  1021
		}
sl@0
  1022
	group.Close();
sl@0
  1023
	return CallWindowFuction(win,winType,func,ws);
sl@0
  1024
	}
sl@0
  1025
sl@0
  1026
LOCAL_C TInt DoPanicTest5(TInt aTest, TAny *aScreenNumber)
sl@0
  1027
	{
sl@0
  1028
	RWsSession ws;
sl@0
  1029
	User::LeaveIfError(ws.Connect());
sl@0
  1030
sl@0
  1031
	CWsScreenDevice *scrDev=new(ELeave) CWsScreenDevice(ws);
sl@0
  1032
	scrDev->Construct((TInt)aScreenNumber);
sl@0
  1033
sl@0
  1034
	RWindowGroup group(ws);
sl@0
  1035
	group.Construct(235);
sl@0
  1036
	group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
sl@0
  1037
 	RWindow window(ws);
sl@0
  1038
	window.Construct(group,896);
sl@0
  1039
	CWindowGc *gc=new(ELeave) CWindowGc(scrDev);
sl@0
  1040
	gc->Construct();
sl@0
  1041
	gc->Activate(window);
sl@0
  1042
	group.Close();
sl@0
  1043
	switch (aTest)
sl@0
  1044
		{
sl@0
  1045
	case 0:
sl@0
  1046
		gc->Deactivate();
sl@0
  1047
		gc->Activate(window);
sl@0
  1048
		break;
sl@0
  1049
	case 1:
sl@0
  1050
		gc->DrawLine(TPoint(0,0),TPoint(10,10));
sl@0
  1051
		break;
sl@0
  1052
	default:
sl@0
  1053
		return(EWsExitReasonFinished);
sl@0
  1054
		}
sl@0
  1055
	ws.Flush();
sl@0
  1056
	return(EWsExitReasonBad);	// Should never get here, but it's baaddd if it does
sl@0
  1057
	}
sl@0
  1058
sl@0
  1059
#if defined(_DEBUG)
sl@0
  1060
LOCAL_C TInt DoPanicTest6(TInt /*aInt*/, TAny *aScreenNumber)
sl@0
  1061
	{
sl@0
  1062
	RWsSession ws;
sl@0
  1063
	User::LeaveIfError(ws.Connect());
sl@0
  1064
	RWindowGroup group1(ws);
sl@0
  1065
	CWsScreenDevice* screen=new(ELeave) CWsScreenDevice(ws);
sl@0
  1066
	User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
sl@0
  1067
	group1.Construct(123456,ETrue,screen);
sl@0
  1068
	RWindowGroup group2(ws);
sl@0
  1069
	group2.Construct(123456,ETrue,screen);	// Should panic client here
sl@0
  1070
	return(EWsExitReasonBad);	// Should never get here
sl@0
  1071
	}
sl@0
  1072
#endif
sl@0
  1073
sl@0
  1074
void CTWindowTest::TestInvalidFunctionsL()
sl@0
  1075
//
sl@0
  1076
// This code casts windows to be different types and then sends messages for the 'cast' that
sl@0
  1077
// should not be sent to the original type of window. These should all result in panics
sl@0
  1078
//
sl@0
  1079
	{
sl@0
  1080
	static TClientPanic PanicCode[]={EWservPanicDescriptor,EWservPanicDescriptor,EWservPanicDescriptor,
sl@0
  1081
									 EWservPanicNoPointerBuffer,EWservPanicBackupDisplayMode,
sl@0
  1082
									 EWservPanicNoFont};	// Dummy end value to catch out overflowing the array
sl@0
  1083
	INFO_PRINTF1(_L("AUTO  Test Invalid Functions "));
sl@0
  1084
	INFO_PRINTF1(_L(" Opcode Panics"));
sl@0
  1085
sl@0
  1086
	for (TInt source=0;source<3;source++)
sl@0
  1087
		for (TInt target=0;target<3;target++)
sl@0
  1088
			if (source!=target)
sl@0
  1089
				for (TInt panic=0;;panic++)
sl@0
  1090
					{
sl@0
  1091
					TBool testFinished=EFalse;
sl@0
  1092
					TEST(iTest->TestWsPanicL(DoPanicTest,EWservPanicOpcode,source*10000+target*100+panic,(TAny*)iTest->iScreenNumber,&testFinished));
sl@0
  1093
					if (testFinished)
sl@0
  1094
						break;
sl@0
  1095
					}
sl@0
  1096
	_LIT(KSet,"Various Different Panics");
sl@0
  1097
	INFO_PRINTF1(KSet);
sl@0
  1098
	RDebug::Print(KPlatsecBegin);
sl@0
  1099
	for(TInt index=0;;index++)
sl@0
  1100
		{
sl@0
  1101
		TBool testFinished=EFalse;
sl@0
  1102
		TEST(iTest->TestWsPanicL(DoPanicTest2,PanicCode[index],index,(TAny*)iTest->iScreenNumber,&testFinished));
sl@0
  1103
		if (testFinished)
sl@0
  1104
			break;
sl@0
  1105
		}
sl@0
  1106
	RDebug::Print(KPlatsecEnd);
sl@0
  1107
	iTest->CloseAllPanicWindows();
sl@0
  1108
	}
sl@0
  1109
sl@0
  1110
void CTWindowTest::ShadowAutoClearTest()
sl@0
  1111
	{
sl@0
  1112
	RWindowGroup group(TheClient->iWs);
sl@0
  1113
	group.Construct(1111);
sl@0
  1114
	group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
sl@0
  1115
sl@0
  1116
	RWindow background(TheClient->iWs);
sl@0
  1117
	background.Construct(group,133);
sl@0
  1118
	background.SetBackgroundColor();
sl@0
  1119
	background.Activate();
sl@0
  1120
sl@0
  1121
	background.BeginRedraw();
sl@0
  1122
	TheClient->iGc->Activate(background);
sl@0
  1123
	TheClient->iGc->SetBrushColor(TRgb::Gray4(1));
sl@0
  1124
	TheClient->iGc->Clear();
sl@0
  1125
	background.EndRedraw();
sl@0
  1126
//
sl@0
  1127
	RBlankWindow tab2(TheClient->iWs);
sl@0
  1128
	tab2.Construct(group,144);
sl@0
  1129
	tab2.SetExtent(TPoint(10,00),TSize(200,10));
sl@0
  1130
	tab2.SetColor(TRgb::Gray256(170));
sl@0
  1131
	tab2.SetShadowHeight(1);
sl@0
  1132
	tab2.Activate();
sl@0
  1133
	RBlankWindow tab1(TheClient->iWs);
sl@0
  1134
	tab1.Construct(group,155);
sl@0
  1135
	tab1.SetExtent(TPoint(70,00),TSize(10,10));
sl@0
  1136
	tab1.SetColor(TRgb::Gray256(170));
sl@0
  1137
	tab1.SetShadowHeight(1);
sl@0
  1138
	tab1.Activate();
sl@0
  1139
	RBlankWindow blank(TheClient->iWs);
sl@0
  1140
	blank.Construct(group,156);
sl@0
  1141
	blank.SetExtent(TPoint(50,10),TSize(100,100));
sl@0
  1142
	blank.SetColor(TRgb::Gray256(170));
sl@0
  1143
	blank.SetShadowHeight(0);
sl@0
  1144
	blank.Activate();
sl@0
  1145
//
sl@0
  1146
	tab1.Close();
sl@0
  1147
	tab1.Construct(group,166);
sl@0
  1148
	tab1.SetExtent(TPoint(50,00),TSize(10,10));
sl@0
  1149
	tab1.SetColor(TRgb::Gray256(170));
sl@0
  1150
	tab1.SetShadowHeight(1);
sl@0
  1151
	tab1.Activate();
sl@0
  1152
	blank.Close();
sl@0
  1153
	RBlankWindow blank2(TheClient->iWs);
sl@0
  1154
	blank2.Construct(group,177);
sl@0
  1155
	blank2.SetColor(TRgb::Gray256(255));
sl@0
  1156
	blank2.SetExtent(TPoint(10,10),TSize(100,120));
sl@0
  1157
	blank2.SetShadowHeight(2);
sl@0
  1158
	blank2.Activate();
sl@0
  1159
	TheClient->iWs.Flush();
sl@0
  1160
//
sl@0
  1161
	background.BeginRedraw();
sl@0
  1162
	TheClient->iGc->SetBrushColor(TRgb::Gray4(1));
sl@0
  1163
	TheClient->iGc->Clear();
sl@0
  1164
	background.EndRedraw();
sl@0
  1165
//
sl@0
  1166
	tab1.Close();
sl@0
  1167
	tab2.Close();
sl@0
  1168
	blank2.Close();
sl@0
  1169
	background.BeginRedraw();
sl@0
  1170
	TheClient->iGc->Clear();
sl@0
  1171
	TheClient->iGc->Deactivate();
sl@0
  1172
	background.EndRedraw();
sl@0
  1173
	TheClient->iWs.Finish();
sl@0
  1174
	TSize size=TheClient->iScreen->SizeInPixels();
sl@0
  1175
	TBool rectCompare = TheClient->iScreen->RectCompare(TRect(0,0,size.iWidth>>1,size.iHeight),TRect(size.iWidth>>1,0,(size.iWidth>>1)<<1,size.iHeight));	
sl@0
  1176
	TEST(rectCompare);
sl@0
  1177
	if(!rectCompare)
sl@0
  1178
		INFO_PRINTF3(_L("TheClient->iScreen->RectCompare return value - Expected: %d, Actual: %d"), ETrue, rectCompare);
sl@0
  1179
	background.Close();
sl@0
  1180
	group.Close();
sl@0
  1181
	}
sl@0
  1182
sl@0
  1183
void CTWindowTest::ClearRedraw(RWindow &aWindow, TRgb aRgb)
sl@0
  1184
	{
sl@0
  1185
	aWindow.BeginRedraw();
sl@0
  1186
	TheClient->iGc->Activate(aWindow);
sl@0
  1187
	TheClient->iGc->SetBrushColor(aRgb);
sl@0
  1188
	TheClient->iGc->Clear();
sl@0
  1189
	TheClient->iGc->Deactivate();
sl@0
  1190
	aWindow.EndRedraw();
sl@0
  1191
	}
sl@0
  1192
sl@0
  1193
void CTWindowTest::CheckCorner(TCorner aCorner, const TInt *aInsetList)
sl@0
  1194
	{
sl@0
  1195
	TRect rect(TPoint(1,1),iBlankWin2->Size());
sl@0
  1196
	TPoint pos;
sl@0
  1197
	TInt direction;
sl@0
  1198
	if (aCorner==ECornerTL || aCorner==ECornerTR)
sl@0
  1199
		{
sl@0
  1200
		pos.iY=rect.iTl.iY;
sl@0
  1201
		direction=1;
sl@0
  1202
		}
sl@0
  1203
	else
sl@0
  1204
		{
sl@0
  1205
		pos.iY=rect.iBr.iY-1;
sl@0
  1206
		direction= -1;
sl@0
  1207
		}
sl@0
  1208
	if (aCorner==ECornerTL || aCorner==ECornerBL)
sl@0
  1209
		pos.iX=rect.iTl.iX;
sl@0
  1210
	else
sl@0
  1211
		pos.iX=rect.iBr.iX-8;
sl@0
  1212
	TRgb rgbBuf[8];
sl@0
  1213
	TPtr8 desc((TUint8 *)rgbBuf,sizeof(rgbBuf));
sl@0
  1214
	for(TInt count=0;count<ENumCornerInsets;count++,pos.iY+=direction)
sl@0
  1215
		{
sl@0
  1216
		iScreenDev->GetScanLine(desc,pos,8,EColor16MA);
sl@0
  1217
		if (aCorner==ECornerTR || aCorner==ECornerBR)
sl@0
  1218
			{
sl@0
  1219
			for(TInt loop=0;loop<4;loop++)
sl@0
  1220
				{
sl@0
  1221
				TRgb tmp=rgbBuf[loop];
sl@0
  1222
				rgbBuf[loop]=rgbBuf[8-1-loop];
sl@0
  1223
				rgbBuf[8-1-loop]=tmp;
sl@0
  1224
				}
sl@0
  1225
			}
sl@0
  1226
		// We can't compare rgb value from original source against screen value in EColor64K mode as
sl@0
  1227
		// the color component might be truncated (EColor64K is 16-bit using format RGB565),
sl@0
  1228
		// ie R or B components might be reduced from 8-bit to 5-bit and G from 8-bit to 6-bit
sl@0
  1229
		//
sl@0
  1230
		// For example: RGB value of Gray4(1) is 0x555555, it is drawn to screen in RGB565 as 0x52AA,
sl@0
  1231
		// when it's converted back to RGB for comparison, the value becomes 0x525552
sl@0
  1232
		TRgb col1=TRgb::Gray4(1);
sl@0
  1233
		TRgb col2=TRgb::Gray4(3);
sl@0
  1234
		if (iScreenDev->DisplayMode()==EColor64K)
sl@0
  1235
			{
sl@0
  1236
			col1=TRgb::Color64K(col1.Color64K());
sl@0
  1237
			col2=TRgb::Color64K(col2.Color64K());
sl@0
  1238
			}
sl@0
  1239
		TInt loop2=0;
sl@0
  1240
		for(;loop2<aInsetList[count];loop2++)
sl@0
  1241
			{	
sl@0
  1242
			TEST(rgbBuf[loop2]==col1);				
sl@0
  1243
			}
sl@0
  1244
		for(;loop2<8;loop2++)
sl@0
  1245
			{		
sl@0
  1246
			TEST(rgbBuf[loop2]==col2);
sl@0
  1247
			}
sl@0
  1248
		}
sl@0
  1249
	}
sl@0
  1250
sl@0
  1251
void CTWindowTest::doCornerTest(TCornerType aCornerType, TInt aFlags)
sl@0
  1252
	{
sl@0
  1253
	const TInt *corners=corner0;
sl@0
  1254
	switch(aCornerType)
sl@0
  1255
		{
sl@0
  1256
		case EWindowCorner1:
sl@0
  1257
			corners=corner1;
sl@0
  1258
			break;
sl@0
  1259
		case EWindowCorner2:
sl@0
  1260
			corners=corner2;
sl@0
  1261
			break;
sl@0
  1262
		case EWindowCorner3:
sl@0
  1263
			corners=corner3;
sl@0
  1264
			break;
sl@0
  1265
		case EWindowCorner5:
sl@0
  1266
			corners=corner5;
sl@0
  1267
			break;
sl@0
  1268
		default:
sl@0
  1269
			break;
sl@0
  1270
		}
sl@0
  1271
	iBlankWin2->BaseWin()->SetCornerType(aCornerType,aFlags);
sl@0
  1272
	if (!(aFlags&EWindowCornerNotTL))
sl@0
  1273
		CheckCorner(ECornerTL, corners);
sl@0
  1274
	if (!(aFlags&EWindowCornerNotTR))
sl@0
  1275
		CheckCorner(ECornerTR, corners);
sl@0
  1276
	if (!(aFlags&EWindowCornerNotBL))
sl@0
  1277
		CheckCorner(ECornerBL, corners);
sl@0
  1278
	if (!(aFlags&EWindowCornerNotBR))
sl@0
  1279
		CheckCorner(ECornerBR, corners);
sl@0
  1280
//
sl@0
  1281
	if (aFlags&EWindowCornerNotTL)
sl@0
  1282
		CheckCorner(ECornerTL, corner0);
sl@0
  1283
	if (aFlags&EWindowCornerNotTR)
sl@0
  1284
		CheckCorner(ECornerTR, corner0);
sl@0
  1285
	if (aFlags&EWindowCornerNotBL)
sl@0
  1286
		CheckCorner(ECornerBL, corner0);
sl@0
  1287
	if (aFlags&EWindowCornerNotBR)
sl@0
  1288
		CheckCorner(ECornerBR, corner0);
sl@0
  1289
	}
sl@0
  1290
sl@0
  1291
void CTWindowTest::doCornerTestsL()
sl@0
  1292
	{
sl@0
  1293
	iScreenDev=new(ELeave) CWsScreenDevice(TheClient->iWs);
sl@0
  1294
	User::LeaveIfError(iScreenDev->Construct(iTest->iScreenNumber));
sl@0
  1295
	iBlankWin1=new(ELeave) CTBlankWindow();
sl@0
  1296
	iBlankWin1->SetUpL(TPoint(1,1),TSize(100,50),TheClient->iGroup,*TheClient->iGc);
sl@0
  1297
	iBlankWin1->SetColor(TRgb::Gray4(1));
sl@0
  1298
	iBlankWin2=new(ELeave) CTBlankWindow();
sl@0
  1299
	iBlankWin2->SetUpL(TPoint(1,1),iBlankWin1->Size(),TheClient->iGroup,*TheClient->iGc);
sl@0
  1300
	iBlankWin2->SetColor(TRgb::Gray4(3));
sl@0
  1301
	iBlankWin2->BaseWin()->SetShadowHeight(0);
sl@0
  1302
	doCornerTest(EWindowCornerSquare,0);
sl@0
  1303
	doCornerTest(EWindowCornerSquare,EWindowCornerNotBL);
sl@0
  1304
	doCornerTest(EWindowCorner1,0);	// 0 + all corners missing
sl@0
  1305
	doCornerTest(EWindowCorner1,EWindowCornerNotTL|EWindowCornerNotTR|EWindowCornerNotBL|EWindowCornerNotBR);
sl@0
  1306
	doCornerTest(EWindowCorner2,0);	// 0 + all sets of 3 corners missing
sl@0
  1307
	doCornerTest(EWindowCorner2,EWindowCornerNotTR|EWindowCornerNotBL|EWindowCornerNotBR);
sl@0
  1308
	doCornerTest(EWindowCorner2,EWindowCornerNotTL|EWindowCornerNotBL|EWindowCornerNotBR);
sl@0
  1309
	doCornerTest(EWindowCorner2,EWindowCornerNotTL|EWindowCornerNotTR|EWindowCornerNotBR);
sl@0
  1310
	doCornerTest(EWindowCorner2,EWindowCornerNotTL|EWindowCornerNotTR|EWindowCornerNotBL);
sl@0
  1311
	doCornerTest(EWindowCorner3,0);	// 0 + all 4 individual corners missing
sl@0
  1312
	doCornerTest(EWindowCorner3,EWindowCornerNotTL);
sl@0
  1313
	doCornerTest(EWindowCorner3,EWindowCornerNotTR);
sl@0
  1314
	doCornerTest(EWindowCorner3,EWindowCornerNotBL);
sl@0
  1315
	doCornerTest(EWindowCorner3,EWindowCornerNotBR);
sl@0
  1316
	doCornerTest(EWindowCorner5,0);	// 0 + all pairs of corners missing
sl@0
  1317
	doCornerTest(EWindowCorner5,EWindowCornerNotTL|EWindowCornerNotTR);
sl@0
  1318
	doCornerTest(EWindowCorner5,EWindowCornerNotTL|EWindowCornerNotBL);
sl@0
  1319
	doCornerTest(EWindowCorner5,EWindowCornerNotTL|EWindowCornerNotBR);
sl@0
  1320
	doCornerTest(EWindowCorner5,EWindowCornerNotTR|EWindowCornerNotBL);
sl@0
  1321
	doCornerTest(EWindowCorner5,EWindowCornerNotTR|EWindowCornerNotBR);
sl@0
  1322
	doCornerTest(EWindowCorner5,EWindowCornerNotBL|EWindowCornerNotBR);
sl@0
  1323
	}
sl@0
  1324
sl@0
  1325
void CTWindowTest::CornerTests()
sl@0
  1326
	{
sl@0
  1327
	TRAP_IGNORE(doCornerTestsL());
sl@0
  1328
	delete iBlankWin2;
sl@0
  1329
	delete iBlankWin1;
sl@0
  1330
	delete iScreenDev;
sl@0
  1331
	}
sl@0
  1332
sl@0
  1333
LOCAL_C void doMegaTreeThread(TInt aScreenNumber)
sl@0
  1334
	{
sl@0
  1335
	CTrapCleanup::New();
sl@0
  1336
	RWsSession ws;
sl@0
  1337
	ws.Connect();
sl@0
  1338
	CWsScreenDevice *scrDev=new(ELeave) CWsScreenDevice(ws);
sl@0
  1339
	scrDev->Construct(aScreenNumber);
sl@0
  1340
	RWindowGroup group(ws);
sl@0
  1341
	group.Construct(1);
sl@0
  1342
	group.EnableReceiptOfFocus(EFalse);
sl@0
  1343
	RWindow parent(ws);
sl@0
  1344
	parent.Construct(group,123);
sl@0
  1345
	parent.Activate();
sl@0
  1346
	CWindowGc *gc=new(ELeave) CWindowGc(scrDev);
sl@0
  1347
	gc->Construct();
sl@0
  1348
	TSize max(parent.Size());
sl@0
  1349
	RWindow prev=parent;
sl@0
  1350
	TBool horiz=EFalse;
sl@0
  1351
	TInt color=0;
sl@0
  1352
	for(TInt count=0;count<100;count++)
sl@0
  1353
		{
sl@0
  1354
		RWindow win(ws);
sl@0
  1355
		if (win.Construct(prev,ENullWsHandle)!=KErrNone)
sl@0
  1356
			break;
sl@0
  1357
		win.SetExtent(horiz?TPoint(1,0):TPoint(0,1),max);
sl@0
  1358
		win.SetBackgroundColor(TRgb::Gray4(color));
sl@0
  1359
		color=(color+1)%4;
sl@0
  1360
		win.Activate();
sl@0
  1361
		win.BeginRedraw();
sl@0
  1362
		gc->Activate(win);
sl@0
  1363
		gc->Clear();
sl@0
  1364
		gc->Deactivate();
sl@0
  1365
		win.EndRedraw();
sl@0
  1366
		prev=win;
sl@0
  1367
		horiz=!horiz;
sl@0
  1368
		}
sl@0
  1369
	parent.SetVisible(EFalse);
sl@0
  1370
	parent.SetVisible(ETrue);
sl@0
  1371
	parent.SetPosition(TPoint(-1,-1));
sl@0
  1372
	parent.SetPosition(TPoint(0,0));
sl@0
  1373
	parent.Close();
sl@0
  1374
	ws.Close();
sl@0
  1375
	}
sl@0
  1376
sl@0
  1377
LOCAL_C TInt MegaTreeThread(TAny *aScreenNumber)
sl@0
  1378
	{
sl@0
  1379
	TRAPD(err,doMegaTreeThread((TInt)aScreenNumber));
sl@0
  1380
	return(err);
sl@0
  1381
	}
sl@0
  1382
sl@0
  1383
void CTWindowTest::CreateMegaTree()
sl@0
  1384
	{
sl@0
  1385
	const TUint KThreadHeapSize=0x2000;
sl@0
  1386
	RThread thread;
sl@0
  1387
	if (thread.Create(_L("MegaTree"),MegaTreeThread,KDefaultStackSize,KThreadHeapSize,KThreadHeapSize,(TAny*)iTest->iScreenNumber,EOwnerThread)==KErrNone)
sl@0
  1388
		{
sl@0
  1389
		TRequestStatus stat;
sl@0
  1390
		thread.Logon(stat);
sl@0
  1391
		thread.Resume();
sl@0
  1392
		User::WaitForRequest(stat);		
sl@0
  1393
		TEST(stat==KErrNone);
sl@0
  1394
		}
sl@0
  1395
	thread.Close();
sl@0
  1396
	}
sl@0
  1397
sl@0
  1398
void CTWindowTest::TiledWindowTestL()
sl@0
  1399
	{
sl@0
  1400
	RWindow parent(TheClient->iWs);
sl@0
  1401
	User::LeaveIfError(parent.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle));
sl@0
  1402
	CleanupStack::PushL(TCleanupItem(CleanUpWindow,&parent));
sl@0
  1403
	parent.SetExtent(TPoint(10,10),TSize(50,50));
sl@0
  1404
	parent.Activate();
sl@0
  1405
//
sl@0
  1406
	RWindow child1(TheClient->iWs);
sl@0
  1407
	User::LeaveIfError(child1.Construct(parent,ENullWsHandle));
sl@0
  1408
	CleanupStack::PushL(TCleanupItem(CleanUpWindow,&child1));
sl@0
  1409
	child1.SetExtent(TPoint(0,0),TSize(50,20));
sl@0
  1410
	child1.Activate();
sl@0
  1411
//
sl@0
  1412
	RWindow child2(TheClient->iWs);
sl@0
  1413
	User::LeaveIfError(child2.Construct(parent,ENullWsHandle));
sl@0
  1414
	CleanupStack::PushL(TCleanupItem(CleanUpWindow,&child2));
sl@0
  1415
	child2.SetExtent(TPoint(0,20),TSize(50,30));
sl@0
  1416
	child2.Activate();
sl@0
  1417
//
sl@0
  1418
	child1.BeginRedraw();
sl@0
  1419
	TSize rect1Size(25,20);
sl@0
  1420
	TheGc->Activate(child1);
sl@0
  1421
	TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
  1422
	TheGc->DrawRect(TRect(rect1Size));
sl@0
  1423
	TheGc->DrawRect(TRect(TPoint(rect1Size.iWidth,0),rect1Size));
sl@0
  1424
	TheGc->Deactivate();
sl@0
  1425
	child1.EndRedraw();
sl@0
  1426
//
sl@0
  1427
	child2.BeginRedraw();
sl@0
  1428
	TSize rect2Size(25,30);
sl@0
  1429
	TheGc->Activate(child2);
sl@0
  1430
	TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
  1431
	TheGc->DrawRect(TRect(rect2Size));
sl@0
  1432
	TheGc->DrawRect(TRect(TPoint(rect2Size.iWidth,0),rect2Size));
sl@0
  1433
	TheGc->Deactivate();
sl@0
  1434
	child2.EndRedraw();
sl@0
  1435
//
sl@0
  1436
// Left and right halves should be identical
sl@0
  1437
//
sl@0
  1438
	TBool rectCompare = !TheClient->iScreen->RectCompare(TRect(10,10,35,60),TRect(35,10,70,60));	
sl@0
  1439
	TEST(rectCompare);
sl@0
  1440
	if(!rectCompare)
sl@0
  1441
		INFO_PRINTF3(_L("TheClient->iScreen->RectCompare return value - Expected: %d, Actual: %d"), ETrue, rectCompare);
sl@0
  1442
//
sl@0
  1443
	CleanupStack::PopAndDestroy(3);
sl@0
  1444
	}
sl@0
  1445
sl@0
  1446
void CTWindowTest::TiledWindowTest2L()
sl@0
  1447
	{
sl@0
  1448
	TSize size(200,240);		//Parent Windows
sl@0
  1449
	TSize childSize(TSize(size.iWidth/2,size.iHeight/2));		//Child Windows
sl@0
  1450
	TSize dialogueSize(50,50);
sl@0
  1451
sl@0
  1452
	TheClient->iWs.SetAutoFlush(ETrue);
sl@0
  1453
	RBlankWindow parent1(TheClient->iWs);
sl@0
  1454
	User::LeaveIfError(parent1.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle));
sl@0
  1455
	CleanupStack::PushL(TCleanupItem(CleanUpWindow,&parent1));
sl@0
  1456
	parent1.SetExtent(TPoint(240,0),size);
sl@0
  1457
	parent1.SetColor(TRgb::Gray4(2));
sl@0
  1458
	parent1.Activate();
sl@0
  1459
sl@0
  1460
	TheClient->iWs.SetAutoFlush(ETrue);
sl@0
  1461
	RBlankWindow parent2(TheClient->iWs);
sl@0
  1462
	User::LeaveIfError(parent2.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle));
sl@0
  1463
	CleanupStack::PushL(TCleanupItem(CleanUpWindow,&parent2));
sl@0
  1464
	parent2.SetExtent(TPoint(440,0),size);
sl@0
  1465
	parent2.SetColor(TRgb::Gray4(2));
sl@0
  1466
	parent2.Activate();
sl@0
  1467
sl@0
  1468
	TheClient->iWs.SetAutoFlush(ETrue);
sl@0
  1469
	RBlankWindow child1(TheClient->iWs);
sl@0
  1470
	User::LeaveIfError(child1.Construct(parent1,ENullWsHandle));
sl@0
  1471
	CleanupStack::PushL(TCleanupItem(CleanUpWindow,&child1));
sl@0
  1472
	child1.SetExtent(TPoint(0,0),childSize);
sl@0
  1473
	child1.SetColor(TRgb::Gray4(2));
sl@0
  1474
	child1.Activate();
sl@0
  1475
sl@0
  1476
	TheClient->iWs.SetAutoFlush(ETrue);
sl@0
  1477
	RBlankWindow child2(TheClient->iWs);
sl@0
  1478
	User::LeaveIfError(child2.Construct(parent1,ENullWsHandle));
sl@0
  1479
	CleanupStack::PushL(TCleanupItem(CleanUpWindow,&child2));
sl@0
  1480
	child2.SetExtent(TPoint(0,childSize.iHeight),childSize);
sl@0
  1481
	child2.SetColor(TRgb::Gray4(2));
sl@0
  1482
	child2.Activate();
sl@0
  1483
sl@0
  1484
	TheClient->iWs.SetAutoFlush(ETrue);
sl@0
  1485
	RBlankWindow child3(TheClient->iWs);
sl@0
  1486
	User::LeaveIfError(child3.Construct(parent1,ENullWsHandle));
sl@0
  1487
	CleanupStack::PushL(TCleanupItem(CleanUpWindow,&child3));
sl@0
  1488
	child3.SetExtent(TPoint(childSize.iWidth,0),TSize(childSize.iWidth,size.iHeight));
sl@0
  1489
	child3.SetColor(TRgb::Gray4(2));
sl@0
  1490
	child3.Activate();
sl@0
  1491
sl@0
  1492
	TPoint dialoguePos(375,93);
sl@0
  1493
	TheClient->iWs.SetAutoFlush(ETrue);
sl@0
  1494
	RBlankWindow dialog1(TheClient->iWs);
sl@0
  1495
	User::LeaveIfError(dialog1.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle));
sl@0
  1496
	CleanupStack::PushL(TCleanupItem(CleanUpWindow,&dialog1));
sl@0
  1497
	dialog1.SetExtent(dialoguePos,dialogueSize);
sl@0
  1498
	dialog1.SetColor(TRgb::Gray4(3));
sl@0
  1499
	dialog1.SetShadowHeight(4);
sl@0
  1500
	dialog1.Activate();
sl@0
  1501
sl@0
  1502
	TheClient->iWs.SetAutoFlush(ETrue);
sl@0
  1503
	RBlankWindow dialog2(TheClient->iWs);
sl@0
  1504
	User::LeaveIfError(dialog2.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle));
sl@0
  1505
	CleanupStack::PushL(TCleanupItem(CleanUpWindow,&dialog2));
sl@0
  1506
	dialog2.SetExtent(TPoint(dialoguePos.iX+size.iWidth,dialoguePos.iY),dialogueSize);
sl@0
  1507
	dialog2.SetColor(TRgb::Gray4(3));
sl@0
  1508
	dialog2.SetShadowHeight(0);
sl@0
  1509
	dialog2.Activate();
sl@0
  1510
sl@0
  1511
	TInt ii;
sl@0
  1512
	for (ii=400;ii>374;ii-=25)
sl@0
  1513
		dialog1.SetPosition(TPoint(ii,93));
sl@0
  1514
	TheClient->iWs.SetAutoFlush(EFalse);
sl@0
  1515
	CleanupStack::PopAndDestroy(7);
sl@0
  1516
	}
sl@0
  1517
sl@0
  1518
void CTWindowTest::ColorTestL()
sl@0
  1519
	{
sl@0
  1520
	if (iTest->MaxGrays() == 0)
sl@0
  1521
		return;
sl@0
  1522
sl@0
  1523
	_LIT(KSet,"AUTO  Color Test ");
sl@0
  1524
	INFO_PRINTF1(KSet);
sl@0
  1525
	RWindow window(TheClient->iWs);
sl@0
  1526
	User::LeaveIfError(window.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle));
sl@0
  1527
	PushWindowL(&window);
sl@0
  1528
	window.SetExtent(TPoint(10,10),TSize(50,50));
sl@0
  1529
	window.Activate();
sl@0
  1530
	TInt colorMode,mode;
sl@0
  1531
	TInt currentMode=TheClient->iScreen->DisplayMode();	
sl@0
  1532
	TEST(currentMode==EGray4 || currentMode==EColor16 || currentMode==EColor256 || currentMode == EColor64K);
sl@0
  1533
	if(currentMode!=EGray4 && currentMode!=EColor16 && currentMode!=EColor256 && currentMode != EColor64K)
sl@0
  1534
		INFO_PRINTF5(_L("TheClient->iScreen->DisplayMode() return value - Expected: %d or %d or %d, Actual: %d"), EGray4, EColor16, EColor256, currentMode);
sl@0
  1535
	INFO_PRINTF1(_L(" Done Setup"));
sl@0
  1536
	for(colorMode=EGray4;colorMode<EColorLast;colorMode++)
sl@0
  1537
		{
sl@0
  1538
		INFO_PRINTF1(_L(" Loop 1"));
sl@0
  1539
		if (colorMode==ERgb || (colorMode==EGray256 && TDisplayModeUtils::IsDisplayModeColor(REINTERPRET_CAST(TDisplayMode&,currentMode))) ||  (colorMode==EGray256 && TDisplayModeUtils::IsDisplayModeColor(REINTERPRET_CAST(TDisplayMode&,currentMode))) )
sl@0
  1540
			continue;
sl@0
  1541
		User::LeaveIfError(window.SetRequiredDisplayMode((TDisplayMode&)colorMode));
sl@0
  1542
		mode=window.DisplayMode();
sl@0
  1543
		if (!(mode==currentMode || mode==colorMode))
sl@0
  1544
			{
sl@0
  1545
			_LIT(KModes," Failed in Loop1  SetTo=%d, Actual=%d, Current=%d");
sl@0
  1546
			TBuf<64> log;
sl@0
  1547
			log.Format(KModes,colorMode,mode,currentMode);
sl@0
  1548
			INFO_PRINTF1(log);
sl@0
  1549
			}
sl@0
  1550
		if (mode>ERgb && colorMode==EColor64K)
sl@0
  1551
			break;	
sl@0
  1552
		TEST(mode==currentMode || mode==colorMode );
sl@0
  1553
		if (mode!=currentMode && mode!=colorMode)
sl@0
  1554
			INFO_PRINTF4(_L("window.DisplayMode() return value - Expected: %d or %d, Actual: %d"), currentMode, colorMode, mode);
sl@0
  1555
		INFO_PRINTF1(_L(" Loop 2"));
sl@0
  1556
		if (mode>currentMode)
sl@0
  1557
			currentMode=mode;
sl@0
  1558
		if (colorMode==EColor16)
sl@0
  1559
			window.SetSize(TSize(40,60));
sl@0
  1560
		else if (colorMode==EColor4K)
sl@0
  1561
			window.SetSize(TSize(60,40));
sl@0
  1562
		mode=TheClient->iScreen->DisplayMode();
sl@0
  1563
		if(TDisplayModeUtils::NumDisplayModeColors(STATIC_CAST(TDisplayMode,currentMode))==16777216)
sl@0
  1564
			{
sl@0
  1565
			TEST(mode==CFbsDevice::DisplayMode16M());
sl@0
  1566
			if (mode!=CFbsDevice::DisplayMode16M())
sl@0
  1567
				INFO_PRINTF3(_L("window.DisplayMode() return value - Expected: %d, Actual: %d"), CFbsDevice::DisplayMode16M(), mode);
sl@0
  1568
			}
sl@0
  1569
		else
sl@0
  1570
			{		
sl@0
  1571
			TEST(currentMode==mode || currentMode==colorMode);
sl@0
  1572
			if (currentMode!=mode && currentMode!=colorMode)
sl@0
  1573
				INFO_PRINTF3(_L("TheClient->iScreen->DisplayMode() return value  return value - Expected: %d , Actual: %d"), currentMode, mode);
sl@0
  1574
			}
sl@0
  1575
		}
sl@0
  1576
	INFO_PRINTF1(_L(" Done First Loop"));
sl@0
  1577
	TInt color,gray;
sl@0
  1578
	TDisplayMode defMode=TheClient->iWs.GetDefModeMaxNumColors(color,gray);
sl@0
  1579
	TInt screenNo =TheClient->iScreen->GetScreenNumber();
sl@0
  1580
	TDisplayMode defModeForScreen=TheClient->iWs.GetDefModeMaxNumColors(screenNo,color,gray); 
sl@0
  1581
	TEST(defMode==defModeForScreen);
sl@0
  1582
	if (defMode!=defModeForScreen)
sl@0
  1583
		INFO_PRINTF3(_L("TheClient->iScreen->DisplayMode() return value  return value - Expected: %d , Actual: %d"), defMode, defModeForScreen);
sl@0
  1584
	if (color==16777216 && gray==256)
sl@0
  1585
		{		
sl@0
  1586
		TEST(defMode==EGray4 || defMode==EColor256 || defMode==EColor64K);		//WINS
sl@0
  1587
		if (defMode!=EGray4 && defMode!=EColor256 && defMode != EColor64K)
sl@0
  1588
			INFO_PRINTF4(_L("TheClient->iWs.GetDefModeMaxNumColors(color,gray) return value  return value - Expected: %d or %d, Actual: %d"), EGray4, EColor256, defMode);
sl@0
  1589
		}
sl@0
  1590
	else
sl@0
  1591
		{
sl@0
  1592
		if (color==0 && gray==16)
sl@0
  1593
			{		
sl@0
  1594
			TEST(defMode==EGray4);		//S5 family
sl@0
  1595
			if (defMode!=EGray4)
sl@0
  1596
				INFO_PRINTF3(_L("TheClient->iScreen->DisplayMode() return value  return value - Expected: %d , Actual: %d"), EGray4, defMode);
sl@0
  1597
			}
sl@0
  1598
		else
sl@0
  1599
			{
sl@0
  1600
			TLogMessageText buf;
sl@0
  1601
			_LIT(KColorSettings,"##Data  Most Colors=%d, Most Greys=%d, DefMode=%d");
sl@0
  1602
			buf.Format(KColorSettings,color,gray,defMode);
sl@0
  1603
			TheClient->iWs.LogMessage(buf);
sl@0
  1604
			TheClient->iWs.Flush();		
sl@0
  1605
			TEST(defMode==EGray4 || defMode==EColor256);
sl@0
  1606
			if (defMode!=EGray4 && defMode!=EColor256)
sl@0
  1607
				INFO_PRINTF4(_L("TheClient->iWs.GetDefModeMaxNumColors(color,gray) return value  return value - Expected: %d or %d, Actual: %d"), EGray4, EColor256, defMode);
sl@0
  1608
			}
sl@0
  1609
		}
sl@0
  1610
	CArrayFixFlat<TInt> *colorModes=new(ELeave) CArrayFixFlat<TInt>(1);
sl@0
  1611
	CleanupStack::PushL(colorModes);
sl@0
  1612
	User::LeaveIfError(TheClient->iWs.GetColorModeList(screenNo,colorModes));
sl@0
  1613
	TDisplayMode mostColor=ENone;
sl@0
  1614
	TDisplayMode lastGray=ENone;
sl@0
  1615
	TDisplayMode dispMode;
sl@0
  1616
	TInt ii;
sl@0
  1617
	TInt colorModes16M = 0;
sl@0
  1618
	INFO_PRINTF1(_L(" Done Setup 2"));
sl@0
  1619
	for (ii=0;ii<colorModes->Count();ii++)
sl@0
  1620
		{
sl@0
  1621
		dispMode=(TDisplayMode)(*colorModes)[ii];	
sl@0
  1622
		TEST(dispMode!=ERgb);
sl@0
  1623
		if (dispMode==ERgb)
sl@0
  1624
			INFO_PRINTF3(_L("(TDisplayMode)(*colorModes)[i] return value - Not Expected: %d , Actual: %d"), ERgb, dispMode);	
sl@0
  1625
		TEST(dispMode!=ENone);
sl@0
  1626
		if (dispMode==ENone)
sl@0
  1627
			INFO_PRINTF3(_L("(TDisplayMode)(*colorModes)[i] return value - Not Expected: %d , Actual: %d"), ENone, dispMode);
sl@0
  1628
		if (dispMode<=EGray256)
sl@0
  1629
			lastGray=dispMode;
sl@0
  1630
		else
sl@0
  1631
			mostColor=dispMode;
sl@0
  1632
		if(dispMode == EColor16M || dispMode == EColor16MU || dispMode == EColor16MA)
sl@0
  1633
			colorModes16M++;
sl@0
  1634
		}	
sl@0
  1635
	TEST(mostColor!=ERgb);
sl@0
  1636
	if (mostColor==ERgb)
sl@0
  1637
		INFO_PRINTF3(_L("mostColor - Not Expected: %d , Actual: %d"), ERgb, mostColor);	
sl@0
  1638
	TEST(colorModes16M <= 1);
sl@0
  1639
	if (colorModes16M > 1)
sl@0
  1640
		INFO_PRINTF3(_L("Number of times color Modes 16M - less than or equal to: %d , Actual: %d"), 1, colorModes16M);
sl@0
  1641
#if defined(__WINS__)	
sl@0
  1642
	TEST(colorModes16M == 1);
sl@0
  1643
	if (colorModes16M != 1)
sl@0
  1644
		INFO_PRINTF3(_L("Number of times color Modes 16M on wins - equal to: %d , Actual: %d"), 1, colorModes16M);
sl@0
  1645
#endif
sl@0
  1646
	TInt retVal;
sl@0
  1647
	if (color==0)
sl@0
  1648
		{
sl@0
  1649
		TEST(mostColor==ENone);
sl@0
  1650
		if (mostColor!=ENone)
sl@0
  1651
			INFO_PRINTF3(_L("Most color - equal to: %d , Actual: %d"), ENone ,mostColor);
sl@0
  1652
		}
sl@0
  1653
	else
sl@0
  1654
		{
sl@0
  1655
		retVal = TDisplayModeUtils::NumDisplayModeColors(mostColor);		
sl@0
  1656
		TEST(color==retVal);
sl@0
  1657
		if (color!=retVal)
sl@0
  1658
			INFO_PRINTF3(_L("TDisplayModeUtils::NumDisplayModeColors(mostColor) return value - equal to: %d , Actual: %d"), TDisplayModeUtils::NumDisplayModeColors(mostColor), retVal);
sl@0
  1659
		}
sl@0
  1660
	if (gray==0)
sl@0
  1661
		{		
sl@0
  1662
		TEST(lastGray==ENone);
sl@0
  1663
		if (lastGray!=ENone)
sl@0
  1664
			INFO_PRINTF3(_L("LastGray - equal to: %d , Actual: %d"), ENone, lastGray);
sl@0
  1665
		}
sl@0
  1666
	else
sl@0
  1667
		{
sl@0
  1668
		retVal = TDisplayModeUtils::NumDisplayModeColors(lastGray);	
sl@0
  1669
		TEST(gray==retVal);	
sl@0
  1670
		if(gray!=retVal)
sl@0
  1671
			INFO_PRINTF3(_L("Gray - equal to: %d , Actual: %d"), retVal, gray);
sl@0
  1672
		}
sl@0
  1673
	retVal = TDisplayModeUtils::NumDisplayModeColors(ENone);	
sl@0
  1674
	TEST(retVal==0);
sl@0
  1675
	if (retVal!=0)
sl@0
  1676
		INFO_PRINTF3(_L("TDisplayModeUtils::NumDisplayModeColors(ENone) return value - equal to: %d , Actual: %d"), 0, retVal);	
sl@0
  1677
	CleanupStack::PopAndDestroy(2);		//window and mode-array
sl@0
  1678
	}
sl@0
  1679
sl@0
  1680
void CTWindowTest::TestInvalidFunctions2L()
sl@0
  1681
//
sl@0
  1682
// This code casts windows to group windows and vice-versa and then sends messages for the 'cast' that
sl@0
  1683
// should not be sent to the original type of window. These should all result in panics
sl@0
  1684
//
sl@0
  1685
	{
sl@0
  1686
	for (TInt winType=1;winType<7;++winType)		//Skip type 0 (RWindowTreeNode)
sl@0
  1687
		for (TInt panic=0;;panic++)
sl@0
  1688
			{
sl@0
  1689
			TBool testFinished=EFalse;
sl@0
  1690
			TEST(iTest->TestWsPanicL(DoPanicTest3,EWservPanicOpcode,EWinTypeFactor*winType+panic,(TAny*)iTest->iScreenNumber,&testFinished));
sl@0
  1691
			if (testFinished)
sl@0
  1692
				break;
sl@0
  1693
			}
sl@0
  1694
	iTest->CloseAllPanicWindows();
sl@0
  1695
	}
sl@0
  1696
sl@0
  1697
void CTWindowTest::TestDeletedParentPanics1L()
sl@0
  1698
	{
sl@0
  1699
	for (TInt winType=0;winType<7;++winType)
sl@0
  1700
		{
sl@0
  1701
		if (winType==1)		//Skip type 1 (RWindowGroup)
sl@0
  1702
			++winType;
sl@0
  1703
		for (TInt panic=0;;panic++)
sl@0
  1704
			{
sl@0
  1705
			TBool testFinished=EFalse;
sl@0
  1706
			TEST(iTest->TestWsPanicL(DoPanicTest4,EWservPanicParentDeleted,EWinTypeFactor*winType+panic,(TAny*)iTest->iScreenNumber,&testFinished));
sl@0
  1707
			if (testFinished)
sl@0
  1708
				break;
sl@0
  1709
			}
sl@0
  1710
		}
sl@0
  1711
	iTest->CloseAllPanicWindows();
sl@0
  1712
	}
sl@0
  1713
sl@0
  1714
void CTWindowTest::TestDeletedParentPanics2L()
sl@0
  1715
	{
sl@0
  1716
	for (TInt panic=0;;panic++)
sl@0
  1717
		{
sl@0
  1718
		TBool testFinished=EFalse;
sl@0
  1719
		TEST(iTest->TestWsPanicL(DoPanicTest5,EWservPanicParentDeleted,panic,(TAny*)iTest->iScreenNumber,&testFinished));
sl@0
  1720
		if (testFinished)
sl@0
  1721
			break;
sl@0
  1722
		}
sl@0
  1723
	iTest->CloseAllPanicWindows();
sl@0
  1724
	}
sl@0
  1725
sl@0
  1726
void CTWindowTest::Bug1L()
sl@0
  1727
//
sl@0
  1728
// Test a defect found with WSERV 099 that caused a full Eikon ROM to crash before even the splach screen appeared
sl@0
  1729
//
sl@0
  1730
	{
sl@0
  1731
	RWsSession ws;
sl@0
  1732
	User::LeaveIfError(ws.Connect());
sl@0
  1733
	// use correct screen
sl@0
  1734
	CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
sl@0
  1735
	CleanupStack::PushL(screen);
sl@0
  1736
	User::LeaveIfError(screen->Construct(iTest->iScreenNumber));
sl@0
  1737
sl@0
  1738
	RWindowGroup group(ws);
sl@0
  1739
	group.Construct(344);
sl@0
  1740
	group.EnableReceiptOfFocus(EFalse);		//Not done by Eikon, but needed to stop shell window comming to front.
sl@0
  1741
	RBlankWindow blank(ws);
sl@0
  1742
	blank.Construct(group,345);
sl@0
  1743
	blank.SetOrdinalPosition(0,1000);
sl@0
  1744
	blank.Activate();
sl@0
  1745
	RWindow window(ws);
sl@0
  1746
	window.Construct(group,346);
sl@0
  1747
sl@0
  1748
	//Must delete this window to tidy up
sl@0
  1749
	window.Close();
sl@0
  1750
	blank.Close();
sl@0
  1751
	group.Close();
sl@0
  1752
sl@0
  1753
	CleanupStack::PopAndDestroy(screen);
sl@0
  1754
	ws.Close();
sl@0
  1755
	}
sl@0
  1756
sl@0
  1757
void CTWindowTest::TestWindowDelete()
sl@0
  1758
	{
sl@0
  1759
	TInt handles = 344;
sl@0
  1760
	TInt err = KErrNone;
sl@0
  1761
	TInt loop = 0;
sl@0
  1762
	TInt allocFailRate = 0;
sl@0
  1763
	
sl@0
  1764
	RWindowGroup group(TheClient->iWs);
sl@0
  1765
	RWindow parent1(TheClient->iWs);
sl@0
  1766
	RWindow child1(TheClient->iWs);
sl@0
  1767
	RWindow testWindow(TheClient->iWs);
sl@0
  1768
	
sl@0
  1769
	while (loop < 5)
sl@0
  1770
		{
sl@0
  1771
		err = group.Construct(++handles, EFalse);		
sl@0
  1772
		if (err == KErrNone)
sl@0
  1773
			{
sl@0
  1774
			TheClient->iWs.HeapSetFail(RHeap::EDeterministic, allocFailRate);
sl@0
  1775
sl@0
  1776
			//Create parent 1
sl@0
  1777
			err = parent1.Construct(group,++handles);
sl@0
  1778
			if (err == KErrNone)
sl@0
  1779
				{
sl@0
  1780
				parent1.SetExtent(TPoint(10,10),TSize(50,50));
sl@0
  1781
				parent1.Activate();
sl@0
  1782
				}			
sl@0
  1783
			}
sl@0
  1784
		//Create child 1
sl@0
  1785
		if (err == KErrNone)
sl@0
  1786
			{
sl@0
  1787
			err = child1.Construct(parent1,++handles);
sl@0
  1788
			if (err == KErrNone)
sl@0
  1789
				{
sl@0
  1790
				child1.SetExtent(TPoint(),TSize(50,20));
sl@0
  1791
				child1.Activate();
sl@0
  1792
				}
sl@0
  1793
			//Only delete the parent 1, but not the child 1
sl@0
  1794
			parent1.Close();	
sl@0
  1795
			}
sl@0
  1796
		
sl@0
  1797
		if (err == KErrNone) 
sl@0
  1798
			{			
sl@0
  1799
			//Create testWindow
sl@0
  1800
			err = testWindow.Construct(group,++handles);
sl@0
  1801
			if (err == KErrNone)
sl@0
  1802
				{
sl@0
  1803
				testWindow.SetExtent(TPoint(0,20),TSize(50,30));
sl@0
  1804
				testWindow.Activate();
sl@0
  1805
				}
sl@0
  1806
			}
sl@0
  1807
		TheClient->iWs.HeapSetFail(RAllocator::ENone, 0);
sl@0
  1808
			
sl@0
  1809
		child1.Close();
sl@0
  1810
		testWindow.Close();
sl@0
  1811
		group.Close();
sl@0
  1812
		++allocFailRate;
sl@0
  1813
		loop = (err == KErrNone) ? loop + 1 : 0; 
sl@0
  1814
		}
sl@0
  1815
	}
sl@0
  1816
void CTWindowTest::Bug2L()
sl@0
  1817
//
sl@0
  1818
// Test a defect ...
sl@0
  1819
//
sl@0
  1820
	{
sl@0
  1821
	TSize offset(20,20);
sl@0
  1822
	TRect screen(TheClient->iScreen->SizeInPixels()-offset);
sl@0
  1823
	TRgb color;
sl@0
  1824
	RWsSession ws1;
sl@0
  1825
	User::LeaveIfError(ws1.Connect());
sl@0
  1826
	ws1.SetAutoFlush(ETrue);
sl@0
  1827
sl@0
  1828
	// use correct screen
sl@0
  1829
	//
sl@0
  1830
	CWsScreenDevice* scr1 = new (ELeave) CWsScreenDevice(ws1);
sl@0
  1831
	CleanupStack::PushL(scr1);
sl@0
  1832
	User::LeaveIfError(scr1->Construct(iTest->iScreenNumber));
sl@0
  1833
sl@0
  1834
	RWsSession ws2;
sl@0
  1835
	User::LeaveIfError(ws2.Connect());
sl@0
  1836
	ws2.SetAutoFlush(ETrue);
sl@0
  1837
sl@0
  1838
	// use correct screen
sl@0
  1839
	//
sl@0
  1840
	CWsScreenDevice* scr2 = new (ELeave) CWsScreenDevice(ws2);
sl@0
  1841
	CleanupStack::PushL(scr2);
sl@0
  1842
	User::LeaveIfError(scr2->Construct(iTest->iScreenNumber));
sl@0
  1843
sl@0
  1844
	RWindowGroup group1a(ws1);
sl@0
  1845
	group1a.Construct(344);
sl@0
  1846
	group1a.EnableReceiptOfFocus(EFalse);
sl@0
  1847
	group1a.SetOrdinalPosition(0,5);
sl@0
  1848
	RBlankWindow blank1a(ws1);
sl@0
  1849
	blank1a.Construct(group1a,345);
sl@0
  1850
	color=TRgb::Gray4(0);
sl@0
  1851
	blank1a.SetColor(color);
sl@0
  1852
	blank1a.SetExtent(screen.iTl,screen.Size());
sl@0
  1853
	blank1a.EnableBackup();
sl@0
  1854
	blank1a.Activate();
sl@0
  1855
sl@0
  1856
	RWindowGroup group2(ws2);
sl@0
  1857
	group2.Construct(342);
sl@0
  1858
	group2.EnableReceiptOfFocus(EFalse);
sl@0
  1859
	group2.SetOrdinalPosition(0,5);
sl@0
  1860
	RBlankWindow blank2(ws2);
sl@0
  1861
	blank2.Construct(group2,347);
sl@0
  1862
	color=TRgb::Gray4(1);
sl@0
  1863
	blank2.SetColor(color);
sl@0
  1864
	blank2.SetExtent(screen.iTl+TSize(20,0),screen.Size());
sl@0
  1865
	blank2.EnableBackup();
sl@0
  1866
	blank2.Activate();
sl@0
  1867
sl@0
  1868
	RWindowGroup group1b(ws1);
sl@0
  1869
	group1b.Construct(343);
sl@0
  1870
	//group1b.EnableReceiptOfFocus(EFalse);
sl@0
  1871
	group1b.SetOrdinalPosition(0,5);
sl@0
  1872
	RBlankWindow blank1b(ws1);
sl@0
  1873
	blank1b.Construct(group1b,346);
sl@0
  1874
	color=TRgb::Gray4(2);
sl@0
  1875
	blank1b.SetColor(color);
sl@0
  1876
	blank1b.SetExtent(screen.iTl+offset,screen.Size());
sl@0
  1877
	blank1b.EnableBackup();
sl@0
  1878
	blank1b.Activate();
sl@0
  1879
sl@0
  1880
	group1b.Close();
sl@0
  1881
	blank1a.Close();
sl@0
  1882
	blank1b.Close();
sl@0
  1883
	blank2.Close();
sl@0
  1884
	group1a.Close();
sl@0
  1885
	group2.Close();
sl@0
  1886
sl@0
  1887
	CleanupStack::PopAndDestroy(2,scr1);
sl@0
  1888
	ws1.Close();
sl@0
  1889
	ws2.Close();
sl@0
  1890
	}
sl@0
  1891
sl@0
  1892
void CTWindowTest::Bug3L()
sl@0
  1893
//
sl@0
  1894
// Actiate then make visible and backup behind window caused panic.
sl@0
  1895
//
sl@0
  1896
	{
sl@0
  1897
	TSize offset(20,20);
sl@0
  1898
	TRect screen(TheClient->iScreen->SizeInPixels()-offset);
sl@0
  1899
	TRgb color;
sl@0
  1900
	RWsSession ws;
sl@0
  1901
	User::LeaveIfError(ws.Connect());
sl@0
  1902
	ws.SetAutoFlush(ETrue);
sl@0
  1903
sl@0
  1904
	// use correct screen
sl@0
  1905
	//
sl@0
  1906
	CWsScreenDevice* scr = new (ELeave) CWsScreenDevice(ws);
sl@0
  1907
	CleanupStack::PushL(scr);
sl@0
  1908
	User::LeaveIfError(scr->Construct(iTest->iScreenNumber));
sl@0
  1909
sl@0
  1910
	RWindowGroup group(ws);
sl@0
  1911
	group.Construct(348);
sl@0
  1912
	group.EnableReceiptOfFocus(EFalse);
sl@0
  1913
	RBlankWindow blank1(ws);
sl@0
  1914
	blank1.Construct(group,341);
sl@0
  1915
	color=TRgb::Gray4(1);
sl@0
  1916
	blank1.SetColor(color);
sl@0
  1917
	blank1.SetExtent(screen.iTl,screen.Size());
sl@0
  1918
	blank1.EnableBackup();
sl@0
  1919
	blank1.SetVisible(EFalse);
sl@0
  1920
	blank1.Activate();
sl@0
  1921
	blank1.SetVisible(ETrue);
sl@0
  1922
	RBlankWindow blank2(ws);
sl@0
  1923
	blank2.Construct(group,342);
sl@0
  1924
	color=TRgb::Gray4(2);
sl@0
  1925
	blank2.SetColor(color);
sl@0
  1926
	blank2.SetExtent(screen.iTl,screen.Size());
sl@0
  1927
	blank2.EnableBackup();
sl@0
  1928
	blank2.SetVisible(EFalse);
sl@0
  1929
	blank2.SetVisible(ETrue);
sl@0
  1930
	blank2.Activate();
sl@0
  1931
	group.Close();
sl@0
  1932
	blank1.Close();
sl@0
  1933
	blank2.Close();
sl@0
  1934
sl@0
  1935
	CleanupStack::PopAndDestroy(scr);
sl@0
  1936
	ws.Close();
sl@0
  1937
	}
sl@0
  1938
sl@0
  1939
void CTWindowTest::ErrorCodesL()
sl@0
  1940
	{
sl@0
  1941
	RWsSession ws;
sl@0
  1942
	User::LeaveIfError(ws.Connect());
sl@0
  1943
	// use correct screen
sl@0
  1944
	//
sl@0
  1945
	CWsScreenDevice* scr = new (ELeave) CWsScreenDevice(ws);
sl@0
  1946
	CleanupStack::PushL(scr);
sl@0
  1947
	User::LeaveIfError(scr->Construct(iTest->iScreenNumber));
sl@0
  1948
sl@0
  1949
sl@0
  1950
	RWindowGroup group(ws);
sl@0
  1951
	group.Construct(349);
sl@0
  1952
	group.EnableReceiptOfFocus(EFalse);
sl@0
  1953
	RWindow window(TheClient->iWs);
sl@0
  1954
	User::LeaveIfError(window.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle));
sl@0
  1955
	TInt retVal = window.MoveToGroup(22222);		
sl@0
  1956
	TEST(retVal==KErrNotFound);
sl@0
  1957
	if (retVal!=KErrNotFound)
sl@0
  1958
		INFO_PRINTF3(_L("window.MoveToGroup(22222) return value - equal to: %d , Actual: %d"), KErrNotFound, retVal);
sl@0
  1959
	retVal = window.MoveToGroup(group.Identifier());	
sl@0
  1960
	TEST(retVal==KErrNotFound);
sl@0
  1961
	if (retVal!=KErrNotFound)
sl@0
  1962
		INFO_PRINTF3(_L("window.MoveToGroup(group.Identifier()) return value - equal to: %d , Actual: %d"), KErrNotFound, retVal);
sl@0
  1963
	window.Close();
sl@0
  1964
	group.Close();
sl@0
  1965
sl@0
  1966
	CleanupStack::PopAndDestroy(scr);
sl@0
  1967
	ws.Close();
sl@0
  1968
	}
sl@0
  1969
sl@0
  1970
void CTWindowTest::BackColorBugL()
sl@0
  1971
//
sl@0
  1972
// Test a defect with window being drawn with the wrong background color when they are moved on the screen
sl@0
  1973
//
sl@0
  1974
	{
sl@0
  1975
	TSize scrSize(TheClient->iScreen->SizeInPixels());
sl@0
  1976
	TSize checkSize(12,10);			//X-Size needs to be multiple of 4 due to BITGDI change/defect
sl@0
  1977
	CBlankWindow* win;
sl@0
  1978
	win=new(ELeave) CBlankWindow(TRgb(16,16,240));
sl@0
  1979
	CleanupStack::PushL(win);
sl@0
  1980
	win->SetUpL(TPoint(5,5),scrSize-TSize(10,10),TheClient->iGroup,*TheClient->iGc);
sl@0
  1981
	TInt mode=win->BaseWin()->SetRequiredDisplayMode(EColor256);
sl@0
  1982
	const TDisplayMode actualMode=reinterpret_cast<TDisplayMode&>(mode);
sl@0
  1983
	if (!TDisplayModeUtils::IsDisplayModeColor(actualMode) || TDisplayModeUtils::NumDisplayModeColors(actualMode)<256)
sl@0
  1984
		{
sl@0
  1985
		CleanupStack::PopAndDestroy(win);
sl@0
  1986
		return;
sl@0
  1987
		}
sl@0
  1988
	win->RealDraw(ETrue);
sl@0
  1989
	win->Win()->SetBackgroundColor(TRgb(64,224,64));
sl@0
  1990
	CBlankWindow* win3;
sl@0
  1991
	win3=new(ELeave) CBlankWindow(TRgb::Gray16(8));
sl@0
  1992
	CleanupStack::PushL(win3);
sl@0
  1993
	win3->SetUpL(TPoint(12,12),checkSize,TheClient->iGroup,*TheClient->iGc);
sl@0
  1994
	win3->BaseWin()->SetRequiredDisplayMode(EColor256);
sl@0
  1995
	CBlankWindow* win2;
sl@0
  1996
	win2=new(ELeave) CBlankWindow(TRgb(240,16,16));
sl@0
  1997
	CleanupStack::PushL(win2);
sl@0
  1998
	win2->SetUpL(TPoint(10,scrSize.iHeight/2),TSize(scrSize.iWidth/3,scrSize.iHeight/2-10),TheClient->iGroup,*TheClient->iGc);
sl@0
  1999
	win2->BaseWin()->SetRequiredDisplayMode(EColor256);
sl@0
  2000
	win2->RealDraw(EFalse);
sl@0
  2001
sl@0
  2002
	win2->Win()->SetBackgroundColor(TRgb::Gray16(8));
sl@0
  2003
	win2->SetExt(TPoint(scrSize.iWidth/4,30),TSize(scrSize.iWidth/2,2*scrSize.iHeight/3));
sl@0
  2004
	TheClient->iWs.Finish();
sl@0
  2005
	TheClient->WaitForRedrawsToFinish();
sl@0
  2006
	if (!CheckRect(win2,win3,TRect(checkSize)))
sl@0
  2007
		{
sl@0
  2008
		_LIT(KLog,"After window is moved and resizes it doesn't matches the other window");
sl@0
  2009
		LOG_MESSAGE(KLog);
sl@0
  2010
		//Code to save a screen shot useful if this test fails
sl@0
  2011
		/*_LIT(KTest,"E:\\logs\\testexecute\\Window%d");
sl@0
  2012
		TBuf<64> buf;
sl@0
  2013
		buf.Format(KTest,iTest->iState);
sl@0
  2014
		TInt err=iTest->SaveScreen(buf);
sl@0
  2015
		_LIT(KLogSave,"Saved screenshot to file %S, (err=%d)");
sl@0
  2016
		LOG_MESSAGE3(KLogSave,&buf,err);*/
sl@0
  2017
		}
sl@0
  2018
	TheClient->WaitForRedrawsToFinish();
sl@0
  2019
	CleanupStack::PopAndDestroy(3,win);
sl@0
  2020
	}
sl@0
  2021
sl@0
  2022
void CTWindowTest::FocusChangedL()
sl@0
  2023
//
sl@0
  2024
// Test that the focus change is available when the redraw is
sl@0
  2025
// it should be available before, but it isn't always possible to test that
sl@0
  2026
//
sl@0
  2027
	{
sl@0
  2028
	_LIT(KThreadName,"MoveGroup");
sl@0
  2029
	_LIT(KEventWaiting,"Event Waiting when none expected.");
sl@0
  2030
	TInt command;
sl@0
  2031
	iThreadParam.iScreenNumber=iTest->iScreenNumber;
sl@0
  2032
	iFirstFunction=TThreadStartUp(CTWindowTest::MoveGroup,&iThreadParam);
sl@0
  2033
	TRequestStatus status;
sl@0
  2034
	TSize scrSize(TheClient->iScreen->SizeInPixels());
sl@0
  2035
	CTWindowGroup* group1=new(ELeave) CTWindowGroup(TheClient);
sl@0
  2036
	group1->ConstructL();
sl@0
  2037
	CleanupStack::PushL(group1);
sl@0
  2038
	TInt winId1=group1->GroupWin()->Identifier();
sl@0
  2039
	CBlankWindow* win1=new(ELeave) CBlankWindow(TRgb::Gray4(1));
sl@0
  2040
	CleanupStack::PushL(win1);
sl@0
  2041
	win1->SetUpL(TPoint(1,1),TSize(2*scrSize.iWidth/3,2*scrSize.iHeight/3),group1,*TheClient->iGc);
sl@0
  2042
	win1->RealDraw(ETrue);
sl@0
  2043
	win1->Win()->SetBackgroundColor(TRgb::Gray4(3));
sl@0
  2044
	CTWindowGroup* group2=new(ELeave) CTWindowGroup(TheClient);
sl@0
  2045
	group2->ConstructL();
sl@0
  2046
	CleanupStack::PushL(group2);
sl@0
  2047
	TInt winId2=group2->GroupWin()->Identifier();
sl@0
  2048
	CBlankWindow* win2=new(ELeave) CBlankWindow(TRgb::Gray4(2));
sl@0
  2049
	CleanupStack::PushL(win2);
sl@0
  2050
	win2->SetUpL(TPoint(scrSize.iWidth/3-5,scrSize.iHeight/3-5),TSize(2*scrSize.iWidth/3,2*scrSize.iHeight/3),group2,*TheClient->iGc);
sl@0
  2051
	win2->RealDraw(ETrue);
sl@0
  2052
	win2->Win()->SetBackgroundColor(TRgb::Gray4(0));
sl@0
  2053
sl@0
  2054
	TheClient->WaitForRedrawsToFinish();
sl@0
  2055
	TheClient->WaitForAllEventProcessingToFinish();
sl@0
  2056
	command=winId1;
sl@0
  2057
	iThreadParam.iCommand=command;
sl@0
  2058
	TBool noEventWaiting=!TheClient->IsEventWaiting();
sl@0
  2059
	TEST(noEventWaiting);
sl@0
  2060
	if (!noEventWaiting)
sl@0
  2061
		LOG_MESSAGE(KEventWaiting);
sl@0
  2062
	_LIT(KTest1,"FocusChangedL: 1st test completed");
sl@0
  2063
	LOG_MESSAGE(KTest1);
sl@0
  2064
	CProcess* iMoveGroup=CProcess::NewSimpleThreadL(KThreadName,&iFirstFunction,&status);
sl@0
  2065
	User::WaitForRequest(status);
sl@0
  2066
	delete iMoveGroup;
sl@0
  2067
	TEST(TheClient->WaitForEvent());
sl@0
  2068
	TheClient->WaitForAllEventProcessingToFinish();
sl@0
  2069
sl@0
  2070
	command=winId2;
sl@0
  2071
	iThreadParam.iCommand=command;
sl@0
  2072
	TheClient->WaitForRedrawsToFinish();
sl@0
  2073
	noEventWaiting=!TheClient->IsEventWaiting();
sl@0
  2074
	TEST(noEventWaiting);
sl@0
  2075
	if (!noEventWaiting)
sl@0
  2076
		LOG_MESSAGE(KEventWaiting);
sl@0
  2077
	_LIT(KTest2,"FocusChangedL: 2nd test completed");
sl@0
  2078
	LOG_MESSAGE(KTest2);
sl@0
  2079
	iMoveGroup=CProcess::NewSimpleThreadL(KThreadName,&iFirstFunction,&status);
sl@0
  2080
	User::WaitForRequest(status);
sl@0
  2081
	delete iMoveGroup;
sl@0
  2082
	TEST(TheClient->WaitForEvent());
sl@0
  2083
	TheClient->WaitForAllEventProcessingToFinish();
sl@0
  2084
sl@0
  2085
	command=winId2|(1<<EPosShift);
sl@0
  2086
	iThreadParam.iCommand=command;
sl@0
  2087
	TheClient->WaitForRedrawsToFinish();
sl@0
  2088
	noEventWaiting=!TheClient->IsEventWaiting();
sl@0
  2089
	TEST(noEventWaiting);
sl@0
  2090
	if (!noEventWaiting)
sl@0
  2091
		LOG_MESSAGE(KEventWaiting);
sl@0
  2092
	_LIT(KTest3,"FocusChangedL: 3rd test completed");
sl@0
  2093
	LOG_MESSAGE(KTest3);
sl@0
  2094
	iMoveGroup=CProcess::NewSimpleThreadL(KThreadName,&iFirstFunction,&status);
sl@0
  2095
	User::WaitForRequest(status);
sl@0
  2096
	delete iMoveGroup;
sl@0
  2097
	TEST(TheClient->WaitForEvent());
sl@0
  2098
	TheClient->WaitForAllEventProcessingToFinish();
sl@0
  2099
sl@0
  2100
	command=winId1|(1<<EPosShift);
sl@0
  2101
	iThreadParam.iCommand=command;
sl@0
  2102
	TheClient->WaitForRedrawsToFinish();
sl@0
  2103
	noEventWaiting=!TheClient->IsEventWaiting();
sl@0
  2104
	TEST(noEventWaiting);
sl@0
  2105
	if (!noEventWaiting)
sl@0
  2106
		LOG_MESSAGE(KEventWaiting);
sl@0
  2107
	_LIT(KTest4,"FocusChangedL: 4th test completed");
sl@0
  2108
	LOG_MESSAGE(KTest4);
sl@0
  2109
	iMoveGroup=CProcess::NewSimpleThreadL(KThreadName,&iFirstFunction,&status);
sl@0
  2110
	User::WaitForRequest(status);
sl@0
  2111
	delete iMoveGroup;
sl@0
  2112
	TEST(TheClient->WaitForEvent());
sl@0
  2113
	TheClient->WaitForAllEventProcessingToFinish();
sl@0
  2114
sl@0
  2115
	TheClient->WaitForRedrawsToFinish();
sl@0
  2116
	noEventWaiting=!TheClient->IsEventWaiting();
sl@0
  2117
	TEST(noEventWaiting);
sl@0
  2118
	if (!noEventWaiting)
sl@0
  2119
		LOG_MESSAGE(KEventWaiting);
sl@0
  2120
	_LIT(KTest5,"FocusChangedL: 5th and last test completed");
sl@0
  2121
	LOG_MESSAGE(KTest5);
sl@0
  2122
	CleanupStack::PopAndDestroy(2,group2);
sl@0
  2123
	TheClient->Flush();
sl@0
  2124
	TEST(TheClient->WaitForEvent());
sl@0
  2125
	TheClient->WaitForAllEventProcessingToFinish();
sl@0
  2126
	CleanupStack::PopAndDestroy(2,group1);
sl@0
  2127
	}
sl@0
  2128
sl@0
  2129
#define ALT_PRI 78
sl@0
  2130
void CTWindowTest::EventsToAllL()
sl@0
  2131
	{
sl@0
  2132
	CTClient* client1=new(ELeave) CTClient;
sl@0
  2133
	CleanupStack::PushL(client1);
sl@0
  2134
	client1->SetScreenNumber(iTest->iScreenNumber);
sl@0
  2135
	client1->ConstructL();
sl@0
  2136
	CTClient* client2=new(ELeave) CTClient;
sl@0
  2137
	CleanupStack::PushL(client2);
sl@0
  2138
	client2->SetScreenNumber(iTest->iScreenNumber);
sl@0
  2139
	client2->ConstructL();
sl@0
  2140
	CEvWindowGroup* group1a=CEvWindowGroup::NewLC(client1,this);
sl@0
  2141
	CEvWindowGroup* group1b=CEvWindowGroup::NewLC(client1,this);
sl@0
  2142
	CEvWindowGroup* group2a=CEvWindowGroup::NewLC(client2,this);
sl@0
  2143
	CEvWindowGroup* group2b=CEvWindowGroup::NewLC(client2,this);
sl@0
  2144
	/*_LIT(KLog,"Window Group Id's: %d,%d,%d,%d");
sl@0
  2145
	LOG_MESSAGE5(KLog,group1a->GroupWin()->Identifier(),group1b->GroupWin()->Identifier(),group2a->GroupWin()->Identifier(),group2b->GroupWin()->Identifier());*/
sl@0
  2146
	group1a->SendEvent(KBaseUserEvent+1);
sl@0
  2147
	group2b->SendEvent(KBaseUserEvent+2);
sl@0
  2148
	client1->WaitForAllEventProcessingToFinish();
sl@0
  2149
	client2->WaitForAllEventProcessingToFinish();
sl@0
  2150
	TWsEvent event;
sl@0
  2151
	// Assigned random value because before PREQ1226, TWsevent's data wasn't zero initialised.
sl@0
  2152
	// In techview, following function
sl@0
  2153
	// void CEikServAppUi::HandleSystemEventL(const TWsEvent& aEvent)
sl@0
  2154
	// was relaying on TWsevent's data not be zero 
sl@0
  2155
	*(event.Int()) = 0XCCCCCCCC;
sl@0
  2156
	event.SetType(KBaseUserEvent+3);
sl@0
  2157
	group1a->SetExpectedEvent(KBaseUserEvent+3);
sl@0
  2158
	group1b->SetExpectedEvent(KBaseUserEvent+3);
sl@0
  2159
	group2a->SetExpectedEvent(KBaseUserEvent+3);
sl@0
  2160
	group2b->SetExpectedEvent(KBaseUserEvent+3);
sl@0
  2161
	TheClient->iWs.SendEventToAllWindowGroups(event);
sl@0
  2162
	client1->WaitForAllEventProcessingToFinish();
sl@0
  2163
	client2->WaitForAllEventProcessingToFinish();
sl@0
  2164
	event.SetType(KBaseUserEvent+4);
sl@0
  2165
	group1a->SetExpectedEvent(KBaseUserEvent+4);
sl@0
  2166
	group1b->SetExpectedEvent(KBaseUserEvent+4);
sl@0
  2167
	group2a->SetExpectedEvent(KBaseUserEvent+4);
sl@0
  2168
	group2b->SetExpectedEvent(KBaseUserEvent+4);
sl@0
  2169
	TheClient->iWs.SendEventToAllWindowGroups(event);
sl@0
  2170
	client1->WaitForAllEventProcessingToFinish();
sl@0
  2171
	client2->WaitForAllEventProcessingToFinish();
sl@0
  2172
	event.SetType(KBaseUserEvent+5);
sl@0
  2173
	//group1a->SetExpectedEvent(KBaseUserEvent+5);
sl@0
  2174
	group1b->SetExpectedEvent(KBaseUserEvent+5);
sl@0
  2175
	//group2a->SetExpectedEvent(KBaseUserEvent+5);
sl@0
  2176
	group2b->SetExpectedEvent(KBaseUserEvent+5);
sl@0
  2177
	TheClient->iWs.SendEventToOneWindowGroupsPerClient(event);
sl@0
  2178
	client1->WaitForAllEventProcessingToFinish();
sl@0
  2179
	client2->WaitForAllEventProcessingToFinish();
sl@0
  2180
	group1a->WinTreeNode()->SetOrdinalPosition(0);
sl@0
  2181
	client1->Flush();
sl@0
  2182
	event.SetType(KBaseUserEvent+6);
sl@0
  2183
	group1a->SetExpectedEvent(KBaseUserEvent+6);
sl@0
  2184
	group2b->SetExpectedEvent(KBaseUserEvent+6);
sl@0
  2185
	TheClient->iWs.SendEventToOneWindowGroupsPerClient(event);
sl@0
  2186
	client1->WaitForAllEventProcessingToFinish();
sl@0
  2187
	client2->WaitForAllEventProcessingToFinish();
sl@0
  2188
	group2b->WinTreeNode()->SetOrdinalPosition(6);
sl@0
  2189
	client2->Flush();
sl@0
  2190
	event.SetType(KBaseUserEvent+7);
sl@0
  2191
	group1a->SetExpectedEvent(KBaseUserEvent+7);
sl@0
  2192
	group2a->SetExpectedEvent(KBaseUserEvent+7);
sl@0
  2193
	TheClient->iWs.SendEventToOneWindowGroupsPerClient(event);
sl@0
  2194
	client1->WaitForAllEventProcessingToFinish();
sl@0
  2195
	client2->WaitForAllEventProcessingToFinish();
sl@0
  2196
	event.SetType(KBaseUserEvent+8);
sl@0
  2197
	group1a->SetExpectedEvent(KBaseUserEvent+8);
sl@0
  2198
	group1b->SetExpectedEvent(KBaseUserEvent+8);
sl@0
  2199
	group2a->SetExpectedEvent(KBaseUserEvent+8);
sl@0
  2200
	group2b->SetExpectedEvent(KBaseUserEvent+8);
sl@0
  2201
	TheClient->iWs.SendEventToAllWindowGroups(0,event);
sl@0
  2202
	group1a->WinTreeNode()->SetOrdinalPosition(0,ALT_PRI);
sl@0
  2203
	client1->Flush();
sl@0
  2204
	client1->WaitForAllEventProcessingToFinish();
sl@0
  2205
	client2->WaitForAllEventProcessingToFinish();
sl@0
  2206
	event.SetType(KBaseUserEvent+9);
sl@0
  2207
	group1a->SetExpectedEvent(KBaseUserEvent+9);
sl@0
  2208
	TheClient->iWs.SendEventToAllWindowGroups(ALT_PRI,event);
sl@0
  2209
	client1->WaitForAllEventProcessingToFinish();
sl@0
  2210
	client2->WaitForAllEventProcessingToFinish();
sl@0
  2211
	group2b->WinTreeNode()->SetOrdinalPosition(0,ALT_PRI);
sl@0
  2212
	client2->Flush();
sl@0
  2213
	client1->WaitForAllEventProcessingToFinish();
sl@0
  2214
	client2->WaitForAllEventProcessingToFinish();
sl@0
  2215
	event.SetType(KBaseUserEvent+10);
sl@0
  2216
	group1a->SetExpectedEvent(KBaseUserEvent+10);
sl@0
  2217
	group2b->SetExpectedEvent(KBaseUserEvent+10);
sl@0
  2218
	TheClient->iWs.SendEventToAllWindowGroups(ALT_PRI,event);
sl@0
  2219
	client1->WaitForAllEventProcessingToFinish();
sl@0
  2220
	client2->WaitForAllEventProcessingToFinish();
sl@0
  2221
	event.SetType(KBaseUserEvent+11);
sl@0
  2222
	group1b->SetExpectedEvent(KBaseUserEvent+11);
sl@0
  2223
	group2a->SetExpectedEvent(KBaseUserEvent+11);
sl@0
  2224
	TheClient->iWs.SendEventToAllWindowGroups(0,event);
sl@0
  2225
	client1->WaitForAllEventProcessingToFinish();
sl@0
  2226
	client2->WaitForAllEventProcessingToFinish();
sl@0
  2227
	event.SetType(KBaseUserEvent);
sl@0
  2228
	group1a->SetExpectedEvent(KBaseUserEvent);
sl@0
  2229
	group1b->SetExpectedEvent(KBaseUserEvent);
sl@0
  2230
	group2a->SetExpectedEvent(KBaseUserEvent);
sl@0
  2231
	group2b->SetExpectedEvent(KBaseUserEvent);
sl@0
  2232
	TheClient->iWs.SendEventToAllWindowGroups(event);
sl@0
  2233
	client1->WaitForAllEventProcessingToFinish();
sl@0
  2234
	client2->WaitForAllEventProcessingToFinish();
sl@0
  2235
	CleanupStack::PopAndDestroy(6,client1);
sl@0
  2236
	}
sl@0
  2237
sl@0
  2238
void DestroyWindow(TAny* aWindow)
sl@0
  2239
	{
sl@0
  2240
	static_cast<RWindowTreeNode*>(aWindow)->Destroy();
sl@0
  2241
	}
sl@0
  2242
sl@0
  2243
void CTWindowTest::GroupIdL()
sl@0
  2244
	{
sl@0
  2245
	const TInt numWindows=10;
sl@0
  2246
	RWindowGroup group(TheClient->iWs);
sl@0
  2247
	CleanupClosePushL(group);
sl@0
  2248
	User::LeaveIfError(group.Construct(ENullWsHandle));
sl@0
  2249
	TInt id=group.Identifier();
sl@0
  2250
	RWindowTreeNode* prevWindow=&group;
sl@0
  2251
	TInt ii;
sl@0
  2252
	for (ii=0;ii<numWindows;++ii)
sl@0
  2253
		{
sl@0
  2254
		RBlankWindow* window=new(ELeave) RBlankWindow(TheClient->iWs);
sl@0
  2255
		CleanupStack::PushL(TCleanupItem(&DestroyWindow,window));
sl@0
  2256
		User::LeaveIfError(window->Construct(*prevWindow,ENullWsHandle));
sl@0
  2257
		TInt retVal = window->WindowGroupId();		
sl@0
  2258
		TEST(retVal==id);
sl@0
  2259
		if (retVal!=id)
sl@0
  2260
			INFO_PRINTF3(_L("window->WindowGroupId() return value  - equal to: %d , Actual: %d"), id, retVal);
sl@0
  2261
		prevWindow=window;
sl@0
  2262
		}
sl@0
  2263
	CleanupStack::PopAndDestroy(numWindows+1);
sl@0
  2264
	}
sl@0
  2265
sl@0
  2266
/**
sl@0
  2267
@SYMTestCaseID		GRAPHICS-WSERV-0495
sl@0
  2268
sl@0
  2269
@SYMDEF				PDEF131541
sl@0
  2270
sl@0
  2271
@SYMTestCaseDesc	Sending Events using one of the functions SendEventToWindowGroup, SendEventToAllWindowGroups (x2) 
sl@0
  2272
					and SendEventToOneWindowGroupsPerClient when an event queue is full returns an error
sl@0
  2273
sl@0
  2274
@SYMTestPriority	Low
sl@0
  2275
sl@0
  2276
@SYMTestStatus		Implemented
sl@0
  2277
sl@0
  2278
@SYMTestActions		Call the functions repeatly many times and check that an error gets returned eventually
sl@0
  2279
sl@0
  2280
@SYMTestExpectedResults		Functions return the error KErrNoMemory
sl@0
  2281
*/
sl@0
  2282
const TInt numTest=75;		//Must be at least 33
sl@0
  2283
void CTWindowTest::SaturateSendEvent()
sl@0
  2284
	{
sl@0
  2285
	const TInt id=TheClient->iGroup->GroupWin()->Identifier();
sl@0
  2286
	TWsEvent event;
sl@0
  2287
	event.SetType(KBaseUserEvent);
sl@0
  2288
	TInt ii;
sl@0
  2289
sl@0
  2290
	TInt err=KErrNone;
sl@0
  2291
	for (ii=0; ii<=numTest && err==KErrNone;)
sl@0
  2292
		{
sl@0
  2293
		++ii;
sl@0
  2294
		err=TheClient->iWs.SendEventToWindowGroup(id,event);
sl@0
  2295
		}
sl@0
  2296
	TEST(err==KErrNoMemory);
sl@0
  2297
	if (err!=KErrNoMemory)
sl@0
  2298
		{
sl@0
  2299
		_LIT(KLog,"After %d/%d iterations SendEventToWindowGroup returned the error %d");
sl@0
  2300
		LOG_MESSAGE4(KLog,ii,numTest,err);
sl@0
  2301
		}
sl@0
  2302
	TheClient->WaitForAllEventProcessingToFinish();
sl@0
  2303
sl@0
  2304
	err=KErrNone;
sl@0
  2305
	for (ii=0; ii<=numTest && err==KErrNone;)
sl@0
  2306
		{
sl@0
  2307
		++ii;
sl@0
  2308
		err=TheClient->iWs.SendEventToAllWindowGroups(event);
sl@0
  2309
		}
sl@0
  2310
	TEST(err==KErrNoMemory);
sl@0
  2311
	if (err!=KErrNoMemory)
sl@0
  2312
		{
sl@0
  2313
		_LIT(KLog,"After %d/%d iterations SendEventToAllWindowGroups returned the error %d");
sl@0
  2314
		LOG_MESSAGE4(KLog,ii,numTest,err);
sl@0
  2315
		}
sl@0
  2316
	TheClient->WaitForAllEventProcessingToFinish();
sl@0
  2317
	User::After(1000000);		//1sec, give other sessions a chance to respond to the events
sl@0
  2318
sl@0
  2319
	err=KErrNone;
sl@0
  2320
	for (ii=0; ii<=numTest && err==KErrNone;)
sl@0
  2321
		{
sl@0
  2322
		++ii;
sl@0
  2323
		err=TheClient->iWs.SendEventToAllWindowGroups(0,event);
sl@0
  2324
		}
sl@0
  2325
	TEST(err==KErrNoMemory);
sl@0
  2326
	if (err!=KErrNoMemory)
sl@0
  2327
		{
sl@0
  2328
		_LIT(KLog,"After %d/%d iterations SendEventToAllWindowGroups_Priority0 returned the error %d");
sl@0
  2329
		LOG_MESSAGE4(KLog,ii,numTest,err);
sl@0
  2330
		}
sl@0
  2331
	TheClient->WaitForAllEventProcessingToFinish();
sl@0
  2332
	User::After(1000000);		//1sec, give other sessions a chance to respond to the events
sl@0
  2333
sl@0
  2334
	err=KErrNone;
sl@0
  2335
	for (ii=0; ii<=numTest && err==KErrNone;)
sl@0
  2336
		{
sl@0
  2337
		++ii;
sl@0
  2338
		err=TheClient->iWs.SendEventToOneWindowGroupsPerClient(event);
sl@0
  2339
		}
sl@0
  2340
	TEST(err==KErrNoMemory);
sl@0
  2341
	if (err!=KErrNoMemory)
sl@0
  2342
		{
sl@0
  2343
		_LIT(KLog,"After %d/%d iterations SendEventToOneWindowGroupsPerClient returned the error %d");
sl@0
  2344
		LOG_MESSAGE4(KLog,ii,numTest,err);
sl@0
  2345
		}
sl@0
  2346
	TheClient->WaitForAllEventProcessingToFinish();
sl@0
  2347
	User::After(1000000);		//1sec, give other sessions a chance to respond to the events
sl@0
  2348
	}
sl@0
  2349
sl@0
  2350
void CTWindowTest::TestNotSupportedFunctionality()
sl@0
  2351
    {
sl@0
  2352
    TInt err = KErrNone;
sl@0
  2353
    TSize windowSize = TSize(10,10);
sl@0
  2354
    TSize testSize = TSize();
sl@0
  2355
    
sl@0
  2356
    RWindowGroup group(TheClient->iWs);
sl@0
  2357
    RWindow window(TheClient->iWs);
sl@0
  2358
sl@0
  2359
    err = group.Construct((TUint32)&group, EFalse);
sl@0
  2360
    TEST(err==KErrNone);
sl@0
  2361
    err = window.Construct(group,(TUint32)&window);
sl@0
  2362
    TEST(err==KErrNone);
sl@0
  2363
    
sl@0
  2364
    window.SetExtent(TPoint(0,0),windowSize);
sl@0
  2365
    window.Activate();
sl@0
  2366
    
sl@0
  2367
    testSize = window.Size();
sl@0
  2368
    TEST((testSize.iWidth==windowSize.iWidth) && (testSize.iHeight==windowSize.iHeight));
sl@0
  2369
    
sl@0
  2370
    testSize = window.Size();
sl@0
  2371
    TEST((testSize.iWidth==windowSize.iWidth) && (testSize.iHeight==windowSize.iHeight));
sl@0
  2372
    
sl@0
  2373
    window.Close();
sl@0
  2374
    group.Close();  
sl@0
  2375
    }
sl@0
  2376
sl@0
  2377
void CTWindowTest::RunTestCaseL(TInt /*aCurTestCase*/)
sl@0
  2378
	{
sl@0
  2379
	_LIT(KTest1,"Window");
sl@0
  2380
	_LIT(KTest2,"DestroyWindowWithActiveGc");
sl@0
  2381
	_LIT(KTest3,"Shadow/NoAutoClear");
sl@0
  2382
	_LIT(KTest4,"Corner Tests");
sl@0
  2383
	_LIT(KTest5,"Invalid Window Functions");
sl@0
  2384
	_LIT(KTest7,"Mega-Tree");
sl@0
  2385
	_LIT(KTest8,"Tiled Window One");
sl@0
  2386
	_LIT(KTest9,"Tiled Window Two");
sl@0
  2387
	_LIT(KTest10,"Color Test");
sl@0
  2388
	_LIT(KTest11,"Invalid Window Functions2");
sl@0
  2389
	_LIT(KTest12,"Defect 1");
sl@0
  2390
	_LIT(KTest13,"Defect 2");
sl@0
  2391
	_LIT(KTest14,"Parent Deleted 1");
sl@0
  2392
	_LIT(KTest15,"Parent Deleted 2");
sl@0
  2393
	_LIT(KTest16,"Defect 3");
sl@0
  2394
	_LIT(KTest17,"Background Color");
sl@0
  2395
	_LIT(KTest18,"Focus Changed");
sl@0
  2396
	_LIT(KTest21,"Events To All");
sl@0
  2397
	_LIT(KTest22,"Error Codes");
sl@0
  2398
	_LIT(KTest23,"Group Id");
sl@0
  2399
	_LIT(KTest24,"DeleteParentWindowOnly");
sl@0
  2400
#if defined(_DEBUG)
sl@0
  2401
	_LIT(KTest25,"DuplicateWindowHandles");
sl@0
  2402
#else
sl@0
  2403
	_LIT(KTest25skipped,"DuplicateWindowHandles skipped");
sl@0
  2404
#endif
sl@0
  2405
sl@0
  2406
	((CTWindowTestStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
sl@0
  2407
sl@0
  2408
	_LIT(KTest26,"Saturate SendEvent");
sl@0
  2409
	_LIT(KTest27,"Not Supported Functionality");
sl@0
  2410
sl@0
  2411
	switch(++iTest->iState)
sl@0
  2412
		{
sl@0
  2413
/**
sl@0
  2414
@SYMTestCaseID		GRAPHICS-WSERV-0029
sl@0
  2415
sl@0
  2416
@SYMDEF  			DEF081259
sl@0
  2417
sl@0
  2418
@SYMTestCaseDesc    Test window can be created and destroyed correctly
sl@0
  2419
sl@0
  2420
@SYMTestPriority    High
sl@0
  2421
sl@0
  2422
@SYMTestStatus      Implemented
sl@0
  2423
sl@0
  2424
@SYMTestActions     Creates and destroys a window
sl@0
  2425
sl@0
  2426
@SYMTestExpectedResults Window is created and destroyed without error
sl@0
  2427
*/
sl@0
  2428
		case 1:
sl@0
  2429
			((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0029"));
sl@0
  2430
			iTest->LogSubTest(KTest1);
sl@0
  2431
			CreateTestWindowL();
sl@0
  2432
			CheckAndDestroyWindows();
sl@0
  2433
			//iState=17;
sl@0
  2434
			break;
sl@0
  2435
/**
sl@0
  2436
@SYMTestCaseID		GRAPHICS-WSERV-0030
sl@0
  2437
sl@0
  2438
@SYMDEF  			DEF081259
sl@0
  2439
sl@0
  2440
@SYMTestCaseDesc    Creates and destroys window with an active gc
sl@0
  2441
sl@0
  2442
@SYMTestPriority    High
sl@0
  2443
sl@0
  2444
@SYMTestStatus      Implemented
sl@0
  2445
sl@0
  2446
@SYMTestActions     Create and destroy a window with an active gc
sl@0
  2447
sl@0
  2448
@SYMTestExpectedResults Window is created and destroyed without error
sl@0
  2449
*/
sl@0
  2450
		case 2:
sl@0
  2451
			((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0030"));
sl@0
  2452
			iTest->LogSubTest(KTest2);
sl@0
  2453
			CreateTestWindowL();
sl@0
  2454
			DestroyWindowWithActiveGc();
sl@0
  2455
			CreateTestWindowL();
sl@0
  2456
			DestroyWindowWithActiveGc2L();
sl@0
  2457
			break;
sl@0
  2458
/**
sl@0
  2459
@SYMTestCaseID		GRAPHICS-WSERV-0031
sl@0
  2460
sl@0
  2461
@SYMDEF  			DEF081259
sl@0
  2462
sl@0
  2463
@SYMTestCaseDesc    Test that shadow is not automatically cleared when
sl@0
  2464
					drawing a window
sl@0
  2465
sl@0
  2466
@SYMTestPriority    High
sl@0
  2467
sl@0
  2468
@SYMTestStatus      Implemented
sl@0
  2469
sl@0
  2470
@SYMTestActions     Draw windows and check that the shadow is not automatically
sl@0
  2471
					cleared
sl@0
  2472
sl@0
  2473
@SYMTestExpectedResults Screen comparison returns that the shadow was not cleared
sl@0
  2474
*/
sl@0
  2475
		case 3:
sl@0
  2476
			((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0031"));
sl@0
  2477
			//window shadowing is no longer supported. keep the test to make sure clients can still call the methods
sl@0
  2478
			iTest->LogSubTest(KTest3);
sl@0
  2479
			ShadowAutoClearTest();
sl@0
  2480
			break;
sl@0
  2481
/**
sl@0
  2482
@SYMTestCaseID		GRAPHICS-WSERV-0032
sl@0
  2483
sl@0
  2484
@SYMDEF  			DEF081259
sl@0
  2485
sl@0
  2486
@SYMTestCaseDesc    Test the drawing of different types of corner of
sl@0
  2487
					a window
sl@0
  2488
sl@0
  2489
@SYMTestPriority    High
sl@0
  2490
sl@0
  2491
@SYMTestStatus      Implemented
sl@0
  2492
sl@0
  2493
@SYMTestActions     Draw a window with different types of corner
sl@0
  2494
sl@0
  2495
@SYMTestExpectedResults The window is drawn correctly for each corner type
sl@0
  2496
*/
sl@0
  2497
		case 4:
sl@0
  2498
			((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0032"));
sl@0
  2499
			iTest->LogSubTest(KTest4);
sl@0
  2500
			CornerTests();
sl@0
  2501
			break;
sl@0
  2502
/**
sl@0
  2503
@SYMTestCaseID		GRAPHICS-WSERV-0033
sl@0
  2504
sl@0
  2505
@SYMDEF  			DEF081259
sl@0
  2506
sl@0
  2507
@SYMTestCaseDesc    Test for panics when window is sent wrong requests
sl@0
  2508
sl@0
  2509
@SYMTestPriority    High
sl@0
  2510
sl@0
  2511
@SYMTestStatus      Implemented
sl@0
  2512
sl@0
  2513
@SYMTestActions     Send wrong requests to windows and deal with panic
sl@0
  2514
sl@0
  2515
@SYMTestExpectedResults The windows panic as expected
sl@0
  2516
*/
sl@0
  2517
		case 5:
sl@0
  2518
			((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0033"));
sl@0
  2519
			iTest->LogSubTest(KTest5);
sl@0
  2520
			TestInvalidFunctionsL();
sl@0
  2521
			break;
sl@0
  2522
/**
sl@0
  2523
@SYMTestCaseID		GRAPHICS-WSERV-0035
sl@0
  2524
sl@0
  2525
@SYMDEF  			DEF081259
sl@0
  2526
sl@0
  2527
@SYMTestCaseDesc    Draw 100 windows from a thread
sl@0
  2528
sl@0
  2529
@SYMTestPriority    High
sl@0
  2530
sl@0
  2531
@SYMTestStatus      Implemented
sl@0
  2532
sl@0
  2533
@SYMTestActions     Draw 100 windows from the same thread
sl@0
  2534
sl@0
  2535
@SYMTestExpectedResults The windows are all drawn without error
sl@0
  2536
*/
sl@0
  2537
		case 6:
sl@0
  2538
			((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0035"));
sl@0
  2539
			iTest->LogSubTest(KTest7);
sl@0
  2540
			CreateMegaTree();
sl@0
  2541
			break;
sl@0
  2542
/**
sl@0
  2543
@SYMTestCaseID		GRAPHICS-WSERV-0036
sl@0
  2544
sl@0
  2545
@SYMDEF  			DEF081259
sl@0
  2546
sl@0
  2547
@SYMTestCaseDesc    Check that windows can be drawn in a tiled format
sl@0
  2548
sl@0
  2549
@SYMTestPriority    High
sl@0
  2550
sl@0
  2551
@SYMTestStatus      Implemented
sl@0
  2552
sl@0
  2553
@SYMTestActions     Draw two windows in a tiled format and check they
sl@0
  2554
					are identical
sl@0
  2555
sl@0
  2556
@SYMTestExpectedResults The tiled windows are identical
sl@0
  2557
*/
sl@0
  2558
		case 7:
sl@0
  2559
			((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0036"));
sl@0
  2560
sl@0
  2561
			iTest->LogSubTest(KTest8);
sl@0
  2562
			TiledWindowTestL();
sl@0
  2563
			break;
sl@0
  2564
/**
sl@0
  2565
@SYMTestCaseID		GRAPHICS-WSERV-0037
sl@0
  2566
sl@0
  2567
@SYMDEF  			DEF081259
sl@0
  2568
sl@0
  2569
@SYMTestCaseDesc    Check that windows and dialogs can be drawn in a
sl@0
  2570
					tiled format
sl@0
  2571
sl@0
  2572
@SYMTestPriority    High
sl@0
  2573
sl@0
  2574
@SYMTestStatus      Implemented
sl@0
  2575
sl@0
  2576
@SYMTestActions     Draw windows and dialogs in a tiled format
sl@0
  2577
sl@0
  2578
@SYMTestExpectedResults The windows and dialogs are drawn correctly
sl@0
  2579
*/
sl@0
  2580
		case 8:
sl@0
  2581
			((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0037"));
sl@0
  2582
			iTest->LogSubTest(KTest9);
sl@0
  2583
			TiledWindowTest2L();
sl@0
  2584
			break;
sl@0
  2585
/**
sl@0
  2586
@SYMTestCaseID		GRAPHICS-WSERV-0038
sl@0
  2587
sl@0
  2588
@SYMDEF  			DEF081259
sl@0
  2589
sl@0
  2590
@SYMTestCaseDesc    Check drawing into a window with different
sl@0
  2591
					colour set ups
sl@0
  2592
sl@0
  2593
@SYMTestPriority    High
sl@0
  2594
sl@0
  2595
@SYMTestStatus      Implemented
sl@0
  2596
sl@0
  2597
@SYMTestActions     Draw in a window using different colour
sl@0
  2598
					configurations
sl@0
  2599
sl@0
  2600
@SYMTestExpectedResults The different colours are drawn correctly
sl@0
  2601
*/
sl@0
  2602
		case 9:
sl@0
  2603
			((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0038"));
sl@0
  2604
			iTest->LogSubTest(KTest10);
sl@0
  2605
			ColorTestL();
sl@0
  2606
			break;
sl@0
  2607
/**
sl@0
  2608
@SYMTestCaseID		GRAPHICS-WSERV-0039
sl@0
  2609
sl@0
  2610
@SYMDEF  			DEF081259
sl@0
  2611
sl@0
  2612
@SYMTestCaseDesc    Test for panics when window is sent wrong requests
sl@0
  2613
sl@0
  2614
@SYMTestPriority    High
sl@0
  2615
sl@0
  2616
@SYMTestStatus      Implemented
sl@0
  2617
sl@0
  2618
@SYMTestActions     Send wrong requests to windows and deal with panic
sl@0
  2619
sl@0
  2620
@SYMTestExpectedResults The windows panic as expected
sl@0
  2621
*/
sl@0
  2622
		case 10:
sl@0
  2623
			((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0039"));
sl@0
  2624
			iTest->LogSubTest(KTest11);
sl@0
  2625
			TestInvalidFunctions2L();
sl@0
  2626
			break;
sl@0
  2627
/**
sl@0
  2628
@SYMTestCaseID		GRAPHICS-WSERV-0040
sl@0
  2629
sl@0
  2630
@SYMDEF  			DEF081259
sl@0
  2631
sl@0
  2632
@SYMTestCaseDesc    Test for a defect that causes ROM to crash
sl@0
  2633
sl@0
  2634
@SYMTestPriority    High
sl@0
  2635
sl@0
  2636
@SYMTestStatus      Implemented
sl@0
  2637
sl@0
  2638
@SYMTestActions     Test a defect is not present which causes the ROM
sl@0
  2639
					to crash
sl@0
  2640
sl@0
  2641
@SYMTestExpectedResults The defect is not present
sl@0
  2642
*/
sl@0
  2643
		case 11:
sl@0
  2644
			((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0040"));
sl@0
  2645
			iTest->LogSubTest(KTest12);
sl@0
  2646
			Bug1L();
sl@0
  2647
			break;
sl@0
  2648
/**
sl@0
  2649
@SYMTestCaseID		GRAPHICS-WSERV-0041
sl@0
  2650
sl@0
  2651
@SYMDEF  			DEF081259
sl@0
  2652
sl@0
  2653
@SYMTestCaseDesc    Test a previous defect has not returned
sl@0
  2654
sl@0
  2655
@SYMTestPriority    High
sl@0
  2656
sl@0
  2657
@SYMTestStatus      Implemented
sl@0
  2658
sl@0
  2659
@SYMTestActions     Exercise the code the defect was discovered in
sl@0
  2660
sl@0
  2661
@SYMTestExpectedResults The defect is not present
sl@0
  2662
*/
sl@0
  2663
		case 12:
sl@0
  2664
			((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0041"));
sl@0
  2665
			iTest->LogSubTest(KTest13);
sl@0
  2666
			Bug2L();
sl@0
  2667
			break;
sl@0
  2668
/**
sl@0
  2669
@SYMTestCaseID		GRAPHICS-WSERV-0042
sl@0
  2670
sl@0
  2671
@SYMDEF  			DEF081259
sl@0
  2672
					DEF115543
sl@0
  2673
sl@0
  2674
@SYMTestCaseDesc    Test that when a parent window is deleted a panic
sl@0
  2675
					occurs
sl@0
  2676
sl@0
  2677
@SYMTestPriority    High
sl@0
  2678
sl@0
  2679
@SYMTestStatus      Implemented
sl@0
  2680
sl@0
  2681
@SYMTestActions     Delete a parent window and check for a panic
sl@0
  2682
					NOTE: DEF115543 has corrected GRAPHICS-WSERV-0042, and added a lot
sl@0
  2683
					more window functions.
sl@0
  2684
sl@0
  2685
@SYMTestExpectedResults All functions either:
sl@0
  2686
					Panic the owner thread with EWservPanicParentDeleted or
sl@0
  2687
					Get performed without accessing any NULL iParent pointers in the WSERV thread
sl@0
  2688
*/
sl@0
  2689
		case 13:
sl@0
  2690
			((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0042"));
sl@0
  2691
			iTest->LogSubTest(KTest14);
sl@0
  2692
			TestDeletedParentPanics1L();
sl@0
  2693
			break;
sl@0
  2694
/**
sl@0
  2695
@SYMTestCaseID		GRAPHICS-WSERV-0043
sl@0
  2696
sl@0
  2697
@SYMDEF  			DEF081259
sl@0
  2698
sl@0
  2699
@SYMTestCaseDesc    Test that when a parent window is deleted a panic
sl@0
  2700
					occurs
sl@0
  2701
sl@0
  2702
@SYMTestPriority    High
sl@0
  2703
sl@0
  2704
@SYMTestStatus      Implemented
sl@0
  2705
sl@0
  2706
@SYMTestActions     Delete a parent window and check for a panic
sl@0
  2707
sl@0
  2708
@SYMTestExpectedResults The panic occurs as expected
sl@0
  2709
*/
sl@0
  2710
		case 14:
sl@0
  2711
			((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0043"));
sl@0
  2712
			iTest->LogSubTest(KTest15);
sl@0
  2713
			TestDeletedParentPanics2L();
sl@0
  2714
			break;
sl@0
  2715
/**
sl@0
  2716
@SYMTestCaseID		GRAPHICS-WSERV-0044
sl@0
  2717
sl@0
  2718
@SYMDEF  			DEF081259
sl@0
  2719
sl@0
  2720
@SYMTestCaseDesc    Check that activate then make visible and backup
sl@0
  2721
					behind a window does not panic.
sl@0
  2722
sl@0
  2723
@SYMTestPriority    High
sl@0
  2724
sl@0
  2725
@SYMTestStatus      Implemented
sl@0
  2726
sl@0
  2727
@SYMTestActions     Activate then make visible and backup
sl@0
  2728
					behind a window
sl@0
  2729
sl@0
  2730
@SYMTestExpectedResults No panic occurs
sl@0
  2731
*/
sl@0
  2732
		case 15:
sl@0
  2733
			((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0044"));
sl@0
  2734
			iTest->LogSubTest(KTest16);
sl@0
  2735
			Bug3L();
sl@0
  2736
			break;
sl@0
  2737
/**
sl@0
  2738
@SYMTestCaseID		GRAPHICS-WSERV-0045
sl@0
  2739
sl@0
  2740
@SYMDEF  			DEF081259
sl@0
  2741
sl@0
  2742
@SYMTestCaseDesc    Test window being drawn with the correct background
sl@0
  2743
					color when they are moved on the screen
sl@0
  2744
sl@0
  2745
@SYMTestPriority    High
sl@0
  2746
sl@0
  2747
@SYMTestStatus      Implemented
sl@0
  2748
sl@0
  2749
@SYMTestActions     Move window on the screen and check it is drawn with
sl@0
  2750
					the correct background colour
sl@0
  2751
sl@0
  2752
@SYMTestExpectedResults The background coloour is correct
sl@0
  2753
*/
sl@0
  2754
		case 16:
sl@0
  2755
			((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0045"));
sl@0
  2756
			iTest->LogSubTest(KTest17);
sl@0
  2757
			BackColorBugL();
sl@0
  2758
			break;
sl@0
  2759
/**
sl@0
  2760
@SYMTestCaseID		GRAPHICS-WSERV-0046
sl@0
  2761
sl@0
  2762
@SYMDEF  			DEF081259
sl@0
  2763
sl@0
  2764
@SYMTestCaseDesc    Test that the focus change is available after redraw
sl@0
  2765
sl@0
  2766
@SYMTestPriority    High
sl@0
  2767
sl@0
  2768
@SYMTestStatus      Implemented
sl@0
  2769
sl@0
  2770
@SYMTestActions     Redraw and check the focus change is available
sl@0
  2771
sl@0
  2772
@SYMTestExpectedResults The focus change is available
sl@0
  2773
*/
sl@0
  2774
		case 17:
sl@0
  2775
			((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0046"));
sl@0
  2776
			iTest->LogSubTest(KTest18);
sl@0
  2777
			FocusChangedL();
sl@0
  2778
			break;
sl@0
  2779
/**
sl@0
  2780
@SYMTestCaseID		GRAPHICS-WSERV-0048
sl@0
  2781
sl@0
  2782
@SYMDEF  			DEF081259
sl@0
  2783
sl@0
  2784
@SYMTestCaseDesc    Test that events can be sent to a number of window
sl@0
  2785
					groups simultaneously
sl@0
  2786
sl@0
  2787
@SYMTestPriority    High
sl@0
  2788
sl@0
  2789
@SYMTestStatus      Implemented
sl@0
  2790
sl@0
  2791
@SYMTestActions     Send events to a number of window groups and check
sl@0
  2792
					that they all receive them
sl@0
  2793
sl@0
  2794
@SYMTestExpectedResults The events and sent to the window groups correctly
sl@0
  2795
*/
sl@0
  2796
		case 18:
sl@0
  2797
			((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0048"));
sl@0
  2798
			iTest->LogSubTest(KTest21);
sl@0
  2799
			EventsToAllL();
sl@0
  2800
			break;
sl@0
  2801
/**
sl@0
  2802
@SYMTestCaseID		GRAPHICS-WSERV-0049
sl@0
  2803
sl@0
  2804
@SYMDEF  			DEF081259
sl@0
  2805
sl@0
  2806
@SYMTestCaseDesc    Test error code when incorrectly moving a window to
sl@0
  2807
					a group.
sl@0
  2808
sl@0
  2809
@SYMTestPriority    High
sl@0
  2810
sl@0
  2811
@SYMTestStatus      Implemented
sl@0
  2812
sl@0
  2813
@SYMTestActions     Try to move a window to a group and check the error
sl@0
  2814
					codes
sl@0
  2815
sl@0
  2816
@SYMTestExpectedResults The correct error codes are returned
sl@0
  2817
*/
sl@0
  2818
		case 19:
sl@0
  2819
			((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0049"));
sl@0
  2820
			iTest->LogSubTest(KTest22);
sl@0
  2821
			ErrorCodesL();
sl@0
  2822
/**
sl@0
  2823
@SYMTestCaseID		GRAPHICS-WSERV-0050
sl@0
  2824
sl@0
  2825
@SYMDEF  			DEF081259
sl@0
  2826
sl@0
  2827
@SYMTestCaseDesc    Check that the correct group id is assigned to a
sl@0
  2828
					chain of windows
sl@0
  2829
sl@0
  2830
@SYMTestPriority    High
sl@0
  2831
sl@0
  2832
@SYMTestStatus      Implemented
sl@0
  2833
sl@0
  2834
@SYMTestActions     Create a chain of windows in the same group and check
sl@0
  2835
					the all have the same group id
sl@0
  2836
sl@0
  2837
@SYMTestExpectedResults The windows all have the same group id
sl@0
  2838
*/
sl@0
  2839
		case 20:
sl@0
  2840
			((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0050"));
sl@0
  2841
			iTest->LogSubTest(KTest23);
sl@0
  2842
			GroupIdL();
sl@0
  2843
			break;
sl@0
  2844
			
sl@0
  2845
/**
sl@0
  2846
@SYMTestCaseID		GRAPHICS-WSERV-0461
sl@0
  2847
sl@0
  2848
@SYMDEF  			PDEF114190
sl@0
  2849
sl@0
  2850
@SYMTestCaseDesc    Test window redraw queue cleanup when window is deleted in low memory conditions
sl@0
  2851
sl@0
  2852
@SYMTestPriority    High
sl@0
  2853
sl@0
  2854
@SYMTestStatus      Implemented
sl@0
  2855
sl@0
  2856
@SYMTestActions     Have a loop which increases the number of allocations in the server thread before failure;
sl@0
  2857
					Within the loop:
sl@0
  2858
					1) Create a parent window and a child window of the parent; 
sl@0
  2859
					2) Delete the parent window only, but not the child window; 
sl@0
  2860
					3) Create a testWindow. This new window gets added to the redraw queue which will force it 
sl@0
  2861
					reordering. This would crash WSERV due to this defect because the orphaned window (which is 
sl@0
  2862
					the previous child window) is still in the redraw queue
sl@0
  2863
					4) Delete all the windows involved;
sl@0
  2864
sl@0
  2865
@SYMTestExpectedResults		The window redraw queue should be cleaned up when the first window is deleted;
sl@0
  2866
							WSERV should not crash. The test should pass. 
sl@0
  2867
*/		
sl@0
  2868
		case 21:
sl@0
  2869
			((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0461"));
sl@0
  2870
			iTest->LogSubTest(KTest24);
sl@0
  2871
			TestWindowDelete();
sl@0
  2872
			break;
sl@0
  2873
			
sl@0
  2874
/**
sl@0
  2875
@SYMTestCaseID		GRAPHICS-WSERV-0463
sl@0
  2876
sl@0
  2877
@SYMDEF				DEF115601
sl@0
  2878
sl@0
  2879
@SYMTestCaseDesc    Two RWindowGroup objects using same window client handle cause Emulator crash
sl@0
  2880
sl@0
  2881
@SYMTestPriority    Medium
sl@0
  2882
sl@0
  2883
@SYMTestStatus      Implemented
sl@0
  2884
sl@0
  2885
@SYMTestActions     Create two window groups with the same handle.
sl@0
  2886
sl@0
  2887
@SYMTestExpectedResults		WSERV should panic the client thread with the code EWservPanicDuplicateHandle
sl@0
  2888
							and then destroy the window groups without crashing WSERV
sl@0
  2889
*/
sl@0
  2890
		case 22:
sl@0
  2891
#if defined(_DEBUG)
sl@0
  2892
			((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0463"));
sl@0
  2893
			iTest->LogSubTest(KTest25);
sl@0
  2894
			TEST(iTest->TestWsPanicL(DoPanicTest6,EWservPanicDuplicateHandle,0,(TAny*)iTest->iScreenNumber,NULL));
sl@0
  2895
			iTest->CloseAllPanicWindows();
sl@0
  2896
#else
sl@0
  2897
			iTest->LogSubTest(KTest25skipped);	//Client side panic will only occur in debug builds of WServ
sl@0
  2898
#endif
sl@0
  2899
			break;
sl@0
  2900
		case 23:
sl@0
  2901
			((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0495"));
sl@0
  2902
			iTest->LogSubTest(KTest26);
sl@0
  2903
			SaturateSendEvent();
sl@0
  2904
			break;
sl@0
  2905
/**
sl@0
  2906
@SYMTestCaseID      GRAPHICS-WSERV-0655
sl@0
  2907
sl@0
  2908
@SYMDEF             ou1cimx1#329309
sl@0
  2909
sl@0
  2910
@SYMTestCaseDesc    Fix native orientation functionality not supported
sl@0
  2911
sl@0
  2912
@SYMTestPriority    Medium
sl@0
  2913
sl@0
  2914
@SYMTestStatus      Implemented
sl@0
  2915
sl@0
  2916
@SYMTestActions     Call fucntions related to fix native orientation on a window
sl@0
  2917
sl@0
  2918
@SYMTestExpectedResults     Fix native orientation functionality not supported
sl@0
  2919
			*/			
sl@0
  2920
        case 24:
sl@0
  2921
            ((CTWindowTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0655"));
sl@0
  2922
            iTest->LogSubTest(KTest27);
sl@0
  2923
            TestNotSupportedFunctionality();
sl@0
  2924
            break;			
sl@0
  2925
		default:
sl@0
  2926
            		((CTWindowTestStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
sl@0
  2927
			((CTWindowTestStep*)iStep)->CloseTMSGraphicsStep();
sl@0
  2928
			TestComplete();
sl@0
  2929
			break;
sl@0
  2930
		}
sl@0
  2931
	((CTWindowTestStep*)iStep)->RecordTestResultL();
sl@0
  2932
	}
sl@0
  2933
sl@0
  2934
__WS_CONSTRUCT_STEP__(WindowTest)