First public contribution.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Test various cases of Wserv panicing client apps
21 @internalComponent - Internal Symbian test code
25 #include "../tlib/testbase.h"
27 #define TEST_BITMAP _L("Z:\\WSTEST\\WSAUTOTEST.MBM")
29 class RWsSessionHacker : public RWsSession
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);};
39 class RWsBufferHacker // copy of original data structure to access buffer data
43 CWsGraphic::CManager* iManager;
50 TInt iDirectAcessCount;
51 RArray<TInt> iBitmapArray;
52 TBool iInvalidBitmapArray;
55 CTPanic::CTPanic(CTestStep* aStep):
56 CTWsGraphicsBase(aStep)
64 LOCAL_C TInt DoDeletedParentTest(TInt aInt, TAny *aScreenNumber)
67 User::LeaveIfError(ws.Connect());
68 // point to correct screen
69 CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
70 User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
72 RWindowGroup group(ws);
73 User::LeaveIfError(group.Construct(888));
74 group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close
79 User::LeaveIfError(win1.Construct(group,1));
81 User::LeaveIfError(win2.Construct(win1,2));
83 win2.SetExtent(TPoint(1,2),TSize(3,4));
87 return(EWsExitReasonBad);
90 LOCAL_C void ReuseWindow(RWsSession& aWs,RWindowGroup& aGroup,RWindow aCopyWin,RWindow* aPtrWin)
94 User::LeaveIfError(win.Construct(aGroup,17));
95 aCopyWin.SetExtent(TPoint(1,2),TSize(3,4));
98 LOCAL_C void ReuseGroupWindow(RWsSession& aWs,RWindowGroup aCopyWin,RWindowGroup* aPtrWin)
101 RWindowGroup group(aWs);
102 User::LeaveIfError(group.Construct(889));
103 group.EnableReceiptOfFocus(EFalse);
104 aCopyWin.EnableReceiptOfFocus(EFalse);
107 LOCAL_C void ReuseSprite(RWsSession& aWs,RWindow& aWin,RWsSprite aCopySprite,RWsSprite* aPtrSprite)
110 RWsSprite sprite(aWs);
111 sprite.Construct(aWin,TPoint(0,0),0);
112 aCopySprite.SetPosition(TPoint(22,22));
115 LOCAL_C void ReusePointerCursor(RWsSession& aWs,RWsPointerCursor aCopyCursor,RWsPointerCursor* aPtrCursor)
118 RWsPointerCursor cursor(aWs);
120 aCopyCursor.Activate();
123 LOCAL_C TInt DoHandleReUse(TInt aInt, TAny *aScreenNumber)
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
133 User::LeaveIfError(win.Construct(group,1));
136 case 2: //WS_HANDLE_WINDOW
137 ReuseWindow(ws,group,win,&win);
139 case 3: //WS_HANDLE_GROUP_WINDOW
140 ReuseGroupWindow(ws,group,&group);
142 case 4: //WS_HANDLE_SPRITE
144 RWsSprite sprite(ws);
145 sprite.Construct(win,TPoint(0,0),0);
146 ReuseSprite(ws,win,sprite,&sprite);
149 case 5: //WS_HANDLE_POINTER_CURSOR
151 RWsPointerCursor cursor(ws);
153 ReusePointerCursor(ws,cursor,&cursor);
158 return(EWsExitReasonBad);
161 LOCAL_C TInt DoScreenDevicePanicTest(TInt aInt, TAny *aScreenNumber)
164 User::LeaveIfError(ws.Connect());
166 CWsScreenDevice *scrdev=new(ELeave) CWsScreenDevice(ws);
167 User::LeaveIfError(scrdev->Construct((TInt)aScreenNumber));
169 RWindowGroup group(ws);
170 User::LeaveIfError(group.Construct(888));
171 group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close
173 User::LeaveIfError(win.Construct(group, 1));
175 CFbsBitmap *bitmap=new(ELeave) CFbsBitmap;
179 scrdev->CopyScreenToBitmap(bitmap);
182 scrdev->CopyScreenToBitmap(bitmap,TRect(0,0,10,10));
185 return(EWsExitReasonFinished);
188 return(EWsExitReasonBad);
191 LOCAL_C TInt DoOpcodeTests(TInt aInt, TAny *aScreenNumber)
194 User::LeaveIfError(ws.Connect());
196 CWsScreenDevice *scrdev=new(ELeave) CWsScreenDevice(ws);
197 User::LeaveIfError(scrdev->Construct((TInt)aScreenNumber));
199 RWindowGroup group(ws);
200 User::LeaveIfError(group.Construct(888));
201 group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close
203 User::LeaveIfError(win.Construct(group, 1));
206 scrdev->CreateContext(gc);
210 ws.TestWrite(ws.WsHandle(),9999,NULL,0);
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.
226 ws.TestWrite(scrdev->WsHandle(),9999,NULL,0);
230 CWsBitmap *bitmap=new(ELeave) CWsBitmap(ws);
231 bitmap->Create(TSize(10,10),EGray4);
232 ws.TestWrite(bitmap->WsHandle(),9999,NULL,0);
236 ws.TestWrite(win.WsHandle(),9999,NULL,0);
239 ws.TestWrite(group.WsHandle(),9999,NULL,0);
243 RWsSprite sprite(ws);
244 sprite.Construct(win,TPoint(0,0),0);
245 ws.TestWrite(sprite.WsHandle(),9999,NULL,0);
249 return(EWsExitReasonFinished);
252 return(EWsExitReasonBad);
255 TInt DoGraphicsPanicTest(RWsSession& aWs, RWindow& aRWin, RDrawableWindow* aDrawWin, CWindowGc* aGc, CFbsFont* aFont, TInt aTest, TInt aSubTest, TBool aInRedraw, TBool aNeedsValidating)
257 if (aInRedraw || aNeedsValidating)
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
266 TRect rect01(0,0,1,1);
276 TWsGcCmdBoxText boxText(rect01,0,CGraphicsContext::ELeft,0,0x800000,1);
277 aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawBoxText,&boxText,sizeof(boxText));
282 TWsGcCmdDrawText dt(point00,600);
283 aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawText,&dt,sizeof(dt));
288 TWsGcCmdBoxTextOptimised1 dt(rect01,0,600);
289 aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawBoxTextOptimised1,&dt,sizeof(dt));
294 TWsGcCmdDrawTextVertical dt(point00,600,EFalse);
295 aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawTextVertical,&dt,sizeof(dt));
300 TWsGcCmdBoxTextVertical dt(rect01);
302 aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawBoxTextVertical,&dt,sizeof(dt));
306 return(EWsExitReasonFinished);
315 opcode=EWsGcOpGdiBlt2;
318 opcode=EWsGcOpGdiWsBlt2;
321 return(EWsExitReasonFinished);
323 TWsGcCmdGdiBlt2 gdiBlit(point00,0xBADBAD);
324 aWs.TestWrite(aGc->WsHandle(),opcode,&gdiBlit,sizeof(gdiBlit));
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));
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;
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;
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;
360 switch(bmpMode%KNumBadBmpModes)
368 case 2: // Leave them both bad
373 case KPanicIndexMasked:
375 TWsGcCmdBltMasked gdiBlitMasked(point00,bmp1,rect01,bmp2,EFalse);
376 aWs.TestWrite(aGc->WsHandle(),opcodeBlt,&gdiBlitMasked,sizeof(gdiBlitMasked));
379 case KPanicIndexDraw:
381 TWsGcCmdDrawBitmapMasked maskedBitmap(rect01,bmp1,rect01,bmp2,EFalse);
382 aWs.TestWrite(aGc->WsHandle(),opcodeDraw,&maskedBitmap,sizeof(maskedBitmap));
385 case KPanicIndexAlphaBlend:
387 TWsGcCmdAlphaBlendBitmaps alphaBlend(point00,bmp1,rect01,bmp2,point00);
388 aWs.TestWrite(aGc->WsHandle(),EWsGcOpGdiAlphaBlendBitmaps,&alphaBlend,sizeof(alphaBlend));
392 return(EWsExitReasonFinished);
401 TWsClCmdCreateBitmap createBitmap;
402 createBitmap.handle=0xB0D;
403 aWs.TestWrite(aWs.WsHandle(),EWsClOpCreateBitmap,&createBitmap,sizeof(createBitmap));
408 TInt badBrush=0xBADB3054;
409 aWs.TestWrite(aGc->WsHandle(),EWsGcOpUseBrushPattern,&badBrush,sizeof(badBrush));
414 TWsGcCmdDrawBitmap drawBitmap(point00,0xBADBAD);
415 aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawBitmap,&drawBitmap,sizeof(drawBitmap));
419 return(EWsExitReasonFinished);
432 return(EWsExitReasonFinished);
434 aWs.TestWrite(aGc->WsHandle(),opcode,NULL,0);
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;
462 TInt bufDataLen=bufPoints*sizeof(TPoint);
463 if (polyMode==EPanicPolyModePolyLine)
464 bufDataLen+=sizeof(TWsGcCmdDrawPolyLine);
466 bufDataLen+=sizeof(TWsGcCmdDrawPolygon);
467 TAny* bufData=User::AllocL(bufDataLen);
470 if (polyMode==EPanicPolyModePolyLine)
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;
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;
487 const TPoint* endPtr=pointPtr+bufPoints;
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
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;
511 polyData->index=startPoly.totalNumPoints;
514 polyData->index=-123;
517 polyData->numPoints=startPoly.totalNumPoints+1;
520 return(EWsExitReasonFinished);
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));
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
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));
543 TWsGcCmdSegmentedDrawPolygonData iPolyData;
546 polyParams.iPoints[0].iX=1;
547 polyParams.iPoints[0].iY=1;
548 polyParams.iPoints[1].iX=2;
549 polyParams.iPoints[1].iY=2;
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);
562 return(EWsExitReasonFinished);
563 aGc->Activate(*aDrawWin); // Double activate
567 return(EWsExitReasonFinished);
568 aGc->DrawText(_L("No font"),point00);
572 return(EWsExitReasonFinished);
573 aGc->SetBrushStyle(CGraphicsContext::EPatternedBrush);
574 aGc->DrawRect(rect01);
579 return(EWsExitReasonFinished);
581 TPtrC bigAndbad(NULL,5000); // Will go through remote descriptor fetching code
582 aGc->DrawText(bigAndbad,point00);
588 return(EWsExitReasonFinished);
589 TInt badHandle=0xDEADBAD;
590 aWs.TestWrite(aGc->WsHandle(),EWsGcOpUseFont,&badHandle,sizeof(badHandle));
591 aGc->DrawText(_L("BOO!"),point00);
598 return(EWsExitReasonBad);
601 LOCAL_C TInt GraphicsPanicTest(TInt aInt, TAny* aPanicParams)
603 CTPanic::TPanicParams* panicParams=static_cast<CTPanic::TPanicParams*>(aPanicParams);
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.
610 const TBool useTransWin = panicParams->iRedrawMode==EPanicRedrawModeTransRedraw;
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.
617 const TBool inRedraw =
618 panicParams->iRedrawMode==EPanicRedrawModeNormalRedraw ||
619 panicParams->iRedrawMode==EPanicRedrawModeTransRedraw ||
620 panicParams->iRedrawMode==EPanicRedrawModeInvisRedraw;
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.
628 const TBool invisWin = panicParams->iRedrawMode==EPanicRedrawModeInvisRedraw;
631 User::LeaveIfError(ws.Connect());
633 CWsScreenDevice* scrdev=new(ELeave) CWsScreenDevice(ws);
634 User::LeaveIfError(scrdev->Construct(panicParams->iScreen));
636 RWindowGroup group(ws);
637 User::LeaveIfError(group.Construct(888));
638 group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close
639 RDrawableWindow* drawWin;
641 RBackedUpWindow bwin(ws);
642 TBool needsValidating=EFalse;
643 if (useTransWin || inRedraw || invisWin)
646 needsValidating=ETrue;
647 User::LeaveIfError(rwin.Construct(group,1));
650 rwin.SetTransparencyAlphaChannel();
655 // EPanicRedrawModeBackedUpWindow case
657 User::LeaveIfError(bwin.Construct(group, EGray4, 1));
659 const TSize testWinSize(100,100);
660 User::LeaveIfError(drawWin->SetSizeErr(testWinSize));
662 drawWin->SetPosition(TPoint(-testWinSize.iWidth,-testWinSize.iHeight));
665 scrdev->CreateContext(gc);
666 gc->Activate(*drawWin);
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)
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.
680 drawWin->SetPosition(TPoint(0,0));
682 ret=DoGraphicsPanicTest(ws,rwin,drawWin,gc,font,aInt,panicParams->iSubTest,inRedraw,needsValidating);
686 LOCAL_C TInt DoMiscPanicTest(TInt aSubTest, TAny* )
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)
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)
705 if(msgFunc == EWservMessFinish) //RWsSession::Finish() doesn't panic
706 User::Panic(KWSERV, 0); //simulate a "successful" wserv panic to skip the sub test
709 msgFunc|=EPanicWservMessAsynchronousService;
712 msgFunc|=EPanicWservMessAnimDllAsyncCommand;
715 TInt sendItErr=KErrNone;
718 if (msgFunc&EPanicWservMessAsynchronousService)
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;
725 sendItErr=wshacker.PanicItSendReceive(msgFunc);
729 TPtrC8 badDesc(reinterpret_cast<const TUint8*>(0xDEAD),100);
731 ipcArgs.Set(0,&badDesc);
732 if (msgFunc&EPanicWservMessAsynchronousService)
734 sendItErr=wshacker.PanicItSend(msgFunc,ipcArgs);
735 msgFunc&=~EPanicWservMessAsynchronousService;
737 sendItErr=wshacker.PanicItSendReceive(msgFunc,ipcArgs);
739 if (sendItErr==KErrNotSupported)
740 wshacker.PanicItSendReceive(EWservMessCommandBuffer); // Should always panic
744 // Fill Wserv buffer with random garbage
745 RWsBufferHacker* hacker=reinterpret_cast<RWsBufferHacker*>(wshacker.WsBuffer());
746 TInt64 seed=aSubTest;
748 const TInt KMaxRandPanicRetrys=1000;
751 const TInt maxLen=hacker->iBuf.MaxLength()-1;
752 TInt writeLen=1+Math::Rand(seed)%maxLen;
755 TUint8 randData=static_cast<TUint8>(Math::Rand(seed));
756 hacker->iBuf.Append(randData);
760 } while(retries<KMaxRandPanicRetrys);
762 return(EWsExitReasonBad);
765 LOCAL_C TInt DoCMPanicTest(TInt aInt, TAny *aScreenNumber)
768 User::LeaveIfError(ws.Connect());
769 // use correct screen
771 CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
772 User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
777 ws.ComputeMode((RWsSession::TComputeMode)543);
781 return(EWsExitReasonBad);
784 #if defined(_DEBUG) && defined(__WINS__)
785 LOCAL_C TInt DoCKPanicTest(TInt aInt, TAny *aScreenNumber)
788 User::LeaveIfError(ws.Connect());
789 // use correct screen
791 CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
792 User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
794 RWindowGroup group(ws);
795 group.Construct(888);
796 group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close
800 group.CancelCaptureKey(345);
804 return(EWsExitReasonBad);
808 LOCAL_C TInt DoEventPanicTest(TInt aInt, TAny *aScreenNumber)
811 User::LeaveIfError(ws.Connect());
812 // use correct screen
814 CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
815 User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
822 ws.EventReady(&stat);
823 ws.EventReady(&stat);
824 User::After(15000000); //15secs
828 return(EWsExitReasonBad);
831 LOCAL_C TInt DoTBufPtrTests(TInt aInt, TAny *aScreenNumber)
834 User::LeaveIfError(ws.Connect());
835 // use correct screen
837 CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
838 User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
844 TWsClCmdLoadAnimDll dt;
846 ws.TestWrite(ws.WsHandle(),EWsClOpCreateAnimDll,&dt,sizeof(dt));
852 ws.TestWrite(ws.WsHandle(),EWsClOpLogMessage,&len,sizeof(len));
857 RWindowGroup group(ws);
858 group.Construct(888);
859 group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close
863 ws.TestWrite(group.WsHandle(),EWsWinOpSetName,&dt,sizeof(dt));
868 RWindowGroup group(ws);
869 group.Construct(888);
870 group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close
873 dt.ptr=(TDesC *)0x1234;
874 ws.TestWrite(group.WsHandle(),EWsWinOpSetName,&dt,sizeof(dt));
879 return(EWsExitReasonBad);
882 #if defined(_DEBUG) && defined(__WINS__)
883 LOCAL_C TInt DoMismatchedCancelCaptureTest(TInt aInt, TAny *aScreenNumber)
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
894 User::LeaveIfError(win.Construct(group, 1));
900 case CTPanic::ECancelCaptureKey:
901 // Create a capture that is not matched to CancelCaptureKey()
902 capture = group.CaptureLongKey(' ','a',0,0,2,ELongCaptureNormal);
904 group.CancelCaptureKey(capture);
906 case CTPanic::ECancelCaptureKeyUpAndDowns:
907 // Create a capture that is not matched to CancelCaptureKeyUpAndDowns()
908 capture = group.CaptureKey('A',0,0);
910 group.CancelCaptureKeyUpAndDowns(capture);
912 case CTPanic::ECancelCaptureLongKey:
913 // Create a capture that is not matched to CancelCaptureLongKey()
914 capture = group.CaptureKeyUpAndDowns(EStdKeySpace,0,0);
916 group.CancelCaptureLongKey(capture);
921 return(EWsExitReasonBad);
925 class ROverrideProtectionInRSessionBase : public RWsSession
928 inline TInt SendReceive(TInt aFunction,TAny *aPtr) const {return(RSessionBase::SendReceive(aFunction,TIpcArgs(aPtr)));};
931 LOCAL_C TInt DoMultiInitPanicTest(TInt , TAny *aScreenNumber)
933 ROverrideProtectionInRSessionBase ws;
934 User::LeaveIfError(ws.Connect());
936 // use correct screen
938 CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
939 User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
941 RWindowGroup group(ws);
942 group.Construct(888);
943 group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close
945 ws.SendReceive(EWservMessInit,NULL);
947 return(EWsExitReasonBad);
950 LOCAL_C TInt DoSpritePanicTestL(TInt aTest, TAny *aScreenNumber)
953 User::LeaveIfError(ws.Connect());
954 // use correct screen
956 CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
957 User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
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;
968 win.SetCustomPointerCursor(*cursor);
971 ws.SetSystemPointerCursor(*cursor,0);
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()));
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);
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);
1009 return(EWsExitReasonBad);
1013 LOCAL_C TInt DoDoubleConstructionTestL(TInt aTest, TAny *aScreenNumber)
1016 User::LeaveIfError(ws.Connect());
1018 // use correct screen
1020 CWsScreenDevice* screen = new(ELeave) CWsScreenDevice(ws);
1021 User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
1023 RWindowGroup group(ws);
1024 User::LeaveIfError(group.Construct(890, EFalse));
1025 RBlankWindow bwin(ws);
1026 User::LeaveIfError(bwin.Construct(group,900));
1032 RWsSprite sprite = RWsSprite(ws);
1033 User::LeaveIfError(sprite.Construct(bwin,TPoint(),0));
1034 sprite.Construct(bwin,TPoint(),0); //should panic
1040 RWsPointerCursor cursor(ws);
1041 User::LeaveIfError(cursor.Construct(0));
1042 cursor.Construct(0); //should panic
1048 RSoundPlugIn click(ws);
1049 User::LeaveIfError(click.Construct());
1050 click.Construct(); //should panic
1056 RWindowGroup windowgroup(ws);
1057 User::LeaveIfError(windowgroup.Construct(901));
1058 windowgroup.Construct(902); //should panic
1059 windowgroup.Close();
1065 User::LeaveIfError(win.Construct(group,902));
1066 win.Construct(group,903); //should panic
1072 RBlankWindow win(ws);
1073 User::LeaveIfError(win.Construct(group,902));
1074 win.Construct(group,903); //should panic
1080 RBackedUpWindow win(ws);
1081 User::LeaveIfError(win.Construct(group,EGray4,902));
1082 win.Construct(group,EGray4,903); //should panic
1088 RAnimDll animDll=RAnimDll(ws);
1089 User::LeaveIfError(animDll.Load(KAnimDLLName));
1090 animDll.Load(KAnimDLLName); //should panic
1096 CWindowGc *gc = new(ELeave) CWindowGc(screen);
1097 User::LeaveIfError(gc->Construct());
1098 gc->Construct(); //should panic
1104 CWsScreenDevice* screendevice = new (ELeave) CWsScreenDevice(ws);
1105 User::LeaveIfError(screendevice->Construct());
1106 screendevice->Construct(); //should panic
1107 delete screendevice;
1114 return(EWsExitReasonBad);
1118 /** Checks that activating a sprite without members will panic.
1120 LOCAL_C TInt DoTestSpriteActivatePanicL(TInt aTest, TAny *aScreenNumber)
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));
1135 RWsSprite sprite = RWsSprite(ws);
1136 User::LeaveIfError(sprite.Construct(group,TPoint(),0));
1137 sprite.Activate(); //should panic here
1143 RWsSprite sprite = RWsSprite(ws);
1144 User::LeaveIfError(sprite.Construct(bwin,TPoint(),0));
1145 sprite.Activate(); //should panic here
1150 return(EWsExitReasonBad);
1153 /** Checks that activating a RWindow before calling EnableAdvancedPointers will panic the client.
1155 LOCAL_C TInt DoTestAdvancePointerActivatePanicL(TInt /*aTest*/,TAny *aScreenNumber)
1158 User::LeaveIfError(ws.Connect());
1160 CWsScreenDevice *scrdev=new(ELeave) CWsScreenDevice(ws);
1161 User::LeaveIfError(scrdev->Construct((TInt)aScreenNumber));
1163 RWindowGroup group(ws);
1164 User::LeaveIfError(group.Construct(888));
1166 User::LeaveIfError(win.Construct(group, 1));
1168 win.EnableAdvancedPointers(); // This will panic
1170 return(EWsExitReasonBad);
1174 LOCAL_C TInt DoMoveToGroupPanicTestL(TInt aTest, TAny *aScreenNumber)
1177 User::LeaveIfError(ws.Connect());
1178 // use correct screen
1180 CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
1181 User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
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();
1191 RWindowTreeNode* win=&group;
1192 ((RWindowBase*)win)->MoveToGroup(id);
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);
1206 return(EWsExitReasonBad);
1209 LOCAL_C TInt DoGetEventPanicTestL(TInt aTest, TAny *aScreenNumber)
1212 User::LeaveIfError(ws.Connect());
1217 TPckgBuf<TWsEvent> event;
1218 ws.TestWrite(ws.WsHandle(),EWsClOpGetEvent,&event,0);
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);
1236 return(EWsExitReasonBad);
1239 LOCAL_C TInt DoWinHandlePanicTestL(TInt aTest, TAny *)
1242 User::LeaveIfError(ws.Connect());
1243 RWindowGroup group1(ws);
1244 RWindowGroup group2(ws);
1250 User::LeaveIfError(group1.Construct(888));
1251 User::LeaveIfError(group2.Construct(888));
1254 User::LeaveIfError(group1.Construct(777));
1255 User::LeaveIfError(win1.Construct(group1,888));
1256 User::LeaveIfError(win2.Construct(group1,888));
1259 User::LeaveIfError(group1.Construct(777));
1260 User::LeaveIfError(win1.Construct(group1,777));
1263 User::LeaveIfError(group1.Construct(777));
1264 User::LeaveIfError(win1.Construct(group1,0));
1268 return(EWsExitReasonBad);
1272 LOCAL_C TInt DoDeleteScreenPanicTestL(TInt aTest, TAny *aScreenNumber)
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.
1280 User::LeaveIfError(ws.Connect());
1281 // point to correct screen
1282 CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
1283 User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
1285 RWindowGroup group(ws);
1286 User::LeaveIfError(group.Construct(888));
1287 group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close
1290 // Test 1: deleting screen then modifying screen change events is illegal
1293 delete screen, screen=NULL;
1294 group.EnableScreenChangeEvents();
1297 // Test 2: deleting screen then setting window group name is illegal
1300 delete screen, screen=NULL;
1301 _LIT(KPanicTest, "PanicTest");
1302 group.SetName(KPanicTest);
1307 return(EWsExitReasonBad);
1311 LOCAL_C TInt DoUnInitPanicTest(TInt , TAny *)
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");
1318 RUnInitalisedConnect myUnInit;
1320 User::LeaveIfError(myUnInit.Connect(KServerName(), version));
1321 myUnInit.Send(EWservMessCommandBuffer);
1323 return(EWsExitReasonBad);
1326 void CTPanic::TestScreenDevicePanicsL()
1328 TEST(iTest->TestWsPanicL(&DoScreenDevicePanicTest,EWservPanicBitmap,1,(TAny*)iTest->iScreenNumber));
1330 TEST(iTest->TestWsPanicL(&DoScreenDevicePanicTest,EWservPanicBitmap,2,(TAny*)iTest->iScreenNumber));
1333 void CTPanic::TestMiscPanicsL()
1335 TBool finished=EFalse;
1339 const TBool result = iTest->TestWsPanicL(&DoMiscPanicTest, EWservNoPanic, index, NULL, &finished);
1342 INFO_PRINTF2(_L("TestMiscPanicsL %d failed"), index);
1349 void CTPanic::LogHeapInfo()
1351 _LIT(KInfoHeapSummary," WsHeap - Count=%d,Total=%d,Free=%d,Max free=%d");
1352 TPckgBuf<TWsDebugHeapInfo> heapInfo;
1353 TheClient->iWs.DebugInfo(EWsDebugInfoHeap,heapInfo);
1355 infoBuf.Format(KInfoHeapSummary,heapInfo().iCount,heapInfo().iTotal,heapInfo().iAvailable,heapInfo().iLargestAvailable);
1356 INFO_PRINTF1(infoBuf);
1359 void CTPanic::TestGraphicsPanicsL(TClientPanic aExitReason, TInt aIndex, CTPanic::TPanicParams* aPanicParams)
1361 TBool finished=EFalse;
1362 aPanicParams->iSubTest=0;
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);
1369 // uncomment for detailed view of which sub-test failed
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++;
1376 iTest->CloseAllPanicWindows();
1379 void CTPanic::TestGraphicsPanicsL(TPanicRedrawMode aRedrawMode)
1381 CTPanic::TPanicParams pp;
1382 pp.iScreen=iTest->iScreenNumber;
1383 pp.iRedrawMode=aRedrawMode;
1384 static TClientPanic expectedPanics[]=
1386 EWservPanicBufferPtr,
1391 EWservPanicBadPolyData,
1392 EWservPanicBadPolyData,
1394 EWservPanicGcActive,
1397 EWservPanicDescriptor,
1399 EWservNoPanic, // Marks the end of the list
1402 TClientPanic expectedPanic;
1403 while((expectedPanic=expectedPanics[panicIndex++])!=EWservNoPanic)
1405 TestGraphicsPanicsL(expectedPanic,panicIndex,&pp);
1409 void CTPanic::TestGraphicsPanicsL()
1411 TestGraphicsPanicsL(EPanicRedrawModeBackedUpWindow);
1412 TestGraphicsPanicsL(EPanicRedrawModeNormalRedraw);
1413 if (TransparencySupportedL()==KErrNone)
1415 TestGraphicsPanicsL(EPanicRedrawModeTransRedraw);
1417 TestGraphicsPanicsL(EPanicRedrawModeInvisRedraw);
1420 void CTPanic::TestDeletedParentPanicsL()
1422 TEST(iTest->TestWsPanicL(&DoDeletedParentTest,EWservPanicParentDeleted,1,(TAny*)iTest->iScreenNumber));
1425 void CTPanic::TestHandleReUseL()
1427 for (TInt ii=2;ii<6;++ii)
1429 TEST(iTest->TestWsPanicL(&DoHandleReUse,EWservPanicHandle,ii,(TAny*)iTest->iScreenNumber));
1433 void CTPanic::TestComputeModePanicsL()
1435 TEST(iTest->TestWsPanicL(&DoCMPanicTest,EWservPanicSetComputeMode,1,(TAny*)iTest->iScreenNumber));
1438 void CTPanic::TestCaptureKeyPanicsL()
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));
1447 void CTPanic::TestEventPanicsL()
1449 TEST(iTest->TestWsPanicL(&DoEventPanicTest,EWservPanicReadOutstanding,1,(TAny*)iTest->iScreenNumber));
1452 void CTPanic::TestTPtrPanicsL()
1454 TEST(iTest->TestWsPanicL(&DoTBufPtrTests,EWservPanicBufferPtr,1,(TAny*)iTest->iScreenNumber));
1457 void CTPanic::TestOpcodePanicsL()
1460 TBool finishTest = EFalse;
1463 TEST(iTest->TestWsPanicL(&DoOpcodeTests,EWservPanicOpcode,param,(TAny*)iTest->iScreenNumber,&finishTest));
1468 void CTPanic::TestMultiInitPanicL()
1470 TEST(iTest->TestWsPanicL(&DoMultiInitPanicTest,EWservPanicReInitialise,0,(TAny*)iTest->iScreenNumber));
1474 @SYMTestCaseID GRAPHICS-WSERV-0472
1478 @SYMTestCaseDesc Test defect fixes to system panics
1480 @SYMTestPriority High
1482 @SYMTestStatus Implemented
1484 @SYMTestActions Check that various defect fixes to system panics are correct.
1485 Also verify that reconstructing a closed object will succeed.
1487 @SYMTestExpectedResults Panics respond correctly
1489 void CTPanic::TestDoubleConstructionL()
1492 for(TInt test=1;test<11;test++)
1494 TEST(iTest->TestW32PanicL(&DoDoubleConstructionTestL,EW32PanicGraphicDoubleConstruction,test,NULL));
1496 TestDoubleConstructionNoPanic();
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()
1507 User::LeaveIfError(ws.Connect());
1509 RWindowGroup group(ws);
1510 User::LeaveIfError(group.Construct(890, EFalse));
1511 RBlankWindow bwin(ws);
1512 User::LeaveIfError(bwin.Construct(group,900));
1515 RWsSprite sprite(ws);
1516 TEST(KErrNone == sprite.Construct(bwin,TPoint(0,0),0));
1518 TEST(KErrNone == sprite.Construct(bwin,TPoint(0,0),0));
1522 RWsPointerCursor cursor(ws);
1523 TEST(KErrNone == cursor.Construct(0));
1525 TEST(KErrNone == cursor.Construct(0));
1529 RSoundPlugIn click(ws);
1530 TEST(KErrNone == click.Construct());
1532 TEST(KErrNone == click.Construct());
1536 RWindowGroup windowgroup(ws);
1537 TEST(KErrNone ==windowgroup.Construct(901));
1538 windowgroup.Close();
1539 TEST(KErrNone ==windowgroup.Construct(901));
1540 windowgroup.Close();
1544 TEST(KErrNone == win1.Construct(group,902));
1546 TEST(KErrNone == win1.Construct(group,902));
1550 RBlankWindow win2(ws);
1551 TEST(KErrNone == win2.Construct(group,902));
1553 TEST(KErrNone == win2.Construct(group,902));
1557 RBackedUpWindow win3(ws);
1558 TEST(KErrNone == win3.Construct(group,EGray4,902));
1560 TEST(KErrNone == win3.Construct(group,EGray4,902));
1564 RAnimDll animDll=RAnimDll(ws);
1565 TEST(KErrNone == animDll.Load(KAnimDLLName));
1567 TEST(KErrNone == animDll.Load(KAnimDLLName));
1575 void CTPanic::TestSpritePanicsL()
1577 for(TInt test=1;test<4;test++)
1579 TEST(iTest->TestWsPanicL(&DoSpritePanicTestL,EWservPanicSprite,test,(TAny*)iTest->iScreenNumber));
1584 @SYMTestCaseID GRAPHICS-WSERV-0475
1588 @SYMTestCaseDesc Test defect fixes to system panics
1590 @SYMTestPriority High
1592 @SYMTestStatus Implemented
1594 @SYMTestActions Check that various defect fixes to system panics are correct.
1596 @SYMTestExpectedResults Panics respond correctly
1598 void CTPanic::TestSpriteActivatePanicL()
1600 for(TInt test=1;test<3;test++)
1602 TEST(iTest->TestWsPanicL(&DoTestSpriteActivatePanicL,EWservPanicNoSpriteMember,test,NULL));
1606 void CTPanic::TestMoveToGroupPanicsL()
1608 TEST(iTest->TestWsPanicL(&DoMoveToGroupPanicTestL,EWservPanicOpcode,1,(TAny*)iTest->iScreenNumber));
1609 TEST(iTest->TestWsPanicL(&DoMoveToGroupPanicTestL,EWservPanicNotTopClient,2,(TAny*)iTest->iScreenNumber));
1612 void CTPanic::TestDeleteScreenPanicL()
1615 TEST(iTest->TestWsPanicL(&DoDeleteScreenPanicTestL,EWservPanicGroupWinScreenDeviceDeleted,1,(TAny*)iTest->iScreenNumber));
1616 TEST(iTest->TestWsPanicL(&DoDeleteScreenPanicTestL,EWservPanicGroupWinScreenDeviceDeleted,2,(TAny*)iTest->iScreenNumber));
1620 void CTPanic::TestWinHandleErrors()
1623 TEST(iTest->TestWsPanicL(&DoWinHandlePanicTestL,EWservPanicDuplicateHandle,1));
1624 TEST(iTest->TestWsPanicL(&DoWinHandlePanicTestL,EWservPanicDuplicateHandle,2));
1625 TEST(iTest->TestWsPanicL(&DoWinHandlePanicTestL,EWservPanicDuplicateHandle,3));
1627 TEST(iTest->TestWsPanicL(&DoWinHandlePanicTestL,EWservPanicNullHandle,4));
1630 void CTPanic::TestGetEventErrors()
1632 TEST(iTest->TestWsPanicL(&DoGetEventPanicTestL,EWservPanicUnsignalledEventData,1,(TAny*)iTest->iScreenNumber));
1633 TEST(iTest->TestWsPanicL(&DoGetEventPanicTestL,EWservPanicDescriptor,2,(TAny*)iTest->iScreenNumber));
1636 void CTPanic::TestUnInitPanicL()
1638 TEST(iTest->TestWsPanicL(&DoUnInitPanicTest,EWservPanicUninitialisedClient,0,(TAny*)iTest->iScreenNumber));
1641 void CTPanic::TestEnableAdvancePointerActivatePanicL()
1643 TEST(iTest->TestWsPanicL(&DoTestAdvancePointerActivatePanicL,EWservPanicUnableToEnableAdvPointer, 0, (TAny*)iTest->iScreenNumber));
1646 void CTPanic::ConstructL()
1648 TheGc->Activate(*BaseWin->Win());
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());
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();
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())
1667 INFO_PRINTF1(KReportFullRom);
1671 INFO_PRINTF1(KReportGoodRom);
1675 void CTPanic::TestAlphaBlendingPanicL()
1677 INFO_PRINTF1(_L("Masked transparency support has been removed."));
1680 void CTPanic::TestMismatchedCaptureCancelPanicL()
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));
1691 void CTPanic::RunTestCaseL(TInt /*aCurTestCase*/)
1693 ((CTPanicStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
1694 switch(++iTest->iState)
1697 @SYMTestCaseID GRAPHICS-WSERV-0259
1701 @SYMTestCaseDesc Test various system panics
1703 @SYMTestPriority High
1705 @SYMTestStatus Implemented
1707 @SYMTestActions Check that various system panics respond correctly
1709 @SYMTestExpectedResults Panics respond correctly
1713 ((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0259"));
1714 iTest->LogSubTest(_L("TestCaptureKeyPanicsL"));
1715 TestCaptureKeyPanicsL();
1720 iTest->LogSubTest(_L("TestEventPanicsL"));
1726 iTest->LogSubTest(_L("TestComputeModePanicsL"));
1727 TestComputeModePanicsL();
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"));
1744 iTest->LogSubTest(_L("TestGraphicsPanicsL"));
1745 TestGraphicsPanicsL();
1750 iTest->LogSubTest(_L("TestTPtrPanicsL"));
1756 iTest->LogSubTest(_L("TestOpcodePanicsL"));
1757 TestOpcodePanicsL();
1762 iTest->LogSubTest(_L("TestScreenDevicePanicsL"));
1763 TestScreenDevicePanicsL();
1768 iTest->LogSubTest(_L("TestMultiInitPanicL"));
1769 TestMultiInitPanicL();
1773 @SYMTestCaseID GRAPHICS-WSERV-0260
1777 @SYMTestCaseDesc Test various system panics
1779 @SYMTestPriority High
1781 @SYMTestStatus Implemented
1783 @SYMTestActions Check that various system panics respond correctly
1785 @SYMTestExpectedResults Panics respond correctly
1789 ((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0260"));
1790 iTest->LogSubTest(_L("Panic 2"));
1791 TestSpritePanicsL();
1792 TestMoveToGroupPanicsL();
1796 @SYMTestCaseID GRAPHICS-WSERV-0261
1800 @SYMTestCaseDesc Test defect fixes to system panics
1802 @SYMTestPriority High
1804 @SYMTestStatus Implemented
1806 @SYMTestActions Check that various defect fixes to system panics are correct
1808 @SYMTestExpectedResults Panics respond correctly
1812 ((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0261"));
1813 _LIT(KPanicTest,"Defect Fixes (Pan.3)");
1814 iTest->LogSubTest(KPanicTest);
1815 TestDeletedParentPanicsL();
1817 TestDeleteScreenPanicL(); // DEF069809
1821 @SYMTestCaseID GRAPHICS-WSERV-097969-0001
1825 @SYMTestCaseDesc Test defect fixes to system panics
1827 @SYMTestPriority High
1829 @SYMTestStatus Implemented
1831 @SYMTestActions Check that various defect fixes to system panics are correct
1833 @SYMTestExpectedResults Panics respond correctly
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
1847 @SYMTestCaseID GRAPHICS-WSERV-0501
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
1857 ((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0472"));
1858 _LIT(KPanicTest,"Double construction panic test");
1859 iTest->LogSubTest(KPanicTest);
1860 TestDoubleConstructionL(); // DEF118618
1865 ((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0475"));
1866 _LIT(KPanicTest, "RWsSprite Activate() without members panic test");
1867 iTest->LogSubTest(KPanicTest);
1868 TestSpriteActivatePanicL(); //DEF118616
1872 @SYMTestCaseID GRAPHICS-WSERV-0497
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.
1879 @SYMTestPriority High
1881 @SYMTestStatus Implemented
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.
1887 @SYMTestExpectedResults Panics respond correctly in debug only.
1891 ((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0497"));
1892 _LIT(KPanicTest,"TestMismatchedCaptureCancelPanicL");
1893 iTest->LogSubTest(KPanicTest);
1894 TestMismatchedCaptureCancelPanicL();
1897 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
1900 _LIT(KPanicTest, "Non-Redraw Drawing inside Redrawer Panic Test");
1901 iTest->LogSubTest(KPanicTest);
1902 TestNonRedrawRedrawerL();
1907 _LIT(KPanicTest, "Enable advanced pointer Panic Test");
1908 iTest->LogSubTest(KPanicTest);
1909 TestEnableAdvancePointerActivatePanicL();
1915 ((CTPanicStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
1916 ((CTPanicStep*)iStep)->CloseTMSGraphicsStep();
1920 ((CTPanicStep*)iStep)->RecordTestResultL();
1923 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
1924 LOCAL_C TInt DoTestNonRedrawRedrawerL(TInt /* aInt */, TAny * /* aPtr */)
1926 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
1927 CleanupStack::PushL(scheduler);
1928 CActiveScheduler::Install(scheduler);
1931 User::LeaveIfError(session.Connect());
1933 CWsScreenDevice *screenDevice = new (ELeave)CWsScreenDevice(session);
1934 User::LeaveIfError(screenDevice->Construct ());
1936 User::LeaveIfError(screenDevice->CreateContext(gc));
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();
1944 delete screenDevice;
1946 CleanupStack::PopAndDestroy(scheduler);
1947 return(EWsExitReasonBad);
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
1959 void CTPanic::TestNonRedrawRedrawerL()
1961 TEST(iTest->TestWsPanicL(&DoTestNonRedrawRedrawerL,EWservPanicWindowBeginRedrawNotCalled,NULL,NULL));
1964 CNonRedrawWin::CRedrawer::CRedrawer(CNonRedrawWin* aWd) :
1965 CActive(CActive::EPriorityStandard), iWd(aWd){
1966 CActiveScheduler::Add(this);
1967 HandleRedrawEvent();
1970 CNonRedrawWin::CRedrawer::~CRedrawer(){
1974 void CNonRedrawWin::CRedrawer::HandleRedrawEvent(){
1975 iWd->GetSession().RedrawReady(&iStatus);
1979 void CNonRedrawWin::CRedrawer::RunL(){
1980 TWsRedrawEvent redrawEvent;
1981 iWd->GetSession().GetRedraw(redrawEvent);
1983 HandleRedrawEvent();
1986 void CNonRedrawWin::CRedrawer::DoCancel(){
1987 iWd->GetSession().RedrawReadyCancel();
1990 CNonRedrawWin* CNonRedrawWin::NewL(RWsSession &aSession, CWindowGc *aGc){
1991 CNonRedrawWin* self=new(ELeave)CNonRedrawWin(aSession, aGc);
1992 CleanupStack::PushL(self);
1994 CleanupStack::Pop(self);
1998 CNonRedrawWin::CNonRedrawWin(RWsSession &aSession, CWindowGc *aGc):
1999 iSession(aSession), iGc(aGc){}
2001 CNonRedrawWin::~CNonRedrawWin(){
2007 void CNonRedrawWin::Redraw(){
2008 // This is a Non-Redraw Drawing Redrawer; BeginRedraw()/EndRedraw()
2009 // have been intentionally omitted.
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)));
2019 RWsSession &CNonRedrawWin::GetSession(){return iSession;}
2021 void CNonRedrawWin::Invalidate(){iWd.Invalidate();}
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);
2034 iRedrawer=new(ELeave) CRedrawer(this);
2038 TInt RUnInitalisedConnect::Connect(const TDesC &aName, const TVersion &aVersion)
2040 return CreateSession(aName, aVersion, 255);
2043 TInt RUnInitalisedConnect::Send(const TInt aMsg)
2045 return SendReceive(aMsg);
2048 __WS_CONSTRUCT_STEP__(Panic)
2049 #pragma warning( disable : 4505 )