os/graphics/windowing/windowserver/test/tauto/TPANIC.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-2010 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// Test various cases of Wserv panicing client apps
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 "TPANIC.H"
sl@0
    25
#include "../tlib/testbase.h"
sl@0
    26
#include <w32debug.h>
sl@0
    27
#define TEST_BITMAP _L("Z:\\WSTEST\\WSAUTOTEST.MBM")
sl@0
    28
sl@0
    29
class RWsSessionHacker : public RWsSession
sl@0
    30
	{
sl@0
    31
public:
sl@0
    32
	inline RWsBuffer *WsBuffer() const {return(iBuffer);};
sl@0
    33
	inline TInt PanicItSendReceive(TInt aFunction,const TIpcArgs& aArgs) const {return SendReceive(aFunction,aArgs);};
sl@0
    34
	inline TInt PanicItSend(TInt aFunction,const TIpcArgs& aArgs) const {return Send(aFunction,aArgs);};
sl@0
    35
	inline TInt PanicItSendReceive(TInt aFunction) const {return SendReceive(aFunction);};
sl@0
    36
	inline TInt PanicItSend(TInt aFunction) const {return Send(aFunction);};
sl@0
    37
	};
sl@0
    38
sl@0
    39
class RWsBufferHacker // copy of original data structure to access buffer data
sl@0
    40
	{
sl@0
    41
public:
sl@0
    42
	RWsSession* iSession;
sl@0
    43
	CWsGraphic::CManager* iManager;
sl@0
    44
	TBool iAutoFlush;
sl@0
    45
	TPtr8 iBuf;
sl@0
    46
	RWsBuffer* iNext;
sl@0
    47
	TInt iPreviousHandle;
sl@0
    48
	TInt iBufSize;
sl@0
    49
	TInt iMaxBufSize;
sl@0
    50
	TInt iDirectAcessCount;
sl@0
    51
	RArray<TInt> iBitmapArray;
sl@0
    52
	TBool iInvalidBitmapArray;
sl@0
    53
	};
sl@0
    54
sl@0
    55
CTPanic::CTPanic(CTestStep* aStep):
sl@0
    56
	CTWsGraphicsBase(aStep)
sl@0
    57
	{
sl@0
    58
	}
sl@0
    59
	
sl@0
    60
CTPanic::~CTPanic()
sl@0
    61
	{
sl@0
    62
	}
sl@0
    63
sl@0
    64
LOCAL_C TInt DoDeletedParentTest(TInt aInt, TAny *aScreenNumber)
sl@0
    65
	{
sl@0
    66
	RWsSession ws;
sl@0
    67
	User::LeaveIfError(ws.Connect());
sl@0
    68
	// point to correct screen
sl@0
    69
	CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
sl@0
    70
	User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
sl@0
    71
	
sl@0
    72
	RWindowGroup group(ws);
sl@0
    73
	User::LeaveIfError(group.Construct(888));
sl@0
    74
	group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
sl@0
    75
	switch(aInt)
sl@0
    76
		{
sl@0
    77
		case 1:
sl@0
    78
			RWindow win1(ws);
sl@0
    79
			User::LeaveIfError(win1.Construct(group,1));
sl@0
    80
			RWindow win2(ws);
sl@0
    81
			User::LeaveIfError(win2.Construct(win1,2));
sl@0
    82
			win1.Close();
sl@0
    83
			win2.SetExtent(TPoint(1,2),TSize(3,4));
sl@0
    84
			break;
sl@0
    85
		}
sl@0
    86
	ws.Flush();
sl@0
    87
	return(EWsExitReasonBad);
sl@0
    88
	}
sl@0
    89
sl@0
    90
LOCAL_C void ReuseWindow(RWsSession& aWs,RWindowGroup& aGroup,RWindow aCopyWin,RWindow* aPtrWin)
sl@0
    91
	{
sl@0
    92
	aPtrWin->Close();
sl@0
    93
	RWindow win(aWs);
sl@0
    94
	User::LeaveIfError(win.Construct(aGroup,17));
sl@0
    95
	aCopyWin.SetExtent(TPoint(1,2),TSize(3,4));	
sl@0
    96
	}
sl@0
    97
sl@0
    98
LOCAL_C void ReuseGroupWindow(RWsSession& aWs,RWindowGroup aCopyWin,RWindowGroup* aPtrWin)
sl@0
    99
	{
sl@0
   100
	aPtrWin->Close();
sl@0
   101
	RWindowGroup group(aWs);
sl@0
   102
	User::LeaveIfError(group.Construct(889));
sl@0
   103
	group.EnableReceiptOfFocus(EFalse);	
sl@0
   104
	aCopyWin.EnableReceiptOfFocus(EFalse);	
sl@0
   105
	}
sl@0
   106
sl@0
   107
LOCAL_C void ReuseSprite(RWsSession& aWs,RWindow& aWin,RWsSprite aCopySprite,RWsSprite* aPtrSprite)
sl@0
   108
	{
sl@0
   109
	aPtrSprite->Close();
sl@0
   110
	RWsSprite sprite(aWs);
sl@0
   111
	sprite.Construct(aWin,TPoint(0,0),0);
sl@0
   112
	aCopySprite.SetPosition(TPoint(22,22));	
sl@0
   113
	}
sl@0
   114
sl@0
   115
LOCAL_C void ReusePointerCursor(RWsSession& aWs,RWsPointerCursor aCopyCursor,RWsPointerCursor* aPtrCursor)
sl@0
   116
	{
sl@0
   117
	aPtrCursor->Close();
sl@0
   118
	RWsPointerCursor cursor(aWs);
sl@0
   119
	cursor.Construct(0);
sl@0
   120
	aCopyCursor.Activate();	
sl@0
   121
	}
sl@0
   122
sl@0
   123
LOCAL_C TInt DoHandleReUse(TInt aInt, TAny *aScreenNumber)
sl@0
   124
	{
sl@0
   125
	RWsSession ws;
sl@0
   126
	User::LeaveIfError(ws.Connect());
sl@0
   127
	CWsScreenDevice *scrdev=new(ELeave) CWsScreenDevice(ws);
sl@0
   128
	scrdev->Construct((TInt)aScreenNumber);
sl@0
   129
	RWindowGroup group(ws);
sl@0
   130
	User::LeaveIfError(group.Construct(888));
sl@0
   131
	group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
sl@0
   132
	RWindow win(ws);
sl@0
   133
	User::LeaveIfError(win.Construct(group,1));
sl@0
   134
	switch(aInt)
sl@0
   135
		{
sl@0
   136
		case 2:			//WS_HANDLE_WINDOW
sl@0
   137
			ReuseWindow(ws,group,win,&win);
sl@0
   138
			break;
sl@0
   139
		case 3:			//WS_HANDLE_GROUP_WINDOW
sl@0
   140
			ReuseGroupWindow(ws,group,&group);
sl@0
   141
			break;
sl@0
   142
		case 4:			//WS_HANDLE_SPRITE
sl@0
   143
			{
sl@0
   144
			RWsSprite sprite(ws);
sl@0
   145
			sprite.Construct(win,TPoint(0,0),0);
sl@0
   146
			ReuseSprite(ws,win,sprite,&sprite);
sl@0
   147
			}
sl@0
   148
			break;
sl@0
   149
		case 5:			//WS_HANDLE_POINTER_CURSOR
sl@0
   150
			{
sl@0
   151
			RWsPointerCursor cursor(ws);
sl@0
   152
			cursor.Construct(0);
sl@0
   153
			ReusePointerCursor(ws,cursor,&cursor);
sl@0
   154
			}
sl@0
   155
			break;
sl@0
   156
		}
sl@0
   157
	ws.Flush();
sl@0
   158
	return(EWsExitReasonBad);
sl@0
   159
	}
sl@0
   160
sl@0
   161
LOCAL_C TInt DoScreenDevicePanicTest(TInt aInt, TAny *aScreenNumber)
sl@0
   162
	{
sl@0
   163
	RWsSession ws;
sl@0
   164
	User::LeaveIfError(ws.Connect());
sl@0
   165
sl@0
   166
	CWsScreenDevice *scrdev=new(ELeave) CWsScreenDevice(ws);
sl@0
   167
	User::LeaveIfError(scrdev->Construct((TInt)aScreenNumber));
sl@0
   168
	
sl@0
   169
	RWindowGroup group(ws);
sl@0
   170
	User::LeaveIfError(group.Construct(888));
sl@0
   171
	group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
sl@0
   172
	RWindow win(ws);
sl@0
   173
	User::LeaveIfError(win.Construct(group, 1));
sl@0
   174
	win.Activate();
sl@0
   175
	CFbsBitmap *bitmap=new(ELeave) CFbsBitmap;
sl@0
   176
 	switch(aInt)
sl@0
   177
		{
sl@0
   178
		case 1:
sl@0
   179
			scrdev->CopyScreenToBitmap(bitmap);
sl@0
   180
			break;
sl@0
   181
		case 2:
sl@0
   182
			scrdev->CopyScreenToBitmap(bitmap,TRect(0,0,10,10));
sl@0
   183
			break;
sl@0
   184
		default:
sl@0
   185
			return(EWsExitReasonFinished);
sl@0
   186
		}
sl@0
   187
	ws.Flush();
sl@0
   188
	return(EWsExitReasonBad);
sl@0
   189
	}
sl@0
   190
sl@0
   191
LOCAL_C TInt DoOpcodeTests(TInt aInt, TAny *aScreenNumber)
sl@0
   192
	{
sl@0
   193
	RWsSession ws;
sl@0
   194
	User::LeaveIfError(ws.Connect());
sl@0
   195
sl@0
   196
	CWsScreenDevice *scrdev=new(ELeave) CWsScreenDevice(ws);
sl@0
   197
	User::LeaveIfError(scrdev->Construct((TInt)aScreenNumber));
sl@0
   198
	
sl@0
   199
	RWindowGroup group(ws);
sl@0
   200
	User::LeaveIfError(group.Construct(888));
sl@0
   201
	group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
sl@0
   202
	RWindow win(ws);
sl@0
   203
	User::LeaveIfError(win.Construct(group, 1));
sl@0
   204
	win.Activate();
sl@0
   205
	CWindowGc *gc;
sl@0
   206
	scrdev->CreateContext(gc);
sl@0
   207
 	switch(aInt)
sl@0
   208
		{
sl@0
   209
		case 1:
sl@0
   210
			ws.TestWrite(ws.WsHandle(),9999,NULL,0);
sl@0
   211
			break;
sl@0
   212
		case 2:
sl@0
   213
			gc->Activate(win);
sl@0
   214
			win.BeginRedraw();
sl@0
   215
			ws.TestWrite(gc->WsHandle(),9999,NULL,0);
sl@0
   216
			/* This only panics if the command is processed immediately.  If it goes into the redraw
sl@0
   217
			store then it will be unable to panic the client untill an additional buffer has been received,
sl@0
   218
			hence the double flush.
sl@0
   219
			*/
sl@0
   220
			win.EndRedraw();
sl@0
   221
			ws.Finish();
sl@0
   222
			win.BeginRedraw();
sl@0
   223
			win.EndRedraw();
sl@0
   224
			break;
sl@0
   225
		case 3:
sl@0
   226
			ws.TestWrite(scrdev->WsHandle(),9999,NULL,0);
sl@0
   227
			break;
sl@0
   228
		case 4:
sl@0
   229
			{
sl@0
   230
			CWsBitmap *bitmap=new(ELeave) CWsBitmap(ws);
sl@0
   231
			bitmap->Create(TSize(10,10),EGray4);
sl@0
   232
			ws.TestWrite(bitmap->WsHandle(),9999,NULL,0);
sl@0
   233
			}
sl@0
   234
			break;
sl@0
   235
		case 5:
sl@0
   236
			ws.TestWrite(win.WsHandle(),9999,NULL,0);
sl@0
   237
			break;
sl@0
   238
		case 6:
sl@0
   239
			ws.TestWrite(group.WsHandle(),9999,NULL,0);
sl@0
   240
			break;
sl@0
   241
		case 7:
sl@0
   242
			{
sl@0
   243
			RWsSprite sprite(ws);
sl@0
   244
			sprite.Construct(win,TPoint(0,0),0);
sl@0
   245
			ws.TestWrite(sprite.WsHandle(),9999,NULL,0);
sl@0
   246
			}
sl@0
   247
			break;
sl@0
   248
		default:
sl@0
   249
			return(EWsExitReasonFinished);
sl@0
   250
		}
sl@0
   251
	ws.Flush();
sl@0
   252
	return(EWsExitReasonBad);
sl@0
   253
	}
sl@0
   254
sl@0
   255
TInt DoGraphicsPanicTest(RWsSession& aWs, RWindow& aRWin, RDrawableWindow* aDrawWin, CWindowGc* aGc, CFbsFont* aFont, TInt aTest, TInt aSubTest, TBool aInRedraw, TBool aNeedsValidating)
sl@0
   256
	{
sl@0
   257
	if (aInRedraw || aNeedsValidating)
sl@0
   258
		{
sl@0
   259
		aRWin.BeginRedraw();
sl@0
   260
		if (!aInRedraw)
sl@0
   261
			{ // TransWin without redraw active needs the begin/end to make the redraw store active
sl@0
   262
			aRWin.EndRedraw(); // or else all graphics will simply be ignored and no panics will occur
sl@0
   263
			}
sl@0
   264
		}
sl@0
   265
	aWs.Flush();
sl@0
   266
	TRect rect01(0,0,1,1);
sl@0
   267
	TPoint point00;
sl@0
   268
	switch(aTest)
sl@0
   269
		{
sl@0
   270
	case 1:
sl@0
   271
		aGc->UseFont(aFont);
sl@0
   272
		switch(aSubTest)
sl@0
   273
			{
sl@0
   274
		case 0:
sl@0
   275
			{
sl@0
   276
			TWsGcCmdBoxText boxText(rect01,0,CGraphicsContext::ELeft,0,0x800000,1);
sl@0
   277
			aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawBoxText,&boxText,sizeof(boxText));
sl@0
   278
			}
sl@0
   279
			break;
sl@0
   280
		case 1:
sl@0
   281
			{
sl@0
   282
			TWsGcCmdDrawText dt(point00,600);
sl@0
   283
			aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawText,&dt,sizeof(dt));
sl@0
   284
			}
sl@0
   285
			break;
sl@0
   286
		case 2:
sl@0
   287
			{
sl@0
   288
			TWsGcCmdBoxTextOptimised1 dt(rect01,0,600);
sl@0
   289
			aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawBoxTextOptimised1,&dt,sizeof(dt));
sl@0
   290
			}
sl@0
   291
			break;
sl@0
   292
		case 3:
sl@0
   293
			{
sl@0
   294
			TWsGcCmdDrawTextVertical dt(point00,600,EFalse);
sl@0
   295
			aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawTextVertical,&dt,sizeof(dt));
sl@0
   296
			}
sl@0
   297
			break;
sl@0
   298
		case 4:
sl@0
   299
			{
sl@0
   300
			TWsGcCmdBoxTextVertical dt(rect01);
sl@0
   301
			dt.length=600;
sl@0
   302
			aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawBoxTextVertical,&dt,sizeof(dt));
sl@0
   303
			}
sl@0
   304
			break;
sl@0
   305
		case 5:
sl@0
   306
			return(EWsExitReasonFinished);
sl@0
   307
			}
sl@0
   308
		break;
sl@0
   309
	case 2:
sl@0
   310
		{
sl@0
   311
		TInt opcode=0;
sl@0
   312
		switch(aSubTest)
sl@0
   313
			{
sl@0
   314
		case 0:
sl@0
   315
			opcode=EWsGcOpGdiBlt2;
sl@0
   316
			break;
sl@0
   317
		case 1:
sl@0
   318
			opcode=EWsGcOpGdiWsBlt2;
sl@0
   319
			break;
sl@0
   320
		case 2:
sl@0
   321
			return(EWsExitReasonFinished);
sl@0
   322
			}
sl@0
   323
		TWsGcCmdGdiBlt2 gdiBlit(point00,0xBADBAD);
sl@0
   324
		aWs.TestWrite(aGc->WsHandle(),opcode,&gdiBlit,sizeof(gdiBlit));
sl@0
   325
		if (aInRedraw)
sl@0
   326
			{ // Adding two bad bitmaps to redraw store fbs store causes leave as NULL handles of failed bitmaps clash
sl@0
   327
			gdiBlit.handle=0xBADBAD2;
sl@0
   328
			aWs.TestWrite(aGc->WsHandle(),opcode,&gdiBlit,sizeof(gdiBlit));
sl@0
   329
			}
sl@0
   330
		}
sl@0
   331
		break;
sl@0
   332
	case 3:
sl@0
   333
		{
sl@0
   334
		const TInt KNumBadBmpModes=3;
sl@0
   335
		const TInt KNumTestsPerOpcode=KNumBadBmpModes*2;
sl@0
   336
		enum {KPanicIndexMasked,KPanicIndexDraw,KPanicIndexAlphaBlend,KPanicIndexMax};
sl@0
   337
		TInt opcodeMode=aSubTest/KNumTestsPerOpcode;
sl@0
   338
		TInt bmpMode=aSubTest%KNumTestsPerOpcode;
sl@0
   339
		TInt bmp1=0xBADBAD;
sl@0
   340
		TInt bmp2=0xBADBAD;
sl@0
   341
		TInt goodBmp;
sl@0
   342
		TInt opcodeBlt;
sl@0
   343
		TInt opcodeDraw;
sl@0
   344
		if (bmpMode<KNumBadBmpModes)
sl@0
   345
			{	// These two use a CFbsBitmap
sl@0
   346
			CFbsBitmap* goodBitmap=new(ELeave) CFbsBitmap;
sl@0
   347
			goodBitmap->Create(TSize(10,10),EGray4);
sl@0
   348
			goodBmp=goodBitmap->Handle();
sl@0
   349
			opcodeBlt=EWsGcOpGdiBltMasked;
sl@0
   350
			opcodeDraw=EWsGcOpDrawBitmapMasked;
sl@0
   351
			}
sl@0
   352
		else
sl@0
   353
			{	// These two use a CWsBitmap
sl@0
   354
			CWsBitmap* goodBitmap=new(ELeave) CWsBitmap(aWs);
sl@0
   355
			goodBitmap->Create(TSize(10,10),EGray4);
sl@0
   356
			goodBmp=goodBitmap->WsHandle();
sl@0
   357
			opcodeBlt=EWsGcOpGdiWsBltMasked;
sl@0
   358
			opcodeDraw=EWsGcOpWsDrawBitmapMasked;
sl@0
   359
			}
sl@0
   360
		switch(bmpMode%KNumBadBmpModes)
sl@0
   361
			{
sl@0
   362
		case 0:
sl@0
   363
			bmp2=goodBmp;
sl@0
   364
			break;
sl@0
   365
		case 1:
sl@0
   366
			bmp1=goodBmp;
sl@0
   367
			break;
sl@0
   368
		case 2:	// Leave them both bad
sl@0
   369
			break;
sl@0
   370
			}
sl@0
   371
		switch(opcodeMode)
sl@0
   372
			{
sl@0
   373
		case KPanicIndexMasked:
sl@0
   374
			{
sl@0
   375
			TWsGcCmdBltMasked gdiBlitMasked(point00,bmp1,rect01,bmp2,EFalse);
sl@0
   376
			aWs.TestWrite(aGc->WsHandle(),opcodeBlt,&gdiBlitMasked,sizeof(gdiBlitMasked));
sl@0
   377
			}
sl@0
   378
			break;
sl@0
   379
		case KPanicIndexDraw:
sl@0
   380
			{
sl@0
   381
			TWsGcCmdDrawBitmapMasked maskedBitmap(rect01,bmp1,rect01,bmp2,EFalse);
sl@0
   382
			aWs.TestWrite(aGc->WsHandle(),opcodeDraw,&maskedBitmap,sizeof(maskedBitmap));
sl@0
   383
			}
sl@0
   384
			break;
sl@0
   385
		case KPanicIndexAlphaBlend:
sl@0
   386
			{
sl@0
   387
			TWsGcCmdAlphaBlendBitmaps alphaBlend(point00,bmp1,rect01,bmp2,point00);
sl@0
   388
			aWs.TestWrite(aGc->WsHandle(),EWsGcOpGdiAlphaBlendBitmaps,&alphaBlend,sizeof(alphaBlend));
sl@0
   389
			}
sl@0
   390
			break;
sl@0
   391
		case KPanicIndexMax:
sl@0
   392
			return(EWsExitReasonFinished);
sl@0
   393
			}
sl@0
   394
		}
sl@0
   395
		break;
sl@0
   396
	case 4:
sl@0
   397
		switch(aSubTest)
sl@0
   398
			{
sl@0
   399
		case 0:
sl@0
   400
			{
sl@0
   401
			TWsClCmdCreateBitmap createBitmap;
sl@0
   402
			createBitmap.handle=0xB0D;
sl@0
   403
			aWs.TestWrite(aWs.WsHandle(),EWsClOpCreateBitmap,&createBitmap,sizeof(createBitmap));
sl@0
   404
			}
sl@0
   405
			break;
sl@0
   406
		case 1:
sl@0
   407
			{
sl@0
   408
			TInt badBrush=0xBADB3054;
sl@0
   409
			aWs.TestWrite(aGc->WsHandle(),EWsGcOpUseBrushPattern,&badBrush,sizeof(badBrush));
sl@0
   410
			}
sl@0
   411
			break;
sl@0
   412
		case 2:
sl@0
   413
			{
sl@0
   414
			TWsGcCmdDrawBitmap drawBitmap(point00,0xBADBAD);
sl@0
   415
			aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawBitmap,&drawBitmap,sizeof(drawBitmap));
sl@0
   416
			}
sl@0
   417
			break;
sl@0
   418
		case 3:
sl@0
   419
			return(EWsExitReasonFinished);
sl@0
   420
			}
sl@0
   421
		break;
sl@0
   422
	case 5:
sl@0
   423
		// test bad opcodes
sl@0
   424
		{
sl@0
   425
		TInt opcode=0;
sl@0
   426
		switch(aSubTest)
sl@0
   427
			{
sl@0
   428
		case 0:
sl@0
   429
			opcode=9999;
sl@0
   430
			break;
sl@0
   431
		case 1:
sl@0
   432
			return(EWsExitReasonFinished);
sl@0
   433
			}
sl@0
   434
		aWs.TestWrite(aGc->WsHandle(),opcode,NULL,0);
sl@0
   435
		}
sl@0
   436
		break;
sl@0
   437
	case 6:
sl@0
   438
		{// Test EWsGcOpDrawPolygon with invalid parameters
sl@0
   439
		 // First two times has slightly more points specified than exist in the data
sl@0
   440
		 // Third time time has a massive number of points in the header
sl@0
   441
		const TInt KNumTestsPerPolyMode=3;
sl@0
   442
		enum TPanicPolyMode {EPanicPolyModePolygon,EPanicPolyModePolyLine,EPanicPolyModeEnd};
sl@0
   443
		TInt polyMode=aSubTest/KNumTestsPerPolyMode;
sl@0
   444
		if (polyMode==EPanicPolyModeEnd)
sl@0
   445
			return(EWsExitReasonFinished);
sl@0
   446
		TInt subMode=aSubTest%KNumTestsPerPolyMode;
sl@0
   447
		TInt bufPoints=0;
sl@0
   448
		TInt headerPoints=1;
sl@0
   449
		switch(subMode)
sl@0
   450
			{
sl@0
   451
		case 0:
sl@0
   452
			break;
sl@0
   453
		case 1:
sl@0
   454
			bufPoints=2;
sl@0
   455
			headerPoints=8;
sl@0
   456
			break;
sl@0
   457
		case 2:
sl@0
   458
			bufPoints=2;
sl@0
   459
			headerPoints=999999;
sl@0
   460
			break;
sl@0
   461
			}
sl@0
   462
		TInt bufDataLen=bufPoints*sizeof(TPoint);
sl@0
   463
		if (polyMode==EPanicPolyModePolyLine)
sl@0
   464
			bufDataLen+=sizeof(TWsGcCmdDrawPolyLine);
sl@0
   465
		else
sl@0
   466
			bufDataLen+=sizeof(TWsGcCmdDrawPolygon);
sl@0
   467
		TAny* bufData=User::AllocL(bufDataLen);
sl@0
   468
		TPoint* pointPtr;
sl@0
   469
		TInt opcode;
sl@0
   470
		if (polyMode==EPanicPolyModePolyLine)
sl@0
   471
			{
sl@0
   472
			TWsGcCmdDrawPolyLine* drawPolyline=static_cast<TWsGcCmdDrawPolyLine*>(bufData);
sl@0
   473
			drawPolyline->numPoints=headerPoints;
sl@0
   474
			drawPolyline->more=EFalse;
sl@0
   475
			drawPolyline->last=point00;
sl@0
   476
			pointPtr=reinterpret_cast<TPoint*>(drawPolyline+1);
sl@0
   477
			opcode=EWsGcOpDrawPolyLine;
sl@0
   478
			}
sl@0
   479
		else
sl@0
   480
			{
sl@0
   481
			TWsGcCmdDrawPolygon* drawPolygon=static_cast<TWsGcCmdDrawPolygon*>(bufData);
sl@0
   482
			drawPolygon->numPoints=headerPoints;
sl@0
   483
			drawPolygon->fillRule=CGraphicsContext::EAlternate;
sl@0
   484
			pointPtr=reinterpret_cast<TPoint*>(drawPolygon+1);
sl@0
   485
			opcode=EWsGcOpDrawPolygon;
sl@0
   486
			}
sl@0
   487
		const TPoint* endPtr=pointPtr+bufPoints;
sl@0
   488
		TInt pointPos=0;
sl@0
   489
		while(pointPtr<endPtr)
sl@0
   490
			*pointPtr++=TPoint(pointPos,pointPos);
sl@0
   491
		aWs.TestWrite(aGc->WsHandle(),opcode,bufData,bufDataLen);
sl@0
   492
		aWs.Flush();	// Needs flush to make sure EndRedraw() doesn't make buffer bigger and catch out buf len check
sl@0
   493
		}
sl@0
   494
		break;
sl@0
   495
	case 7:
sl@0
   496
		{
sl@0
   497
		// first sets the index to match the total count
sl@0
   498
		// second sets the index negative
sl@0
   499
		// fourth sends too much data
sl@0
   500
		TWsGcCmdStartSegmentedDrawPolygon startPoly;
sl@0
   501
		startPoly.totalNumPoints=8;
sl@0
   502
		aWs.TestWrite(aGc->WsHandle(),EWsGcOpStartSegmentedDrawPolygon,&startPoly,sizeof(startPoly));
sl@0
   503
		TInt bufDataLen=sizeof(TWsGcCmdSegmentedDrawPolygonData)+startPoly.totalNumPoints*sizeof(TPoint);
sl@0
   504
		TAny* bufData=User::AllocL(bufDataLen);
sl@0
   505
		TWsGcCmdSegmentedDrawPolygonData* polyData=static_cast<TWsGcCmdSegmentedDrawPolygonData*>(bufData);
sl@0
   506
		polyData->numPoints=1;
sl@0
   507
		polyData->index=0;
sl@0
   508
		switch(aSubTest)
sl@0
   509
			{
sl@0
   510
		case 0:
sl@0
   511
			polyData->index=startPoly.totalNumPoints;
sl@0
   512
			break;
sl@0
   513
		case 1:
sl@0
   514
			polyData->index=-123;
sl@0
   515
			break;
sl@0
   516
		case 2:
sl@0
   517
			polyData->numPoints=startPoly.totalNumPoints+1;
sl@0
   518
			break;
sl@0
   519
		case 3:
sl@0
   520
			return(EWsExitReasonFinished);
sl@0
   521
			}
sl@0
   522
		aWs.TestWrite(aGc->WsHandle(),EWsGcOpSegmentedDrawPolygonData,polyData,bufDataLen);
sl@0
   523
		TWsGcCmdDrawSegmentedPolygon drawit;
sl@0
   524
		drawit.fillRule=CGraphicsContext::EAlternate;
sl@0
   525
		aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawSegmentedPolygon,&drawit,sizeof(drawit));
sl@0
   526
		}
sl@0
   527
		break;
sl@0
   528
	case 8:
sl@0
   529
		{
sl@0
   530
		if (aSubTest==1)
sl@0
   531
			return(EWsExitReasonFinished);
sl@0
   532
		// This is a test designed to specificially test polylines still work after the previous
sl@0
   533
		// polyline/polygon tests. One potential defect is they leave the common redraw store gc
sl@0
   534
		// in a bad state still holding part of the poly data and causing a EWservPanicBadPolyData
sl@0
   535
		// panic.
sl@0
   536
		// This test is designed to make sure the drawpolyline call works ok and we reach the bad
sl@0
   537
		// opcode panic instead.
sl@0
   538
		TWsGcCmdStartSegmentedDrawPolygon startPoly;
sl@0
   539
		startPoly.totalNumPoints=2;
sl@0
   540
		aWs.TestWrite(aGc->WsHandle(),EWsGcOpStartSegmentedDrawPolygon,&startPoly,sizeof(startPoly));
sl@0
   541
		struct
sl@0
   542
			{
sl@0
   543
			TWsGcCmdSegmentedDrawPolygonData iPolyData;
sl@0
   544
			TPoint iPoints[2];
sl@0
   545
			} polyParams;
sl@0
   546
		polyParams.iPoints[0].iX=1;
sl@0
   547
		polyParams.iPoints[0].iY=1;
sl@0
   548
		polyParams.iPoints[1].iX=2;
sl@0
   549
		polyParams.iPoints[1].iY=2;
sl@0
   550
			
sl@0
   551
		polyParams.iPolyData.numPoints=2;
sl@0
   552
		polyParams.iPolyData.index=0;
sl@0
   553
		aWs.TestWrite(aGc->WsHandle(),EWsGcOpSegmentedDrawPolygonData,&polyParams.iPolyData,sizeof(polyParams));
sl@0
   554
		TWsGcCmdDrawSegmentedPolygon drawit;
sl@0
   555
		drawit.fillRule=CGraphicsContext::EAlternate;
sl@0
   556
		aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawSegmentedPolygon,&drawit,sizeof(drawit));
sl@0
   557
		aWs.TestWrite(aGc->WsHandle(),9999,NULL,0);
sl@0
   558
		}
sl@0
   559
		break;
sl@0
   560
	case 9:
sl@0
   561
		if (aSubTest==1)
sl@0
   562
			return(EWsExitReasonFinished);
sl@0
   563
		aGc->Activate(*aDrawWin);	// Double activate
sl@0
   564
		break;
sl@0
   565
	case 10:
sl@0
   566
		if (aSubTest==1)
sl@0
   567
			return(EWsExitReasonFinished);
sl@0
   568
		aGc->DrawText(_L("No font"),point00);
sl@0
   569
		break;
sl@0
   570
	case 11:
sl@0
   571
		if (aSubTest==1)
sl@0
   572
			return(EWsExitReasonFinished);
sl@0
   573
		aGc->SetBrushStyle(CGraphicsContext::EPatternedBrush);
sl@0
   574
		aGc->DrawRect(rect01);
sl@0
   575
		break;
sl@0
   576
	case 12:
sl@0
   577
		{
sl@0
   578
		if (aSubTest==1)
sl@0
   579
			return(EWsExitReasonFinished);
sl@0
   580
		aGc->UseFont(aFont);
sl@0
   581
		TPtrC bigAndbad(NULL,5000);	// Will go through remote descriptor fetching code
sl@0
   582
		aGc->DrawText(bigAndbad,point00);
sl@0
   583
		}
sl@0
   584
		break;
sl@0
   585
	case 13:
sl@0
   586
		{
sl@0
   587
		if (aSubTest==1)
sl@0
   588
			return(EWsExitReasonFinished);
sl@0
   589
		TInt badHandle=0xDEADBAD;
sl@0
   590
		aWs.TestWrite(aGc->WsHandle(),EWsGcOpUseFont,&badHandle,sizeof(badHandle));
sl@0
   591
		aGc->DrawText(_L("BOO!"),point00);
sl@0
   592
		}
sl@0
   593
		break;
sl@0
   594
		}
sl@0
   595
	if (aInRedraw)
sl@0
   596
		aRWin.EndRedraw();
sl@0
   597
	aWs.Finish();
sl@0
   598
	return(EWsExitReasonBad);
sl@0
   599
	}
sl@0
   600
sl@0
   601
LOCAL_C TInt GraphicsPanicTest(TInt aInt, TAny* aPanicParams)
sl@0
   602
	{
sl@0
   603
	CTPanic::TPanicParams* panicParams=static_cast<CTPanic::TPanicParams*>(aPanicParams);
sl@0
   604
	/*
sl@0
   605
	 * Drawing to a transparent window goes via the redraw store. In this
sl@0
   606
	 * situation parameters do not get checked during the original processing
sl@0
   607
	 * of the incoming graphics commands. They are only caught later when 
sl@0
   608
	 * playing back from the redraw store.
sl@0
   609
	 */
sl@0
   610
	const TBool useTransWin = panicParams->iRedrawMode==EPanicRedrawModeTransRedraw;
sl@0
   611
	/*
sl@0
   612
	 * We always do redraw drawing unless we are using a BackedUpWindow.
sl@0
   613
	 * Redraws can affect the way graphics commands are pre-processed, 
sl@0
   614
	 * as with transparent windows they can also cause commands to get
sl@0
   615
	 * buffered in the redraw store and played back later.
sl@0
   616
	 */
sl@0
   617
	const TBool inRedraw =
sl@0
   618
		panicParams->iRedrawMode==EPanicRedrawModeNormalRedraw ||
sl@0
   619
		panicParams->iRedrawMode==EPanicRedrawModeTransRedraw ||
sl@0
   620
		panicParams->iRedrawMode==EPanicRedrawModeInvisRedraw;
sl@0
   621
	/*
sl@0
   622
	 * Drawing to an invisible window skips some of the code where errors
sl@0
   623
	 * are caught. Particularly text drawing commands that skip the actual
sl@0
   624
	 * drawing, but still process the update of the justification, this
sl@0
   625
	 * has the potential of missing parameter checks made during the actual
sl@0
   626
	 * drawing, but being caught out when processing the justification update.
sl@0
   627
	 */
sl@0
   628
	const TBool invisWin = panicParams->iRedrawMode==EPanicRedrawModeInvisRedraw;
sl@0
   629
	
sl@0
   630
	RWsSession ws;
sl@0
   631
	User::LeaveIfError(ws.Connect());
sl@0
   632
sl@0
   633
	CWsScreenDevice* scrdev=new(ELeave) CWsScreenDevice(ws);
sl@0
   634
	User::LeaveIfError(scrdev->Construct(panicParams->iScreen));
sl@0
   635
	
sl@0
   636
	RWindowGroup group(ws);
sl@0
   637
	User::LeaveIfError(group.Construct(888));
sl@0
   638
	group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
sl@0
   639
	RDrawableWindow* drawWin;
sl@0
   640
	RWindow rwin(ws);
sl@0
   641
	RBackedUpWindow bwin(ws);
sl@0
   642
	TBool needsValidating=EFalse;
sl@0
   643
	if (useTransWin || inRedraw || invisWin)
sl@0
   644
		{
sl@0
   645
		drawWin=&rwin;
sl@0
   646
		needsValidating=ETrue;
sl@0
   647
		User::LeaveIfError(rwin.Construct(group,1));
sl@0
   648
		if (useTransWin)
sl@0
   649
			{
sl@0
   650
			rwin.SetTransparencyAlphaChannel();
sl@0
   651
			}
sl@0
   652
		}
sl@0
   653
	else
sl@0
   654
		{
sl@0
   655
		// EPanicRedrawModeBackedUpWindow case
sl@0
   656
		drawWin=&bwin;
sl@0
   657
		User::LeaveIfError(bwin.Construct(group, EGray4, 1));
sl@0
   658
		}
sl@0
   659
	const TSize testWinSize(100,100);
sl@0
   660
	User::LeaveIfError(drawWin->SetSizeErr(testWinSize));
sl@0
   661
	if (invisWin)
sl@0
   662
		drawWin->SetPosition(TPoint(-testWinSize.iWidth,-testWinSize.iHeight));
sl@0
   663
	drawWin->Activate();
sl@0
   664
	CWindowGc* gc;
sl@0
   665
	scrdev->CreateContext(gc);
sl@0
   666
	gc->Activate(*drawWin);
sl@0
   667
	CFbsFont* font;
sl@0
   668
	User::LeaveIfError(scrdev->GetNearestFontToDesignHeightInTwips((CFont*&)font,TFontSpec()));
sl@0
   669
	TInt ret=DoGraphicsPanicTest(ws,rwin,drawWin,gc,font,aInt,panicParams->iSubTest,inRedraw,needsValidating);
sl@0
   670
	if (ret!=EWsExitReasonFinished && invisWin)
sl@0
   671
		{
sl@0
   672
		/*
sl@0
   673
		 * Some functions are totally skipped on invisible windows, parameter
sl@0
   674
		 * errors will be harmlessly ignored in these case. To make the test
sl@0
   675
		 * pass we re-do the tests with the window now visible. The purpose
sl@0
   676
		 * of the invisible draw tests was not to check the client is always
sl@0
   677
		 * panicked doing illegal draws to invisible windows, but to make sure
sl@0
   678
		 * they had no harmful side effects.
sl@0
   679
		 */
sl@0
   680
		drawWin->SetPosition(TPoint(0,0));
sl@0
   681
		gc->Reset();
sl@0
   682
		ret=DoGraphicsPanicTest(ws,rwin,drawWin,gc,font,aInt,panicParams->iSubTest,inRedraw,needsValidating);
sl@0
   683
		}
sl@0
   684
	return(ret);
sl@0
   685
	}
sl@0
   686
LOCAL_C TInt DoMiscPanicTest(TInt aSubTest, TAny* )
sl@0
   687
	{
sl@0
   688
	const TInt KNumPanicFuncsPerMode=EWsClOpLastEnumValue;
sl@0
   689
	const TInt KNumPanicFuncModes=6;
sl@0
   690
	const TInt KNumPanicSendTests=KNumPanicFuncsPerMode*KNumPanicFuncModes;
sl@0
   691
	const TInt KNumRandGarbageTests=500;
sl@0
   692
	if (aSubTest==(KNumPanicSendTests+KNumRandGarbageTests))
sl@0
   693
		return(EWsExitReasonFinished);
sl@0
   694
	RWsSessionHacker wshacker;
sl@0
   695
	User::LeaveIfError(wshacker.Connect());
sl@0
   696
	if (aSubTest<KNumPanicSendTests)
sl@0
   697
		{
sl@0
   698
		TInt messageMode=aSubTest/KNumPanicFuncsPerMode;
sl@0
   699
		TInt msgFunc=aSubTest%KNumPanicFuncsPerMode;
sl@0
   700
		const TInt EPanicWservMessAsynchronousService=0x010000; //copy of EWservMessAsynchronousService
sl@0
   701
		const TInt EPanicWservMessAnimDllAsyncCommand=0x100000; //copy of EWservMessAnimDllAsyncCommand
sl@0
   702
		switch(messageMode%3)
sl@0
   703
			{
sl@0
   704
		case 0:
sl@0
   705
			if(msgFunc == EWservMessFinish) //RWsSession::Finish() doesn't panic
sl@0
   706
				User::Panic(KWSERV, 0); //simulate a "successful" wserv panic to skip the sub test
sl@0
   707
			break;
sl@0
   708
		case 1:
sl@0
   709
			msgFunc|=EPanicWservMessAsynchronousService;
sl@0
   710
			break;
sl@0
   711
		case 2:
sl@0
   712
			msgFunc|=EPanicWservMessAnimDllAsyncCommand;
sl@0
   713
			break;
sl@0
   714
			}
sl@0
   715
		TInt sendItErr=KErrNone;
sl@0
   716
		if (messageMode<3)
sl@0
   717
			{
sl@0
   718
			if (msgFunc&EPanicWservMessAsynchronousService)
sl@0
   719
				{
sl@0
   720
				wshacker.PanicItSend(msgFunc);
sl@0
   721
				// Async request, probably won't panic, we just want to make sure nothing crashes 'orribly
sl@0
   722
				// So do it again without the async bit and let normal handling cause the panic
sl@0
   723
				msgFunc&=~EPanicWservMessAsynchronousService;
sl@0
   724
				}
sl@0
   725
			sendItErr=wshacker.PanicItSendReceive(msgFunc);
sl@0
   726
			}
sl@0
   727
		else
sl@0
   728
			{
sl@0
   729
			TPtrC8 badDesc(reinterpret_cast<const TUint8*>(0xDEAD),100);
sl@0
   730
			TIpcArgs ipcArgs;
sl@0
   731
			ipcArgs.Set(0,&badDesc);
sl@0
   732
			if (msgFunc&EPanicWservMessAsynchronousService)
sl@0
   733
				{
sl@0
   734
				sendItErr=wshacker.PanicItSend(msgFunc,ipcArgs);
sl@0
   735
				msgFunc&=~EPanicWservMessAsynchronousService;
sl@0
   736
				}
sl@0
   737
			sendItErr=wshacker.PanicItSendReceive(msgFunc,ipcArgs);
sl@0
   738
			}
sl@0
   739
		if (sendItErr==KErrNotSupported)
sl@0
   740
			wshacker.PanicItSendReceive(EWservMessCommandBuffer); // Should always panic
sl@0
   741
		}
sl@0
   742
	else
sl@0
   743
		{
sl@0
   744
	// Fill Wserv buffer with random garbage
sl@0
   745
		RWsBufferHacker* hacker=reinterpret_cast<RWsBufferHacker*>(wshacker.WsBuffer());
sl@0
   746
		TInt64 seed=aSubTest;
sl@0
   747
		TInt retries=0;
sl@0
   748
		const TInt KMaxRandPanicRetrys=1000;
sl@0
   749
		do
sl@0
   750
			{
sl@0
   751
			const TInt maxLen=hacker->iBuf.MaxLength()-1;
sl@0
   752
			TInt writeLen=1+Math::Rand(seed)%maxLen;
sl@0
   753
			while(writeLen--)
sl@0
   754
				{
sl@0
   755
				TUint8 randData=static_cast<TUint8>(Math::Rand(seed));
sl@0
   756
				hacker->iBuf.Append(randData);
sl@0
   757
				}
sl@0
   758
			wshacker.Flush();
sl@0
   759
			retries++;
sl@0
   760
			} while(retries<KMaxRandPanicRetrys);
sl@0
   761
		}
sl@0
   762
	return(EWsExitReasonBad);
sl@0
   763
	}
sl@0
   764
sl@0
   765
LOCAL_C TInt DoCMPanicTest(TInt aInt, TAny *aScreenNumber)
sl@0
   766
	{
sl@0
   767
	RWsSession ws;
sl@0
   768
	User::LeaveIfError(ws.Connect());
sl@0
   769
	// use correct screen
sl@0
   770
	//
sl@0
   771
	CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
sl@0
   772
	User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
sl@0
   773
sl@0
   774
	switch(aInt)
sl@0
   775
		{
sl@0
   776
		case 1:
sl@0
   777
			ws.ComputeMode((RWsSession::TComputeMode)543);
sl@0
   778
			break;
sl@0
   779
		}
sl@0
   780
	ws.Flush();
sl@0
   781
	return(EWsExitReasonBad);
sl@0
   782
	}
sl@0
   783
sl@0
   784
#if defined(_DEBUG) && defined(__WINS__)
sl@0
   785
LOCAL_C TInt DoCKPanicTest(TInt aInt, TAny *aScreenNumber)
sl@0
   786
	{
sl@0
   787
	RWsSession ws;
sl@0
   788
	User::LeaveIfError(ws.Connect());
sl@0
   789
	// use correct screen
sl@0
   790
	//
sl@0
   791
	CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
sl@0
   792
	User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
sl@0
   793
sl@0
   794
	RWindowGroup group(ws);
sl@0
   795
	group.Construct(888);
sl@0
   796
	group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
sl@0
   797
	switch(aInt)
sl@0
   798
		{
sl@0
   799
		case 1:
sl@0
   800
			group.CancelCaptureKey(345);
sl@0
   801
			break;
sl@0
   802
		}
sl@0
   803
	ws.Flush();
sl@0
   804
	return(EWsExitReasonBad);
sl@0
   805
	}
sl@0
   806
#endif
sl@0
   807
sl@0
   808
LOCAL_C TInt DoEventPanicTest(TInt aInt, TAny *aScreenNumber)
sl@0
   809
	{
sl@0
   810
	RWsSession ws;
sl@0
   811
	User::LeaveIfError(ws.Connect());
sl@0
   812
	// use correct screen
sl@0
   813
	//
sl@0
   814
	CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
sl@0
   815
	User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
sl@0
   816
sl@0
   817
sl@0
   818
	switch(aInt)
sl@0
   819
		{
sl@0
   820
		case 1:
sl@0
   821
			TRequestStatus stat;
sl@0
   822
			ws.EventReady(&stat);
sl@0
   823
			ws.EventReady(&stat);
sl@0
   824
			User::After(15000000);		//15secs
sl@0
   825
			break;
sl@0
   826
		}
sl@0
   827
	ws.Flush();
sl@0
   828
	return(EWsExitReasonBad);
sl@0
   829
	}
sl@0
   830
sl@0
   831
LOCAL_C TInt DoTBufPtrTests(TInt aInt, TAny *aScreenNumber)
sl@0
   832
	{
sl@0
   833
	RWsSession ws;
sl@0
   834
	User::LeaveIfError(ws.Connect());
sl@0
   835
	// use correct screen
sl@0
   836
	//
sl@0
   837
	CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
sl@0
   838
	User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
sl@0
   839
	
sl@0
   840
	switch(aInt)
sl@0
   841
		{
sl@0
   842
		case 1:
sl@0
   843
			{
sl@0
   844
			TWsClCmdLoadAnimDll dt;
sl@0
   845
			dt.length=600;
sl@0
   846
			ws.TestWrite(ws.WsHandle(),EWsClOpCreateAnimDll,&dt,sizeof(dt));
sl@0
   847
			}
sl@0
   848
			break;
sl@0
   849
		case 2:
sl@0
   850
			{
sl@0
   851
			TInt len=600;
sl@0
   852
			ws.TestWrite(ws.WsHandle(),EWsClOpLogMessage,&len,sizeof(len));
sl@0
   853
			}
sl@0
   854
			break;
sl@0
   855
		case 3:
sl@0
   856
			{
sl@0
   857
			RWindowGroup group(ws);
sl@0
   858
			group.Construct(888);
sl@0
   859
			group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
sl@0
   860
			TWsWinCmdSetName dt;
sl@0
   861
			dt.length=600;
sl@0
   862
			dt.ptr=NULL;
sl@0
   863
			ws.TestWrite(group.WsHandle(),EWsWinOpSetName,&dt,sizeof(dt));
sl@0
   864
			}
sl@0
   865
			break;
sl@0
   866
		case 4:
sl@0
   867
			{
sl@0
   868
			RWindowGroup group(ws);
sl@0
   869
			group.Construct(888);
sl@0
   870
			group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
sl@0
   871
			TWsWinCmdSetName dt;
sl@0
   872
			dt.length=600;
sl@0
   873
			dt.ptr=(TDesC *)0x1234;
sl@0
   874
			ws.TestWrite(group.WsHandle(),EWsWinOpSetName,&dt,sizeof(dt));
sl@0
   875
			}
sl@0
   876
			break;
sl@0
   877
		}
sl@0
   878
	ws.Flush();
sl@0
   879
	return(EWsExitReasonBad);
sl@0
   880
	}
sl@0
   881
sl@0
   882
#if defined(_DEBUG) && defined(__WINS__)		
sl@0
   883
LOCAL_C TInt DoMismatchedCancelCaptureTest(TInt aInt, TAny *aScreenNumber)
sl@0
   884
	{
sl@0
   885
	RWsSession ws;
sl@0
   886
	User::LeaveIfError(ws.Connect());
sl@0
   887
	// use correct screen		
sl@0
   888
	CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
sl@0
   889
	User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
sl@0
   890
	RWindowGroup group(ws);
sl@0
   891
	User::LeaveIfError(group.Construct(888));
sl@0
   892
	group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
sl@0
   893
	RWindow win(ws);
sl@0
   894
	User::LeaveIfError(win.Construct(group, 1));
sl@0
   895
	win.Activate();
sl@0
   896
	TInt capture;
sl@0
   897
	
sl@0
   898
	switch (aInt)
sl@0
   899
		{
sl@0
   900
		case CTPanic::ECancelCaptureKey:
sl@0
   901
			// Create a capture that is not matched to CancelCaptureKey()
sl@0
   902
			capture = group.CaptureLongKey(' ','a',0,0,2,ELongCaptureNormal);
sl@0
   903
			ws.Flush();
sl@0
   904
			group.CancelCaptureKey(capture);
sl@0
   905
			break;
sl@0
   906
		case CTPanic::ECancelCaptureKeyUpAndDowns:
sl@0
   907
			// Create a capture that is not matched to CancelCaptureKeyUpAndDowns()
sl@0
   908
			capture = group.CaptureKey('A',0,0);
sl@0
   909
			ws.Flush();
sl@0
   910
			group.CancelCaptureKeyUpAndDowns(capture);
sl@0
   911
			break;
sl@0
   912
		case CTPanic::ECancelCaptureLongKey:
sl@0
   913
			// Create a capture that is not matched to CancelCaptureLongKey()
sl@0
   914
			capture = group.CaptureKeyUpAndDowns(EStdKeySpace,0,0);
sl@0
   915
			ws.Flush();
sl@0
   916
			group.CancelCaptureLongKey(capture);
sl@0
   917
			break;
sl@0
   918
		}
sl@0
   919
	
sl@0
   920
	ws.Flush();
sl@0
   921
	return(EWsExitReasonBad);
sl@0
   922
	}
sl@0
   923
#endif // _DEBUG
sl@0
   924
sl@0
   925
class ROverrideProtectionInRSessionBase : public RWsSession
sl@0
   926
	{
sl@0
   927
public:
sl@0
   928
	inline TInt SendReceive(TInt aFunction,TAny *aPtr) const {return(RSessionBase::SendReceive(aFunction,TIpcArgs(aPtr)));};
sl@0
   929
	};
sl@0
   930
sl@0
   931
LOCAL_C TInt DoMultiInitPanicTest(TInt , TAny *aScreenNumber)
sl@0
   932
	{
sl@0
   933
	ROverrideProtectionInRSessionBase ws;
sl@0
   934
	User::LeaveIfError(ws.Connect());
sl@0
   935
	
sl@0
   936
	// use correct screen
sl@0
   937
	//
sl@0
   938
	CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
sl@0
   939
	User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
sl@0
   940
	
sl@0
   941
	RWindowGroup group(ws);
sl@0
   942
	group.Construct(888);
sl@0
   943
	group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
sl@0
   944
	ws.Flush();
sl@0
   945
	ws.SendReceive(EWservMessInit,NULL);
sl@0
   946
	
sl@0
   947
	return(EWsExitReasonBad);
sl@0
   948
	}
sl@0
   949
	
sl@0
   950
LOCAL_C TInt DoSpritePanicTestL(TInt aTest, TAny *aScreenNumber)
sl@0
   951
	{
sl@0
   952
	RWsSession ws;
sl@0
   953
	User::LeaveIfError(ws.Connect());
sl@0
   954
	// use correct screen
sl@0
   955
	//
sl@0
   956
	CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
sl@0
   957
	User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
sl@0
   958
	
sl@0
   959
	RWindowGroup group(ws);
sl@0
   960
	User::LeaveIfError(group.Construct(889));
sl@0
   961
	group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
sl@0
   962
	RBlankWindow win(ws);
sl@0
   963
	User::LeaveIfError(win.Construct(group,898));
sl@0
   964
	RWsPointerCursor* cursor=(RWsPointerCursor*)&win;
sl@0
   965
	switch (aTest)
sl@0
   966
		{
sl@0
   967
	case 1:
sl@0
   968
		win.SetCustomPointerCursor(*cursor);
sl@0
   969
		break;
sl@0
   970
	case 2:
sl@0
   971
		ws.SetSystemPointerCursor(*cursor,0);
sl@0
   972
		break;
sl@0
   973
	case 3:
sl@0
   974
		{
sl@0
   975
		RAnimDll animDll=RAnimDll(ws);
sl@0
   976
		User::LeaveIfError(animDll.Load(KAnimDLLName));
sl@0
   977
		RTestAnim anim=RTestAnim(animDll);
sl@0
   978
		RWsSprite* sprite=(RWsSprite*)&win;
sl@0
   979
		User::LeaveIfError(anim.Construct(*sprite,EAnimTypeSprite,TPtrC8()));
sl@0
   980
		}
sl@0
   981
		break;
sl@0
   982
	case 4:
sl@0
   983
		{
sl@0
   984
		CFbsBitmap* bitmap=new(ELeave) CFbsBitmap;
sl@0
   985
		CleanupStack::PushL(bitmap);
sl@0
   986
		User::LeaveIfError(bitmap->Load(TEST_BITMAP_NAME,0));
sl@0
   987
		win.SetExtent(TPoint(),TSize(150,250));
sl@0
   988
		win.SetVisible(ETrue);
sl@0
   989
		win.Activate();
sl@0
   990
		RWsSprite sprite(ws);
sl@0
   991
		User::LeaveIfError(sprite.Construct(win,TPoint(),0));
sl@0
   992
		TSpriteMember member;
sl@0
   993
		member.iMaskBitmap=NULL;
sl@0
   994
		member.iInvertMask=EFalse;
sl@0
   995
		member.iDrawMode=CGraphicsContext::EDrawModePEN;
sl@0
   996
		member.iOffset=TPoint();
sl@0
   997
		member.iInterval=TTimeIntervalMicroSeconds32(0);
sl@0
   998
		member.iBitmap=bitmap;
sl@0
   999
		User::LeaveIfError(sprite.AppendMember(member));
sl@0
  1000
		User::LeaveIfError(sprite.Activate());
sl@0
  1001
		User::After(1000000); //1 sec
sl@0
  1002
		User::LeaveIfError(bitmap->Resize(bitmap->SizeInPixels() + TSize(200,200)));
sl@0
  1003
		User::After(1000000); //1 sec
sl@0
  1004
		CleanupStack::Pop(bitmap);
sl@0
  1005
		break;
sl@0
  1006
		}
sl@0
  1007
		}
sl@0
  1008
	ws.Flush();
sl@0
  1009
	return(EWsExitReasonBad);
sl@0
  1010
	}
sl@0
  1011
sl@0
  1012
#ifdef __WINS__
sl@0
  1013
LOCAL_C TInt DoDoubleConstructionTestL(TInt aTest, TAny *aScreenNumber)
sl@0
  1014
	{		
sl@0
  1015
	RWsSession ws;
sl@0
  1016
	User::LeaveIfError(ws.Connect());
sl@0
  1017
	
sl@0
  1018
	// use correct screen
sl@0
  1019
	//
sl@0
  1020
	CWsScreenDevice* screen = new(ELeave) CWsScreenDevice(ws);
sl@0
  1021
	User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
sl@0
  1022
	
sl@0
  1023
	RWindowGroup group(ws);
sl@0
  1024
	User::LeaveIfError(group.Construct(890, EFalse));
sl@0
  1025
	RBlankWindow bwin(ws);
sl@0
  1026
	User::LeaveIfError(bwin.Construct(group,900));
sl@0
  1027
	
sl@0
  1028
	switch (aTest)
sl@0
  1029
		{
sl@0
  1030
	case 1:
sl@0
  1031
		{
sl@0
  1032
		RWsSprite sprite = RWsSprite(ws);
sl@0
  1033
		User::LeaveIfError(sprite.Construct(bwin,TPoint(),0));
sl@0
  1034
		sprite.Construct(bwin,TPoint(),0); //should panic
sl@0
  1035
		sprite.Close();
sl@0
  1036
		}
sl@0
  1037
		break;
sl@0
  1038
	case 2:
sl@0
  1039
		{
sl@0
  1040
		RWsPointerCursor cursor(ws);
sl@0
  1041
		User::LeaveIfError(cursor.Construct(0));
sl@0
  1042
		cursor.Construct(0); //should panic
sl@0
  1043
		cursor.Close();
sl@0
  1044
		}
sl@0
  1045
		break;
sl@0
  1046
	case 3:
sl@0
  1047
		{
sl@0
  1048
		RSoundPlugIn click(ws);
sl@0
  1049
		User::LeaveIfError(click.Construct());
sl@0
  1050
		click.Construct(); //should panic
sl@0
  1051
		click.Close();
sl@0
  1052
		}
sl@0
  1053
		break;
sl@0
  1054
	case 4:
sl@0
  1055
		{
sl@0
  1056
		RWindowGroup windowgroup(ws);
sl@0
  1057
		User::LeaveIfError(windowgroup.Construct(901));
sl@0
  1058
		windowgroup.Construct(902); //should panic
sl@0
  1059
		windowgroup.Close();
sl@0
  1060
		}
sl@0
  1061
		break;
sl@0
  1062
	case 5:
sl@0
  1063
		{
sl@0
  1064
		RWindow win(ws);
sl@0
  1065
		User::LeaveIfError(win.Construct(group,902));
sl@0
  1066
		win.Construct(group,903); //should panic
sl@0
  1067
		win.Close(); 
sl@0
  1068
		}
sl@0
  1069
		break;
sl@0
  1070
	case 6:
sl@0
  1071
		{
sl@0
  1072
		RBlankWindow win(ws);
sl@0
  1073
		User::LeaveIfError(win.Construct(group,902));
sl@0
  1074
		win.Construct(group,903); //should panic
sl@0
  1075
		win.Close(); 
sl@0
  1076
		}
sl@0
  1077
		break;
sl@0
  1078
	case 7:
sl@0
  1079
		{
sl@0
  1080
		RBackedUpWindow win(ws);
sl@0
  1081
		User::LeaveIfError(win.Construct(group,EGray4,902));
sl@0
  1082
		win.Construct(group,EGray4,903); //should panic
sl@0
  1083
		win.Close(); 
sl@0
  1084
		}
sl@0
  1085
		break;
sl@0
  1086
	case 8:
sl@0
  1087
		{
sl@0
  1088
		RAnimDll animDll=RAnimDll(ws);
sl@0
  1089
		User::LeaveIfError(animDll.Load(KAnimDLLName));
sl@0
  1090
		animDll.Load(KAnimDLLName); //should panic
sl@0
  1091
		animDll.Close();
sl@0
  1092
		}
sl@0
  1093
		break;
sl@0
  1094
	case 9:
sl@0
  1095
		{
sl@0
  1096
		CWindowGc *gc = new(ELeave) CWindowGc(screen);
sl@0
  1097
		User::LeaveIfError(gc->Construct());
sl@0
  1098
		gc->Construct(); //should panic
sl@0
  1099
		delete gc;
sl@0
  1100
		}
sl@0
  1101
		break;
sl@0
  1102
	case 10:
sl@0
  1103
		{
sl@0
  1104
		CWsScreenDevice* screendevice = new (ELeave) CWsScreenDevice(ws);
sl@0
  1105
		User::LeaveIfError(screendevice->Construct());
sl@0
  1106
		screendevice->Construct(); //should panic
sl@0
  1107
		delete screendevice;
sl@0
  1108
		}
sl@0
  1109
		break;
sl@0
  1110
	default:
sl@0
  1111
		break;
sl@0
  1112
		}
sl@0
  1113
	ws.Flush();
sl@0
  1114
	return(EWsExitReasonBad);
sl@0
  1115
	}
sl@0
  1116
#endif
sl@0
  1117
sl@0
  1118
/** Checks that activating a sprite without members will panic.
sl@0
  1119
*/
sl@0
  1120
LOCAL_C TInt DoTestSpriteActivatePanicL(TInt aTest, TAny *aScreenNumber)
sl@0
  1121
	{
sl@0
  1122
	RWsSession ws;
sl@0
  1123
	User::LeaveIfError(ws.Connect());
sl@0
  1124
	CWsScreenDevice* screen = new(ELeave) CWsScreenDevice(ws);
sl@0
  1125
	User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
sl@0
  1126
	RWindowGroup group(ws);
sl@0
  1127
	User::LeaveIfError(group.Construct(891, EFalse, screen));
sl@0
  1128
	RBlankWindow bwin(ws);
sl@0
  1129
	User::LeaveIfError(bwin.Construct(group,892));
sl@0
  1130
	
sl@0
  1131
	switch(aTest)
sl@0
  1132
		{
sl@0
  1133
	case 1:
sl@0
  1134
		{
sl@0
  1135
		RWsSprite sprite = RWsSprite(ws);
sl@0
  1136
		User::LeaveIfError(sprite.Construct(group,TPoint(),0));
sl@0
  1137
		sprite.Activate();	//should panic here
sl@0
  1138
		sprite.Close();
sl@0
  1139
		}
sl@0
  1140
		break;
sl@0
  1141
	case 2:
sl@0
  1142
		{
sl@0
  1143
		RWsSprite sprite = RWsSprite(ws);
sl@0
  1144
		User::LeaveIfError(sprite.Construct(bwin,TPoint(),0));
sl@0
  1145
		sprite.Activate();	//should panic here
sl@0
  1146
		sprite.Close();
sl@0
  1147
		}
sl@0
  1148
		break;
sl@0
  1149
		}
sl@0
  1150
	return(EWsExitReasonBad);
sl@0
  1151
	}
sl@0
  1152
sl@0
  1153
/** Checks that activating a RWindow before calling EnableAdvancedPointers will panic the client.
sl@0
  1154
*/
sl@0
  1155
LOCAL_C TInt DoTestAdvancePointerActivatePanicL(TInt /*aTest*/,TAny *aScreenNumber)
sl@0
  1156
    {
sl@0
  1157
    RWsSession ws;
sl@0
  1158
    User::LeaveIfError(ws.Connect());
sl@0
  1159
sl@0
  1160
    CWsScreenDevice *scrdev=new(ELeave) CWsScreenDevice(ws);
sl@0
  1161
    User::LeaveIfError(scrdev->Construct((TInt)aScreenNumber));
sl@0
  1162
    
sl@0
  1163
    RWindowGroup group(ws);
sl@0
  1164
    User::LeaveIfError(group.Construct(888));
sl@0
  1165
    RWindow win(ws);
sl@0
  1166
    User::LeaveIfError(win.Construct(group, 1));
sl@0
  1167
    win.Activate();
sl@0
  1168
    win.EnableAdvancedPointers(); // This will panic
sl@0
  1169
    ws.Flush();
sl@0
  1170
    return(EWsExitReasonBad);
sl@0
  1171
    }
sl@0
  1172
sl@0
  1173
sl@0
  1174
LOCAL_C TInt DoMoveToGroupPanicTestL(TInt aTest, TAny *aScreenNumber)
sl@0
  1175
	{
sl@0
  1176
	RWsSession ws;
sl@0
  1177
	User::LeaveIfError(ws.Connect());
sl@0
  1178
	// use correct screen
sl@0
  1179
	//
sl@0
  1180
	CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
sl@0
  1181
	User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
sl@0
  1182
	
sl@0
  1183
	RWindowGroup group(ws);
sl@0
  1184
	User::LeaveIfError(group.Construct(887));
sl@0
  1185
	group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
sl@0
  1186
	TInt id=group.Identifier();
sl@0
  1187
	switch (aTest)
sl@0
  1188
		{
sl@0
  1189
	case 1:
sl@0
  1190
		{
sl@0
  1191
		RWindowTreeNode* win=&group;
sl@0
  1192
		((RWindowBase*)win)->MoveToGroup(id);
sl@0
  1193
		}
sl@0
  1194
		break;
sl@0
  1195
	case 2:
sl@0
  1196
		{
sl@0
  1197
		RBlankWindow win1(ws);
sl@0
  1198
		User::LeaveIfError(win1.Construct(group,878));
sl@0
  1199
		RBlankWindow win2(ws);
sl@0
  1200
		User::LeaveIfError(win2.Construct(win1,788));
sl@0
  1201
		win2.MoveToGroup(id);
sl@0
  1202
		}
sl@0
  1203
		break;
sl@0
  1204
		}
sl@0
  1205
	ws.Flush();
sl@0
  1206
	return(EWsExitReasonBad);
sl@0
  1207
	}
sl@0
  1208
sl@0
  1209
LOCAL_C TInt DoGetEventPanicTestL(TInt aTest, TAny *aScreenNumber)
sl@0
  1210
	{
sl@0
  1211
	RWsSession ws;
sl@0
  1212
	User::LeaveIfError(ws.Connect());
sl@0
  1213
	switch(aTest)
sl@0
  1214
		{
sl@0
  1215
	case 1:
sl@0
  1216
		{
sl@0
  1217
		TPckgBuf<TWsEvent> event;
sl@0
  1218
		ws.TestWrite(ws.WsHandle(),EWsClOpGetEvent,&event,0);
sl@0
  1219
		}
sl@0
  1220
		break;
sl@0
  1221
	case 2:
sl@0
  1222
		{
sl@0
  1223
		CWsScreenDevice* screen=new(ELeave) CWsScreenDevice(ws);
sl@0
  1224
		User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
sl@0
  1225
		RWindowGroup group(ws);
sl@0
  1226
		User::LeaveIfError(group.Construct(555));	// trigger a focus changed event
sl@0
  1227
		TRequestStatus stat;
sl@0
  1228
		ws.EventReady(&stat);
sl@0
  1229
		User::WaitForRequest(stat);
sl@0
  1230
		TPtrC8 badDesc(reinterpret_cast<const TUint8*>(0xDEAD),100);
sl@0
  1231
		ws.TestWrite(ws.WsHandle(),EWsClOpGetEvent,&badDesc,0);
sl@0
  1232
		}
sl@0
  1233
		break;
sl@0
  1234
		}
sl@0
  1235
	ws.Flush();
sl@0
  1236
	return(EWsExitReasonBad);
sl@0
  1237
	}
sl@0
  1238
sl@0
  1239
LOCAL_C TInt DoWinHandlePanicTestL(TInt aTest, TAny *)
sl@0
  1240
	{
sl@0
  1241
	RWsSession ws;
sl@0
  1242
	User::LeaveIfError(ws.Connect());
sl@0
  1243
	RWindowGroup group1(ws);
sl@0
  1244
	RWindowGroup group2(ws);
sl@0
  1245
	RWindow win1(ws);
sl@0
  1246
	RWindow win2(ws);
sl@0
  1247
	switch(aTest)
sl@0
  1248
		{
sl@0
  1249
	case 1:
sl@0
  1250
		User::LeaveIfError(group1.Construct(888));
sl@0
  1251
		User::LeaveIfError(group2.Construct(888));
sl@0
  1252
		break;
sl@0
  1253
	case 2:
sl@0
  1254
		User::LeaveIfError(group1.Construct(777));
sl@0
  1255
		User::LeaveIfError(win1.Construct(group1,888));
sl@0
  1256
		User::LeaveIfError(win2.Construct(group1,888));
sl@0
  1257
		break;
sl@0
  1258
	case 3:
sl@0
  1259
		User::LeaveIfError(group1.Construct(777));
sl@0
  1260
		User::LeaveIfError(win1.Construct(group1,777));
sl@0
  1261
		break;
sl@0
  1262
	case 4:
sl@0
  1263
		User::LeaveIfError(group1.Construct(777));
sl@0
  1264
		User::LeaveIfError(win1.Construct(group1,0));
sl@0
  1265
		break;
sl@0
  1266
		}
sl@0
  1267
	ws.Flush();
sl@0
  1268
	return(EWsExitReasonBad);
sl@0
  1269
	}
sl@0
  1270
sl@0
  1271
#ifdef __WINS__
sl@0
  1272
LOCAL_C TInt DoDeleteScreenPanicTestL(TInt aTest, TAny *aScreenNumber)
sl@0
  1273
/**
sl@0
  1274
 * Test examples of use of the 'screen device deleted' panic for group windows.
sl@0
  1275
 * This is issued to panic the client, if they make API calls to RWindowGroup after having deleted
sl@0
  1276
 * the CWsScreenDevice with which that window group is associated.
sl@0
  1277
 */
sl@0
  1278
	{
sl@0
  1279
	RWsSession ws;
sl@0
  1280
	User::LeaveIfError(ws.Connect());
sl@0
  1281
	// point to correct screen
sl@0
  1282
	CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
sl@0
  1283
	User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
sl@0
  1284
	
sl@0
  1285
	RWindowGroup group(ws);
sl@0
  1286
	User::LeaveIfError(group.Construct(888));
sl@0
  1287
	group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
sl@0
  1288
	switch(aTest)
sl@0
  1289
		{
sl@0
  1290
		// Test 1: deleting screen then modifying screen change events is illegal
sl@0
  1291
		case 1:
sl@0
  1292
			{
sl@0
  1293
			delete screen, screen=NULL;
sl@0
  1294
			group.EnableScreenChangeEvents();
sl@0
  1295
			break;
sl@0
  1296
			}
sl@0
  1297
		// Test 2: deleting screen then setting window group name is illegal
sl@0
  1298
		case 2:
sl@0
  1299
			{
sl@0
  1300
			delete screen, screen=NULL;
sl@0
  1301
			_LIT(KPanicTest, "PanicTest");
sl@0
  1302
			group.SetName(KPanicTest);
sl@0
  1303
			break;
sl@0
  1304
			}
sl@0
  1305
		}
sl@0
  1306
	ws.Flush();
sl@0
  1307
	return(EWsExitReasonBad);
sl@0
  1308
	}
sl@0
  1309
#endif
sl@0
  1310
sl@0
  1311
LOCAL_C TInt DoUnInitPanicTest(TInt , TAny *)
sl@0
  1312
	{
sl@0
  1313
	// Creating a client session outside the test harness for panicking
sl@0
  1314
	//  before initialisation as the test harness initialises the one it creates.
sl@0
  1315
	TVersion version(0,0,0);
sl@0
  1316
	_LIT(KServerName, "!Windowserver");
sl@0
  1317
	
sl@0
  1318
	RUnInitalisedConnect myUnInit;
sl@0
  1319
sl@0
  1320
	User::LeaveIfError(myUnInit.Connect(KServerName(), version));
sl@0
  1321
	myUnInit.Send(EWservMessCommandBuffer);
sl@0
  1322
	
sl@0
  1323
	return(EWsExitReasonBad);
sl@0
  1324
	}
sl@0
  1325
sl@0
  1326
void CTPanic::TestScreenDevicePanicsL()
sl@0
  1327
	{
sl@0
  1328
	TEST(iTest->TestWsPanicL(&DoScreenDevicePanicTest,EWservPanicBitmap,1,(TAny*)iTest->iScreenNumber));
sl@0
  1329
	
sl@0
  1330
	TEST(iTest->TestWsPanicL(&DoScreenDevicePanicTest,EWservPanicBitmap,2,(TAny*)iTest->iScreenNumber));
sl@0
  1331
	}
sl@0
  1332
sl@0
  1333
void CTPanic::TestMiscPanicsL()
sl@0
  1334
	{
sl@0
  1335
	TBool finished=EFalse;
sl@0
  1336
	TInt index=0;
sl@0
  1337
	while(!finished)
sl@0
  1338
		{
sl@0
  1339
		const TBool result = iTest->TestWsPanicL(&DoMiscPanicTest, EWservNoPanic, index, NULL, &finished);
sl@0
  1340
		if(!result)
sl@0
  1341
			{
sl@0
  1342
			INFO_PRINTF2(_L("TestMiscPanicsL %d failed"), index);
sl@0
  1343
			TEST(result);
sl@0
  1344
			}
sl@0
  1345
		index++;
sl@0
  1346
		}
sl@0
  1347
	}
sl@0
  1348
sl@0
  1349
void CTPanic::LogHeapInfo()
sl@0
  1350
	{
sl@0
  1351
	_LIT(KInfoHeapSummary," WsHeap - Count=%d,Total=%d,Free=%d,Max free=%d");
sl@0
  1352
	TPckgBuf<TWsDebugHeapInfo> heapInfo;
sl@0
  1353
	TheClient->iWs.DebugInfo(EWsDebugInfoHeap,heapInfo);
sl@0
  1354
	TBuf<256> infoBuf;
sl@0
  1355
	infoBuf.Format(KInfoHeapSummary,heapInfo().iCount,heapInfo().iTotal,heapInfo().iAvailable,heapInfo().iLargestAvailable);
sl@0
  1356
	INFO_PRINTF1(infoBuf);
sl@0
  1357
	}
sl@0
  1358
sl@0
  1359
void CTPanic::TestGraphicsPanicsL(TClientPanic aExitReason, TInt aIndex, CTPanic::TPanicParams* aPanicParams)
sl@0
  1360
	{
sl@0
  1361
	TBool finished=EFalse;
sl@0
  1362
	aPanicParams->iSubTest=0;
sl@0
  1363
sl@0
  1364
	// uncomment to show which test is being run
sl@0
  1365
	INFO_PRINTF3(_L("GraphicsPanicTest %d, mode=%d"),aIndex,aPanicParams->iRedrawMode);
sl@0
  1366
    RDebug::Print(_L("GraphicsPanicTest %d, mode=%d"),aIndex,aPanicParams->iRedrawMode);
sl@0
  1367
	do
sl@0
  1368
		{
sl@0
  1369
		// uncomment for detailed view of which sub-test failed
sl@0
  1370
		LogHeapInfo();
sl@0
  1371
		INFO_PRINTF4(_L("GraphicsPanicTest %d/%d, mode=%d"),aIndex,aPanicParams->iSubTest,aPanicParams->iRedrawMode);
sl@0
  1372
		RDebug::Print(_L("GraphicsPanicTest %d/%d, mode=%d"),aIndex,aPanicParams->iSubTest,aPanicParams->iRedrawMode);
sl@0
  1373
		TEST(iTest->TestWsPanicL(&GraphicsPanicTest,aExitReason,aIndex,aPanicParams,&finished));
sl@0
  1374
		aPanicParams->iSubTest++;
sl@0
  1375
		} while(!finished);
sl@0
  1376
	iTest->CloseAllPanicWindows();
sl@0
  1377
	}
sl@0
  1378
sl@0
  1379
void CTPanic::TestGraphicsPanicsL(TPanicRedrawMode aRedrawMode)
sl@0
  1380
	{
sl@0
  1381
	CTPanic::TPanicParams pp;
sl@0
  1382
	pp.iScreen=iTest->iScreenNumber;
sl@0
  1383
	pp.iRedrawMode=aRedrawMode;
sl@0
  1384
	static TClientPanic expectedPanics[]=
sl@0
  1385
		{
sl@0
  1386
		EWservPanicBufferPtr,
sl@0
  1387
		EWservPanicBitmap,
sl@0
  1388
		EWservPanicBitmap,
sl@0
  1389
		EWservPanicBitmap,
sl@0
  1390
		EWservPanicOpcode,
sl@0
  1391
		EWservPanicBadPolyData,
sl@0
  1392
		EWservPanicBadPolyData,
sl@0
  1393
		EWservPanicOpcode,
sl@0
  1394
		EWservPanicGcActive,
sl@0
  1395
		EWservPanicNoFont,
sl@0
  1396
		EWservPanicNoBrush,
sl@0
  1397
		EWservPanicDescriptor,
sl@0
  1398
		EWservPanicFont,
sl@0
  1399
		EWservNoPanic,	// Marks the end of the list
sl@0
  1400
		};
sl@0
  1401
	TInt panicIndex=0;
sl@0
  1402
	TClientPanic expectedPanic;
sl@0
  1403
	while((expectedPanic=expectedPanics[panicIndex++])!=EWservNoPanic)
sl@0
  1404
		{
sl@0
  1405
		TestGraphicsPanicsL(expectedPanic,panicIndex,&pp);
sl@0
  1406
		}
sl@0
  1407
	}
sl@0
  1408
sl@0
  1409
void CTPanic::TestGraphicsPanicsL()
sl@0
  1410
	{
sl@0
  1411
	TestGraphicsPanicsL(EPanicRedrawModeBackedUpWindow);
sl@0
  1412
	TestGraphicsPanicsL(EPanicRedrawModeNormalRedraw);
sl@0
  1413
	if (TransparencySupportedL()==KErrNone)
sl@0
  1414
		{
sl@0
  1415
		TestGraphicsPanicsL(EPanicRedrawModeTransRedraw);
sl@0
  1416
		}
sl@0
  1417
	TestGraphicsPanicsL(EPanicRedrawModeInvisRedraw);
sl@0
  1418
	}
sl@0
  1419
sl@0
  1420
void CTPanic::TestDeletedParentPanicsL()
sl@0
  1421
	{
sl@0
  1422
	TEST(iTest->TestWsPanicL(&DoDeletedParentTest,EWservPanicParentDeleted,1,(TAny*)iTest->iScreenNumber));
sl@0
  1423
	}
sl@0
  1424
sl@0
  1425
void CTPanic::TestHandleReUseL()
sl@0
  1426
	{
sl@0
  1427
	for (TInt ii=2;ii<6;++ii)
sl@0
  1428
		{
sl@0
  1429
		TEST(iTest->TestWsPanicL(&DoHandleReUse,EWservPanicHandle,ii,(TAny*)iTest->iScreenNumber));
sl@0
  1430
		}
sl@0
  1431
	}
sl@0
  1432
sl@0
  1433
void CTPanic::TestComputeModePanicsL()
sl@0
  1434
	{
sl@0
  1435
	TEST(iTest->TestWsPanicL(&DoCMPanicTest,EWservPanicSetComputeMode,1,(TAny*)iTest->iScreenNumber));
sl@0
  1436
	}
sl@0
  1437
sl@0
  1438
void CTPanic::TestCaptureKeyPanicsL()
sl@0
  1439
	{
sl@0
  1440
// Run this test in debug on emulator only.
sl@0
  1441
// On a debug ROM the release version of the wserv.exe is included so the test can't be run as no panic happens. 
sl@0
  1442
#if defined(_DEBUG) && defined(__WINS__)
sl@0
  1443
	TEST(iTest->TestWsPanicL(&DoCKPanicTest,EWservPanicDestroy,1,(TAny*)iTest->iScreenNumber));
sl@0
  1444
#endif
sl@0
  1445
	}
sl@0
  1446
sl@0
  1447
void CTPanic::TestEventPanicsL()
sl@0
  1448
	{
sl@0
  1449
	TEST(iTest->TestWsPanicL(&DoEventPanicTest,EWservPanicReadOutstanding,1,(TAny*)iTest->iScreenNumber));
sl@0
  1450
	}
sl@0
  1451
sl@0
  1452
void CTPanic::TestTPtrPanicsL()
sl@0
  1453
	{
sl@0
  1454
	TEST(iTest->TestWsPanicL(&DoTBufPtrTests,EWservPanicBufferPtr,1,(TAny*)iTest->iScreenNumber));
sl@0
  1455
	}
sl@0
  1456
sl@0
  1457
void CTPanic::TestOpcodePanicsL()
sl@0
  1458
	{
sl@0
  1459
	TInt param=1;
sl@0
  1460
	TBool finishTest = EFalse;
sl@0
  1461
	while(!finishTest)
sl@0
  1462
		{
sl@0
  1463
		TEST(iTest->TestWsPanicL(&DoOpcodeTests,EWservPanicOpcode,param,(TAny*)iTest->iScreenNumber,&finishTest));
sl@0
  1464
		param++;
sl@0
  1465
		}
sl@0
  1466
	}
sl@0
  1467
sl@0
  1468
void CTPanic::TestMultiInitPanicL()
sl@0
  1469
	{
sl@0
  1470
	TEST(iTest->TestWsPanicL(&DoMultiInitPanicTest,EWservPanicReInitialise,0,(TAny*)iTest->iScreenNumber));
sl@0
  1471
	}
sl@0
  1472
sl@0
  1473
/**
sl@0
  1474
@SYMTestCaseID		GRAPHICS-WSERV-0472
sl@0
  1475
sl@0
  1476
@SYMDEF             DEF118618
sl@0
  1477
sl@0
  1478
@SYMTestCaseDesc    Test defect fixes to system panics 
sl@0
  1479
sl@0
  1480
@SYMTestPriority    High
sl@0
  1481
sl@0
  1482
@SYMTestStatus      Implemented
sl@0
  1483
sl@0
  1484
@SYMTestActions     Check that various defect fixes to system panics are correct.
sl@0
  1485
					Also verify that reconstructing a closed object will succeed.
sl@0
  1486
sl@0
  1487
@SYMTestExpectedResults Panics respond correctly
sl@0
  1488
*/
sl@0
  1489
void CTPanic::TestDoubleConstructionL()
sl@0
  1490
	{
sl@0
  1491
#ifdef __WINS__
sl@0
  1492
	for(TInt test=1;test<11;test++)
sl@0
  1493
		{
sl@0
  1494
		TEST(iTest->TestW32PanicL(&DoDoubleConstructionTestL,EW32PanicGraphicDoubleConstruction,test,NULL));
sl@0
  1495
		}
sl@0
  1496
	TestDoubleConstructionNoPanic();
sl@0
  1497
#endif
sl@0
  1498
	}
sl@0
  1499
	
sl@0
  1500
/** Verifies the following scenario	is valid:
sl@0
  1501
	1. Create some wserv client-side objects.
sl@0
  1502
	2. Call Close on them.
sl@0
  1503
	3. Reconstruct them and they shouldn't panic this time. */
sl@0
  1504
void CTPanic::TestDoubleConstructionNoPanic()
sl@0
  1505
	{
sl@0
  1506
	RWsSession ws;
sl@0
  1507
	User::LeaveIfError(ws.Connect());
sl@0
  1508
	
sl@0
  1509
	RWindowGroup group(ws);
sl@0
  1510
	User::LeaveIfError(group.Construct(890, EFalse));
sl@0
  1511
	RBlankWindow bwin(ws);
sl@0
  1512
	User::LeaveIfError(bwin.Construct(group,900));
sl@0
  1513
	
sl@0
  1514
	//RWsSprite
sl@0
  1515
	RWsSprite sprite(ws);
sl@0
  1516
	TEST(KErrNone == sprite.Construct(bwin,TPoint(0,0),0));
sl@0
  1517
	sprite.Close();
sl@0
  1518
	TEST(KErrNone == sprite.Construct(bwin,TPoint(0,0),0));
sl@0
  1519
	sprite.Close();
sl@0
  1520
	
sl@0
  1521
	//RWsPointerCursor
sl@0
  1522
	RWsPointerCursor cursor(ws);
sl@0
  1523
	TEST(KErrNone == cursor.Construct(0));
sl@0
  1524
	cursor.Close();
sl@0
  1525
	TEST(KErrNone == cursor.Construct(0));
sl@0
  1526
	cursor.Close();
sl@0
  1527
	
sl@0
  1528
	//RSoundPlugIn
sl@0
  1529
	RSoundPlugIn click(ws);
sl@0
  1530
	TEST(KErrNone == click.Construct());
sl@0
  1531
	click.Close();
sl@0
  1532
	TEST(KErrNone == click.Construct());
sl@0
  1533
	click.Close();
sl@0
  1534
	
sl@0
  1535
	//RWindowGroup
sl@0
  1536
	RWindowGroup windowgroup(ws);
sl@0
  1537
	TEST(KErrNone ==windowgroup.Construct(901));
sl@0
  1538
	windowgroup.Close();
sl@0
  1539
	TEST(KErrNone ==windowgroup.Construct(901));
sl@0
  1540
	windowgroup.Close();
sl@0
  1541
	
sl@0
  1542
	//RWindow
sl@0
  1543
	RWindow win1(ws);
sl@0
  1544
	TEST(KErrNone == win1.Construct(group,902));
sl@0
  1545
	win1.Close(); 
sl@0
  1546
	TEST(KErrNone == win1.Construct(group,902));
sl@0
  1547
	win1.Close(); 
sl@0
  1548
	
sl@0
  1549
	//RBlankWindow
sl@0
  1550
	RBlankWindow win2(ws);
sl@0
  1551
	TEST(KErrNone == win2.Construct(group,902));
sl@0
  1552
	win2.Close(); 
sl@0
  1553
	TEST(KErrNone == win2.Construct(group,902));
sl@0
  1554
	win2.Close();
sl@0
  1555
	
sl@0
  1556
	//RBackedUpWindow
sl@0
  1557
	RBackedUpWindow win3(ws);
sl@0
  1558
	TEST(KErrNone == win3.Construct(group,EGray4,902));
sl@0
  1559
	win3.Close();
sl@0
  1560
	TEST(KErrNone == win3.Construct(group,EGray4,902));
sl@0
  1561
	win3.Close(); 
sl@0
  1562
	
sl@0
  1563
	//RAnimDll
sl@0
  1564
	RAnimDll animDll=RAnimDll(ws);
sl@0
  1565
	TEST(KErrNone == animDll.Load(KAnimDLLName));
sl@0
  1566
	animDll.Close();
sl@0
  1567
	TEST(KErrNone == animDll.Load(KAnimDLLName));
sl@0
  1568
	animDll.Close();
sl@0
  1569
	
sl@0
  1570
	group.Close();
sl@0
  1571
	bwin.Close();
sl@0
  1572
	ws.Close();
sl@0
  1573
	}
sl@0
  1574
sl@0
  1575
void CTPanic::TestSpritePanicsL()
sl@0
  1576
	{
sl@0
  1577
	for(TInt test=1;test<4;test++)
sl@0
  1578
		{
sl@0
  1579
		TEST(iTest->TestWsPanicL(&DoSpritePanicTestL,EWservPanicSprite,test,(TAny*)iTest->iScreenNumber));
sl@0
  1580
		}
sl@0
  1581
	}
sl@0
  1582
sl@0
  1583
/**
sl@0
  1584
@SYMTestCaseID		GRAPHICS-WSERV-0475
sl@0
  1585
sl@0
  1586
@SYMDEF             DEF118616
sl@0
  1587
sl@0
  1588
@SYMTestCaseDesc    Test defect fixes to system panics 
sl@0
  1589
sl@0
  1590
@SYMTestPriority    High
sl@0
  1591
sl@0
  1592
@SYMTestStatus      Implemented
sl@0
  1593
sl@0
  1594
@SYMTestActions     Check that various defect fixes to system panics are correct.
sl@0
  1595
sl@0
  1596
@SYMTestExpectedResults Panics respond correctly
sl@0
  1597
*/
sl@0
  1598
void CTPanic::TestSpriteActivatePanicL()
sl@0
  1599
	{
sl@0
  1600
	for(TInt test=1;test<3;test++)
sl@0
  1601
		{
sl@0
  1602
		TEST(iTest->TestWsPanicL(&DoTestSpriteActivatePanicL,EWservPanicNoSpriteMember,test,NULL));
sl@0
  1603
		}
sl@0
  1604
	}
sl@0
  1605
sl@0
  1606
void CTPanic::TestMoveToGroupPanicsL()
sl@0
  1607
	{
sl@0
  1608
	TEST(iTest->TestWsPanicL(&DoMoveToGroupPanicTestL,EWservPanicOpcode,1,(TAny*)iTest->iScreenNumber));
sl@0
  1609
	TEST(iTest->TestWsPanicL(&DoMoveToGroupPanicTestL,EWservPanicNotTopClient,2,(TAny*)iTest->iScreenNumber));
sl@0
  1610
	}
sl@0
  1611
sl@0
  1612
void CTPanic::TestDeleteScreenPanicL()
sl@0
  1613
	{
sl@0
  1614
#ifdef __WINS__
sl@0
  1615
	TEST(iTest->TestWsPanicL(&DoDeleteScreenPanicTestL,EWservPanicGroupWinScreenDeviceDeleted,1,(TAny*)iTest->iScreenNumber));
sl@0
  1616
	TEST(iTest->TestWsPanicL(&DoDeleteScreenPanicTestL,EWservPanicGroupWinScreenDeviceDeleted,2,(TAny*)iTest->iScreenNumber));
sl@0
  1617
#endif
sl@0
  1618
	}
sl@0
  1619
sl@0
  1620
void CTPanic::TestWinHandleErrors()
sl@0
  1621
	{
sl@0
  1622
#ifdef __WINS__
sl@0
  1623
	TEST(iTest->TestWsPanicL(&DoWinHandlePanicTestL,EWservPanicDuplicateHandle,1));
sl@0
  1624
	TEST(iTest->TestWsPanicL(&DoWinHandlePanicTestL,EWservPanicDuplicateHandle,2));
sl@0
  1625
	TEST(iTest->TestWsPanicL(&DoWinHandlePanicTestL,EWservPanicDuplicateHandle,3));
sl@0
  1626
#endif
sl@0
  1627
	TEST(iTest->TestWsPanicL(&DoWinHandlePanicTestL,EWservPanicNullHandle,4));
sl@0
  1628
	}
sl@0
  1629
sl@0
  1630
void CTPanic::TestGetEventErrors()
sl@0
  1631
	{
sl@0
  1632
	TEST(iTest->TestWsPanicL(&DoGetEventPanicTestL,EWservPanicUnsignalledEventData,1,(TAny*)iTest->iScreenNumber));
sl@0
  1633
	TEST(iTest->TestWsPanicL(&DoGetEventPanicTestL,EWservPanicDescriptor,2,(TAny*)iTest->iScreenNumber));
sl@0
  1634
	}
sl@0
  1635
sl@0
  1636
void CTPanic::TestUnInitPanicL()
sl@0
  1637
	{
sl@0
  1638
	TEST(iTest->TestWsPanicL(&DoUnInitPanicTest,EWservPanicUninitialisedClient,0,(TAny*)iTest->iScreenNumber));
sl@0
  1639
	}
sl@0
  1640
sl@0
  1641
void CTPanic::TestEnableAdvancePointerActivatePanicL()
sl@0
  1642
    {
sl@0
  1643
    TEST(iTest->TestWsPanicL(&DoTestAdvancePointerActivatePanicL,EWservPanicUnableToEnableAdvPointer, 0, (TAny*)iTest->iScreenNumber));
sl@0
  1644
    }
sl@0
  1645
sl@0
  1646
void CTPanic::ConstructL()
sl@0
  1647
	{
sl@0
  1648
	TheGc->Activate(*BaseWin->Win());
sl@0
  1649
	TheGc->Clear();
sl@0
  1650
	TheGc->SetBrushColor(TRgb::Gray16(12));
sl@0
  1651
	TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
  1652
	TheGc->SetPenStyle(CGraphicsContext::ENullPen);
sl@0
  1653
	TheGc->DrawRect(TRect(BaseWin->Win()->Size()));
sl@0
  1654
	TheGc->Deactivate();
sl@0
  1655
	TheGc->Activate(*TestWin->Win());
sl@0
  1656
	TheGc->Clear();
sl@0
  1657
	TheGc->SetBrushColor(TRgb::Gray16(4));
sl@0
  1658
	TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
  1659
	TheGc->SetPenStyle(CGraphicsContext::ENullPen);
sl@0
  1660
	TheGc->DrawRect(TRect(TestWin->Win()->Size()));
sl@0
  1661
	TheGc->Deactivate();
sl@0
  1662
//
sl@0
  1663
	_LIT(KReportFullRom,"Warning full ROM, EikSrv present, panic dialogs may interfere with tests");
sl@0
  1664
	_LIT(KReportGoodRom,"ROM OK, No EikSrv present");
sl@0
  1665
	if (iTest->IsFullRomL())
sl@0
  1666
		{
sl@0
  1667
		INFO_PRINTF1(KReportFullRom);
sl@0
  1668
		}
sl@0
  1669
	else
sl@0
  1670
		{
sl@0
  1671
		INFO_PRINTF1(KReportGoodRom);
sl@0
  1672
		}
sl@0
  1673
	}
sl@0
  1674
sl@0
  1675
void CTPanic::TestAlphaBlendingPanicL()
sl@0
  1676
	{
sl@0
  1677
	INFO_PRINTF1(_L("Masked transparency support has been removed."));
sl@0
  1678
	}
sl@0
  1679
	
sl@0
  1680
void CTPanic::TestMismatchedCaptureCancelPanicL()
sl@0
  1681
	{		
sl@0
  1682
// Run this test in debug on emulator only.
sl@0
  1683
// On a debug ROM the release version of the wserv.exe is included so the test can't be run as no panic happens. 
sl@0
  1684
#if defined(_DEBUG) && defined(__WINS__)		
sl@0
  1685
	TEST(iTest->TestWsPanicL(DoMismatchedCancelCaptureTest,EWservPanicDestroy,ECancelCaptureKey,(TAny*)iTest->iScreenNumber));
sl@0
  1686
	TEST(iTest->TestWsPanicL(DoMismatchedCancelCaptureTest,EWservPanicDestroy,ECancelCaptureKeyUpAndDowns,(TAny*)iTest->iScreenNumber));
sl@0
  1687
	TEST(iTest->TestWsPanicL(DoMismatchedCancelCaptureTest,EWservPanicDestroy,ECancelCaptureLongKey,(TAny*)iTest->iScreenNumber));
sl@0
  1688
#endif
sl@0
  1689
	}
sl@0
  1690
sl@0
  1691
void CTPanic::RunTestCaseL(TInt /*aCurTestCase*/)
sl@0
  1692
	{
sl@0
  1693
	((CTPanicStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
sl@0
  1694
	switch(++iTest->iState)
sl@0
  1695
		{
sl@0
  1696
/**
sl@0
  1697
@SYMTestCaseID		GRAPHICS-WSERV-0259
sl@0
  1698
sl@0
  1699
@SYMDEF             DEF081259
sl@0
  1700
sl@0
  1701
@SYMTestCaseDesc    Test various system panics 
sl@0
  1702
sl@0
  1703
@SYMTestPriority    High
sl@0
  1704
sl@0
  1705
@SYMTestStatus      Implemented
sl@0
  1706
sl@0
  1707
@SYMTestActions     Check that various system panics respond correctly 
sl@0
  1708
sl@0
  1709
@SYMTestExpectedResults Panics respond correctly
sl@0
  1710
*/
sl@0
  1711
		case 1:
sl@0
  1712
			{
sl@0
  1713
			((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0259"));
sl@0
  1714
			iTest->LogSubTest(_L("TestCaptureKeyPanicsL"));
sl@0
  1715
			TestCaptureKeyPanicsL();
sl@0
  1716
			}
sl@0
  1717
			break;
sl@0
  1718
		case 2:
sl@0
  1719
		    {
sl@0
  1720
			iTest->LogSubTest(_L("TestEventPanicsL"));
sl@0
  1721
			TestEventPanicsL();
sl@0
  1722
		    }
sl@0
  1723
		    break;
sl@0
  1724
		case 3:
sl@0
  1725
		    {
sl@0
  1726
			iTest->LogSubTest(_L("TestComputeModePanicsL"));
sl@0
  1727
			TestComputeModePanicsL();
sl@0
  1728
		    }
sl@0
  1729
		    break;
sl@0
  1730
		case 4:
sl@0
  1731
		    {
sl@0
  1732
#ifdef __WINS__
sl@0
  1733
//  Only running this under WINS as the tests are a bit excessive, firing off all sorts of illegal
sl@0
  1734
// opcode/flag combinations, as well as buffers of random data.
sl@0
  1735
// Currently on ARM builds they're failing with KErrOutOfMemory, probably running out of handles
sl@0
  1736
// somewhere in the OS.
sl@0
  1737
			iTest->LogSubTest(_L("TestMiscPanicsL"));
sl@0
  1738
			TestMiscPanicsL();
sl@0
  1739
#endif
sl@0
  1740
		    }
sl@0
  1741
		    break;
sl@0
  1742
		case 5:
sl@0
  1743
		    {
sl@0
  1744
			iTest->LogSubTest(_L("TestGraphicsPanicsL"));
sl@0
  1745
			TestGraphicsPanicsL();
sl@0
  1746
		    }
sl@0
  1747
		    break;
sl@0
  1748
		case 6:
sl@0
  1749
		    {
sl@0
  1750
			iTest->LogSubTest(_L("TestTPtrPanicsL"));
sl@0
  1751
			TestTPtrPanicsL();
sl@0
  1752
		    }
sl@0
  1753
		    break;
sl@0
  1754
		case 7:
sl@0
  1755
		    {
sl@0
  1756
			iTest->LogSubTest(_L("TestOpcodePanicsL"));
sl@0
  1757
			TestOpcodePanicsL();
sl@0
  1758
		    }
sl@0
  1759
		    break;
sl@0
  1760
		case 8:
sl@0
  1761
		    {
sl@0
  1762
			iTest->LogSubTest(_L("TestScreenDevicePanicsL"));
sl@0
  1763
			TestScreenDevicePanicsL();
sl@0
  1764
		    }
sl@0
  1765
		    break;
sl@0
  1766
		case 9:
sl@0
  1767
		    {
sl@0
  1768
			iTest->LogSubTest(_L("TestMultiInitPanicL"));
sl@0
  1769
			TestMultiInitPanicL();
sl@0
  1770
			}
sl@0
  1771
			break;
sl@0
  1772
/**
sl@0
  1773
@SYMTestCaseID		GRAPHICS-WSERV-0260
sl@0
  1774
sl@0
  1775
@SYMDEF             DEF081259
sl@0
  1776
sl@0
  1777
@SYMTestCaseDesc    Test various system panics 
sl@0
  1778
sl@0
  1779
@SYMTestPriority    High
sl@0
  1780
sl@0
  1781
@SYMTestStatus      Implemented
sl@0
  1782
sl@0
  1783
@SYMTestActions     Check that various system panics respond correctly 
sl@0
  1784
sl@0
  1785
@SYMTestExpectedResults Panics respond correctly
sl@0
  1786
*/
sl@0
  1787
		case 10:
sl@0
  1788
			{
sl@0
  1789
			((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0260"));
sl@0
  1790
			iTest->LogSubTest(_L("Panic 2"));
sl@0
  1791
			TestSpritePanicsL();
sl@0
  1792
			TestMoveToGroupPanicsL();
sl@0
  1793
			}
sl@0
  1794
			break;
sl@0
  1795
/**
sl@0
  1796
@SYMTestCaseID		GRAPHICS-WSERV-0261
sl@0
  1797
sl@0
  1798
@SYMDEF             DEF081259
sl@0
  1799
sl@0
  1800
@SYMTestCaseDesc    Test defect fixes to system panics 
sl@0
  1801
sl@0
  1802
@SYMTestPriority    High
sl@0
  1803
sl@0
  1804
@SYMTestStatus      Implemented
sl@0
  1805
sl@0
  1806
@SYMTestActions     Check that various defect fixes to system panics are correct 
sl@0
  1807
sl@0
  1808
@SYMTestExpectedResults Panics respond correctly
sl@0
  1809
*/			
sl@0
  1810
		case 11:
sl@0
  1811
			{
sl@0
  1812
			((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0261"));
sl@0
  1813
			_LIT(KPanicTest,"Defect Fixes (Pan.3)");
sl@0
  1814
			iTest->LogSubTest(KPanicTest);
sl@0
  1815
			TestDeletedParentPanicsL();
sl@0
  1816
			TestHandleReUseL();
sl@0
  1817
			TestDeleteScreenPanicL(); // DEF069809
sl@0
  1818
			}
sl@0
  1819
			break;
sl@0
  1820
/**
sl@0
  1821
@SYMTestCaseID		GRAPHICS-WSERV-097969-0001
sl@0
  1822
sl@0
  1823
@SYMDEF             DEF097969
sl@0
  1824
sl@0
  1825
@SYMTestCaseDesc    Test defect fixes to system panics 
sl@0
  1826
sl@0
  1827
@SYMTestPriority    High
sl@0
  1828
sl@0
  1829
@SYMTestStatus      Implemented
sl@0
  1830
sl@0
  1831
@SYMTestActions     Check that various defect fixes to system panics are correct 
sl@0
  1832
sl@0
  1833
@SYMTestExpectedResults Panics respond correctly
sl@0
  1834
*/			
sl@0
  1835
		case 12:
sl@0
  1836
			{
sl@0
  1837
			((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-097969-0001"));
sl@0
  1838
			_LIT(KPanicTest,"Server panic defect Fix (Pan.4)");
sl@0
  1839
			iTest->LogSubTest(KPanicTest);
sl@0
  1840
			TestUnInitPanicL();	// DEF097969
sl@0
  1841
			}
sl@0
  1842
			break;
sl@0
  1843
		
sl@0
  1844
		case 13:
sl@0
  1845
			{
sl@0
  1846
/**
sl@0
  1847
@SYMTestCaseID		GRAPHICS-WSERV-0501
sl@0
  1848
*/
sl@0
  1849
			((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0501"));
sl@0
  1850
			_LIT(KPanicTest,"AlphaBlending Bitmap panic defect Fix (Pan.5)");
sl@0
  1851
			iTest->LogSubTest(KPanicTest);
sl@0
  1852
			TestAlphaBlendingPanicL();	// DEF112916
sl@0
  1853
			}
sl@0
  1854
			break;
sl@0
  1855
		case 14:
sl@0
  1856
			{		
sl@0
  1857
            ((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0472"));
sl@0
  1858
			_LIT(KPanicTest,"Double construction panic test");
sl@0
  1859
			iTest->LogSubTest(KPanicTest);
sl@0
  1860
			TestDoubleConstructionL();	// DEF118618
sl@0
  1861
			}
sl@0
  1862
			break;
sl@0
  1863
		case 15:
sl@0
  1864
			{
sl@0
  1865
			((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0475"));
sl@0
  1866
			_LIT(KPanicTest, "RWsSprite Activate() without members panic test");
sl@0
  1867
			iTest->LogSubTest(KPanicTest);
sl@0
  1868
			TestSpriteActivatePanicL(); //DEF118616				
sl@0
  1869
			}
sl@0
  1870
			break;
sl@0
  1871
/**
sl@0
  1872
@SYMTestCaseID		GRAPHICS-WSERV-0497
sl@0
  1873
sl@0
  1874
@SYMDEF             DEF133776
sl@0
  1875
sl@0
  1876
@SYMTestCaseDesc     Test that a debug only panic occurs when an attempt
sl@0
  1877
 is made to cancel a key capture using the wrong cancel capture API.
sl@0
  1878
sl@0
  1879
@SYMTestPriority    High
sl@0
  1880
sl@0
  1881
@SYMTestStatus      Implemented
sl@0
  1882
sl@0
  1883
@SYMTestActions     Check that calling the each RWindowGroup::CancelCapture***() API
sl@0
  1884
 using the handle returned from a mismatched RWindowGroup::Capture***() call causes
sl@0
  1885
 a debug only panic. Tests each of the three RWindowGroup::CancelCapture***() APIs.
sl@0
  1886
sl@0
  1887
@SYMTestExpectedResults Panics respond correctly in debug only.
sl@0
  1888
*/			
sl@0
  1889
		case 16:
sl@0
  1890
			{
sl@0
  1891
			((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0497"));
sl@0
  1892
			_LIT(KPanicTest,"TestMismatchedCaptureCancelPanicL");
sl@0
  1893
			iTest->LogSubTest(KPanicTest);
sl@0
  1894
			TestMismatchedCaptureCancelPanicL();				
sl@0
  1895
			}
sl@0
  1896
			break;			
sl@0
  1897
#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
sl@0
  1898
		case 17:
sl@0
  1899
			{
sl@0
  1900
			_LIT(KPanicTest, "Non-Redraw Drawing inside Redrawer Panic Test");
sl@0
  1901
			iTest->LogSubTest(KPanicTest);
sl@0
  1902
			TestNonRedrawRedrawerL();
sl@0
  1903
			}
sl@0
  1904
			break;
sl@0
  1905
	  case 18:
sl@0
  1906
      {
sl@0
  1907
      _LIT(KPanicTest, "Enable advanced pointer Panic Test");
sl@0
  1908
      iTest->LogSubTest(KPanicTest);
sl@0
  1909
      TestEnableAdvancePointerActivatePanicL();
sl@0
  1910
      }   
sl@0
  1911
			break;
sl@0
  1912
						
sl@0
  1913
#endif			
sl@0
  1914
		default:
sl@0
  1915
            		((CTPanicStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
sl@0
  1916
			((CTPanicStep*)iStep)->CloseTMSGraphicsStep();
sl@0
  1917
			TestComplete();
sl@0
  1918
			break;
sl@0
  1919
		}
sl@0
  1920
	((CTPanicStep*)iStep)->RecordTestResultL();
sl@0
  1921
	}
sl@0
  1922
sl@0
  1923
#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
sl@0
  1924
LOCAL_C TInt DoTestNonRedrawRedrawerL(TInt /* aInt */, TAny * /* aPtr */)
sl@0
  1925
	{
sl@0
  1926
	CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
sl@0
  1927
	CleanupStack::PushL(scheduler);
sl@0
  1928
	CActiveScheduler::Install(scheduler);
sl@0
  1929
	
sl@0
  1930
	RWsSession session;
sl@0
  1931
	User::LeaveIfError(session.Connect());
sl@0
  1932
	
sl@0
  1933
	CWsScreenDevice *screenDevice = new (ELeave)CWsScreenDevice(session);
sl@0
  1934
	User::LeaveIfError(screenDevice->Construct ());
sl@0
  1935
	CWindowGc *gc;
sl@0
  1936
	User::LeaveIfError(screenDevice->CreateContext(gc));
sl@0
  1937
	
sl@0
  1938
	CNonRedrawWin *nonRedrawWin=CNonRedrawWin::NewL(session, gc);	
sl@0
  1939
	nonRedrawWin->Invalidate(); 
sl@0
  1940
	CActiveScheduler::Start();
sl@0
  1941
	User::After(2000000); // so the Redrawer has a chance to run 
sl@0
  1942
	CActiveScheduler::Stop();
sl@0
  1943
	delete gc;
sl@0
  1944
	delete screenDevice;
sl@0
  1945
	session.Close();
sl@0
  1946
	CleanupStack::PopAndDestroy(scheduler);
sl@0
  1947
	return(EWsExitReasonBad);
sl@0
  1948
	}
sl@0
  1949
sl@0
  1950
/**
sl@0
  1951
@SYMTestCaseID		GRAPHICS-WSERV-0121808
sl@0
  1952
@SYMDEF             DEF121808: No more Non-Redraw drawing for NGA (test added during DEF134308) 
sl@0
  1953
@SYMTestCaseDesc    Test defect fixes to system panics 
sl@0
  1954
@SYMTestPriority    High
sl@0
  1955
@SYMTestStatus      Implemented
sl@0
  1956
@SYMTestActions     Check that WServ panics a client which uses Non-Redraw drawing in the Redrawer.
sl@0
  1957
@SYMTestExpectedResults Panics respond correctly
sl@0
  1958
*/
sl@0
  1959
void CTPanic::TestNonRedrawRedrawerL()
sl@0
  1960
	{
sl@0
  1961
	TEST(iTest->TestWsPanicL(&DoTestNonRedrawRedrawerL,EWservPanicWindowBeginRedrawNotCalled,NULL,NULL));
sl@0
  1962
	}
sl@0
  1963
sl@0
  1964
CNonRedrawWin::CRedrawer::CRedrawer(CNonRedrawWin* aWd) :
sl@0
  1965
	CActive(CActive::EPriorityStandard), iWd(aWd){
sl@0
  1966
	CActiveScheduler::Add(this);
sl@0
  1967
	HandleRedrawEvent();	
sl@0
  1968
}
sl@0
  1969
sl@0
  1970
CNonRedrawWin::CRedrawer::~CRedrawer(){
sl@0
  1971
	Cancel();
sl@0
  1972
}
sl@0
  1973
sl@0
  1974
void CNonRedrawWin::CRedrawer::HandleRedrawEvent(){
sl@0
  1975
	iWd->GetSession().RedrawReady(&iStatus);
sl@0
  1976
	SetActive();
sl@0
  1977
}
sl@0
  1978
sl@0
  1979
void CNonRedrawWin::CRedrawer::RunL(){
sl@0
  1980
	TWsRedrawEvent redrawEvent;
sl@0
  1981
	iWd->GetSession().GetRedraw(redrawEvent);	
sl@0
  1982
	iWd->Redraw();
sl@0
  1983
	HandleRedrawEvent();
sl@0
  1984
}
sl@0
  1985
sl@0
  1986
void CNonRedrawWin::CRedrawer::DoCancel(){
sl@0
  1987
	iWd->GetSession().RedrawReadyCancel();
sl@0
  1988
}
sl@0
  1989
sl@0
  1990
CNonRedrawWin* CNonRedrawWin::NewL(RWsSession &aSession, CWindowGc *aGc){
sl@0
  1991
	CNonRedrawWin* self=new(ELeave)CNonRedrawWin(aSession, aGc);
sl@0
  1992
	CleanupStack::PushL(self);
sl@0
  1993
	self->ConstrucL();
sl@0
  1994
	CleanupStack::Pop(self);
sl@0
  1995
	return self;
sl@0
  1996
}
sl@0
  1997
sl@0
  1998
CNonRedrawWin::CNonRedrawWin(RWsSession &aSession, CWindowGc *aGc):
sl@0
  1999
	iSession(aSession), iGc(aGc){}
sl@0
  2000
sl@0
  2001
CNonRedrawWin::~CNonRedrawWin(){
sl@0
  2002
	delete iRedrawer;
sl@0
  2003
	iWd.Close();
sl@0
  2004
	iWdGrp.Close();	
sl@0
  2005
}
sl@0
  2006
sl@0
  2007
void CNonRedrawWin::Redraw(){
sl@0
  2008
	// This is a Non-Redraw Drawing Redrawer; BeginRedraw()/EndRedraw()
sl@0
  2009
	// have been intentionally omitted.
sl@0
  2010
	iGc->Activate(iWd);	
sl@0
  2011
	iGc->SetBrushColor(TRgb(255,0,0));
sl@0
  2012
	iGc->SetPenColor(KRgbBlue);
sl@0
  2013
	iGc->SetPenSize(TSize(10,20));
sl@0
  2014
	iGc->DrawRect(TRect(TPoint(10,10),TPoint(50,50)));	
sl@0
  2015
	iGc->Deactivate();
sl@0
  2016
	iSession.Finish();			
sl@0
  2017
}
sl@0
  2018
sl@0
  2019
RWsSession &CNonRedrawWin::GetSession(){return iSession;}
sl@0
  2020
sl@0
  2021
void CNonRedrawWin::Invalidate(){iWd.Invalidate();}
sl@0
  2022
sl@0
  2023
void CNonRedrawWin::ConstrucL(){
sl@0
  2024
	iWdGrp=RWindowGroup(iSession);	
sl@0
  2025
	iWdGrp.Construct((TUint32)this,ETrue);
sl@0
  2026
	_LIT(KWndGrpName,"NonRedrawWndGrp");
sl@0
  2027
	iWdGrp.SetName(KWndGrpName);	
sl@0
  2028
	iWd=RWindow(iSession);	
sl@0
  2029
	iWd.Construct(iWdGrp, 0x101);	
sl@0
  2030
	User::LeaveIfError(iWd.SetExtentErr(TPoint(0,0),TSize(150,150)));
sl@0
  2031
	iWd.SetBackgroundColor(KRgbWhite);
sl@0
  2032
	iWd.SetOrdinalPosition(0);	
sl@0
  2033
	iWd.Activate();	
sl@0
  2034
	iRedrawer=new(ELeave) CRedrawer(this);
sl@0
  2035
}
sl@0
  2036
#endif
sl@0
  2037
sl@0
  2038
TInt RUnInitalisedConnect::Connect(const TDesC &aName, const TVersion &aVersion)
sl@0
  2039
	{
sl@0
  2040
	return CreateSession(aName, aVersion, 255);
sl@0
  2041
	}
sl@0
  2042
sl@0
  2043
TInt RUnInitalisedConnect::Send(const TInt aMsg)
sl@0
  2044
	{
sl@0
  2045
	return SendReceive(aMsg);
sl@0
  2046
	}
sl@0
  2047
sl@0
  2048
__WS_CONSTRUCT_STEP__(Panic)
sl@0
  2049
#pragma warning( disable : 4505 )