windowing/windowserver/tauto/TPANIC.CPP
changeset 116 171fae344dd4
parent 103 2717213c588a
equal deleted inserted replaced
103:2717213c588a 116:171fae344dd4
     1 // Copyright (c) 1996-2009 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 LOCAL_C TInt DoMoveToGroupPanicTestL(TInt aTest, TAny *aScreenNumber)
       
  1154 	{
       
  1155 	RWsSession ws;
       
  1156 	User::LeaveIfError(ws.Connect());
       
  1157 	// use correct screen
       
  1158 	//
       
  1159 	CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
       
  1160 	User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
       
  1161 	
       
  1162 	RWindowGroup group(ws);
       
  1163 	User::LeaveIfError(group.Construct(887));
       
  1164 	group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
       
  1165 	TInt id=group.Identifier();
       
  1166 	switch (aTest)
       
  1167 		{
       
  1168 	case 1:
       
  1169 		{
       
  1170 		RWindowTreeNode* win=&group;
       
  1171 		((RWindowBase*)win)->MoveToGroup(id);
       
  1172 		}
       
  1173 		break;
       
  1174 	case 2:
       
  1175 		{
       
  1176 		RBlankWindow win1(ws);
       
  1177 		User::LeaveIfError(win1.Construct(group,878));
       
  1178 		RBlankWindow win2(ws);
       
  1179 		User::LeaveIfError(win2.Construct(win1,788));
       
  1180 		win2.MoveToGroup(id);
       
  1181 		}
       
  1182 		break;
       
  1183 		}
       
  1184 	ws.Flush();
       
  1185 	return(EWsExitReasonBad);
       
  1186 	}
       
  1187 
       
  1188 LOCAL_C TInt DoGetEventPanicTestL(TInt aTest, TAny *aScreenNumber)
       
  1189 	{
       
  1190 	RWsSession ws;
       
  1191 	User::LeaveIfError(ws.Connect());
       
  1192 	switch(aTest)
       
  1193 		{
       
  1194 	case 1:
       
  1195 		{
       
  1196 		TPckgBuf<TWsEvent> event;
       
  1197 		ws.TestWrite(ws.WsHandle(),EWsClOpGetEvent,&event,0);
       
  1198 		}
       
  1199 		break;
       
  1200 	case 2:
       
  1201 		{
       
  1202 		CWsScreenDevice* screen=new(ELeave) CWsScreenDevice(ws);
       
  1203 		User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
       
  1204 		RWindowGroup group(ws);
       
  1205 		User::LeaveIfError(group.Construct(555));	// trigger a focus changed event
       
  1206 		TRequestStatus stat;
       
  1207 		ws.EventReady(&stat);
       
  1208 		User::WaitForRequest(stat);
       
  1209 		TPtrC8 badDesc(reinterpret_cast<const TUint8*>(0xDEAD),100);
       
  1210 		ws.TestWrite(ws.WsHandle(),EWsClOpGetEvent,&badDesc,0);
       
  1211 		}
       
  1212 		break;
       
  1213 		}
       
  1214 	ws.Flush();
       
  1215 	return(EWsExitReasonBad);
       
  1216 	}
       
  1217 
       
  1218 LOCAL_C TInt DoWinHandlePanicTestL(TInt aTest, TAny *)
       
  1219 	{
       
  1220 	RWsSession ws;
       
  1221 	User::LeaveIfError(ws.Connect());
       
  1222 	RWindowGroup group1(ws);
       
  1223 	RWindowGroup group2(ws);
       
  1224 	RWindow win1(ws);
       
  1225 	RWindow win2(ws);
       
  1226 	switch(aTest)
       
  1227 		{
       
  1228 	case 1:
       
  1229 		User::LeaveIfError(group1.Construct(888));
       
  1230 		User::LeaveIfError(group2.Construct(888));
       
  1231 		break;
       
  1232 	case 2:
       
  1233 		User::LeaveIfError(group1.Construct(777));
       
  1234 		User::LeaveIfError(win1.Construct(group1,888));
       
  1235 		User::LeaveIfError(win2.Construct(group1,888));
       
  1236 		break;
       
  1237 	case 3:
       
  1238 		User::LeaveIfError(group1.Construct(777));
       
  1239 		User::LeaveIfError(win1.Construct(group1,777));
       
  1240 		break;
       
  1241 	case 4:
       
  1242 		User::LeaveIfError(group1.Construct(777));
       
  1243 		User::LeaveIfError(win1.Construct(group1,0));
       
  1244 		break;
       
  1245 		}
       
  1246 	ws.Flush();
       
  1247 	return(EWsExitReasonBad);
       
  1248 	}
       
  1249 
       
  1250 #ifdef __WINS__
       
  1251 LOCAL_C TInt DoDeleteScreenPanicTestL(TInt aTest, TAny *aScreenNumber)
       
  1252 /**
       
  1253  * Test examples of use of the 'screen device deleted' panic for group windows.
       
  1254  * This is issued to panic the client, if they make API calls to RWindowGroup after having deleted
       
  1255  * the CWsScreenDevice with which that window group is associated.
       
  1256  */
       
  1257 	{
       
  1258 	RWsSession ws;
       
  1259 	User::LeaveIfError(ws.Connect());
       
  1260 	// point to correct screen
       
  1261 	CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
       
  1262 	User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
       
  1263 	
       
  1264 	RWindowGroup group(ws);
       
  1265 	User::LeaveIfError(group.Construct(888));
       
  1266 	group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
       
  1267 	switch(aTest)
       
  1268 		{
       
  1269 		// Test 1: deleting screen then modifying screen change events is illegal
       
  1270 		case 1:
       
  1271 			{
       
  1272 			delete screen, screen=NULL;
       
  1273 			group.EnableScreenChangeEvents();
       
  1274 			break;
       
  1275 			}
       
  1276 		// Test 2: deleting screen then setting window group name is illegal
       
  1277 		case 2:
       
  1278 			{
       
  1279 			delete screen, screen=NULL;
       
  1280 			_LIT(KPanicTest, "PanicTest");
       
  1281 			group.SetName(KPanicTest);
       
  1282 			break;
       
  1283 			}
       
  1284 		}
       
  1285 	ws.Flush();
       
  1286 	return(EWsExitReasonBad);
       
  1287 	}
       
  1288 #endif
       
  1289 
       
  1290 LOCAL_C TInt DoUnInitPanicTest(TInt , TAny *)
       
  1291 	{
       
  1292 	// Creating a client session outside the test harness for panicking
       
  1293 	//  before initialisation as the test harness initialises the one it creates.
       
  1294 	TVersion version(0,0,0);
       
  1295 	_LIT(KServerName, "!Windowserver");
       
  1296 	
       
  1297 	RUnInitalisedConnect myUnInit;
       
  1298 
       
  1299 	User::LeaveIfError(myUnInit.Connect(KServerName(), version));
       
  1300 	myUnInit.Send(EWservMessCommandBuffer);
       
  1301 	
       
  1302 	return(EWsExitReasonBad);
       
  1303 	}
       
  1304 
       
  1305 void CTPanic::TestScreenDevicePanicsL()
       
  1306 	{
       
  1307 	TEST(iTest->TestWsPanicL(&DoScreenDevicePanicTest,EWservPanicBitmap,1,(TAny*)iTest->iScreenNumber));
       
  1308 	
       
  1309 	TEST(iTest->TestWsPanicL(&DoScreenDevicePanicTest,EWservPanicBitmap,2,(TAny*)iTest->iScreenNumber));
       
  1310 	}
       
  1311 
       
  1312 void CTPanic::TestMiscPanicsL()
       
  1313 	{
       
  1314 	TBool finished=EFalse;
       
  1315 	TInt index=0;
       
  1316 	while(!finished)
       
  1317 		{
       
  1318 		const TBool result = iTest->TestWsPanicL(&DoMiscPanicTest, EWservNoPanic, index, NULL, &finished);
       
  1319 		if(!result)
       
  1320 			{
       
  1321 			INFO_PRINTF2(_L("TestMiscPanicsL %d failed"), index);
       
  1322 			TEST(result);
       
  1323 			}
       
  1324 		index++;
       
  1325 		}
       
  1326 	}
       
  1327 
       
  1328 void CTPanic::LogHeapInfo()
       
  1329 	{
       
  1330 	_LIT(KInfoHeapSummary," WsHeap - Count=%d,Total=%d,Free=%d,Max free=%d");
       
  1331 	TPckgBuf<TWsDebugHeapInfo> heapInfo;
       
  1332 	TheClient->iWs.DebugInfo(EWsDebugInfoHeap,heapInfo);
       
  1333 	TBuf<256> infoBuf;
       
  1334 	infoBuf.Format(KInfoHeapSummary,heapInfo().iCount,heapInfo().iTotal,heapInfo().iAvailable,heapInfo().iLargestAvailable);
       
  1335 	INFO_PRINTF1(infoBuf);
       
  1336 	}
       
  1337 
       
  1338 void CTPanic::TestGraphicsPanicsL(TClientPanic aExitReason, TInt aIndex, CTPanic::TPanicParams* aPanicParams)
       
  1339 	{
       
  1340 	TBool finished=EFalse;
       
  1341 	aPanicParams->iSubTest=0;
       
  1342 
       
  1343 	// uncomment to show which test is being run
       
  1344 	INFO_PRINTF3(_L("GraphicsPanicTest %d, mode=%d"),aIndex,aPanicParams->iRedrawMode);
       
  1345     RDebug::Print(_L("GraphicsPanicTest %d, mode=%d"),aIndex,aPanicParams->iRedrawMode);
       
  1346 	do
       
  1347 		{
       
  1348 		// uncomment for detailed view of which sub-test failed
       
  1349 		LogHeapInfo();
       
  1350 		INFO_PRINTF4(_L("GraphicsPanicTest %d/%d, mode=%d"),aIndex,aPanicParams->iSubTest,aPanicParams->iRedrawMode);
       
  1351 		RDebug::Print(_L("GraphicsPanicTest %d/%d, mode=%d"),aIndex,aPanicParams->iSubTest,aPanicParams->iRedrawMode);
       
  1352 		TEST(iTest->TestWsPanicL(&GraphicsPanicTest,aExitReason,aIndex,aPanicParams,&finished));
       
  1353 		aPanicParams->iSubTest++;
       
  1354 		} while(!finished);
       
  1355 	iTest->CloseAllPanicWindows();
       
  1356 	}
       
  1357 
       
  1358 void CTPanic::TestGraphicsPanicsL(TPanicRedrawMode aRedrawMode)
       
  1359 	{
       
  1360 	CTPanic::TPanicParams pp;
       
  1361 	pp.iScreen=iTest->iScreenNumber;
       
  1362 	pp.iRedrawMode=aRedrawMode;
       
  1363 	static TClientPanic expectedPanics[]=
       
  1364 		{
       
  1365 		EWservPanicBufferPtr,
       
  1366 		EWservPanicBitmap,
       
  1367 		EWservPanicBitmap,
       
  1368 		EWservPanicBitmap,
       
  1369 		EWservPanicOpcode,
       
  1370 		EWservPanicBadPolyData,
       
  1371 		EWservPanicBadPolyData,
       
  1372 		EWservPanicOpcode,
       
  1373 		EWservPanicGcActive,
       
  1374 		EWservPanicNoFont,
       
  1375 		EWservPanicNoBrush,
       
  1376 		EWservPanicDescriptor,
       
  1377 		EWservPanicFont,
       
  1378 		EWservNoPanic,	// Marks the end of the list
       
  1379 		};
       
  1380 	TInt panicIndex=0;
       
  1381 	TClientPanic expectedPanic;
       
  1382 	while((expectedPanic=expectedPanics[panicIndex++])!=EWservNoPanic)
       
  1383 		{
       
  1384 		TestGraphicsPanicsL(expectedPanic,panicIndex,&pp);
       
  1385 		}
       
  1386 	}
       
  1387 
       
  1388 void CTPanic::TestGraphicsPanicsL()
       
  1389 	{
       
  1390 	TestGraphicsPanicsL(EPanicRedrawModeBackedUpWindow);
       
  1391 	TestGraphicsPanicsL(EPanicRedrawModeNormalRedraw);
       
  1392 	if (TransparencySupportedL()==KErrNone)
       
  1393 		{
       
  1394 		TestGraphicsPanicsL(EPanicRedrawModeTransRedraw);
       
  1395 		}
       
  1396 	TestGraphicsPanicsL(EPanicRedrawModeInvisRedraw);
       
  1397 	}
       
  1398 
       
  1399 void CTPanic::TestDeletedParentPanicsL()
       
  1400 	{
       
  1401 	TEST(iTest->TestWsPanicL(&DoDeletedParentTest,EWservPanicParentDeleted,1,(TAny*)iTest->iScreenNumber));
       
  1402 	}
       
  1403 
       
  1404 void CTPanic::TestHandleReUseL()
       
  1405 	{
       
  1406 	for (TInt ii=2;ii<6;++ii)
       
  1407 		{
       
  1408 		TEST(iTest->TestWsPanicL(&DoHandleReUse,EWservPanicHandle,ii,(TAny*)iTest->iScreenNumber));
       
  1409 		}
       
  1410 	}
       
  1411 
       
  1412 void CTPanic::TestComputeModePanicsL()
       
  1413 	{
       
  1414 	TEST(iTest->TestWsPanicL(&DoCMPanicTest,EWservPanicSetComputeMode,1,(TAny*)iTest->iScreenNumber));
       
  1415 	}
       
  1416 
       
  1417 void CTPanic::TestCaptureKeyPanicsL()
       
  1418 	{
       
  1419 // Run this test in debug on emulator only.
       
  1420 // On a debug ROM the release version of the wserv.exe is included so the test can't be run as no panic happens. 
       
  1421 #if defined(_DEBUG) && defined(__WINS__)
       
  1422 	TEST(iTest->TestWsPanicL(&DoCKPanicTest,EWservPanicDestroy,1,(TAny*)iTest->iScreenNumber));
       
  1423 #endif
       
  1424 	}
       
  1425 
       
  1426 void CTPanic::TestEventPanicsL()
       
  1427 	{
       
  1428 	TEST(iTest->TestWsPanicL(&DoEventPanicTest,EWservPanicReadOutstanding,1,(TAny*)iTest->iScreenNumber));
       
  1429 	}
       
  1430 
       
  1431 void CTPanic::TestTPtrPanicsL()
       
  1432 	{
       
  1433 	TEST(iTest->TestWsPanicL(&DoTBufPtrTests,EWservPanicBufferPtr,1,(TAny*)iTest->iScreenNumber));
       
  1434 	}
       
  1435 
       
  1436 void CTPanic::TestOpcodePanicsL()
       
  1437 	{
       
  1438 	TInt param=1;
       
  1439 	TBool finishTest = EFalse;
       
  1440 	while(!finishTest)
       
  1441 		{
       
  1442 		TEST(iTest->TestWsPanicL(&DoOpcodeTests,EWservPanicOpcode,param,(TAny*)iTest->iScreenNumber,&finishTest));
       
  1443 		param++;
       
  1444 		}
       
  1445 	}
       
  1446 
       
  1447 void CTPanic::TestMultiInitPanicL()
       
  1448 	{
       
  1449 	TEST(iTest->TestWsPanicL(&DoMultiInitPanicTest,EWservPanicReInitialise,0,(TAny*)iTest->iScreenNumber));
       
  1450 	}
       
  1451 
       
  1452 /**
       
  1453 @SYMTestCaseID		GRAPHICS-WSERV-0472
       
  1454 
       
  1455 @SYMDEF             DEF118618
       
  1456 
       
  1457 @SYMTestCaseDesc    Test defect fixes to system panics 
       
  1458 
       
  1459 @SYMTestPriority    High
       
  1460 
       
  1461 @SYMTestStatus      Implemented
       
  1462 
       
  1463 @SYMTestActions     Check that various defect fixes to system panics are correct.
       
  1464 					Also verify that reconstructing a closed object will succeed.
       
  1465 
       
  1466 @SYMTestExpectedResults Panics respond correctly
       
  1467 */
       
  1468 void CTPanic::TestDoubleConstructionL()
       
  1469 	{
       
  1470 #ifdef __WINS__
       
  1471 	for(TInt test=1;test<11;test++)
       
  1472 		{
       
  1473 		TEST(iTest->TestW32PanicL(&DoDoubleConstructionTestL,EW32PanicGraphicDoubleConstruction,test,NULL));
       
  1474 		}
       
  1475 	TestDoubleConstructionNoPanic();
       
  1476 #endif
       
  1477 	}
       
  1478 	
       
  1479 /** Verifies the following scenario	is valid:
       
  1480 	1. Create some wserv client-side objects.
       
  1481 	2. Call Close on them.
       
  1482 	3. Reconstruct them and they shouldn't panic this time. */
       
  1483 void CTPanic::TestDoubleConstructionNoPanic()
       
  1484 	{
       
  1485 	RWsSession ws;
       
  1486 	User::LeaveIfError(ws.Connect());
       
  1487 	
       
  1488 	RWindowGroup group(ws);
       
  1489 	User::LeaveIfError(group.Construct(890, EFalse));
       
  1490 	RBlankWindow bwin(ws);
       
  1491 	User::LeaveIfError(bwin.Construct(group,900));
       
  1492 	
       
  1493 	//RWsSprite
       
  1494 	RWsSprite sprite(ws);
       
  1495 	TEST(KErrNone == sprite.Construct(bwin,TPoint(0,0),0));
       
  1496 	sprite.Close();
       
  1497 	TEST(KErrNone == sprite.Construct(bwin,TPoint(0,0),0));
       
  1498 	sprite.Close();
       
  1499 	
       
  1500 	//RWsPointerCursor
       
  1501 	RWsPointerCursor cursor(ws);
       
  1502 	TEST(KErrNone == cursor.Construct(0));
       
  1503 	cursor.Close();
       
  1504 	TEST(KErrNone == cursor.Construct(0));
       
  1505 	cursor.Close();
       
  1506 	
       
  1507 	//RSoundPlugIn
       
  1508 	RSoundPlugIn click(ws);
       
  1509 	TEST(KErrNone == click.Construct());
       
  1510 	click.Close();
       
  1511 	TEST(KErrNone == click.Construct());
       
  1512 	click.Close();
       
  1513 	
       
  1514 	//RWindowGroup
       
  1515 	RWindowGroup windowgroup(ws);
       
  1516 	TEST(KErrNone ==windowgroup.Construct(901));
       
  1517 	windowgroup.Close();
       
  1518 	TEST(KErrNone ==windowgroup.Construct(901));
       
  1519 	windowgroup.Close();
       
  1520 	
       
  1521 	//RWindow
       
  1522 	RWindow win1(ws);
       
  1523 	TEST(KErrNone == win1.Construct(group,902));
       
  1524 	win1.Close(); 
       
  1525 	TEST(KErrNone == win1.Construct(group,902));
       
  1526 	win1.Close(); 
       
  1527 	
       
  1528 	//RBlankWindow
       
  1529 	RBlankWindow win2(ws);
       
  1530 	TEST(KErrNone == win2.Construct(group,902));
       
  1531 	win2.Close(); 
       
  1532 	TEST(KErrNone == win2.Construct(group,902));
       
  1533 	win2.Close();
       
  1534 	
       
  1535 	//RBackedUpWindow
       
  1536 	RBackedUpWindow win3(ws);
       
  1537 	TEST(KErrNone == win3.Construct(group,EGray4,902));
       
  1538 	win3.Close();
       
  1539 	TEST(KErrNone == win3.Construct(group,EGray4,902));
       
  1540 	win3.Close(); 
       
  1541 	
       
  1542 	//RAnimDll
       
  1543 	RAnimDll animDll=RAnimDll(ws);
       
  1544 	TEST(KErrNone == animDll.Load(KAnimDLLName));
       
  1545 	animDll.Close();
       
  1546 	TEST(KErrNone == animDll.Load(KAnimDLLName));
       
  1547 	animDll.Close();
       
  1548 	
       
  1549 	group.Close();
       
  1550 	bwin.Close();
       
  1551 	ws.Close();
       
  1552 	}
       
  1553 
       
  1554 void CTPanic::TestSpritePanicsL()
       
  1555 	{
       
  1556 	for(TInt test=1;test<4;test++)
       
  1557 		{
       
  1558 		TEST(iTest->TestWsPanicL(&DoSpritePanicTestL,EWservPanicSprite,test,(TAny*)iTest->iScreenNumber));
       
  1559 		}
       
  1560 	}
       
  1561 
       
  1562 /**
       
  1563 @SYMTestCaseID		GRAPHICS-WSERV-0475
       
  1564 
       
  1565 @SYMDEF             DEF118616
       
  1566 
       
  1567 @SYMTestCaseDesc    Test defect fixes to system panics 
       
  1568 
       
  1569 @SYMTestPriority    High
       
  1570 
       
  1571 @SYMTestStatus      Implemented
       
  1572 
       
  1573 @SYMTestActions     Check that various defect fixes to system panics are correct.
       
  1574 
       
  1575 @SYMTestExpectedResults Panics respond correctly
       
  1576 */
       
  1577 void CTPanic::TestSpriteActivatePanicL()
       
  1578 	{
       
  1579 	for(TInt test=1;test<3;test++)
       
  1580 		{
       
  1581 		TEST(iTest->TestWsPanicL(&DoTestSpriteActivatePanicL,EWservPanicNoSpriteMember,test,NULL));
       
  1582 		}
       
  1583 	}
       
  1584 
       
  1585 void CTPanic::TestMoveToGroupPanicsL()
       
  1586 	{
       
  1587 	TEST(iTest->TestWsPanicL(&DoMoveToGroupPanicTestL,EWservPanicOpcode,1,(TAny*)iTest->iScreenNumber));
       
  1588 	TEST(iTest->TestWsPanicL(&DoMoveToGroupPanicTestL,EWservPanicNotTopClient,2,(TAny*)iTest->iScreenNumber));
       
  1589 	}
       
  1590 
       
  1591 void CTPanic::TestDeleteScreenPanicL()
       
  1592 	{
       
  1593 #ifdef __WINS__
       
  1594 	TEST(iTest->TestWsPanicL(&DoDeleteScreenPanicTestL,EWservPanicGroupWinScreenDeviceDeleted,1,(TAny*)iTest->iScreenNumber));
       
  1595 	TEST(iTest->TestWsPanicL(&DoDeleteScreenPanicTestL,EWservPanicGroupWinScreenDeviceDeleted,2,(TAny*)iTest->iScreenNumber));
       
  1596 #endif
       
  1597 	}
       
  1598 
       
  1599 void CTPanic::TestWinHandleErrors()
       
  1600 	{
       
  1601 #ifdef __WINS__
       
  1602 	TEST(iTest->TestWsPanicL(&DoWinHandlePanicTestL,EWservPanicDuplicateHandle,1));
       
  1603 	TEST(iTest->TestWsPanicL(&DoWinHandlePanicTestL,EWservPanicDuplicateHandle,2));
       
  1604 	TEST(iTest->TestWsPanicL(&DoWinHandlePanicTestL,EWservPanicDuplicateHandle,3));
       
  1605 #endif
       
  1606 	TEST(iTest->TestWsPanicL(&DoWinHandlePanicTestL,EWservPanicNullHandle,4));
       
  1607 	}
       
  1608 
       
  1609 void CTPanic::TestGetEventErrors()
       
  1610 	{
       
  1611 	TEST(iTest->TestWsPanicL(&DoGetEventPanicTestL,EWservPanicUnsignalledEventData,1,(TAny*)iTest->iScreenNumber));
       
  1612 	TEST(iTest->TestWsPanicL(&DoGetEventPanicTestL,EWservPanicDescriptor,2,(TAny*)iTest->iScreenNumber));
       
  1613 	}
       
  1614 
       
  1615 void CTPanic::TestUnInitPanicL()
       
  1616 	{
       
  1617 	TEST(iTest->TestWsPanicL(&DoUnInitPanicTest,EWservPanicUninitialisedClient,0,(TAny*)iTest->iScreenNumber));
       
  1618 	}
       
  1619 
       
  1620 void CTPanic::ConstructL()
       
  1621 	{
       
  1622 	TheGc->Activate(*BaseWin->Win());
       
  1623 	TheGc->Clear();
       
  1624 	TheGc->SetBrushColor(TRgb::Gray16(12));
       
  1625 	TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
  1626 	TheGc->SetPenStyle(CGraphicsContext::ENullPen);
       
  1627 	TheGc->DrawRect(TRect(BaseWin->Win()->Size()));
       
  1628 	TheGc->Deactivate();
       
  1629 	TheGc->Activate(*TestWin->Win());
       
  1630 	TheGc->Clear();
       
  1631 	TheGc->SetBrushColor(TRgb::Gray16(4));
       
  1632 	TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
  1633 	TheGc->SetPenStyle(CGraphicsContext::ENullPen);
       
  1634 	TheGc->DrawRect(TRect(TestWin->Win()->Size()));
       
  1635 	TheGc->Deactivate();
       
  1636 //
       
  1637 	_LIT(KReportFullRom,"Warning full ROM, EikSrv present, panic dialogs may interfere with tests");
       
  1638 	_LIT(KReportGoodRom,"ROM OK, No EikSrv present");
       
  1639 	if (iTest->IsFullRomL())
       
  1640 		{
       
  1641 		INFO_PRINTF1(KReportFullRom);
       
  1642 		}
       
  1643 	else
       
  1644 		{
       
  1645 		INFO_PRINTF1(KReportGoodRom);
       
  1646 		}
       
  1647 	}
       
  1648 
       
  1649 void CTPanic::TestAlphaBlendingPanicL()
       
  1650 	{
       
  1651 	INFO_PRINTF1(_L("Masked transparency support has been removed."));
       
  1652 	}
       
  1653 	
       
  1654 void CTPanic::TestMismatchedCaptureCancelPanicL()
       
  1655 	{		
       
  1656 // Run this test in debug on emulator only.
       
  1657 // On a debug ROM the release version of the wserv.exe is included so the test can't be run as no panic happens. 
       
  1658 #if defined(_DEBUG) && defined(__WINS__)		
       
  1659 	TEST(iTest->TestWsPanicL(DoMismatchedCancelCaptureTest,EWservPanicDestroy,ECancelCaptureKey,(TAny*)iTest->iScreenNumber));
       
  1660 	TEST(iTest->TestWsPanicL(DoMismatchedCancelCaptureTest,EWservPanicDestroy,ECancelCaptureKeyUpAndDowns,(TAny*)iTest->iScreenNumber));
       
  1661 	TEST(iTest->TestWsPanicL(DoMismatchedCancelCaptureTest,EWservPanicDestroy,ECancelCaptureLongKey,(TAny*)iTest->iScreenNumber));
       
  1662 #endif
       
  1663 	}
       
  1664 
       
  1665 void CTPanic::RunTestCaseL(TInt /*aCurTestCase*/)
       
  1666 	{
       
  1667 	((CTPanicStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
       
  1668 	switch(++iTest->iState)
       
  1669 		{
       
  1670 /**
       
  1671 @SYMTestCaseID		GRAPHICS-WSERV-0259
       
  1672 
       
  1673 @SYMDEF             DEF081259
       
  1674 
       
  1675 @SYMTestCaseDesc    Test various system panics 
       
  1676 
       
  1677 @SYMTestPriority    High
       
  1678 
       
  1679 @SYMTestStatus      Implemented
       
  1680 
       
  1681 @SYMTestActions     Check that various system panics respond correctly 
       
  1682 
       
  1683 @SYMTestExpectedResults Panics respond correctly
       
  1684 */
       
  1685 		case 1:
       
  1686 			{
       
  1687 			((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0259"));
       
  1688 			iTest->LogSubTest(_L("TestCaptureKeyPanicsL"));
       
  1689 			TestCaptureKeyPanicsL();
       
  1690 			}
       
  1691 			break;
       
  1692 		case 2:
       
  1693 		    {
       
  1694 			iTest->LogSubTest(_L("TestEventPanicsL"));
       
  1695 			TestEventPanicsL();
       
  1696 		    }
       
  1697 		    break;
       
  1698 		case 3:
       
  1699 		    {
       
  1700 			iTest->LogSubTest(_L("TestComputeModePanicsL"));
       
  1701 			TestComputeModePanicsL();
       
  1702 		    }
       
  1703 		    break;
       
  1704 		case 4:
       
  1705 		    {
       
  1706 #ifdef __WINS__
       
  1707 //  Only running this under WINS as the tests are a bit excessive, firing off all sorts of illegal
       
  1708 // opcode/flag combinations, as well as buffers of random data.
       
  1709 // Currently on ARM builds they're failing with KErrOutOfMemory, probably running out of handles
       
  1710 // somewhere in the OS.
       
  1711 			iTest->LogSubTest(_L("TestMiscPanicsL"));
       
  1712 			TestMiscPanicsL();
       
  1713 #endif
       
  1714 		    }
       
  1715 		    break;
       
  1716 		case 5:
       
  1717 		    {
       
  1718 			iTest->LogSubTest(_L("TestGraphicsPanicsL"));
       
  1719 			TestGraphicsPanicsL();
       
  1720 		    }
       
  1721 		    break;
       
  1722 		case 6:
       
  1723 		    {
       
  1724 			iTest->LogSubTest(_L("TestTPtrPanicsL"));
       
  1725 			TestTPtrPanicsL();
       
  1726 		    }
       
  1727 		    break;
       
  1728 		case 7:
       
  1729 		    {
       
  1730 			iTest->LogSubTest(_L("TestOpcodePanicsL"));
       
  1731 			TestOpcodePanicsL();
       
  1732 		    }
       
  1733 		    break;
       
  1734 		case 8:
       
  1735 		    {
       
  1736 			iTest->LogSubTest(_L("TestScreenDevicePanicsL"));
       
  1737 			TestScreenDevicePanicsL();
       
  1738 		    }
       
  1739 		    break;
       
  1740 		case 9:
       
  1741 		    {
       
  1742 			iTest->LogSubTest(_L("TestMultiInitPanicL"));
       
  1743 			TestMultiInitPanicL();
       
  1744 			}
       
  1745 			break;
       
  1746 /**
       
  1747 @SYMTestCaseID		GRAPHICS-WSERV-0260
       
  1748 
       
  1749 @SYMDEF             DEF081259
       
  1750 
       
  1751 @SYMTestCaseDesc    Test various system panics 
       
  1752 
       
  1753 @SYMTestPriority    High
       
  1754 
       
  1755 @SYMTestStatus      Implemented
       
  1756 
       
  1757 @SYMTestActions     Check that various system panics respond correctly 
       
  1758 
       
  1759 @SYMTestExpectedResults Panics respond correctly
       
  1760 */
       
  1761 		case 10:
       
  1762 			{
       
  1763 			((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0260"));
       
  1764 			iTest->LogSubTest(_L("Panic 2"));
       
  1765 			TestSpritePanicsL();
       
  1766 			TestMoveToGroupPanicsL();
       
  1767 			}
       
  1768 			break;
       
  1769 /**
       
  1770 @SYMTestCaseID		GRAPHICS-WSERV-0261
       
  1771 
       
  1772 @SYMDEF             DEF081259
       
  1773 
       
  1774 @SYMTestCaseDesc    Test defect fixes to system panics 
       
  1775 
       
  1776 @SYMTestPriority    High
       
  1777 
       
  1778 @SYMTestStatus      Implemented
       
  1779 
       
  1780 @SYMTestActions     Check that various defect fixes to system panics are correct 
       
  1781 
       
  1782 @SYMTestExpectedResults Panics respond correctly
       
  1783 */			
       
  1784 		case 11:
       
  1785 			{
       
  1786 			((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0261"));
       
  1787 			_LIT(KPanicTest,"Defect Fixes (Pan.3)");
       
  1788 			iTest->LogSubTest(KPanicTest);
       
  1789 			TestDeletedParentPanicsL();
       
  1790 			TestHandleReUseL();
       
  1791 			TestDeleteScreenPanicL(); // DEF069809
       
  1792 			}
       
  1793 			break;
       
  1794 /**
       
  1795 @SYMTestCaseID		GRAPHICS-WSERV-097969-0001
       
  1796 
       
  1797 @SYMDEF             DEF097969
       
  1798 
       
  1799 @SYMTestCaseDesc    Test defect fixes to system panics 
       
  1800 
       
  1801 @SYMTestPriority    High
       
  1802 
       
  1803 @SYMTestStatus      Implemented
       
  1804 
       
  1805 @SYMTestActions     Check that various defect fixes to system panics are correct 
       
  1806 
       
  1807 @SYMTestExpectedResults Panics respond correctly
       
  1808 */			
       
  1809 		case 12:
       
  1810 			{
       
  1811 			((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-097969-0001"));
       
  1812 			_LIT(KPanicTest,"Server panic defect Fix (Pan.4)");
       
  1813 			iTest->LogSubTest(KPanicTest);
       
  1814 			TestUnInitPanicL();	// DEF097969
       
  1815 			}
       
  1816 			break;
       
  1817 		
       
  1818 		case 13:
       
  1819 			{
       
  1820 /**
       
  1821 @SYMTestCaseID		GRAPHICS-WSERV-0501
       
  1822 */
       
  1823 			((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0501"));
       
  1824 			_LIT(KPanicTest,"AlphaBlending Bitmap panic defect Fix (Pan.5)");
       
  1825 			iTest->LogSubTest(KPanicTest);
       
  1826 			TestAlphaBlendingPanicL();	// DEF112916
       
  1827 			}
       
  1828 			break;
       
  1829 		case 14:
       
  1830 			{		
       
  1831             ((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0472"));
       
  1832 			_LIT(KPanicTest,"Double construction panic test");
       
  1833 			iTest->LogSubTest(KPanicTest);
       
  1834 			TestDoubleConstructionL();	// DEF118618
       
  1835 			}
       
  1836 			break;
       
  1837 		case 15:
       
  1838 			{
       
  1839 			((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0475"));
       
  1840 			_LIT(KPanicTest, "RWsSprite Activate() without members panic test");
       
  1841 			iTest->LogSubTest(KPanicTest);
       
  1842 			TestSpriteActivatePanicL(); //DEF118616				
       
  1843 			}
       
  1844 			break;
       
  1845 /**
       
  1846 @SYMTestCaseID		GRAPHICS-WSERV-0497
       
  1847 
       
  1848 @SYMDEF             DEF133776
       
  1849 
       
  1850 @SYMTestCaseDesc     Test that a debug only panic occurs when an attempt
       
  1851  is made to cancel a key capture using the wrong cancel capture API.
       
  1852 
       
  1853 @SYMTestPriority    High
       
  1854 
       
  1855 @SYMTestStatus      Implemented
       
  1856 
       
  1857 @SYMTestActions     Check that calling the each RWindowGroup::CancelCapture***() API
       
  1858  using the handle returned from a mismatched RWindowGroup::Capture***() call causes
       
  1859  a debug only panic. Tests each of the three RWindowGroup::CancelCapture***() APIs.
       
  1860 
       
  1861 @SYMTestExpectedResults Panics respond correctly in debug only.
       
  1862 */			
       
  1863 		case 16:
       
  1864 			{
       
  1865 			((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0497"));
       
  1866 			_LIT(KPanicTest,"TestMismatchedCaptureCancelPanicL");
       
  1867 			iTest->LogSubTest(KPanicTest);
       
  1868 			TestMismatchedCaptureCancelPanicL();				
       
  1869 			}
       
  1870 			break;			
       
  1871 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
       
  1872 		case 17:
       
  1873 			{
       
  1874 			_LIT(KPanicTest, "Non-Redraw Drawing inside Redrawer Panic Test");
       
  1875 			iTest->LogSubTest(KPanicTest);
       
  1876 			TestNonRedrawRedrawerL();
       
  1877 			}			
       
  1878 #endif			
       
  1879 		default:
       
  1880             		((CTPanicStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
       
  1881 			((CTPanicStep*)iStep)->CloseTMSGraphicsStep();
       
  1882 			TestComplete();
       
  1883 			break;
       
  1884 		}
       
  1885 	((CTPanicStep*)iStep)->RecordTestResultL();
       
  1886 	}
       
  1887 
       
  1888 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
       
  1889 LOCAL_C TInt DoTestNonRedrawRedrawerL(TInt /* aInt */, TAny * /* aPtr */)
       
  1890 	{
       
  1891 	CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
       
  1892 	CleanupStack::PushL(scheduler);
       
  1893 	CActiveScheduler::Install(scheduler);
       
  1894 	
       
  1895 	RWsSession session;
       
  1896 	User::LeaveIfError(session.Connect());
       
  1897 	
       
  1898 	CWsScreenDevice *screenDevice = new (ELeave)CWsScreenDevice(session);
       
  1899 	User::LeaveIfError(screenDevice->Construct ());
       
  1900 	CWindowGc *gc;
       
  1901 	User::LeaveIfError(screenDevice->CreateContext(gc));
       
  1902 	
       
  1903 	CNonRedrawWin *nonRedrawWin=CNonRedrawWin::NewL(session, gc);	
       
  1904 	nonRedrawWin->Invalidate(); 
       
  1905 	CActiveScheduler::Start();
       
  1906 	User::After(2000000); // so the Redrawer has a chance to run 
       
  1907 	CActiveScheduler::Stop();
       
  1908 	delete gc;
       
  1909 	delete screenDevice;
       
  1910 	session.Close();
       
  1911 	CleanupStack::PopAndDestroy(scheduler);
       
  1912 	return(EWsExitReasonBad);
       
  1913 	}
       
  1914 
       
  1915 /**
       
  1916 @SYMTestCaseID		GRAPHICS-WSERV-0121808
       
  1917 @SYMDEF             DEF121808: No more Non-Redraw drawing for NGA (test added during DEF134308) 
       
  1918 @SYMTestCaseDesc    Test defect fixes to system panics 
       
  1919 @SYMTestPriority    High
       
  1920 @SYMTestStatus      Implemented
       
  1921 @SYMTestActions     Check that WServ panics a client which uses Non-Redraw drawing in the Redrawer.
       
  1922 @SYMTestExpectedResults Panics respond correctly
       
  1923 */
       
  1924 void CTPanic::TestNonRedrawRedrawerL()
       
  1925 	{
       
  1926 	TEST(iTest->TestWsPanicL(&DoTestNonRedrawRedrawerL,EWservPanicWindowBeginRedrawNotCalled,NULL,NULL));
       
  1927 	}
       
  1928 
       
  1929 CNonRedrawWin::CRedrawer::CRedrawer(CNonRedrawWin* aWd) :
       
  1930 	CActive(CActive::EPriorityStandard), iWd(aWd){
       
  1931 	CActiveScheduler::Add(this);
       
  1932 	HandleRedrawEvent();	
       
  1933 }
       
  1934 
       
  1935 CNonRedrawWin::CRedrawer::~CRedrawer(){
       
  1936 	Cancel();
       
  1937 }
       
  1938 
       
  1939 void CNonRedrawWin::CRedrawer::HandleRedrawEvent(){
       
  1940 	iWd->GetSession().RedrawReady(&iStatus);
       
  1941 	SetActive();
       
  1942 }
       
  1943 
       
  1944 void CNonRedrawWin::CRedrawer::RunL(){
       
  1945 	TWsRedrawEvent redrawEvent;
       
  1946 	iWd->GetSession().GetRedraw(redrawEvent);	
       
  1947 	iWd->Redraw();
       
  1948 	HandleRedrawEvent();
       
  1949 }
       
  1950 
       
  1951 void CNonRedrawWin::CRedrawer::DoCancel(){
       
  1952 	iWd->GetSession().RedrawReadyCancel();
       
  1953 }
       
  1954 
       
  1955 CNonRedrawWin* CNonRedrawWin::NewL(RWsSession &aSession, CWindowGc *aGc){
       
  1956 	CNonRedrawWin* self=new(ELeave)CNonRedrawWin(aSession, aGc);
       
  1957 	CleanupStack::PushL(self);
       
  1958 	self->ConstrucL();
       
  1959 	CleanupStack::Pop(self);
       
  1960 	return self;
       
  1961 }
       
  1962 
       
  1963 CNonRedrawWin::CNonRedrawWin(RWsSession &aSession, CWindowGc *aGc):
       
  1964 	iSession(aSession), iGc(aGc){}
       
  1965 
       
  1966 CNonRedrawWin::~CNonRedrawWin(){
       
  1967 	delete iRedrawer;
       
  1968 	iWd.Close();
       
  1969 	iWdGrp.Close();	
       
  1970 }
       
  1971 
       
  1972 void CNonRedrawWin::Redraw(){
       
  1973 	// This is a Non-Redraw Drawing Redrawer; BeginRedraw()/EndRedraw()
       
  1974 	// have been intentionally omitted.
       
  1975 	iGc->Activate(iWd);	
       
  1976 	iGc->SetBrushColor(TRgb(255,0,0));
       
  1977 	iGc->SetPenColor(KRgbBlue);
       
  1978 	iGc->SetPenSize(TSize(10,20));
       
  1979 	iGc->DrawRect(TRect(TPoint(10,10),TPoint(50,50)));	
       
  1980 	iGc->Deactivate();
       
  1981 	iSession.Finish();			
       
  1982 }
       
  1983 
       
  1984 RWsSession &CNonRedrawWin::GetSession(){return iSession;}
       
  1985 
       
  1986 void CNonRedrawWin::Invalidate(){iWd.Invalidate();}
       
  1987 
       
  1988 void CNonRedrawWin::ConstrucL(){
       
  1989 	iWdGrp=RWindowGroup(iSession);	
       
  1990 	iWdGrp.Construct((TUint32)this,ETrue);
       
  1991 	_LIT(KWndGrpName,"NonRedrawWndGrp");
       
  1992 	iWdGrp.SetName(KWndGrpName);	
       
  1993 	iWd=RWindow(iSession);	
       
  1994 	iWd.Construct(iWdGrp, 0x101);	
       
  1995 	User::LeaveIfError(iWd.SetExtentErr(TPoint(0,0),TSize(150,150)));
       
  1996 	iWd.SetBackgroundColor(KRgbWhite);
       
  1997 	iWd.SetOrdinalPosition(0);	
       
  1998 	iWd.Activate();	
       
  1999 	iRedrawer=new(ELeave) CRedrawer(this);
       
  2000 }
       
  2001 #endif
       
  2002 
       
  2003 TInt RUnInitalisedConnect::Connect(const TDesC &aName, const TVersion &aVersion)
       
  2004 	{
       
  2005 	return CreateSession(aName, aVersion, 255);
       
  2006 	}
       
  2007 
       
  2008 TInt RUnInitalisedConnect::Send(const TInt aMsg)
       
  2009 	{
       
  2010 	return SendReceive(aMsg);
       
  2011 	}
       
  2012 
       
  2013 __WS_CONSTRUCT_STEP__(Panic)
       
  2014 #pragma warning( disable : 4505 )