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