os/graphics/windowing/windowserver/test/tauto/TPANIC.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/windowing/windowserver/test/tauto/TPANIC.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,2049 @@
     1.4 +// Copyright (c) 1996-2010 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// Test various cases of Wserv panicing client apps
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +/**
    1.22 + @file
    1.23 + @test
    1.24 + @internalComponent - Internal Symbian test code
    1.25 +*/
    1.26 +
    1.27 +#include "TPANIC.H"
    1.28 +#include "../tlib/testbase.h"
    1.29 +#include <w32debug.h>
    1.30 +#define TEST_BITMAP _L("Z:\\WSTEST\\WSAUTOTEST.MBM")
    1.31 +
    1.32 +class RWsSessionHacker : public RWsSession
    1.33 +	{
    1.34 +public:
    1.35 +	inline RWsBuffer *WsBuffer() const {return(iBuffer);};
    1.36 +	inline TInt PanicItSendReceive(TInt aFunction,const TIpcArgs& aArgs) const {return SendReceive(aFunction,aArgs);};
    1.37 +	inline TInt PanicItSend(TInt aFunction,const TIpcArgs& aArgs) const {return Send(aFunction,aArgs);};
    1.38 +	inline TInt PanicItSendReceive(TInt aFunction) const {return SendReceive(aFunction);};
    1.39 +	inline TInt PanicItSend(TInt aFunction) const {return Send(aFunction);};
    1.40 +	};
    1.41 +
    1.42 +class RWsBufferHacker // copy of original data structure to access buffer data
    1.43 +	{
    1.44 +public:
    1.45 +	RWsSession* iSession;
    1.46 +	CWsGraphic::CManager* iManager;
    1.47 +	TBool iAutoFlush;
    1.48 +	TPtr8 iBuf;
    1.49 +	RWsBuffer* iNext;
    1.50 +	TInt iPreviousHandle;
    1.51 +	TInt iBufSize;
    1.52 +	TInt iMaxBufSize;
    1.53 +	TInt iDirectAcessCount;
    1.54 +	RArray<TInt> iBitmapArray;
    1.55 +	TBool iInvalidBitmapArray;
    1.56 +	};
    1.57 +
    1.58 +CTPanic::CTPanic(CTestStep* aStep):
    1.59 +	CTWsGraphicsBase(aStep)
    1.60 +	{
    1.61 +	}
    1.62 +	
    1.63 +CTPanic::~CTPanic()
    1.64 +	{
    1.65 +	}
    1.66 +
    1.67 +LOCAL_C TInt DoDeletedParentTest(TInt aInt, TAny *aScreenNumber)
    1.68 +	{
    1.69 +	RWsSession ws;
    1.70 +	User::LeaveIfError(ws.Connect());
    1.71 +	// point to correct screen
    1.72 +	CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
    1.73 +	User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
    1.74 +	
    1.75 +	RWindowGroup group(ws);
    1.76 +	User::LeaveIfError(group.Construct(888));
    1.77 +	group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
    1.78 +	switch(aInt)
    1.79 +		{
    1.80 +		case 1:
    1.81 +			RWindow win1(ws);
    1.82 +			User::LeaveIfError(win1.Construct(group,1));
    1.83 +			RWindow win2(ws);
    1.84 +			User::LeaveIfError(win2.Construct(win1,2));
    1.85 +			win1.Close();
    1.86 +			win2.SetExtent(TPoint(1,2),TSize(3,4));
    1.87 +			break;
    1.88 +		}
    1.89 +	ws.Flush();
    1.90 +	return(EWsExitReasonBad);
    1.91 +	}
    1.92 +
    1.93 +LOCAL_C void ReuseWindow(RWsSession& aWs,RWindowGroup& aGroup,RWindow aCopyWin,RWindow* aPtrWin)
    1.94 +	{
    1.95 +	aPtrWin->Close();
    1.96 +	RWindow win(aWs);
    1.97 +	User::LeaveIfError(win.Construct(aGroup,17));
    1.98 +	aCopyWin.SetExtent(TPoint(1,2),TSize(3,4));	
    1.99 +	}
   1.100 +
   1.101 +LOCAL_C void ReuseGroupWindow(RWsSession& aWs,RWindowGroup aCopyWin,RWindowGroup* aPtrWin)
   1.102 +	{
   1.103 +	aPtrWin->Close();
   1.104 +	RWindowGroup group(aWs);
   1.105 +	User::LeaveIfError(group.Construct(889));
   1.106 +	group.EnableReceiptOfFocus(EFalse);	
   1.107 +	aCopyWin.EnableReceiptOfFocus(EFalse);	
   1.108 +	}
   1.109 +
   1.110 +LOCAL_C void ReuseSprite(RWsSession& aWs,RWindow& aWin,RWsSprite aCopySprite,RWsSprite* aPtrSprite)
   1.111 +	{
   1.112 +	aPtrSprite->Close();
   1.113 +	RWsSprite sprite(aWs);
   1.114 +	sprite.Construct(aWin,TPoint(0,0),0);
   1.115 +	aCopySprite.SetPosition(TPoint(22,22));	
   1.116 +	}
   1.117 +
   1.118 +LOCAL_C void ReusePointerCursor(RWsSession& aWs,RWsPointerCursor aCopyCursor,RWsPointerCursor* aPtrCursor)
   1.119 +	{
   1.120 +	aPtrCursor->Close();
   1.121 +	RWsPointerCursor cursor(aWs);
   1.122 +	cursor.Construct(0);
   1.123 +	aCopyCursor.Activate();	
   1.124 +	}
   1.125 +
   1.126 +LOCAL_C TInt DoHandleReUse(TInt aInt, TAny *aScreenNumber)
   1.127 +	{
   1.128 +	RWsSession ws;
   1.129 +	User::LeaveIfError(ws.Connect());
   1.130 +	CWsScreenDevice *scrdev=new(ELeave) CWsScreenDevice(ws);
   1.131 +	scrdev->Construct((TInt)aScreenNumber);
   1.132 +	RWindowGroup group(ws);
   1.133 +	User::LeaveIfError(group.Construct(888));
   1.134 +	group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
   1.135 +	RWindow win(ws);
   1.136 +	User::LeaveIfError(win.Construct(group,1));
   1.137 +	switch(aInt)
   1.138 +		{
   1.139 +		case 2:			//WS_HANDLE_WINDOW
   1.140 +			ReuseWindow(ws,group,win,&win);
   1.141 +			break;
   1.142 +		case 3:			//WS_HANDLE_GROUP_WINDOW
   1.143 +			ReuseGroupWindow(ws,group,&group);
   1.144 +			break;
   1.145 +		case 4:			//WS_HANDLE_SPRITE
   1.146 +			{
   1.147 +			RWsSprite sprite(ws);
   1.148 +			sprite.Construct(win,TPoint(0,0),0);
   1.149 +			ReuseSprite(ws,win,sprite,&sprite);
   1.150 +			}
   1.151 +			break;
   1.152 +		case 5:			//WS_HANDLE_POINTER_CURSOR
   1.153 +			{
   1.154 +			RWsPointerCursor cursor(ws);
   1.155 +			cursor.Construct(0);
   1.156 +			ReusePointerCursor(ws,cursor,&cursor);
   1.157 +			}
   1.158 +			break;
   1.159 +		}
   1.160 +	ws.Flush();
   1.161 +	return(EWsExitReasonBad);
   1.162 +	}
   1.163 +
   1.164 +LOCAL_C TInt DoScreenDevicePanicTest(TInt aInt, TAny *aScreenNumber)
   1.165 +	{
   1.166 +	RWsSession ws;
   1.167 +	User::LeaveIfError(ws.Connect());
   1.168 +
   1.169 +	CWsScreenDevice *scrdev=new(ELeave) CWsScreenDevice(ws);
   1.170 +	User::LeaveIfError(scrdev->Construct((TInt)aScreenNumber));
   1.171 +	
   1.172 +	RWindowGroup group(ws);
   1.173 +	User::LeaveIfError(group.Construct(888));
   1.174 +	group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
   1.175 +	RWindow win(ws);
   1.176 +	User::LeaveIfError(win.Construct(group, 1));
   1.177 +	win.Activate();
   1.178 +	CFbsBitmap *bitmap=new(ELeave) CFbsBitmap;
   1.179 + 	switch(aInt)
   1.180 +		{
   1.181 +		case 1:
   1.182 +			scrdev->CopyScreenToBitmap(bitmap);
   1.183 +			break;
   1.184 +		case 2:
   1.185 +			scrdev->CopyScreenToBitmap(bitmap,TRect(0,0,10,10));
   1.186 +			break;
   1.187 +		default:
   1.188 +			return(EWsExitReasonFinished);
   1.189 +		}
   1.190 +	ws.Flush();
   1.191 +	return(EWsExitReasonBad);
   1.192 +	}
   1.193 +
   1.194 +LOCAL_C TInt DoOpcodeTests(TInt aInt, TAny *aScreenNumber)
   1.195 +	{
   1.196 +	RWsSession ws;
   1.197 +	User::LeaveIfError(ws.Connect());
   1.198 +
   1.199 +	CWsScreenDevice *scrdev=new(ELeave) CWsScreenDevice(ws);
   1.200 +	User::LeaveIfError(scrdev->Construct((TInt)aScreenNumber));
   1.201 +	
   1.202 +	RWindowGroup group(ws);
   1.203 +	User::LeaveIfError(group.Construct(888));
   1.204 +	group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
   1.205 +	RWindow win(ws);
   1.206 +	User::LeaveIfError(win.Construct(group, 1));
   1.207 +	win.Activate();
   1.208 +	CWindowGc *gc;
   1.209 +	scrdev->CreateContext(gc);
   1.210 + 	switch(aInt)
   1.211 +		{
   1.212 +		case 1:
   1.213 +			ws.TestWrite(ws.WsHandle(),9999,NULL,0);
   1.214 +			break;
   1.215 +		case 2:
   1.216 +			gc->Activate(win);
   1.217 +			win.BeginRedraw();
   1.218 +			ws.TestWrite(gc->WsHandle(),9999,NULL,0);
   1.219 +			/* This only panics if the command is processed immediately.  If it goes into the redraw
   1.220 +			store then it will be unable to panic the client untill an additional buffer has been received,
   1.221 +			hence the double flush.
   1.222 +			*/
   1.223 +			win.EndRedraw();
   1.224 +			ws.Finish();
   1.225 +			win.BeginRedraw();
   1.226 +			win.EndRedraw();
   1.227 +			break;
   1.228 +		case 3:
   1.229 +			ws.TestWrite(scrdev->WsHandle(),9999,NULL,0);
   1.230 +			break;
   1.231 +		case 4:
   1.232 +			{
   1.233 +			CWsBitmap *bitmap=new(ELeave) CWsBitmap(ws);
   1.234 +			bitmap->Create(TSize(10,10),EGray4);
   1.235 +			ws.TestWrite(bitmap->WsHandle(),9999,NULL,0);
   1.236 +			}
   1.237 +			break;
   1.238 +		case 5:
   1.239 +			ws.TestWrite(win.WsHandle(),9999,NULL,0);
   1.240 +			break;
   1.241 +		case 6:
   1.242 +			ws.TestWrite(group.WsHandle(),9999,NULL,0);
   1.243 +			break;
   1.244 +		case 7:
   1.245 +			{
   1.246 +			RWsSprite sprite(ws);
   1.247 +			sprite.Construct(win,TPoint(0,0),0);
   1.248 +			ws.TestWrite(sprite.WsHandle(),9999,NULL,0);
   1.249 +			}
   1.250 +			break;
   1.251 +		default:
   1.252 +			return(EWsExitReasonFinished);
   1.253 +		}
   1.254 +	ws.Flush();
   1.255 +	return(EWsExitReasonBad);
   1.256 +	}
   1.257 +
   1.258 +TInt DoGraphicsPanicTest(RWsSession& aWs, RWindow& aRWin, RDrawableWindow* aDrawWin, CWindowGc* aGc, CFbsFont* aFont, TInt aTest, TInt aSubTest, TBool aInRedraw, TBool aNeedsValidating)
   1.259 +	{
   1.260 +	if (aInRedraw || aNeedsValidating)
   1.261 +		{
   1.262 +		aRWin.BeginRedraw();
   1.263 +		if (!aInRedraw)
   1.264 +			{ // TransWin without redraw active needs the begin/end to make the redraw store active
   1.265 +			aRWin.EndRedraw(); // or else all graphics will simply be ignored and no panics will occur
   1.266 +			}
   1.267 +		}
   1.268 +	aWs.Flush();
   1.269 +	TRect rect01(0,0,1,1);
   1.270 +	TPoint point00;
   1.271 +	switch(aTest)
   1.272 +		{
   1.273 +	case 1:
   1.274 +		aGc->UseFont(aFont);
   1.275 +		switch(aSubTest)
   1.276 +			{
   1.277 +		case 0:
   1.278 +			{
   1.279 +			TWsGcCmdBoxText boxText(rect01,0,CGraphicsContext::ELeft,0,0x800000,1);
   1.280 +			aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawBoxText,&boxText,sizeof(boxText));
   1.281 +			}
   1.282 +			break;
   1.283 +		case 1:
   1.284 +			{
   1.285 +			TWsGcCmdDrawText dt(point00,600);
   1.286 +			aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawText,&dt,sizeof(dt));
   1.287 +			}
   1.288 +			break;
   1.289 +		case 2:
   1.290 +			{
   1.291 +			TWsGcCmdBoxTextOptimised1 dt(rect01,0,600);
   1.292 +			aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawBoxTextOptimised1,&dt,sizeof(dt));
   1.293 +			}
   1.294 +			break;
   1.295 +		case 3:
   1.296 +			{
   1.297 +			TWsGcCmdDrawTextVertical dt(point00,600,EFalse);
   1.298 +			aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawTextVertical,&dt,sizeof(dt));
   1.299 +			}
   1.300 +			break;
   1.301 +		case 4:
   1.302 +			{
   1.303 +			TWsGcCmdBoxTextVertical dt(rect01);
   1.304 +			dt.length=600;
   1.305 +			aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawBoxTextVertical,&dt,sizeof(dt));
   1.306 +			}
   1.307 +			break;
   1.308 +		case 5:
   1.309 +			return(EWsExitReasonFinished);
   1.310 +			}
   1.311 +		break;
   1.312 +	case 2:
   1.313 +		{
   1.314 +		TInt opcode=0;
   1.315 +		switch(aSubTest)
   1.316 +			{
   1.317 +		case 0:
   1.318 +			opcode=EWsGcOpGdiBlt2;
   1.319 +			break;
   1.320 +		case 1:
   1.321 +			opcode=EWsGcOpGdiWsBlt2;
   1.322 +			break;
   1.323 +		case 2:
   1.324 +			return(EWsExitReasonFinished);
   1.325 +			}
   1.326 +		TWsGcCmdGdiBlt2 gdiBlit(point00,0xBADBAD);
   1.327 +		aWs.TestWrite(aGc->WsHandle(),opcode,&gdiBlit,sizeof(gdiBlit));
   1.328 +		if (aInRedraw)
   1.329 +			{ // Adding two bad bitmaps to redraw store fbs store causes leave as NULL handles of failed bitmaps clash
   1.330 +			gdiBlit.handle=0xBADBAD2;
   1.331 +			aWs.TestWrite(aGc->WsHandle(),opcode,&gdiBlit,sizeof(gdiBlit));
   1.332 +			}
   1.333 +		}
   1.334 +		break;
   1.335 +	case 3:
   1.336 +		{
   1.337 +		const TInt KNumBadBmpModes=3;
   1.338 +		const TInt KNumTestsPerOpcode=KNumBadBmpModes*2;
   1.339 +		enum {KPanicIndexMasked,KPanicIndexDraw,KPanicIndexAlphaBlend,KPanicIndexMax};
   1.340 +		TInt opcodeMode=aSubTest/KNumTestsPerOpcode;
   1.341 +		TInt bmpMode=aSubTest%KNumTestsPerOpcode;
   1.342 +		TInt bmp1=0xBADBAD;
   1.343 +		TInt bmp2=0xBADBAD;
   1.344 +		TInt goodBmp;
   1.345 +		TInt opcodeBlt;
   1.346 +		TInt opcodeDraw;
   1.347 +		if (bmpMode<KNumBadBmpModes)
   1.348 +			{	// These two use a CFbsBitmap
   1.349 +			CFbsBitmap* goodBitmap=new(ELeave) CFbsBitmap;
   1.350 +			goodBitmap->Create(TSize(10,10),EGray4);
   1.351 +			goodBmp=goodBitmap->Handle();
   1.352 +			opcodeBlt=EWsGcOpGdiBltMasked;
   1.353 +			opcodeDraw=EWsGcOpDrawBitmapMasked;
   1.354 +			}
   1.355 +		else
   1.356 +			{	// These two use a CWsBitmap
   1.357 +			CWsBitmap* goodBitmap=new(ELeave) CWsBitmap(aWs);
   1.358 +			goodBitmap->Create(TSize(10,10),EGray4);
   1.359 +			goodBmp=goodBitmap->WsHandle();
   1.360 +			opcodeBlt=EWsGcOpGdiWsBltMasked;
   1.361 +			opcodeDraw=EWsGcOpWsDrawBitmapMasked;
   1.362 +			}
   1.363 +		switch(bmpMode%KNumBadBmpModes)
   1.364 +			{
   1.365 +		case 0:
   1.366 +			bmp2=goodBmp;
   1.367 +			break;
   1.368 +		case 1:
   1.369 +			bmp1=goodBmp;
   1.370 +			break;
   1.371 +		case 2:	// Leave them both bad
   1.372 +			break;
   1.373 +			}
   1.374 +		switch(opcodeMode)
   1.375 +			{
   1.376 +		case KPanicIndexMasked:
   1.377 +			{
   1.378 +			TWsGcCmdBltMasked gdiBlitMasked(point00,bmp1,rect01,bmp2,EFalse);
   1.379 +			aWs.TestWrite(aGc->WsHandle(),opcodeBlt,&gdiBlitMasked,sizeof(gdiBlitMasked));
   1.380 +			}
   1.381 +			break;
   1.382 +		case KPanicIndexDraw:
   1.383 +			{
   1.384 +			TWsGcCmdDrawBitmapMasked maskedBitmap(rect01,bmp1,rect01,bmp2,EFalse);
   1.385 +			aWs.TestWrite(aGc->WsHandle(),opcodeDraw,&maskedBitmap,sizeof(maskedBitmap));
   1.386 +			}
   1.387 +			break;
   1.388 +		case KPanicIndexAlphaBlend:
   1.389 +			{
   1.390 +			TWsGcCmdAlphaBlendBitmaps alphaBlend(point00,bmp1,rect01,bmp2,point00);
   1.391 +			aWs.TestWrite(aGc->WsHandle(),EWsGcOpGdiAlphaBlendBitmaps,&alphaBlend,sizeof(alphaBlend));
   1.392 +			}
   1.393 +			break;
   1.394 +		case KPanicIndexMax:
   1.395 +			return(EWsExitReasonFinished);
   1.396 +			}
   1.397 +		}
   1.398 +		break;
   1.399 +	case 4:
   1.400 +		switch(aSubTest)
   1.401 +			{
   1.402 +		case 0:
   1.403 +			{
   1.404 +			TWsClCmdCreateBitmap createBitmap;
   1.405 +			createBitmap.handle=0xB0D;
   1.406 +			aWs.TestWrite(aWs.WsHandle(),EWsClOpCreateBitmap,&createBitmap,sizeof(createBitmap));
   1.407 +			}
   1.408 +			break;
   1.409 +		case 1:
   1.410 +			{
   1.411 +			TInt badBrush=0xBADB3054;
   1.412 +			aWs.TestWrite(aGc->WsHandle(),EWsGcOpUseBrushPattern,&badBrush,sizeof(badBrush));
   1.413 +			}
   1.414 +			break;
   1.415 +		case 2:
   1.416 +			{
   1.417 +			TWsGcCmdDrawBitmap drawBitmap(point00,0xBADBAD);
   1.418 +			aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawBitmap,&drawBitmap,sizeof(drawBitmap));
   1.419 +			}
   1.420 +			break;
   1.421 +		case 3:
   1.422 +			return(EWsExitReasonFinished);
   1.423 +			}
   1.424 +		break;
   1.425 +	case 5:
   1.426 +		// test bad opcodes
   1.427 +		{
   1.428 +		TInt opcode=0;
   1.429 +		switch(aSubTest)
   1.430 +			{
   1.431 +		case 0:
   1.432 +			opcode=9999;
   1.433 +			break;
   1.434 +		case 1:
   1.435 +			return(EWsExitReasonFinished);
   1.436 +			}
   1.437 +		aWs.TestWrite(aGc->WsHandle(),opcode,NULL,0);
   1.438 +		}
   1.439 +		break;
   1.440 +	case 6:
   1.441 +		{// Test EWsGcOpDrawPolygon with invalid parameters
   1.442 +		 // First two times has slightly more points specified than exist in the data
   1.443 +		 // Third time time has a massive number of points in the header
   1.444 +		const TInt KNumTestsPerPolyMode=3;
   1.445 +		enum TPanicPolyMode {EPanicPolyModePolygon,EPanicPolyModePolyLine,EPanicPolyModeEnd};
   1.446 +		TInt polyMode=aSubTest/KNumTestsPerPolyMode;
   1.447 +		if (polyMode==EPanicPolyModeEnd)
   1.448 +			return(EWsExitReasonFinished);
   1.449 +		TInt subMode=aSubTest%KNumTestsPerPolyMode;
   1.450 +		TInt bufPoints=0;
   1.451 +		TInt headerPoints=1;
   1.452 +		switch(subMode)
   1.453 +			{
   1.454 +		case 0:
   1.455 +			break;
   1.456 +		case 1:
   1.457 +			bufPoints=2;
   1.458 +			headerPoints=8;
   1.459 +			break;
   1.460 +		case 2:
   1.461 +			bufPoints=2;
   1.462 +			headerPoints=999999;
   1.463 +			break;
   1.464 +			}
   1.465 +		TInt bufDataLen=bufPoints*sizeof(TPoint);
   1.466 +		if (polyMode==EPanicPolyModePolyLine)
   1.467 +			bufDataLen+=sizeof(TWsGcCmdDrawPolyLine);
   1.468 +		else
   1.469 +			bufDataLen+=sizeof(TWsGcCmdDrawPolygon);
   1.470 +		TAny* bufData=User::AllocL(bufDataLen);
   1.471 +		TPoint* pointPtr;
   1.472 +		TInt opcode;
   1.473 +		if (polyMode==EPanicPolyModePolyLine)
   1.474 +			{
   1.475 +			TWsGcCmdDrawPolyLine* drawPolyline=static_cast<TWsGcCmdDrawPolyLine*>(bufData);
   1.476 +			drawPolyline->numPoints=headerPoints;
   1.477 +			drawPolyline->more=EFalse;
   1.478 +			drawPolyline->last=point00;
   1.479 +			pointPtr=reinterpret_cast<TPoint*>(drawPolyline+1);
   1.480 +			opcode=EWsGcOpDrawPolyLine;
   1.481 +			}
   1.482 +		else
   1.483 +			{
   1.484 +			TWsGcCmdDrawPolygon* drawPolygon=static_cast<TWsGcCmdDrawPolygon*>(bufData);
   1.485 +			drawPolygon->numPoints=headerPoints;
   1.486 +			drawPolygon->fillRule=CGraphicsContext::EAlternate;
   1.487 +			pointPtr=reinterpret_cast<TPoint*>(drawPolygon+1);
   1.488 +			opcode=EWsGcOpDrawPolygon;
   1.489 +			}
   1.490 +		const TPoint* endPtr=pointPtr+bufPoints;
   1.491 +		TInt pointPos=0;
   1.492 +		while(pointPtr<endPtr)
   1.493 +			*pointPtr++=TPoint(pointPos,pointPos);
   1.494 +		aWs.TestWrite(aGc->WsHandle(),opcode,bufData,bufDataLen);
   1.495 +		aWs.Flush();	// Needs flush to make sure EndRedraw() doesn't make buffer bigger and catch out buf len check
   1.496 +		}
   1.497 +		break;
   1.498 +	case 7:
   1.499 +		{
   1.500 +		// first sets the index to match the total count
   1.501 +		// second sets the index negative
   1.502 +		// fourth sends too much data
   1.503 +		TWsGcCmdStartSegmentedDrawPolygon startPoly;
   1.504 +		startPoly.totalNumPoints=8;
   1.505 +		aWs.TestWrite(aGc->WsHandle(),EWsGcOpStartSegmentedDrawPolygon,&startPoly,sizeof(startPoly));
   1.506 +		TInt bufDataLen=sizeof(TWsGcCmdSegmentedDrawPolygonData)+startPoly.totalNumPoints*sizeof(TPoint);
   1.507 +		TAny* bufData=User::AllocL(bufDataLen);
   1.508 +		TWsGcCmdSegmentedDrawPolygonData* polyData=static_cast<TWsGcCmdSegmentedDrawPolygonData*>(bufData);
   1.509 +		polyData->numPoints=1;
   1.510 +		polyData->index=0;
   1.511 +		switch(aSubTest)
   1.512 +			{
   1.513 +		case 0:
   1.514 +			polyData->index=startPoly.totalNumPoints;
   1.515 +			break;
   1.516 +		case 1:
   1.517 +			polyData->index=-123;
   1.518 +			break;
   1.519 +		case 2:
   1.520 +			polyData->numPoints=startPoly.totalNumPoints+1;
   1.521 +			break;
   1.522 +		case 3:
   1.523 +			return(EWsExitReasonFinished);
   1.524 +			}
   1.525 +		aWs.TestWrite(aGc->WsHandle(),EWsGcOpSegmentedDrawPolygonData,polyData,bufDataLen);
   1.526 +		TWsGcCmdDrawSegmentedPolygon drawit;
   1.527 +		drawit.fillRule=CGraphicsContext::EAlternate;
   1.528 +		aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawSegmentedPolygon,&drawit,sizeof(drawit));
   1.529 +		}
   1.530 +		break;
   1.531 +	case 8:
   1.532 +		{
   1.533 +		if (aSubTest==1)
   1.534 +			return(EWsExitReasonFinished);
   1.535 +		// This is a test designed to specificially test polylines still work after the previous
   1.536 +		// polyline/polygon tests. One potential defect is they leave the common redraw store gc
   1.537 +		// in a bad state still holding part of the poly data and causing a EWservPanicBadPolyData
   1.538 +		// panic.
   1.539 +		// This test is designed to make sure the drawpolyline call works ok and we reach the bad
   1.540 +		// opcode panic instead.
   1.541 +		TWsGcCmdStartSegmentedDrawPolygon startPoly;
   1.542 +		startPoly.totalNumPoints=2;
   1.543 +		aWs.TestWrite(aGc->WsHandle(),EWsGcOpStartSegmentedDrawPolygon,&startPoly,sizeof(startPoly));
   1.544 +		struct
   1.545 +			{
   1.546 +			TWsGcCmdSegmentedDrawPolygonData iPolyData;
   1.547 +			TPoint iPoints[2];
   1.548 +			} polyParams;
   1.549 +		polyParams.iPoints[0].iX=1;
   1.550 +		polyParams.iPoints[0].iY=1;
   1.551 +		polyParams.iPoints[1].iX=2;
   1.552 +		polyParams.iPoints[1].iY=2;
   1.553 +			
   1.554 +		polyParams.iPolyData.numPoints=2;
   1.555 +		polyParams.iPolyData.index=0;
   1.556 +		aWs.TestWrite(aGc->WsHandle(),EWsGcOpSegmentedDrawPolygonData,&polyParams.iPolyData,sizeof(polyParams));
   1.557 +		TWsGcCmdDrawSegmentedPolygon drawit;
   1.558 +		drawit.fillRule=CGraphicsContext::EAlternate;
   1.559 +		aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawSegmentedPolygon,&drawit,sizeof(drawit));
   1.560 +		aWs.TestWrite(aGc->WsHandle(),9999,NULL,0);
   1.561 +		}
   1.562 +		break;
   1.563 +	case 9:
   1.564 +		if (aSubTest==1)
   1.565 +			return(EWsExitReasonFinished);
   1.566 +		aGc->Activate(*aDrawWin);	// Double activate
   1.567 +		break;
   1.568 +	case 10:
   1.569 +		if (aSubTest==1)
   1.570 +			return(EWsExitReasonFinished);
   1.571 +		aGc->DrawText(_L("No font"),point00);
   1.572 +		break;
   1.573 +	case 11:
   1.574 +		if (aSubTest==1)
   1.575 +			return(EWsExitReasonFinished);
   1.576 +		aGc->SetBrushStyle(CGraphicsContext::EPatternedBrush);
   1.577 +		aGc->DrawRect(rect01);
   1.578 +		break;
   1.579 +	case 12:
   1.580 +		{
   1.581 +		if (aSubTest==1)
   1.582 +			return(EWsExitReasonFinished);
   1.583 +		aGc->UseFont(aFont);
   1.584 +		TPtrC bigAndbad(NULL,5000);	// Will go through remote descriptor fetching code
   1.585 +		aGc->DrawText(bigAndbad,point00);
   1.586 +		}
   1.587 +		break;
   1.588 +	case 13:
   1.589 +		{
   1.590 +		if (aSubTest==1)
   1.591 +			return(EWsExitReasonFinished);
   1.592 +		TInt badHandle=0xDEADBAD;
   1.593 +		aWs.TestWrite(aGc->WsHandle(),EWsGcOpUseFont,&badHandle,sizeof(badHandle));
   1.594 +		aGc->DrawText(_L("BOO!"),point00);
   1.595 +		}
   1.596 +		break;
   1.597 +		}
   1.598 +	if (aInRedraw)
   1.599 +		aRWin.EndRedraw();
   1.600 +	aWs.Finish();
   1.601 +	return(EWsExitReasonBad);
   1.602 +	}
   1.603 +
   1.604 +LOCAL_C TInt GraphicsPanicTest(TInt aInt, TAny* aPanicParams)
   1.605 +	{
   1.606 +	CTPanic::TPanicParams* panicParams=static_cast<CTPanic::TPanicParams*>(aPanicParams);
   1.607 +	/*
   1.608 +	 * Drawing to a transparent window goes via the redraw store. In this
   1.609 +	 * situation parameters do not get checked during the original processing
   1.610 +	 * of the incoming graphics commands. They are only caught later when 
   1.611 +	 * playing back from the redraw store.
   1.612 +	 */
   1.613 +	const TBool useTransWin = panicParams->iRedrawMode==EPanicRedrawModeTransRedraw;
   1.614 +	/*
   1.615 +	 * We always do redraw drawing unless we are using a BackedUpWindow.
   1.616 +	 * Redraws can affect the way graphics commands are pre-processed, 
   1.617 +	 * as with transparent windows they can also cause commands to get
   1.618 +	 * buffered in the redraw store and played back later.
   1.619 +	 */
   1.620 +	const TBool inRedraw =
   1.621 +		panicParams->iRedrawMode==EPanicRedrawModeNormalRedraw ||
   1.622 +		panicParams->iRedrawMode==EPanicRedrawModeTransRedraw ||
   1.623 +		panicParams->iRedrawMode==EPanicRedrawModeInvisRedraw;
   1.624 +	/*
   1.625 +	 * Drawing to an invisible window skips some of the code where errors
   1.626 +	 * are caught. Particularly text drawing commands that skip the actual
   1.627 +	 * drawing, but still process the update of the justification, this
   1.628 +	 * has the potential of missing parameter checks made during the actual
   1.629 +	 * drawing, but being caught out when processing the justification update.
   1.630 +	 */
   1.631 +	const TBool invisWin = panicParams->iRedrawMode==EPanicRedrawModeInvisRedraw;
   1.632 +	
   1.633 +	RWsSession ws;
   1.634 +	User::LeaveIfError(ws.Connect());
   1.635 +
   1.636 +	CWsScreenDevice* scrdev=new(ELeave) CWsScreenDevice(ws);
   1.637 +	User::LeaveIfError(scrdev->Construct(panicParams->iScreen));
   1.638 +	
   1.639 +	RWindowGroup group(ws);
   1.640 +	User::LeaveIfError(group.Construct(888));
   1.641 +	group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
   1.642 +	RDrawableWindow* drawWin;
   1.643 +	RWindow rwin(ws);
   1.644 +	RBackedUpWindow bwin(ws);
   1.645 +	TBool needsValidating=EFalse;
   1.646 +	if (useTransWin || inRedraw || invisWin)
   1.647 +		{
   1.648 +		drawWin=&rwin;
   1.649 +		needsValidating=ETrue;
   1.650 +		User::LeaveIfError(rwin.Construct(group,1));
   1.651 +		if (useTransWin)
   1.652 +			{
   1.653 +			rwin.SetTransparencyAlphaChannel();
   1.654 +			}
   1.655 +		}
   1.656 +	else
   1.657 +		{
   1.658 +		// EPanicRedrawModeBackedUpWindow case
   1.659 +		drawWin=&bwin;
   1.660 +		User::LeaveIfError(bwin.Construct(group, EGray4, 1));
   1.661 +		}
   1.662 +	const TSize testWinSize(100,100);
   1.663 +	User::LeaveIfError(drawWin->SetSizeErr(testWinSize));
   1.664 +	if (invisWin)
   1.665 +		drawWin->SetPosition(TPoint(-testWinSize.iWidth,-testWinSize.iHeight));
   1.666 +	drawWin->Activate();
   1.667 +	CWindowGc* gc;
   1.668 +	scrdev->CreateContext(gc);
   1.669 +	gc->Activate(*drawWin);
   1.670 +	CFbsFont* font;
   1.671 +	User::LeaveIfError(scrdev->GetNearestFontToDesignHeightInTwips((CFont*&)font,TFontSpec()));
   1.672 +	TInt ret=DoGraphicsPanicTest(ws,rwin,drawWin,gc,font,aInt,panicParams->iSubTest,inRedraw,needsValidating);
   1.673 +	if (ret!=EWsExitReasonFinished && invisWin)
   1.674 +		{
   1.675 +		/*
   1.676 +		 * Some functions are totally skipped on invisible windows, parameter
   1.677 +		 * errors will be harmlessly ignored in these case. To make the test
   1.678 +		 * pass we re-do the tests with the window now visible. The purpose
   1.679 +		 * of the invisible draw tests was not to check the client is always
   1.680 +		 * panicked doing illegal draws to invisible windows, but to make sure
   1.681 +		 * they had no harmful side effects.
   1.682 +		 */
   1.683 +		drawWin->SetPosition(TPoint(0,0));
   1.684 +		gc->Reset();
   1.685 +		ret=DoGraphicsPanicTest(ws,rwin,drawWin,gc,font,aInt,panicParams->iSubTest,inRedraw,needsValidating);
   1.686 +		}
   1.687 +	return(ret);
   1.688 +	}
   1.689 +LOCAL_C TInt DoMiscPanicTest(TInt aSubTest, TAny* )
   1.690 +	{
   1.691 +	const TInt KNumPanicFuncsPerMode=EWsClOpLastEnumValue;
   1.692 +	const TInt KNumPanicFuncModes=6;
   1.693 +	const TInt KNumPanicSendTests=KNumPanicFuncsPerMode*KNumPanicFuncModes;
   1.694 +	const TInt KNumRandGarbageTests=500;
   1.695 +	if (aSubTest==(KNumPanicSendTests+KNumRandGarbageTests))
   1.696 +		return(EWsExitReasonFinished);
   1.697 +	RWsSessionHacker wshacker;
   1.698 +	User::LeaveIfError(wshacker.Connect());
   1.699 +	if (aSubTest<KNumPanicSendTests)
   1.700 +		{
   1.701 +		TInt messageMode=aSubTest/KNumPanicFuncsPerMode;
   1.702 +		TInt msgFunc=aSubTest%KNumPanicFuncsPerMode;
   1.703 +		const TInt EPanicWservMessAsynchronousService=0x010000; //copy of EWservMessAsynchronousService
   1.704 +		const TInt EPanicWservMessAnimDllAsyncCommand=0x100000; //copy of EWservMessAnimDllAsyncCommand
   1.705 +		switch(messageMode%3)
   1.706 +			{
   1.707 +		case 0:
   1.708 +			if(msgFunc == EWservMessFinish) //RWsSession::Finish() doesn't panic
   1.709 +				User::Panic(KWSERV, 0); //simulate a "successful" wserv panic to skip the sub test
   1.710 +			break;
   1.711 +		case 1:
   1.712 +			msgFunc|=EPanicWservMessAsynchronousService;
   1.713 +			break;
   1.714 +		case 2:
   1.715 +			msgFunc|=EPanicWservMessAnimDllAsyncCommand;
   1.716 +			break;
   1.717 +			}
   1.718 +		TInt sendItErr=KErrNone;
   1.719 +		if (messageMode<3)
   1.720 +			{
   1.721 +			if (msgFunc&EPanicWservMessAsynchronousService)
   1.722 +				{
   1.723 +				wshacker.PanicItSend(msgFunc);
   1.724 +				// Async request, probably won't panic, we just want to make sure nothing crashes 'orribly
   1.725 +				// So do it again without the async bit and let normal handling cause the panic
   1.726 +				msgFunc&=~EPanicWservMessAsynchronousService;
   1.727 +				}
   1.728 +			sendItErr=wshacker.PanicItSendReceive(msgFunc);
   1.729 +			}
   1.730 +		else
   1.731 +			{
   1.732 +			TPtrC8 badDesc(reinterpret_cast<const TUint8*>(0xDEAD),100);
   1.733 +			TIpcArgs ipcArgs;
   1.734 +			ipcArgs.Set(0,&badDesc);
   1.735 +			if (msgFunc&EPanicWservMessAsynchronousService)
   1.736 +				{
   1.737 +				sendItErr=wshacker.PanicItSend(msgFunc,ipcArgs);
   1.738 +				msgFunc&=~EPanicWservMessAsynchronousService;
   1.739 +				}
   1.740 +			sendItErr=wshacker.PanicItSendReceive(msgFunc,ipcArgs);
   1.741 +			}
   1.742 +		if (sendItErr==KErrNotSupported)
   1.743 +			wshacker.PanicItSendReceive(EWservMessCommandBuffer); // Should always panic
   1.744 +		}
   1.745 +	else
   1.746 +		{
   1.747 +	// Fill Wserv buffer with random garbage
   1.748 +		RWsBufferHacker* hacker=reinterpret_cast<RWsBufferHacker*>(wshacker.WsBuffer());
   1.749 +		TInt64 seed=aSubTest;
   1.750 +		TInt retries=0;
   1.751 +		const TInt KMaxRandPanicRetrys=1000;
   1.752 +		do
   1.753 +			{
   1.754 +			const TInt maxLen=hacker->iBuf.MaxLength()-1;
   1.755 +			TInt writeLen=1+Math::Rand(seed)%maxLen;
   1.756 +			while(writeLen--)
   1.757 +				{
   1.758 +				TUint8 randData=static_cast<TUint8>(Math::Rand(seed));
   1.759 +				hacker->iBuf.Append(randData);
   1.760 +				}
   1.761 +			wshacker.Flush();
   1.762 +			retries++;
   1.763 +			} while(retries<KMaxRandPanicRetrys);
   1.764 +		}
   1.765 +	return(EWsExitReasonBad);
   1.766 +	}
   1.767 +
   1.768 +LOCAL_C TInt DoCMPanicTest(TInt aInt, TAny *aScreenNumber)
   1.769 +	{
   1.770 +	RWsSession ws;
   1.771 +	User::LeaveIfError(ws.Connect());
   1.772 +	// use correct screen
   1.773 +	//
   1.774 +	CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
   1.775 +	User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
   1.776 +
   1.777 +	switch(aInt)
   1.778 +		{
   1.779 +		case 1:
   1.780 +			ws.ComputeMode((RWsSession::TComputeMode)543);
   1.781 +			break;
   1.782 +		}
   1.783 +	ws.Flush();
   1.784 +	return(EWsExitReasonBad);
   1.785 +	}
   1.786 +
   1.787 +#if defined(_DEBUG) && defined(__WINS__)
   1.788 +LOCAL_C TInt DoCKPanicTest(TInt aInt, TAny *aScreenNumber)
   1.789 +	{
   1.790 +	RWsSession ws;
   1.791 +	User::LeaveIfError(ws.Connect());
   1.792 +	// use correct screen
   1.793 +	//
   1.794 +	CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
   1.795 +	User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
   1.796 +
   1.797 +	RWindowGroup group(ws);
   1.798 +	group.Construct(888);
   1.799 +	group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
   1.800 +	switch(aInt)
   1.801 +		{
   1.802 +		case 1:
   1.803 +			group.CancelCaptureKey(345);
   1.804 +			break;
   1.805 +		}
   1.806 +	ws.Flush();
   1.807 +	return(EWsExitReasonBad);
   1.808 +	}
   1.809 +#endif
   1.810 +
   1.811 +LOCAL_C TInt DoEventPanicTest(TInt aInt, TAny *aScreenNumber)
   1.812 +	{
   1.813 +	RWsSession ws;
   1.814 +	User::LeaveIfError(ws.Connect());
   1.815 +	// use correct screen
   1.816 +	//
   1.817 +	CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
   1.818 +	User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
   1.819 +
   1.820 +
   1.821 +	switch(aInt)
   1.822 +		{
   1.823 +		case 1:
   1.824 +			TRequestStatus stat;
   1.825 +			ws.EventReady(&stat);
   1.826 +			ws.EventReady(&stat);
   1.827 +			User::After(15000000);		//15secs
   1.828 +			break;
   1.829 +		}
   1.830 +	ws.Flush();
   1.831 +	return(EWsExitReasonBad);
   1.832 +	}
   1.833 +
   1.834 +LOCAL_C TInt DoTBufPtrTests(TInt aInt, TAny *aScreenNumber)
   1.835 +	{
   1.836 +	RWsSession ws;
   1.837 +	User::LeaveIfError(ws.Connect());
   1.838 +	// use correct screen
   1.839 +	//
   1.840 +	CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
   1.841 +	User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
   1.842 +	
   1.843 +	switch(aInt)
   1.844 +		{
   1.845 +		case 1:
   1.846 +			{
   1.847 +			TWsClCmdLoadAnimDll dt;
   1.848 +			dt.length=600;
   1.849 +			ws.TestWrite(ws.WsHandle(),EWsClOpCreateAnimDll,&dt,sizeof(dt));
   1.850 +			}
   1.851 +			break;
   1.852 +		case 2:
   1.853 +			{
   1.854 +			TInt len=600;
   1.855 +			ws.TestWrite(ws.WsHandle(),EWsClOpLogMessage,&len,sizeof(len));
   1.856 +			}
   1.857 +			break;
   1.858 +		case 3:
   1.859 +			{
   1.860 +			RWindowGroup group(ws);
   1.861 +			group.Construct(888);
   1.862 +			group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
   1.863 +			TWsWinCmdSetName dt;
   1.864 +			dt.length=600;
   1.865 +			dt.ptr=NULL;
   1.866 +			ws.TestWrite(group.WsHandle(),EWsWinOpSetName,&dt,sizeof(dt));
   1.867 +			}
   1.868 +			break;
   1.869 +		case 4:
   1.870 +			{
   1.871 +			RWindowGroup group(ws);
   1.872 +			group.Construct(888);
   1.873 +			group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
   1.874 +			TWsWinCmdSetName dt;
   1.875 +			dt.length=600;
   1.876 +			dt.ptr=(TDesC *)0x1234;
   1.877 +			ws.TestWrite(group.WsHandle(),EWsWinOpSetName,&dt,sizeof(dt));
   1.878 +			}
   1.879 +			break;
   1.880 +		}
   1.881 +	ws.Flush();
   1.882 +	return(EWsExitReasonBad);
   1.883 +	}
   1.884 +
   1.885 +#if defined(_DEBUG) && defined(__WINS__)		
   1.886 +LOCAL_C TInt DoMismatchedCancelCaptureTest(TInt aInt, TAny *aScreenNumber)
   1.887 +	{
   1.888 +	RWsSession ws;
   1.889 +	User::LeaveIfError(ws.Connect());
   1.890 +	// use correct screen		
   1.891 +	CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
   1.892 +	User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
   1.893 +	RWindowGroup group(ws);
   1.894 +	User::LeaveIfError(group.Construct(888));
   1.895 +	group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
   1.896 +	RWindow win(ws);
   1.897 +	User::LeaveIfError(win.Construct(group, 1));
   1.898 +	win.Activate();
   1.899 +	TInt capture;
   1.900 +	
   1.901 +	switch (aInt)
   1.902 +		{
   1.903 +		case CTPanic::ECancelCaptureKey:
   1.904 +			// Create a capture that is not matched to CancelCaptureKey()
   1.905 +			capture = group.CaptureLongKey(' ','a',0,0,2,ELongCaptureNormal);
   1.906 +			ws.Flush();
   1.907 +			group.CancelCaptureKey(capture);
   1.908 +			break;
   1.909 +		case CTPanic::ECancelCaptureKeyUpAndDowns:
   1.910 +			// Create a capture that is not matched to CancelCaptureKeyUpAndDowns()
   1.911 +			capture = group.CaptureKey('A',0,0);
   1.912 +			ws.Flush();
   1.913 +			group.CancelCaptureKeyUpAndDowns(capture);
   1.914 +			break;
   1.915 +		case CTPanic::ECancelCaptureLongKey:
   1.916 +			// Create a capture that is not matched to CancelCaptureLongKey()
   1.917 +			capture = group.CaptureKeyUpAndDowns(EStdKeySpace,0,0);
   1.918 +			ws.Flush();
   1.919 +			group.CancelCaptureLongKey(capture);
   1.920 +			break;
   1.921 +		}
   1.922 +	
   1.923 +	ws.Flush();
   1.924 +	return(EWsExitReasonBad);
   1.925 +	}
   1.926 +#endif // _DEBUG
   1.927 +
   1.928 +class ROverrideProtectionInRSessionBase : public RWsSession
   1.929 +	{
   1.930 +public:
   1.931 +	inline TInt SendReceive(TInt aFunction,TAny *aPtr) const {return(RSessionBase::SendReceive(aFunction,TIpcArgs(aPtr)));};
   1.932 +	};
   1.933 +
   1.934 +LOCAL_C TInt DoMultiInitPanicTest(TInt , TAny *aScreenNumber)
   1.935 +	{
   1.936 +	ROverrideProtectionInRSessionBase ws;
   1.937 +	User::LeaveIfError(ws.Connect());
   1.938 +	
   1.939 +	// use correct screen
   1.940 +	//
   1.941 +	CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
   1.942 +	User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
   1.943 +	
   1.944 +	RWindowGroup group(ws);
   1.945 +	group.Construct(888);
   1.946 +	group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
   1.947 +	ws.Flush();
   1.948 +	ws.SendReceive(EWservMessInit,NULL);
   1.949 +	
   1.950 +	return(EWsExitReasonBad);
   1.951 +	}
   1.952 +	
   1.953 +LOCAL_C TInt DoSpritePanicTestL(TInt aTest, TAny *aScreenNumber)
   1.954 +	{
   1.955 +	RWsSession ws;
   1.956 +	User::LeaveIfError(ws.Connect());
   1.957 +	// use correct screen
   1.958 +	//
   1.959 +	CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
   1.960 +	User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
   1.961 +	
   1.962 +	RWindowGroup group(ws);
   1.963 +	User::LeaveIfError(group.Construct(889));
   1.964 +	group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
   1.965 +	RBlankWindow win(ws);
   1.966 +	User::LeaveIfError(win.Construct(group,898));
   1.967 +	RWsPointerCursor* cursor=(RWsPointerCursor*)&win;
   1.968 +	switch (aTest)
   1.969 +		{
   1.970 +	case 1:
   1.971 +		win.SetCustomPointerCursor(*cursor);
   1.972 +		break;
   1.973 +	case 2:
   1.974 +		ws.SetSystemPointerCursor(*cursor,0);
   1.975 +		break;
   1.976 +	case 3:
   1.977 +		{
   1.978 +		RAnimDll animDll=RAnimDll(ws);
   1.979 +		User::LeaveIfError(animDll.Load(KAnimDLLName));
   1.980 +		RTestAnim anim=RTestAnim(animDll);
   1.981 +		RWsSprite* sprite=(RWsSprite*)&win;
   1.982 +		User::LeaveIfError(anim.Construct(*sprite,EAnimTypeSprite,TPtrC8()));
   1.983 +		}
   1.984 +		break;
   1.985 +	case 4:
   1.986 +		{
   1.987 +		CFbsBitmap* bitmap=new(ELeave) CFbsBitmap;
   1.988 +		CleanupStack::PushL(bitmap);
   1.989 +		User::LeaveIfError(bitmap->Load(TEST_BITMAP_NAME,0));
   1.990 +		win.SetExtent(TPoint(),TSize(150,250));
   1.991 +		win.SetVisible(ETrue);
   1.992 +		win.Activate();
   1.993 +		RWsSprite sprite(ws);
   1.994 +		User::LeaveIfError(sprite.Construct(win,TPoint(),0));
   1.995 +		TSpriteMember member;
   1.996 +		member.iMaskBitmap=NULL;
   1.997 +		member.iInvertMask=EFalse;
   1.998 +		member.iDrawMode=CGraphicsContext::EDrawModePEN;
   1.999 +		member.iOffset=TPoint();
  1.1000 +		member.iInterval=TTimeIntervalMicroSeconds32(0);
  1.1001 +		member.iBitmap=bitmap;
  1.1002 +		User::LeaveIfError(sprite.AppendMember(member));
  1.1003 +		User::LeaveIfError(sprite.Activate());
  1.1004 +		User::After(1000000); //1 sec
  1.1005 +		User::LeaveIfError(bitmap->Resize(bitmap->SizeInPixels() + TSize(200,200)));
  1.1006 +		User::After(1000000); //1 sec
  1.1007 +		CleanupStack::Pop(bitmap);
  1.1008 +		break;
  1.1009 +		}
  1.1010 +		}
  1.1011 +	ws.Flush();
  1.1012 +	return(EWsExitReasonBad);
  1.1013 +	}
  1.1014 +
  1.1015 +#ifdef __WINS__
  1.1016 +LOCAL_C TInt DoDoubleConstructionTestL(TInt aTest, TAny *aScreenNumber)
  1.1017 +	{		
  1.1018 +	RWsSession ws;
  1.1019 +	User::LeaveIfError(ws.Connect());
  1.1020 +	
  1.1021 +	// use correct screen
  1.1022 +	//
  1.1023 +	CWsScreenDevice* screen = new(ELeave) CWsScreenDevice(ws);
  1.1024 +	User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
  1.1025 +	
  1.1026 +	RWindowGroup group(ws);
  1.1027 +	User::LeaveIfError(group.Construct(890, EFalse));
  1.1028 +	RBlankWindow bwin(ws);
  1.1029 +	User::LeaveIfError(bwin.Construct(group,900));
  1.1030 +	
  1.1031 +	switch (aTest)
  1.1032 +		{
  1.1033 +	case 1:
  1.1034 +		{
  1.1035 +		RWsSprite sprite = RWsSprite(ws);
  1.1036 +		User::LeaveIfError(sprite.Construct(bwin,TPoint(),0));
  1.1037 +		sprite.Construct(bwin,TPoint(),0); //should panic
  1.1038 +		sprite.Close();
  1.1039 +		}
  1.1040 +		break;
  1.1041 +	case 2:
  1.1042 +		{
  1.1043 +		RWsPointerCursor cursor(ws);
  1.1044 +		User::LeaveIfError(cursor.Construct(0));
  1.1045 +		cursor.Construct(0); //should panic
  1.1046 +		cursor.Close();
  1.1047 +		}
  1.1048 +		break;
  1.1049 +	case 3:
  1.1050 +		{
  1.1051 +		RSoundPlugIn click(ws);
  1.1052 +		User::LeaveIfError(click.Construct());
  1.1053 +		click.Construct(); //should panic
  1.1054 +		click.Close();
  1.1055 +		}
  1.1056 +		break;
  1.1057 +	case 4:
  1.1058 +		{
  1.1059 +		RWindowGroup windowgroup(ws);
  1.1060 +		User::LeaveIfError(windowgroup.Construct(901));
  1.1061 +		windowgroup.Construct(902); //should panic
  1.1062 +		windowgroup.Close();
  1.1063 +		}
  1.1064 +		break;
  1.1065 +	case 5:
  1.1066 +		{
  1.1067 +		RWindow win(ws);
  1.1068 +		User::LeaveIfError(win.Construct(group,902));
  1.1069 +		win.Construct(group,903); //should panic
  1.1070 +		win.Close(); 
  1.1071 +		}
  1.1072 +		break;
  1.1073 +	case 6:
  1.1074 +		{
  1.1075 +		RBlankWindow win(ws);
  1.1076 +		User::LeaveIfError(win.Construct(group,902));
  1.1077 +		win.Construct(group,903); //should panic
  1.1078 +		win.Close(); 
  1.1079 +		}
  1.1080 +		break;
  1.1081 +	case 7:
  1.1082 +		{
  1.1083 +		RBackedUpWindow win(ws);
  1.1084 +		User::LeaveIfError(win.Construct(group,EGray4,902));
  1.1085 +		win.Construct(group,EGray4,903); //should panic
  1.1086 +		win.Close(); 
  1.1087 +		}
  1.1088 +		break;
  1.1089 +	case 8:
  1.1090 +		{
  1.1091 +		RAnimDll animDll=RAnimDll(ws);
  1.1092 +		User::LeaveIfError(animDll.Load(KAnimDLLName));
  1.1093 +		animDll.Load(KAnimDLLName); //should panic
  1.1094 +		animDll.Close();
  1.1095 +		}
  1.1096 +		break;
  1.1097 +	case 9:
  1.1098 +		{
  1.1099 +		CWindowGc *gc = new(ELeave) CWindowGc(screen);
  1.1100 +		User::LeaveIfError(gc->Construct());
  1.1101 +		gc->Construct(); //should panic
  1.1102 +		delete gc;
  1.1103 +		}
  1.1104 +		break;
  1.1105 +	case 10:
  1.1106 +		{
  1.1107 +		CWsScreenDevice* screendevice = new (ELeave) CWsScreenDevice(ws);
  1.1108 +		User::LeaveIfError(screendevice->Construct());
  1.1109 +		screendevice->Construct(); //should panic
  1.1110 +		delete screendevice;
  1.1111 +		}
  1.1112 +		break;
  1.1113 +	default:
  1.1114 +		break;
  1.1115 +		}
  1.1116 +	ws.Flush();
  1.1117 +	return(EWsExitReasonBad);
  1.1118 +	}
  1.1119 +#endif
  1.1120 +
  1.1121 +/** Checks that activating a sprite without members will panic.
  1.1122 +*/
  1.1123 +LOCAL_C TInt DoTestSpriteActivatePanicL(TInt aTest, TAny *aScreenNumber)
  1.1124 +	{
  1.1125 +	RWsSession ws;
  1.1126 +	User::LeaveIfError(ws.Connect());
  1.1127 +	CWsScreenDevice* screen = new(ELeave) CWsScreenDevice(ws);
  1.1128 +	User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
  1.1129 +	RWindowGroup group(ws);
  1.1130 +	User::LeaveIfError(group.Construct(891, EFalse, screen));
  1.1131 +	RBlankWindow bwin(ws);
  1.1132 +	User::LeaveIfError(bwin.Construct(group,892));
  1.1133 +	
  1.1134 +	switch(aTest)
  1.1135 +		{
  1.1136 +	case 1:
  1.1137 +		{
  1.1138 +		RWsSprite sprite = RWsSprite(ws);
  1.1139 +		User::LeaveIfError(sprite.Construct(group,TPoint(),0));
  1.1140 +		sprite.Activate();	//should panic here
  1.1141 +		sprite.Close();
  1.1142 +		}
  1.1143 +		break;
  1.1144 +	case 2:
  1.1145 +		{
  1.1146 +		RWsSprite sprite = RWsSprite(ws);
  1.1147 +		User::LeaveIfError(sprite.Construct(bwin,TPoint(),0));
  1.1148 +		sprite.Activate();	//should panic here
  1.1149 +		sprite.Close();
  1.1150 +		}
  1.1151 +		break;
  1.1152 +		}
  1.1153 +	return(EWsExitReasonBad);
  1.1154 +	}
  1.1155 +
  1.1156 +/** Checks that activating a RWindow before calling EnableAdvancedPointers will panic the client.
  1.1157 +*/
  1.1158 +LOCAL_C TInt DoTestAdvancePointerActivatePanicL(TInt /*aTest*/,TAny *aScreenNumber)
  1.1159 +    {
  1.1160 +    RWsSession ws;
  1.1161 +    User::LeaveIfError(ws.Connect());
  1.1162 +
  1.1163 +    CWsScreenDevice *scrdev=new(ELeave) CWsScreenDevice(ws);
  1.1164 +    User::LeaveIfError(scrdev->Construct((TInt)aScreenNumber));
  1.1165 +    
  1.1166 +    RWindowGroup group(ws);
  1.1167 +    User::LeaveIfError(group.Construct(888));
  1.1168 +    RWindow win(ws);
  1.1169 +    User::LeaveIfError(win.Construct(group, 1));
  1.1170 +    win.Activate();
  1.1171 +    win.EnableAdvancedPointers(); // This will panic
  1.1172 +    ws.Flush();
  1.1173 +    return(EWsExitReasonBad);
  1.1174 +    }
  1.1175 +
  1.1176 +
  1.1177 +LOCAL_C TInt DoMoveToGroupPanicTestL(TInt aTest, TAny *aScreenNumber)
  1.1178 +	{
  1.1179 +	RWsSession ws;
  1.1180 +	User::LeaveIfError(ws.Connect());
  1.1181 +	// use correct screen
  1.1182 +	//
  1.1183 +	CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
  1.1184 +	User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
  1.1185 +	
  1.1186 +	RWindowGroup group(ws);
  1.1187 +	User::LeaveIfError(group.Construct(887));
  1.1188 +	group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
  1.1189 +	TInt id=group.Identifier();
  1.1190 +	switch (aTest)
  1.1191 +		{
  1.1192 +	case 1:
  1.1193 +		{
  1.1194 +		RWindowTreeNode* win=&group;
  1.1195 +		((RWindowBase*)win)->MoveToGroup(id);
  1.1196 +		}
  1.1197 +		break;
  1.1198 +	case 2:
  1.1199 +		{
  1.1200 +		RBlankWindow win1(ws);
  1.1201 +		User::LeaveIfError(win1.Construct(group,878));
  1.1202 +		RBlankWindow win2(ws);
  1.1203 +		User::LeaveIfError(win2.Construct(win1,788));
  1.1204 +		win2.MoveToGroup(id);
  1.1205 +		}
  1.1206 +		break;
  1.1207 +		}
  1.1208 +	ws.Flush();
  1.1209 +	return(EWsExitReasonBad);
  1.1210 +	}
  1.1211 +
  1.1212 +LOCAL_C TInt DoGetEventPanicTestL(TInt aTest, TAny *aScreenNumber)
  1.1213 +	{
  1.1214 +	RWsSession ws;
  1.1215 +	User::LeaveIfError(ws.Connect());
  1.1216 +	switch(aTest)
  1.1217 +		{
  1.1218 +	case 1:
  1.1219 +		{
  1.1220 +		TPckgBuf<TWsEvent> event;
  1.1221 +		ws.TestWrite(ws.WsHandle(),EWsClOpGetEvent,&event,0);
  1.1222 +		}
  1.1223 +		break;
  1.1224 +	case 2:
  1.1225 +		{
  1.1226 +		CWsScreenDevice* screen=new(ELeave) CWsScreenDevice(ws);
  1.1227 +		User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
  1.1228 +		RWindowGroup group(ws);
  1.1229 +		User::LeaveIfError(group.Construct(555));	// trigger a focus changed event
  1.1230 +		TRequestStatus stat;
  1.1231 +		ws.EventReady(&stat);
  1.1232 +		User::WaitForRequest(stat);
  1.1233 +		TPtrC8 badDesc(reinterpret_cast<const TUint8*>(0xDEAD),100);
  1.1234 +		ws.TestWrite(ws.WsHandle(),EWsClOpGetEvent,&badDesc,0);
  1.1235 +		}
  1.1236 +		break;
  1.1237 +		}
  1.1238 +	ws.Flush();
  1.1239 +	return(EWsExitReasonBad);
  1.1240 +	}
  1.1241 +
  1.1242 +LOCAL_C TInt DoWinHandlePanicTestL(TInt aTest, TAny *)
  1.1243 +	{
  1.1244 +	RWsSession ws;
  1.1245 +	User::LeaveIfError(ws.Connect());
  1.1246 +	RWindowGroup group1(ws);
  1.1247 +	RWindowGroup group2(ws);
  1.1248 +	RWindow win1(ws);
  1.1249 +	RWindow win2(ws);
  1.1250 +	switch(aTest)
  1.1251 +		{
  1.1252 +	case 1:
  1.1253 +		User::LeaveIfError(group1.Construct(888));
  1.1254 +		User::LeaveIfError(group2.Construct(888));
  1.1255 +		break;
  1.1256 +	case 2:
  1.1257 +		User::LeaveIfError(group1.Construct(777));
  1.1258 +		User::LeaveIfError(win1.Construct(group1,888));
  1.1259 +		User::LeaveIfError(win2.Construct(group1,888));
  1.1260 +		break;
  1.1261 +	case 3:
  1.1262 +		User::LeaveIfError(group1.Construct(777));
  1.1263 +		User::LeaveIfError(win1.Construct(group1,777));
  1.1264 +		break;
  1.1265 +	case 4:
  1.1266 +		User::LeaveIfError(group1.Construct(777));
  1.1267 +		User::LeaveIfError(win1.Construct(group1,0));
  1.1268 +		break;
  1.1269 +		}
  1.1270 +	ws.Flush();
  1.1271 +	return(EWsExitReasonBad);
  1.1272 +	}
  1.1273 +
  1.1274 +#ifdef __WINS__
  1.1275 +LOCAL_C TInt DoDeleteScreenPanicTestL(TInt aTest, TAny *aScreenNumber)
  1.1276 +/**
  1.1277 + * Test examples of use of the 'screen device deleted' panic for group windows.
  1.1278 + * This is issued to panic the client, if they make API calls to RWindowGroup after having deleted
  1.1279 + * the CWsScreenDevice with which that window group is associated.
  1.1280 + */
  1.1281 +	{
  1.1282 +	RWsSession ws;
  1.1283 +	User::LeaveIfError(ws.Connect());
  1.1284 +	// point to correct screen
  1.1285 +	CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
  1.1286 +	User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
  1.1287 +	
  1.1288 +	RWindowGroup group(ws);
  1.1289 +	User::LeaveIfError(group.Construct(888));
  1.1290 +	group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
  1.1291 +	switch(aTest)
  1.1292 +		{
  1.1293 +		// Test 1: deleting screen then modifying screen change events is illegal
  1.1294 +		case 1:
  1.1295 +			{
  1.1296 +			delete screen, screen=NULL;
  1.1297 +			group.EnableScreenChangeEvents();
  1.1298 +			break;
  1.1299 +			}
  1.1300 +		// Test 2: deleting screen then setting window group name is illegal
  1.1301 +		case 2:
  1.1302 +			{
  1.1303 +			delete screen, screen=NULL;
  1.1304 +			_LIT(KPanicTest, "PanicTest");
  1.1305 +			group.SetName(KPanicTest);
  1.1306 +			break;
  1.1307 +			}
  1.1308 +		}
  1.1309 +	ws.Flush();
  1.1310 +	return(EWsExitReasonBad);
  1.1311 +	}
  1.1312 +#endif
  1.1313 +
  1.1314 +LOCAL_C TInt DoUnInitPanicTest(TInt , TAny *)
  1.1315 +	{
  1.1316 +	// Creating a client session outside the test harness for panicking
  1.1317 +	//  before initialisation as the test harness initialises the one it creates.
  1.1318 +	TVersion version(0,0,0);
  1.1319 +	_LIT(KServerName, "!Windowserver");
  1.1320 +	
  1.1321 +	RUnInitalisedConnect myUnInit;
  1.1322 +
  1.1323 +	User::LeaveIfError(myUnInit.Connect(KServerName(), version));
  1.1324 +	myUnInit.Send(EWservMessCommandBuffer);
  1.1325 +	
  1.1326 +	return(EWsExitReasonBad);
  1.1327 +	}
  1.1328 +
  1.1329 +void CTPanic::TestScreenDevicePanicsL()
  1.1330 +	{
  1.1331 +	TEST(iTest->TestWsPanicL(&DoScreenDevicePanicTest,EWservPanicBitmap,1,(TAny*)iTest->iScreenNumber));
  1.1332 +	
  1.1333 +	TEST(iTest->TestWsPanicL(&DoScreenDevicePanicTest,EWservPanicBitmap,2,(TAny*)iTest->iScreenNumber));
  1.1334 +	}
  1.1335 +
  1.1336 +void CTPanic::TestMiscPanicsL()
  1.1337 +	{
  1.1338 +	TBool finished=EFalse;
  1.1339 +	TInt index=0;
  1.1340 +	while(!finished)
  1.1341 +		{
  1.1342 +		const TBool result = iTest->TestWsPanicL(&DoMiscPanicTest, EWservNoPanic, index, NULL, &finished);
  1.1343 +		if(!result)
  1.1344 +			{
  1.1345 +			INFO_PRINTF2(_L("TestMiscPanicsL %d failed"), index);
  1.1346 +			TEST(result);
  1.1347 +			}
  1.1348 +		index++;
  1.1349 +		}
  1.1350 +	}
  1.1351 +
  1.1352 +void CTPanic::LogHeapInfo()
  1.1353 +	{
  1.1354 +	_LIT(KInfoHeapSummary," WsHeap - Count=%d,Total=%d,Free=%d,Max free=%d");
  1.1355 +	TPckgBuf<TWsDebugHeapInfo> heapInfo;
  1.1356 +	TheClient->iWs.DebugInfo(EWsDebugInfoHeap,heapInfo);
  1.1357 +	TBuf<256> infoBuf;
  1.1358 +	infoBuf.Format(KInfoHeapSummary,heapInfo().iCount,heapInfo().iTotal,heapInfo().iAvailable,heapInfo().iLargestAvailable);
  1.1359 +	INFO_PRINTF1(infoBuf);
  1.1360 +	}
  1.1361 +
  1.1362 +void CTPanic::TestGraphicsPanicsL(TClientPanic aExitReason, TInt aIndex, CTPanic::TPanicParams* aPanicParams)
  1.1363 +	{
  1.1364 +	TBool finished=EFalse;
  1.1365 +	aPanicParams->iSubTest=0;
  1.1366 +
  1.1367 +	// uncomment to show which test is being run
  1.1368 +	INFO_PRINTF3(_L("GraphicsPanicTest %d, mode=%d"),aIndex,aPanicParams->iRedrawMode);
  1.1369 +    RDebug::Print(_L("GraphicsPanicTest %d, mode=%d"),aIndex,aPanicParams->iRedrawMode);
  1.1370 +	do
  1.1371 +		{
  1.1372 +		// uncomment for detailed view of which sub-test failed
  1.1373 +		LogHeapInfo();
  1.1374 +		INFO_PRINTF4(_L("GraphicsPanicTest %d/%d, mode=%d"),aIndex,aPanicParams->iSubTest,aPanicParams->iRedrawMode);
  1.1375 +		RDebug::Print(_L("GraphicsPanicTest %d/%d, mode=%d"),aIndex,aPanicParams->iSubTest,aPanicParams->iRedrawMode);
  1.1376 +		TEST(iTest->TestWsPanicL(&GraphicsPanicTest,aExitReason,aIndex,aPanicParams,&finished));
  1.1377 +		aPanicParams->iSubTest++;
  1.1378 +		} while(!finished);
  1.1379 +	iTest->CloseAllPanicWindows();
  1.1380 +	}
  1.1381 +
  1.1382 +void CTPanic::TestGraphicsPanicsL(TPanicRedrawMode aRedrawMode)
  1.1383 +	{
  1.1384 +	CTPanic::TPanicParams pp;
  1.1385 +	pp.iScreen=iTest->iScreenNumber;
  1.1386 +	pp.iRedrawMode=aRedrawMode;
  1.1387 +	static TClientPanic expectedPanics[]=
  1.1388 +		{
  1.1389 +		EWservPanicBufferPtr,
  1.1390 +		EWservPanicBitmap,
  1.1391 +		EWservPanicBitmap,
  1.1392 +		EWservPanicBitmap,
  1.1393 +		EWservPanicOpcode,
  1.1394 +		EWservPanicBadPolyData,
  1.1395 +		EWservPanicBadPolyData,
  1.1396 +		EWservPanicOpcode,
  1.1397 +		EWservPanicGcActive,
  1.1398 +		EWservPanicNoFont,
  1.1399 +		EWservPanicNoBrush,
  1.1400 +		EWservPanicDescriptor,
  1.1401 +		EWservPanicFont,
  1.1402 +		EWservNoPanic,	// Marks the end of the list
  1.1403 +		};
  1.1404 +	TInt panicIndex=0;
  1.1405 +	TClientPanic expectedPanic;
  1.1406 +	while((expectedPanic=expectedPanics[panicIndex++])!=EWservNoPanic)
  1.1407 +		{
  1.1408 +		TestGraphicsPanicsL(expectedPanic,panicIndex,&pp);
  1.1409 +		}
  1.1410 +	}
  1.1411 +
  1.1412 +void CTPanic::TestGraphicsPanicsL()
  1.1413 +	{
  1.1414 +	TestGraphicsPanicsL(EPanicRedrawModeBackedUpWindow);
  1.1415 +	TestGraphicsPanicsL(EPanicRedrawModeNormalRedraw);
  1.1416 +	if (TransparencySupportedL()==KErrNone)
  1.1417 +		{
  1.1418 +		TestGraphicsPanicsL(EPanicRedrawModeTransRedraw);
  1.1419 +		}
  1.1420 +	TestGraphicsPanicsL(EPanicRedrawModeInvisRedraw);
  1.1421 +	}
  1.1422 +
  1.1423 +void CTPanic::TestDeletedParentPanicsL()
  1.1424 +	{
  1.1425 +	TEST(iTest->TestWsPanicL(&DoDeletedParentTest,EWservPanicParentDeleted,1,(TAny*)iTest->iScreenNumber));
  1.1426 +	}
  1.1427 +
  1.1428 +void CTPanic::TestHandleReUseL()
  1.1429 +	{
  1.1430 +	for (TInt ii=2;ii<6;++ii)
  1.1431 +		{
  1.1432 +		TEST(iTest->TestWsPanicL(&DoHandleReUse,EWservPanicHandle,ii,(TAny*)iTest->iScreenNumber));
  1.1433 +		}
  1.1434 +	}
  1.1435 +
  1.1436 +void CTPanic::TestComputeModePanicsL()
  1.1437 +	{
  1.1438 +	TEST(iTest->TestWsPanicL(&DoCMPanicTest,EWservPanicSetComputeMode,1,(TAny*)iTest->iScreenNumber));
  1.1439 +	}
  1.1440 +
  1.1441 +void CTPanic::TestCaptureKeyPanicsL()
  1.1442 +	{
  1.1443 +// Run this test in debug on emulator only.
  1.1444 +// On a debug ROM the release version of the wserv.exe is included so the test can't be run as no panic happens. 
  1.1445 +#if defined(_DEBUG) && defined(__WINS__)
  1.1446 +	TEST(iTest->TestWsPanicL(&DoCKPanicTest,EWservPanicDestroy,1,(TAny*)iTest->iScreenNumber));
  1.1447 +#endif
  1.1448 +	}
  1.1449 +
  1.1450 +void CTPanic::TestEventPanicsL()
  1.1451 +	{
  1.1452 +	TEST(iTest->TestWsPanicL(&DoEventPanicTest,EWservPanicReadOutstanding,1,(TAny*)iTest->iScreenNumber));
  1.1453 +	}
  1.1454 +
  1.1455 +void CTPanic::TestTPtrPanicsL()
  1.1456 +	{
  1.1457 +	TEST(iTest->TestWsPanicL(&DoTBufPtrTests,EWservPanicBufferPtr,1,(TAny*)iTest->iScreenNumber));
  1.1458 +	}
  1.1459 +
  1.1460 +void CTPanic::TestOpcodePanicsL()
  1.1461 +	{
  1.1462 +	TInt param=1;
  1.1463 +	TBool finishTest = EFalse;
  1.1464 +	while(!finishTest)
  1.1465 +		{
  1.1466 +		TEST(iTest->TestWsPanicL(&DoOpcodeTests,EWservPanicOpcode,param,(TAny*)iTest->iScreenNumber,&finishTest));
  1.1467 +		param++;
  1.1468 +		}
  1.1469 +	}
  1.1470 +
  1.1471 +void CTPanic::TestMultiInitPanicL()
  1.1472 +	{
  1.1473 +	TEST(iTest->TestWsPanicL(&DoMultiInitPanicTest,EWservPanicReInitialise,0,(TAny*)iTest->iScreenNumber));
  1.1474 +	}
  1.1475 +
  1.1476 +/**
  1.1477 +@SYMTestCaseID		GRAPHICS-WSERV-0472
  1.1478 +
  1.1479 +@SYMDEF             DEF118618
  1.1480 +
  1.1481 +@SYMTestCaseDesc    Test defect fixes to system panics 
  1.1482 +
  1.1483 +@SYMTestPriority    High
  1.1484 +
  1.1485 +@SYMTestStatus      Implemented
  1.1486 +
  1.1487 +@SYMTestActions     Check that various defect fixes to system panics are correct.
  1.1488 +					Also verify that reconstructing a closed object will succeed.
  1.1489 +
  1.1490 +@SYMTestExpectedResults Panics respond correctly
  1.1491 +*/
  1.1492 +void CTPanic::TestDoubleConstructionL()
  1.1493 +	{
  1.1494 +#ifdef __WINS__
  1.1495 +	for(TInt test=1;test<11;test++)
  1.1496 +		{
  1.1497 +		TEST(iTest->TestW32PanicL(&DoDoubleConstructionTestL,EW32PanicGraphicDoubleConstruction,test,NULL));
  1.1498 +		}
  1.1499 +	TestDoubleConstructionNoPanic();
  1.1500 +#endif
  1.1501 +	}
  1.1502 +	
  1.1503 +/** Verifies the following scenario	is valid:
  1.1504 +	1. Create some wserv client-side objects.
  1.1505 +	2. Call Close on them.
  1.1506 +	3. Reconstruct them and they shouldn't panic this time. */
  1.1507 +void CTPanic::TestDoubleConstructionNoPanic()
  1.1508 +	{
  1.1509 +	RWsSession ws;
  1.1510 +	User::LeaveIfError(ws.Connect());
  1.1511 +	
  1.1512 +	RWindowGroup group(ws);
  1.1513 +	User::LeaveIfError(group.Construct(890, EFalse));
  1.1514 +	RBlankWindow bwin(ws);
  1.1515 +	User::LeaveIfError(bwin.Construct(group,900));
  1.1516 +	
  1.1517 +	//RWsSprite
  1.1518 +	RWsSprite sprite(ws);
  1.1519 +	TEST(KErrNone == sprite.Construct(bwin,TPoint(0,0),0));
  1.1520 +	sprite.Close();
  1.1521 +	TEST(KErrNone == sprite.Construct(bwin,TPoint(0,0),0));
  1.1522 +	sprite.Close();
  1.1523 +	
  1.1524 +	//RWsPointerCursor
  1.1525 +	RWsPointerCursor cursor(ws);
  1.1526 +	TEST(KErrNone == cursor.Construct(0));
  1.1527 +	cursor.Close();
  1.1528 +	TEST(KErrNone == cursor.Construct(0));
  1.1529 +	cursor.Close();
  1.1530 +	
  1.1531 +	//RSoundPlugIn
  1.1532 +	RSoundPlugIn click(ws);
  1.1533 +	TEST(KErrNone == click.Construct());
  1.1534 +	click.Close();
  1.1535 +	TEST(KErrNone == click.Construct());
  1.1536 +	click.Close();
  1.1537 +	
  1.1538 +	//RWindowGroup
  1.1539 +	RWindowGroup windowgroup(ws);
  1.1540 +	TEST(KErrNone ==windowgroup.Construct(901));
  1.1541 +	windowgroup.Close();
  1.1542 +	TEST(KErrNone ==windowgroup.Construct(901));
  1.1543 +	windowgroup.Close();
  1.1544 +	
  1.1545 +	//RWindow
  1.1546 +	RWindow win1(ws);
  1.1547 +	TEST(KErrNone == win1.Construct(group,902));
  1.1548 +	win1.Close(); 
  1.1549 +	TEST(KErrNone == win1.Construct(group,902));
  1.1550 +	win1.Close(); 
  1.1551 +	
  1.1552 +	//RBlankWindow
  1.1553 +	RBlankWindow win2(ws);
  1.1554 +	TEST(KErrNone == win2.Construct(group,902));
  1.1555 +	win2.Close(); 
  1.1556 +	TEST(KErrNone == win2.Construct(group,902));
  1.1557 +	win2.Close();
  1.1558 +	
  1.1559 +	//RBackedUpWindow
  1.1560 +	RBackedUpWindow win3(ws);
  1.1561 +	TEST(KErrNone == win3.Construct(group,EGray4,902));
  1.1562 +	win3.Close();
  1.1563 +	TEST(KErrNone == win3.Construct(group,EGray4,902));
  1.1564 +	win3.Close(); 
  1.1565 +	
  1.1566 +	//RAnimDll
  1.1567 +	RAnimDll animDll=RAnimDll(ws);
  1.1568 +	TEST(KErrNone == animDll.Load(KAnimDLLName));
  1.1569 +	animDll.Close();
  1.1570 +	TEST(KErrNone == animDll.Load(KAnimDLLName));
  1.1571 +	animDll.Close();
  1.1572 +	
  1.1573 +	group.Close();
  1.1574 +	bwin.Close();
  1.1575 +	ws.Close();
  1.1576 +	}
  1.1577 +
  1.1578 +void CTPanic::TestSpritePanicsL()
  1.1579 +	{
  1.1580 +	for(TInt test=1;test<4;test++)
  1.1581 +		{
  1.1582 +		TEST(iTest->TestWsPanicL(&DoSpritePanicTestL,EWservPanicSprite,test,(TAny*)iTest->iScreenNumber));
  1.1583 +		}
  1.1584 +	}
  1.1585 +
  1.1586 +/**
  1.1587 +@SYMTestCaseID		GRAPHICS-WSERV-0475
  1.1588 +
  1.1589 +@SYMDEF             DEF118616
  1.1590 +
  1.1591 +@SYMTestCaseDesc    Test defect fixes to system panics 
  1.1592 +
  1.1593 +@SYMTestPriority    High
  1.1594 +
  1.1595 +@SYMTestStatus      Implemented
  1.1596 +
  1.1597 +@SYMTestActions     Check that various defect fixes to system panics are correct.
  1.1598 +
  1.1599 +@SYMTestExpectedResults Panics respond correctly
  1.1600 +*/
  1.1601 +void CTPanic::TestSpriteActivatePanicL()
  1.1602 +	{
  1.1603 +	for(TInt test=1;test<3;test++)
  1.1604 +		{
  1.1605 +		TEST(iTest->TestWsPanicL(&DoTestSpriteActivatePanicL,EWservPanicNoSpriteMember,test,NULL));
  1.1606 +		}
  1.1607 +	}
  1.1608 +
  1.1609 +void CTPanic::TestMoveToGroupPanicsL()
  1.1610 +	{
  1.1611 +	TEST(iTest->TestWsPanicL(&DoMoveToGroupPanicTestL,EWservPanicOpcode,1,(TAny*)iTest->iScreenNumber));
  1.1612 +	TEST(iTest->TestWsPanicL(&DoMoveToGroupPanicTestL,EWservPanicNotTopClient,2,(TAny*)iTest->iScreenNumber));
  1.1613 +	}
  1.1614 +
  1.1615 +void CTPanic::TestDeleteScreenPanicL()
  1.1616 +	{
  1.1617 +#ifdef __WINS__
  1.1618 +	TEST(iTest->TestWsPanicL(&DoDeleteScreenPanicTestL,EWservPanicGroupWinScreenDeviceDeleted,1,(TAny*)iTest->iScreenNumber));
  1.1619 +	TEST(iTest->TestWsPanicL(&DoDeleteScreenPanicTestL,EWservPanicGroupWinScreenDeviceDeleted,2,(TAny*)iTest->iScreenNumber));
  1.1620 +#endif
  1.1621 +	}
  1.1622 +
  1.1623 +void CTPanic::TestWinHandleErrors()
  1.1624 +	{
  1.1625 +#ifdef __WINS__
  1.1626 +	TEST(iTest->TestWsPanicL(&DoWinHandlePanicTestL,EWservPanicDuplicateHandle,1));
  1.1627 +	TEST(iTest->TestWsPanicL(&DoWinHandlePanicTestL,EWservPanicDuplicateHandle,2));
  1.1628 +	TEST(iTest->TestWsPanicL(&DoWinHandlePanicTestL,EWservPanicDuplicateHandle,3));
  1.1629 +#endif
  1.1630 +	TEST(iTest->TestWsPanicL(&DoWinHandlePanicTestL,EWservPanicNullHandle,4));
  1.1631 +	}
  1.1632 +
  1.1633 +void CTPanic::TestGetEventErrors()
  1.1634 +	{
  1.1635 +	TEST(iTest->TestWsPanicL(&DoGetEventPanicTestL,EWservPanicUnsignalledEventData,1,(TAny*)iTest->iScreenNumber));
  1.1636 +	TEST(iTest->TestWsPanicL(&DoGetEventPanicTestL,EWservPanicDescriptor,2,(TAny*)iTest->iScreenNumber));
  1.1637 +	}
  1.1638 +
  1.1639 +void CTPanic::TestUnInitPanicL()
  1.1640 +	{
  1.1641 +	TEST(iTest->TestWsPanicL(&DoUnInitPanicTest,EWservPanicUninitialisedClient,0,(TAny*)iTest->iScreenNumber));
  1.1642 +	}
  1.1643 +
  1.1644 +void CTPanic::TestEnableAdvancePointerActivatePanicL()
  1.1645 +    {
  1.1646 +    TEST(iTest->TestWsPanicL(&DoTestAdvancePointerActivatePanicL,EWservPanicUnableToEnableAdvPointer, 0, (TAny*)iTest->iScreenNumber));
  1.1647 +    }
  1.1648 +
  1.1649 +void CTPanic::ConstructL()
  1.1650 +	{
  1.1651 +	TheGc->Activate(*BaseWin->Win());
  1.1652 +	TheGc->Clear();
  1.1653 +	TheGc->SetBrushColor(TRgb::Gray16(12));
  1.1654 +	TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1655 +	TheGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1656 +	TheGc->DrawRect(TRect(BaseWin->Win()->Size()));
  1.1657 +	TheGc->Deactivate();
  1.1658 +	TheGc->Activate(*TestWin->Win());
  1.1659 +	TheGc->Clear();
  1.1660 +	TheGc->SetBrushColor(TRgb::Gray16(4));
  1.1661 +	TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1662 +	TheGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1663 +	TheGc->DrawRect(TRect(TestWin->Win()->Size()));
  1.1664 +	TheGc->Deactivate();
  1.1665 +//
  1.1666 +	_LIT(KReportFullRom,"Warning full ROM, EikSrv present, panic dialogs may interfere with tests");
  1.1667 +	_LIT(KReportGoodRom,"ROM OK, No EikSrv present");
  1.1668 +	if (iTest->IsFullRomL())
  1.1669 +		{
  1.1670 +		INFO_PRINTF1(KReportFullRom);
  1.1671 +		}
  1.1672 +	else
  1.1673 +		{
  1.1674 +		INFO_PRINTF1(KReportGoodRom);
  1.1675 +		}
  1.1676 +	}
  1.1677 +
  1.1678 +void CTPanic::TestAlphaBlendingPanicL()
  1.1679 +	{
  1.1680 +	INFO_PRINTF1(_L("Masked transparency support has been removed."));
  1.1681 +	}
  1.1682 +	
  1.1683 +void CTPanic::TestMismatchedCaptureCancelPanicL()
  1.1684 +	{		
  1.1685 +// Run this test in debug on emulator only.
  1.1686 +// On a debug ROM the release version of the wserv.exe is included so the test can't be run as no panic happens. 
  1.1687 +#if defined(_DEBUG) && defined(__WINS__)		
  1.1688 +	TEST(iTest->TestWsPanicL(DoMismatchedCancelCaptureTest,EWservPanicDestroy,ECancelCaptureKey,(TAny*)iTest->iScreenNumber));
  1.1689 +	TEST(iTest->TestWsPanicL(DoMismatchedCancelCaptureTest,EWservPanicDestroy,ECancelCaptureKeyUpAndDowns,(TAny*)iTest->iScreenNumber));
  1.1690 +	TEST(iTest->TestWsPanicL(DoMismatchedCancelCaptureTest,EWservPanicDestroy,ECancelCaptureLongKey,(TAny*)iTest->iScreenNumber));
  1.1691 +#endif
  1.1692 +	}
  1.1693 +
  1.1694 +void CTPanic::RunTestCaseL(TInt /*aCurTestCase*/)
  1.1695 +	{
  1.1696 +	((CTPanicStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
  1.1697 +	switch(++iTest->iState)
  1.1698 +		{
  1.1699 +/**
  1.1700 +@SYMTestCaseID		GRAPHICS-WSERV-0259
  1.1701 +
  1.1702 +@SYMDEF             DEF081259
  1.1703 +
  1.1704 +@SYMTestCaseDesc    Test various system panics 
  1.1705 +
  1.1706 +@SYMTestPriority    High
  1.1707 +
  1.1708 +@SYMTestStatus      Implemented
  1.1709 +
  1.1710 +@SYMTestActions     Check that various system panics respond correctly 
  1.1711 +
  1.1712 +@SYMTestExpectedResults Panics respond correctly
  1.1713 +*/
  1.1714 +		case 1:
  1.1715 +			{
  1.1716 +			((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0259"));
  1.1717 +			iTest->LogSubTest(_L("TestCaptureKeyPanicsL"));
  1.1718 +			TestCaptureKeyPanicsL();
  1.1719 +			}
  1.1720 +			break;
  1.1721 +		case 2:
  1.1722 +		    {
  1.1723 +			iTest->LogSubTest(_L("TestEventPanicsL"));
  1.1724 +			TestEventPanicsL();
  1.1725 +		    }
  1.1726 +		    break;
  1.1727 +		case 3:
  1.1728 +		    {
  1.1729 +			iTest->LogSubTest(_L("TestComputeModePanicsL"));
  1.1730 +			TestComputeModePanicsL();
  1.1731 +		    }
  1.1732 +		    break;
  1.1733 +		case 4:
  1.1734 +		    {
  1.1735 +#ifdef __WINS__
  1.1736 +//  Only running this under WINS as the tests are a bit excessive, firing off all sorts of illegal
  1.1737 +// opcode/flag combinations, as well as buffers of random data.
  1.1738 +// Currently on ARM builds they're failing with KErrOutOfMemory, probably running out of handles
  1.1739 +// somewhere in the OS.
  1.1740 +			iTest->LogSubTest(_L("TestMiscPanicsL"));
  1.1741 +			TestMiscPanicsL();
  1.1742 +#endif
  1.1743 +		    }
  1.1744 +		    break;
  1.1745 +		case 5:
  1.1746 +		    {
  1.1747 +			iTest->LogSubTest(_L("TestGraphicsPanicsL"));
  1.1748 +			TestGraphicsPanicsL();
  1.1749 +		    }
  1.1750 +		    break;
  1.1751 +		case 6:
  1.1752 +		    {
  1.1753 +			iTest->LogSubTest(_L("TestTPtrPanicsL"));
  1.1754 +			TestTPtrPanicsL();
  1.1755 +		    }
  1.1756 +		    break;
  1.1757 +		case 7:
  1.1758 +		    {
  1.1759 +			iTest->LogSubTest(_L("TestOpcodePanicsL"));
  1.1760 +			TestOpcodePanicsL();
  1.1761 +		    }
  1.1762 +		    break;
  1.1763 +		case 8:
  1.1764 +		    {
  1.1765 +			iTest->LogSubTest(_L("TestScreenDevicePanicsL"));
  1.1766 +			TestScreenDevicePanicsL();
  1.1767 +		    }
  1.1768 +		    break;
  1.1769 +		case 9:
  1.1770 +		    {
  1.1771 +			iTest->LogSubTest(_L("TestMultiInitPanicL"));
  1.1772 +			TestMultiInitPanicL();
  1.1773 +			}
  1.1774 +			break;
  1.1775 +/**
  1.1776 +@SYMTestCaseID		GRAPHICS-WSERV-0260
  1.1777 +
  1.1778 +@SYMDEF             DEF081259
  1.1779 +
  1.1780 +@SYMTestCaseDesc    Test various system panics 
  1.1781 +
  1.1782 +@SYMTestPriority    High
  1.1783 +
  1.1784 +@SYMTestStatus      Implemented
  1.1785 +
  1.1786 +@SYMTestActions     Check that various system panics respond correctly 
  1.1787 +
  1.1788 +@SYMTestExpectedResults Panics respond correctly
  1.1789 +*/
  1.1790 +		case 10:
  1.1791 +			{
  1.1792 +			((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0260"));
  1.1793 +			iTest->LogSubTest(_L("Panic 2"));
  1.1794 +			TestSpritePanicsL();
  1.1795 +			TestMoveToGroupPanicsL();
  1.1796 +			}
  1.1797 +			break;
  1.1798 +/**
  1.1799 +@SYMTestCaseID		GRAPHICS-WSERV-0261
  1.1800 +
  1.1801 +@SYMDEF             DEF081259
  1.1802 +
  1.1803 +@SYMTestCaseDesc    Test defect fixes to system panics 
  1.1804 +
  1.1805 +@SYMTestPriority    High
  1.1806 +
  1.1807 +@SYMTestStatus      Implemented
  1.1808 +
  1.1809 +@SYMTestActions     Check that various defect fixes to system panics are correct 
  1.1810 +
  1.1811 +@SYMTestExpectedResults Panics respond correctly
  1.1812 +*/			
  1.1813 +		case 11:
  1.1814 +			{
  1.1815 +			((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0261"));
  1.1816 +			_LIT(KPanicTest,"Defect Fixes (Pan.3)");
  1.1817 +			iTest->LogSubTest(KPanicTest);
  1.1818 +			TestDeletedParentPanicsL();
  1.1819 +			TestHandleReUseL();
  1.1820 +			TestDeleteScreenPanicL(); // DEF069809
  1.1821 +			}
  1.1822 +			break;
  1.1823 +/**
  1.1824 +@SYMTestCaseID		GRAPHICS-WSERV-097969-0001
  1.1825 +
  1.1826 +@SYMDEF             DEF097969
  1.1827 +
  1.1828 +@SYMTestCaseDesc    Test defect fixes to system panics 
  1.1829 +
  1.1830 +@SYMTestPriority    High
  1.1831 +
  1.1832 +@SYMTestStatus      Implemented
  1.1833 +
  1.1834 +@SYMTestActions     Check that various defect fixes to system panics are correct 
  1.1835 +
  1.1836 +@SYMTestExpectedResults Panics respond correctly
  1.1837 +*/			
  1.1838 +		case 12:
  1.1839 +			{
  1.1840 +			((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-097969-0001"));
  1.1841 +			_LIT(KPanicTest,"Server panic defect Fix (Pan.4)");
  1.1842 +			iTest->LogSubTest(KPanicTest);
  1.1843 +			TestUnInitPanicL();	// DEF097969
  1.1844 +			}
  1.1845 +			break;
  1.1846 +		
  1.1847 +		case 13:
  1.1848 +			{
  1.1849 +/**
  1.1850 +@SYMTestCaseID		GRAPHICS-WSERV-0501
  1.1851 +*/
  1.1852 +			((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0501"));
  1.1853 +			_LIT(KPanicTest,"AlphaBlending Bitmap panic defect Fix (Pan.5)");
  1.1854 +			iTest->LogSubTest(KPanicTest);
  1.1855 +			TestAlphaBlendingPanicL();	// DEF112916
  1.1856 +			}
  1.1857 +			break;
  1.1858 +		case 14:
  1.1859 +			{		
  1.1860 +            ((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0472"));
  1.1861 +			_LIT(KPanicTest,"Double construction panic test");
  1.1862 +			iTest->LogSubTest(KPanicTest);
  1.1863 +			TestDoubleConstructionL();	// DEF118618
  1.1864 +			}
  1.1865 +			break;
  1.1866 +		case 15:
  1.1867 +			{
  1.1868 +			((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0475"));
  1.1869 +			_LIT(KPanicTest, "RWsSprite Activate() without members panic test");
  1.1870 +			iTest->LogSubTest(KPanicTest);
  1.1871 +			TestSpriteActivatePanicL(); //DEF118616				
  1.1872 +			}
  1.1873 +			break;
  1.1874 +/**
  1.1875 +@SYMTestCaseID		GRAPHICS-WSERV-0497
  1.1876 +
  1.1877 +@SYMDEF             DEF133776
  1.1878 +
  1.1879 +@SYMTestCaseDesc     Test that a debug only panic occurs when an attempt
  1.1880 + is made to cancel a key capture using the wrong cancel capture API.
  1.1881 +
  1.1882 +@SYMTestPriority    High
  1.1883 +
  1.1884 +@SYMTestStatus      Implemented
  1.1885 +
  1.1886 +@SYMTestActions     Check that calling the each RWindowGroup::CancelCapture***() API
  1.1887 + using the handle returned from a mismatched RWindowGroup::Capture***() call causes
  1.1888 + a debug only panic. Tests each of the three RWindowGroup::CancelCapture***() APIs.
  1.1889 +
  1.1890 +@SYMTestExpectedResults Panics respond correctly in debug only.
  1.1891 +*/			
  1.1892 +		case 16:
  1.1893 +			{
  1.1894 +			((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0497"));
  1.1895 +			_LIT(KPanicTest,"TestMismatchedCaptureCancelPanicL");
  1.1896 +			iTest->LogSubTest(KPanicTest);
  1.1897 +			TestMismatchedCaptureCancelPanicL();				
  1.1898 +			}
  1.1899 +			break;			
  1.1900 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
  1.1901 +		case 17:
  1.1902 +			{
  1.1903 +			_LIT(KPanicTest, "Non-Redraw Drawing inside Redrawer Panic Test");
  1.1904 +			iTest->LogSubTest(KPanicTest);
  1.1905 +			TestNonRedrawRedrawerL();
  1.1906 +			}
  1.1907 +			break;
  1.1908 +	  case 18:
  1.1909 +      {
  1.1910 +      _LIT(KPanicTest, "Enable advanced pointer Panic Test");
  1.1911 +      iTest->LogSubTest(KPanicTest);
  1.1912 +      TestEnableAdvancePointerActivatePanicL();
  1.1913 +      }   
  1.1914 +			break;
  1.1915 +						
  1.1916 +#endif			
  1.1917 +		default:
  1.1918 +            		((CTPanicStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
  1.1919 +			((CTPanicStep*)iStep)->CloseTMSGraphicsStep();
  1.1920 +			TestComplete();
  1.1921 +			break;
  1.1922 +		}
  1.1923 +	((CTPanicStep*)iStep)->RecordTestResultL();
  1.1924 +	}
  1.1925 +
  1.1926 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
  1.1927 +LOCAL_C TInt DoTestNonRedrawRedrawerL(TInt /* aInt */, TAny * /* aPtr */)
  1.1928 +	{
  1.1929 +	CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
  1.1930 +	CleanupStack::PushL(scheduler);
  1.1931 +	CActiveScheduler::Install(scheduler);
  1.1932 +	
  1.1933 +	RWsSession session;
  1.1934 +	User::LeaveIfError(session.Connect());
  1.1935 +	
  1.1936 +	CWsScreenDevice *screenDevice = new (ELeave)CWsScreenDevice(session);
  1.1937 +	User::LeaveIfError(screenDevice->Construct ());
  1.1938 +	CWindowGc *gc;
  1.1939 +	User::LeaveIfError(screenDevice->CreateContext(gc));
  1.1940 +	
  1.1941 +	CNonRedrawWin *nonRedrawWin=CNonRedrawWin::NewL(session, gc);	
  1.1942 +	nonRedrawWin->Invalidate(); 
  1.1943 +	CActiveScheduler::Start();
  1.1944 +	User::After(2000000); // so the Redrawer has a chance to run 
  1.1945 +	CActiveScheduler::Stop();
  1.1946 +	delete gc;
  1.1947 +	delete screenDevice;
  1.1948 +	session.Close();
  1.1949 +	CleanupStack::PopAndDestroy(scheduler);
  1.1950 +	return(EWsExitReasonBad);
  1.1951 +	}
  1.1952 +
  1.1953 +/**
  1.1954 +@SYMTestCaseID		GRAPHICS-WSERV-0121808
  1.1955 +@SYMDEF             DEF121808: No more Non-Redraw drawing for NGA (test added during DEF134308) 
  1.1956 +@SYMTestCaseDesc    Test defect fixes to system panics 
  1.1957 +@SYMTestPriority    High
  1.1958 +@SYMTestStatus      Implemented
  1.1959 +@SYMTestActions     Check that WServ panics a client which uses Non-Redraw drawing in the Redrawer.
  1.1960 +@SYMTestExpectedResults Panics respond correctly
  1.1961 +*/
  1.1962 +void CTPanic::TestNonRedrawRedrawerL()
  1.1963 +	{
  1.1964 +	TEST(iTest->TestWsPanicL(&DoTestNonRedrawRedrawerL,EWservPanicWindowBeginRedrawNotCalled,NULL,NULL));
  1.1965 +	}
  1.1966 +
  1.1967 +CNonRedrawWin::CRedrawer::CRedrawer(CNonRedrawWin* aWd) :
  1.1968 +	CActive(CActive::EPriorityStandard), iWd(aWd){
  1.1969 +	CActiveScheduler::Add(this);
  1.1970 +	HandleRedrawEvent();	
  1.1971 +}
  1.1972 +
  1.1973 +CNonRedrawWin::CRedrawer::~CRedrawer(){
  1.1974 +	Cancel();
  1.1975 +}
  1.1976 +
  1.1977 +void CNonRedrawWin::CRedrawer::HandleRedrawEvent(){
  1.1978 +	iWd->GetSession().RedrawReady(&iStatus);
  1.1979 +	SetActive();
  1.1980 +}
  1.1981 +
  1.1982 +void CNonRedrawWin::CRedrawer::RunL(){
  1.1983 +	TWsRedrawEvent redrawEvent;
  1.1984 +	iWd->GetSession().GetRedraw(redrawEvent);	
  1.1985 +	iWd->Redraw();
  1.1986 +	HandleRedrawEvent();
  1.1987 +}
  1.1988 +
  1.1989 +void CNonRedrawWin::CRedrawer::DoCancel(){
  1.1990 +	iWd->GetSession().RedrawReadyCancel();
  1.1991 +}
  1.1992 +
  1.1993 +CNonRedrawWin* CNonRedrawWin::NewL(RWsSession &aSession, CWindowGc *aGc){
  1.1994 +	CNonRedrawWin* self=new(ELeave)CNonRedrawWin(aSession, aGc);
  1.1995 +	CleanupStack::PushL(self);
  1.1996 +	self->ConstrucL();
  1.1997 +	CleanupStack::Pop(self);
  1.1998 +	return self;
  1.1999 +}
  1.2000 +
  1.2001 +CNonRedrawWin::CNonRedrawWin(RWsSession &aSession, CWindowGc *aGc):
  1.2002 +	iSession(aSession), iGc(aGc){}
  1.2003 +
  1.2004 +CNonRedrawWin::~CNonRedrawWin(){
  1.2005 +	delete iRedrawer;
  1.2006 +	iWd.Close();
  1.2007 +	iWdGrp.Close();	
  1.2008 +}
  1.2009 +
  1.2010 +void CNonRedrawWin::Redraw(){
  1.2011 +	// This is a Non-Redraw Drawing Redrawer; BeginRedraw()/EndRedraw()
  1.2012 +	// have been intentionally omitted.
  1.2013 +	iGc->Activate(iWd);	
  1.2014 +	iGc->SetBrushColor(TRgb(255,0,0));
  1.2015 +	iGc->SetPenColor(KRgbBlue);
  1.2016 +	iGc->SetPenSize(TSize(10,20));
  1.2017 +	iGc->DrawRect(TRect(TPoint(10,10),TPoint(50,50)));	
  1.2018 +	iGc->Deactivate();
  1.2019 +	iSession.Finish();			
  1.2020 +}
  1.2021 +
  1.2022 +RWsSession &CNonRedrawWin::GetSession(){return iSession;}
  1.2023 +
  1.2024 +void CNonRedrawWin::Invalidate(){iWd.Invalidate();}
  1.2025 +
  1.2026 +void CNonRedrawWin::ConstrucL(){
  1.2027 +	iWdGrp=RWindowGroup(iSession);	
  1.2028 +	iWdGrp.Construct((TUint32)this,ETrue);
  1.2029 +	_LIT(KWndGrpName,"NonRedrawWndGrp");
  1.2030 +	iWdGrp.SetName(KWndGrpName);	
  1.2031 +	iWd=RWindow(iSession);	
  1.2032 +	iWd.Construct(iWdGrp, 0x101);	
  1.2033 +	User::LeaveIfError(iWd.SetExtentErr(TPoint(0,0),TSize(150,150)));
  1.2034 +	iWd.SetBackgroundColor(KRgbWhite);
  1.2035 +	iWd.SetOrdinalPosition(0);	
  1.2036 +	iWd.Activate();	
  1.2037 +	iRedrawer=new(ELeave) CRedrawer(this);
  1.2038 +}
  1.2039 +#endif
  1.2040 +
  1.2041 +TInt RUnInitalisedConnect::Connect(const TDesC &aName, const TVersion &aVersion)
  1.2042 +	{
  1.2043 +	return CreateSession(aName, aVersion, 255);
  1.2044 +	}
  1.2045 +
  1.2046 +TInt RUnInitalisedConnect::Send(const TInt aMsg)
  1.2047 +	{
  1.2048 +	return SendReceive(aMsg);
  1.2049 +	}
  1.2050 +
  1.2051 +__WS_CONSTRUCT_STEP__(Panic)
  1.2052 +#pragma warning( disable : 4505 )