sl@0: // Copyright (c) 1996-2010 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Test various cases of Wserv panicing client apps sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @test sl@0: @internalComponent - Internal Symbian test code sl@0: */ sl@0: sl@0: #include "TPANIC.H" sl@0: #include "../tlib/testbase.h" sl@0: #include sl@0: #define TEST_BITMAP _L("Z:\\WSTEST\\WSAUTOTEST.MBM") sl@0: sl@0: class RWsSessionHacker : public RWsSession sl@0: { sl@0: public: sl@0: inline RWsBuffer *WsBuffer() const {return(iBuffer);}; sl@0: inline TInt PanicItSendReceive(TInt aFunction,const TIpcArgs& aArgs) const {return SendReceive(aFunction,aArgs);}; sl@0: inline TInt PanicItSend(TInt aFunction,const TIpcArgs& aArgs) const {return Send(aFunction,aArgs);}; sl@0: inline TInt PanicItSendReceive(TInt aFunction) const {return SendReceive(aFunction);}; sl@0: inline TInt PanicItSend(TInt aFunction) const {return Send(aFunction);}; sl@0: }; sl@0: sl@0: class RWsBufferHacker // copy of original data structure to access buffer data sl@0: { sl@0: public: sl@0: RWsSession* iSession; sl@0: CWsGraphic::CManager* iManager; sl@0: TBool iAutoFlush; sl@0: TPtr8 iBuf; sl@0: RWsBuffer* iNext; sl@0: TInt iPreviousHandle; sl@0: TInt iBufSize; sl@0: TInt iMaxBufSize; sl@0: TInt iDirectAcessCount; sl@0: RArray iBitmapArray; sl@0: TBool iInvalidBitmapArray; sl@0: }; sl@0: sl@0: CTPanic::CTPanic(CTestStep* aStep): sl@0: CTWsGraphicsBase(aStep) sl@0: { sl@0: } sl@0: sl@0: CTPanic::~CTPanic() sl@0: { sl@0: } sl@0: sl@0: LOCAL_C TInt DoDeletedParentTest(TInt aInt, TAny *aScreenNumber) sl@0: { sl@0: RWsSession ws; sl@0: User::LeaveIfError(ws.Connect()); sl@0: // point to correct screen sl@0: CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); sl@0: User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); sl@0: sl@0: RWindowGroup group(ws); sl@0: User::LeaveIfError(group.Construct(888)); sl@0: group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close sl@0: switch(aInt) sl@0: { sl@0: case 1: sl@0: RWindow win1(ws); sl@0: User::LeaveIfError(win1.Construct(group,1)); sl@0: RWindow win2(ws); sl@0: User::LeaveIfError(win2.Construct(win1,2)); sl@0: win1.Close(); sl@0: win2.SetExtent(TPoint(1,2),TSize(3,4)); sl@0: break; sl@0: } sl@0: ws.Flush(); sl@0: return(EWsExitReasonBad); sl@0: } sl@0: sl@0: LOCAL_C void ReuseWindow(RWsSession& aWs,RWindowGroup& aGroup,RWindow aCopyWin,RWindow* aPtrWin) sl@0: { sl@0: aPtrWin->Close(); sl@0: RWindow win(aWs); sl@0: User::LeaveIfError(win.Construct(aGroup,17)); sl@0: aCopyWin.SetExtent(TPoint(1,2),TSize(3,4)); sl@0: } sl@0: sl@0: LOCAL_C void ReuseGroupWindow(RWsSession& aWs,RWindowGroup aCopyWin,RWindowGroup* aPtrWin) sl@0: { sl@0: aPtrWin->Close(); sl@0: RWindowGroup group(aWs); sl@0: User::LeaveIfError(group.Construct(889)); sl@0: group.EnableReceiptOfFocus(EFalse); sl@0: aCopyWin.EnableReceiptOfFocus(EFalse); sl@0: } sl@0: sl@0: LOCAL_C void ReuseSprite(RWsSession& aWs,RWindow& aWin,RWsSprite aCopySprite,RWsSprite* aPtrSprite) sl@0: { sl@0: aPtrSprite->Close(); sl@0: RWsSprite sprite(aWs); sl@0: sprite.Construct(aWin,TPoint(0,0),0); sl@0: aCopySprite.SetPosition(TPoint(22,22)); sl@0: } sl@0: sl@0: LOCAL_C void ReusePointerCursor(RWsSession& aWs,RWsPointerCursor aCopyCursor,RWsPointerCursor* aPtrCursor) sl@0: { sl@0: aPtrCursor->Close(); sl@0: RWsPointerCursor cursor(aWs); sl@0: cursor.Construct(0); sl@0: aCopyCursor.Activate(); sl@0: } sl@0: sl@0: LOCAL_C TInt DoHandleReUse(TInt aInt, TAny *aScreenNumber) sl@0: { sl@0: RWsSession ws; sl@0: User::LeaveIfError(ws.Connect()); sl@0: CWsScreenDevice *scrdev=new(ELeave) CWsScreenDevice(ws); sl@0: scrdev->Construct((TInt)aScreenNumber); sl@0: RWindowGroup group(ws); sl@0: User::LeaveIfError(group.Construct(888)); sl@0: group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close sl@0: RWindow win(ws); sl@0: User::LeaveIfError(win.Construct(group,1)); sl@0: switch(aInt) sl@0: { sl@0: case 2: //WS_HANDLE_WINDOW sl@0: ReuseWindow(ws,group,win,&win); sl@0: break; sl@0: case 3: //WS_HANDLE_GROUP_WINDOW sl@0: ReuseGroupWindow(ws,group,&group); sl@0: break; sl@0: case 4: //WS_HANDLE_SPRITE sl@0: { sl@0: RWsSprite sprite(ws); sl@0: sprite.Construct(win,TPoint(0,0),0); sl@0: ReuseSprite(ws,win,sprite,&sprite); sl@0: } sl@0: break; sl@0: case 5: //WS_HANDLE_POINTER_CURSOR sl@0: { sl@0: RWsPointerCursor cursor(ws); sl@0: cursor.Construct(0); sl@0: ReusePointerCursor(ws,cursor,&cursor); sl@0: } sl@0: break; sl@0: } sl@0: ws.Flush(); sl@0: return(EWsExitReasonBad); sl@0: } sl@0: sl@0: LOCAL_C TInt DoScreenDevicePanicTest(TInt aInt, TAny *aScreenNumber) sl@0: { sl@0: RWsSession ws; sl@0: User::LeaveIfError(ws.Connect()); sl@0: sl@0: CWsScreenDevice *scrdev=new(ELeave) CWsScreenDevice(ws); sl@0: User::LeaveIfError(scrdev->Construct((TInt)aScreenNumber)); sl@0: sl@0: RWindowGroup group(ws); sl@0: User::LeaveIfError(group.Construct(888)); sl@0: group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close sl@0: RWindow win(ws); sl@0: User::LeaveIfError(win.Construct(group, 1)); sl@0: win.Activate(); sl@0: CFbsBitmap *bitmap=new(ELeave) CFbsBitmap; sl@0: switch(aInt) sl@0: { sl@0: case 1: sl@0: scrdev->CopyScreenToBitmap(bitmap); sl@0: break; sl@0: case 2: sl@0: scrdev->CopyScreenToBitmap(bitmap,TRect(0,0,10,10)); sl@0: break; sl@0: default: sl@0: return(EWsExitReasonFinished); sl@0: } sl@0: ws.Flush(); sl@0: return(EWsExitReasonBad); sl@0: } sl@0: sl@0: LOCAL_C TInt DoOpcodeTests(TInt aInt, TAny *aScreenNumber) sl@0: { sl@0: RWsSession ws; sl@0: User::LeaveIfError(ws.Connect()); sl@0: sl@0: CWsScreenDevice *scrdev=new(ELeave) CWsScreenDevice(ws); sl@0: User::LeaveIfError(scrdev->Construct((TInt)aScreenNumber)); sl@0: sl@0: RWindowGroup group(ws); sl@0: User::LeaveIfError(group.Construct(888)); sl@0: group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close sl@0: RWindow win(ws); sl@0: User::LeaveIfError(win.Construct(group, 1)); sl@0: win.Activate(); sl@0: CWindowGc *gc; sl@0: scrdev->CreateContext(gc); sl@0: switch(aInt) sl@0: { sl@0: case 1: sl@0: ws.TestWrite(ws.WsHandle(),9999,NULL,0); sl@0: break; sl@0: case 2: sl@0: gc->Activate(win); sl@0: win.BeginRedraw(); sl@0: ws.TestWrite(gc->WsHandle(),9999,NULL,0); sl@0: /* This only panics if the command is processed immediately. If it goes into the redraw sl@0: store then it will be unable to panic the client untill an additional buffer has been received, sl@0: hence the double flush. sl@0: */ sl@0: win.EndRedraw(); sl@0: ws.Finish(); sl@0: win.BeginRedraw(); sl@0: win.EndRedraw(); sl@0: break; sl@0: case 3: sl@0: ws.TestWrite(scrdev->WsHandle(),9999,NULL,0); sl@0: break; sl@0: case 4: sl@0: { sl@0: CWsBitmap *bitmap=new(ELeave) CWsBitmap(ws); sl@0: bitmap->Create(TSize(10,10),EGray4); sl@0: ws.TestWrite(bitmap->WsHandle(),9999,NULL,0); sl@0: } sl@0: break; sl@0: case 5: sl@0: ws.TestWrite(win.WsHandle(),9999,NULL,0); sl@0: break; sl@0: case 6: sl@0: ws.TestWrite(group.WsHandle(),9999,NULL,0); sl@0: break; sl@0: case 7: sl@0: { sl@0: RWsSprite sprite(ws); sl@0: sprite.Construct(win,TPoint(0,0),0); sl@0: ws.TestWrite(sprite.WsHandle(),9999,NULL,0); sl@0: } sl@0: break; sl@0: default: sl@0: return(EWsExitReasonFinished); sl@0: } sl@0: ws.Flush(); sl@0: return(EWsExitReasonBad); sl@0: } sl@0: sl@0: TInt DoGraphicsPanicTest(RWsSession& aWs, RWindow& aRWin, RDrawableWindow* aDrawWin, CWindowGc* aGc, CFbsFont* aFont, TInt aTest, TInt aSubTest, TBool aInRedraw, TBool aNeedsValidating) sl@0: { sl@0: if (aInRedraw || aNeedsValidating) sl@0: { sl@0: aRWin.BeginRedraw(); sl@0: if (!aInRedraw) sl@0: { // TransWin without redraw active needs the begin/end to make the redraw store active sl@0: aRWin.EndRedraw(); // or else all graphics will simply be ignored and no panics will occur sl@0: } sl@0: } sl@0: aWs.Flush(); sl@0: TRect rect01(0,0,1,1); sl@0: TPoint point00; sl@0: switch(aTest) sl@0: { sl@0: case 1: sl@0: aGc->UseFont(aFont); sl@0: switch(aSubTest) sl@0: { sl@0: case 0: sl@0: { sl@0: TWsGcCmdBoxText boxText(rect01,0,CGraphicsContext::ELeft,0,0x800000,1); sl@0: aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawBoxText,&boxText,sizeof(boxText)); sl@0: } sl@0: break; sl@0: case 1: sl@0: { sl@0: TWsGcCmdDrawText dt(point00,600); sl@0: aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawText,&dt,sizeof(dt)); sl@0: } sl@0: break; sl@0: case 2: sl@0: { sl@0: TWsGcCmdBoxTextOptimised1 dt(rect01,0,600); sl@0: aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawBoxTextOptimised1,&dt,sizeof(dt)); sl@0: } sl@0: break; sl@0: case 3: sl@0: { sl@0: TWsGcCmdDrawTextVertical dt(point00,600,EFalse); sl@0: aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawTextVertical,&dt,sizeof(dt)); sl@0: } sl@0: break; sl@0: case 4: sl@0: { sl@0: TWsGcCmdBoxTextVertical dt(rect01); sl@0: dt.length=600; sl@0: aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawBoxTextVertical,&dt,sizeof(dt)); sl@0: } sl@0: break; sl@0: case 5: sl@0: return(EWsExitReasonFinished); sl@0: } sl@0: break; sl@0: case 2: sl@0: { sl@0: TInt opcode=0; sl@0: switch(aSubTest) sl@0: { sl@0: case 0: sl@0: opcode=EWsGcOpGdiBlt2; sl@0: break; sl@0: case 1: sl@0: opcode=EWsGcOpGdiWsBlt2; sl@0: break; sl@0: case 2: sl@0: return(EWsExitReasonFinished); sl@0: } sl@0: TWsGcCmdGdiBlt2 gdiBlit(point00,0xBADBAD); sl@0: aWs.TestWrite(aGc->WsHandle(),opcode,&gdiBlit,sizeof(gdiBlit)); sl@0: if (aInRedraw) sl@0: { // Adding two bad bitmaps to redraw store fbs store causes leave as NULL handles of failed bitmaps clash sl@0: gdiBlit.handle=0xBADBAD2; sl@0: aWs.TestWrite(aGc->WsHandle(),opcode,&gdiBlit,sizeof(gdiBlit)); sl@0: } sl@0: } sl@0: break; sl@0: case 3: sl@0: { sl@0: const TInt KNumBadBmpModes=3; sl@0: const TInt KNumTestsPerOpcode=KNumBadBmpModes*2; sl@0: enum {KPanicIndexMasked,KPanicIndexDraw,KPanicIndexAlphaBlend,KPanicIndexMax}; sl@0: TInt opcodeMode=aSubTest/KNumTestsPerOpcode; sl@0: TInt bmpMode=aSubTest%KNumTestsPerOpcode; sl@0: TInt bmp1=0xBADBAD; sl@0: TInt bmp2=0xBADBAD; sl@0: TInt goodBmp; sl@0: TInt opcodeBlt; sl@0: TInt opcodeDraw; sl@0: if (bmpModeCreate(TSize(10,10),EGray4); sl@0: goodBmp=goodBitmap->Handle(); sl@0: opcodeBlt=EWsGcOpGdiBltMasked; sl@0: opcodeDraw=EWsGcOpDrawBitmapMasked; sl@0: } sl@0: else sl@0: { // These two use a CWsBitmap sl@0: CWsBitmap* goodBitmap=new(ELeave) CWsBitmap(aWs); sl@0: goodBitmap->Create(TSize(10,10),EGray4); sl@0: goodBmp=goodBitmap->WsHandle(); sl@0: opcodeBlt=EWsGcOpGdiWsBltMasked; sl@0: opcodeDraw=EWsGcOpWsDrawBitmapMasked; sl@0: } sl@0: switch(bmpMode%KNumBadBmpModes) sl@0: { sl@0: case 0: sl@0: bmp2=goodBmp; sl@0: break; sl@0: case 1: sl@0: bmp1=goodBmp; sl@0: break; sl@0: case 2: // Leave them both bad sl@0: break; sl@0: } sl@0: switch(opcodeMode) sl@0: { sl@0: case KPanicIndexMasked: sl@0: { sl@0: TWsGcCmdBltMasked gdiBlitMasked(point00,bmp1,rect01,bmp2,EFalse); sl@0: aWs.TestWrite(aGc->WsHandle(),opcodeBlt,&gdiBlitMasked,sizeof(gdiBlitMasked)); sl@0: } sl@0: break; sl@0: case KPanicIndexDraw: sl@0: { sl@0: TWsGcCmdDrawBitmapMasked maskedBitmap(rect01,bmp1,rect01,bmp2,EFalse); sl@0: aWs.TestWrite(aGc->WsHandle(),opcodeDraw,&maskedBitmap,sizeof(maskedBitmap)); sl@0: } sl@0: break; sl@0: case KPanicIndexAlphaBlend: sl@0: { sl@0: TWsGcCmdAlphaBlendBitmaps alphaBlend(point00,bmp1,rect01,bmp2,point00); sl@0: aWs.TestWrite(aGc->WsHandle(),EWsGcOpGdiAlphaBlendBitmaps,&alphaBlend,sizeof(alphaBlend)); sl@0: } sl@0: break; sl@0: case KPanicIndexMax: sl@0: return(EWsExitReasonFinished); sl@0: } sl@0: } sl@0: break; sl@0: case 4: sl@0: switch(aSubTest) sl@0: { sl@0: case 0: sl@0: { sl@0: TWsClCmdCreateBitmap createBitmap; sl@0: createBitmap.handle=0xB0D; sl@0: aWs.TestWrite(aWs.WsHandle(),EWsClOpCreateBitmap,&createBitmap,sizeof(createBitmap)); sl@0: } sl@0: break; sl@0: case 1: sl@0: { sl@0: TInt badBrush=0xBADB3054; sl@0: aWs.TestWrite(aGc->WsHandle(),EWsGcOpUseBrushPattern,&badBrush,sizeof(badBrush)); sl@0: } sl@0: break; sl@0: case 2: sl@0: { sl@0: TWsGcCmdDrawBitmap drawBitmap(point00,0xBADBAD); sl@0: aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawBitmap,&drawBitmap,sizeof(drawBitmap)); sl@0: } sl@0: break; sl@0: case 3: sl@0: return(EWsExitReasonFinished); sl@0: } sl@0: break; sl@0: case 5: sl@0: // test bad opcodes sl@0: { sl@0: TInt opcode=0; sl@0: switch(aSubTest) sl@0: { sl@0: case 0: sl@0: opcode=9999; sl@0: break; sl@0: case 1: sl@0: return(EWsExitReasonFinished); sl@0: } sl@0: aWs.TestWrite(aGc->WsHandle(),opcode,NULL,0); sl@0: } sl@0: break; sl@0: case 6: sl@0: {// Test EWsGcOpDrawPolygon with invalid parameters sl@0: // First two times has slightly more points specified than exist in the data sl@0: // Third time time has a massive number of points in the header sl@0: const TInt KNumTestsPerPolyMode=3; sl@0: enum TPanicPolyMode {EPanicPolyModePolygon,EPanicPolyModePolyLine,EPanicPolyModeEnd}; sl@0: TInt polyMode=aSubTest/KNumTestsPerPolyMode; sl@0: if (polyMode==EPanicPolyModeEnd) sl@0: return(EWsExitReasonFinished); sl@0: TInt subMode=aSubTest%KNumTestsPerPolyMode; sl@0: TInt bufPoints=0; sl@0: TInt headerPoints=1; sl@0: switch(subMode) sl@0: { sl@0: case 0: sl@0: break; sl@0: case 1: sl@0: bufPoints=2; sl@0: headerPoints=8; sl@0: break; sl@0: case 2: sl@0: bufPoints=2; sl@0: headerPoints=999999; sl@0: break; sl@0: } sl@0: TInt bufDataLen=bufPoints*sizeof(TPoint); sl@0: if (polyMode==EPanicPolyModePolyLine) sl@0: bufDataLen+=sizeof(TWsGcCmdDrawPolyLine); sl@0: else sl@0: bufDataLen+=sizeof(TWsGcCmdDrawPolygon); sl@0: TAny* bufData=User::AllocL(bufDataLen); sl@0: TPoint* pointPtr; sl@0: TInt opcode; sl@0: if (polyMode==EPanicPolyModePolyLine) sl@0: { sl@0: TWsGcCmdDrawPolyLine* drawPolyline=static_cast(bufData); sl@0: drawPolyline->numPoints=headerPoints; sl@0: drawPolyline->more=EFalse; sl@0: drawPolyline->last=point00; sl@0: pointPtr=reinterpret_cast(drawPolyline+1); sl@0: opcode=EWsGcOpDrawPolyLine; sl@0: } sl@0: else sl@0: { sl@0: TWsGcCmdDrawPolygon* drawPolygon=static_cast(bufData); sl@0: drawPolygon->numPoints=headerPoints; sl@0: drawPolygon->fillRule=CGraphicsContext::EAlternate; sl@0: pointPtr=reinterpret_cast(drawPolygon+1); sl@0: opcode=EWsGcOpDrawPolygon; sl@0: } sl@0: const TPoint* endPtr=pointPtr+bufPoints; sl@0: TInt pointPos=0; sl@0: while(pointPtrWsHandle(),opcode,bufData,bufDataLen); sl@0: aWs.Flush(); // Needs flush to make sure EndRedraw() doesn't make buffer bigger and catch out buf len check sl@0: } sl@0: break; sl@0: case 7: sl@0: { sl@0: // first sets the index to match the total count sl@0: // second sets the index negative sl@0: // fourth sends too much data sl@0: TWsGcCmdStartSegmentedDrawPolygon startPoly; sl@0: startPoly.totalNumPoints=8; sl@0: aWs.TestWrite(aGc->WsHandle(),EWsGcOpStartSegmentedDrawPolygon,&startPoly,sizeof(startPoly)); sl@0: TInt bufDataLen=sizeof(TWsGcCmdSegmentedDrawPolygonData)+startPoly.totalNumPoints*sizeof(TPoint); sl@0: TAny* bufData=User::AllocL(bufDataLen); sl@0: TWsGcCmdSegmentedDrawPolygonData* polyData=static_cast(bufData); sl@0: polyData->numPoints=1; sl@0: polyData->index=0; sl@0: switch(aSubTest) sl@0: { sl@0: case 0: sl@0: polyData->index=startPoly.totalNumPoints; sl@0: break; sl@0: case 1: sl@0: polyData->index=-123; sl@0: break; sl@0: case 2: sl@0: polyData->numPoints=startPoly.totalNumPoints+1; sl@0: break; sl@0: case 3: sl@0: return(EWsExitReasonFinished); sl@0: } sl@0: aWs.TestWrite(aGc->WsHandle(),EWsGcOpSegmentedDrawPolygonData,polyData,bufDataLen); sl@0: TWsGcCmdDrawSegmentedPolygon drawit; sl@0: drawit.fillRule=CGraphicsContext::EAlternate; sl@0: aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawSegmentedPolygon,&drawit,sizeof(drawit)); sl@0: } sl@0: break; sl@0: case 8: sl@0: { sl@0: if (aSubTest==1) sl@0: return(EWsExitReasonFinished); sl@0: // This is a test designed to specificially test polylines still work after the previous sl@0: // polyline/polygon tests. One potential defect is they leave the common redraw store gc sl@0: // in a bad state still holding part of the poly data and causing a EWservPanicBadPolyData sl@0: // panic. sl@0: // This test is designed to make sure the drawpolyline call works ok and we reach the bad sl@0: // opcode panic instead. sl@0: TWsGcCmdStartSegmentedDrawPolygon startPoly; sl@0: startPoly.totalNumPoints=2; sl@0: aWs.TestWrite(aGc->WsHandle(),EWsGcOpStartSegmentedDrawPolygon,&startPoly,sizeof(startPoly)); sl@0: struct sl@0: { sl@0: TWsGcCmdSegmentedDrawPolygonData iPolyData; sl@0: TPoint iPoints[2]; sl@0: } polyParams; sl@0: polyParams.iPoints[0].iX=1; sl@0: polyParams.iPoints[0].iY=1; sl@0: polyParams.iPoints[1].iX=2; sl@0: polyParams.iPoints[1].iY=2; sl@0: sl@0: polyParams.iPolyData.numPoints=2; sl@0: polyParams.iPolyData.index=0; sl@0: aWs.TestWrite(aGc->WsHandle(),EWsGcOpSegmentedDrawPolygonData,&polyParams.iPolyData,sizeof(polyParams)); sl@0: TWsGcCmdDrawSegmentedPolygon drawit; sl@0: drawit.fillRule=CGraphicsContext::EAlternate; sl@0: aWs.TestWrite(aGc->WsHandle(),EWsGcOpDrawSegmentedPolygon,&drawit,sizeof(drawit)); sl@0: aWs.TestWrite(aGc->WsHandle(),9999,NULL,0); sl@0: } sl@0: break; sl@0: case 9: sl@0: if (aSubTest==1) sl@0: return(EWsExitReasonFinished); sl@0: aGc->Activate(*aDrawWin); // Double activate sl@0: break; sl@0: case 10: sl@0: if (aSubTest==1) sl@0: return(EWsExitReasonFinished); sl@0: aGc->DrawText(_L("No font"),point00); sl@0: break; sl@0: case 11: sl@0: if (aSubTest==1) sl@0: return(EWsExitReasonFinished); sl@0: aGc->SetBrushStyle(CGraphicsContext::EPatternedBrush); sl@0: aGc->DrawRect(rect01); sl@0: break; sl@0: case 12: sl@0: { sl@0: if (aSubTest==1) sl@0: return(EWsExitReasonFinished); sl@0: aGc->UseFont(aFont); sl@0: TPtrC bigAndbad(NULL,5000); // Will go through remote descriptor fetching code sl@0: aGc->DrawText(bigAndbad,point00); sl@0: } sl@0: break; sl@0: case 13: sl@0: { sl@0: if (aSubTest==1) sl@0: return(EWsExitReasonFinished); sl@0: TInt badHandle=0xDEADBAD; sl@0: aWs.TestWrite(aGc->WsHandle(),EWsGcOpUseFont,&badHandle,sizeof(badHandle)); sl@0: aGc->DrawText(_L("BOO!"),point00); sl@0: } sl@0: break; sl@0: } sl@0: if (aInRedraw) sl@0: aRWin.EndRedraw(); sl@0: aWs.Finish(); sl@0: return(EWsExitReasonBad); sl@0: } sl@0: sl@0: LOCAL_C TInt GraphicsPanicTest(TInt aInt, TAny* aPanicParams) sl@0: { sl@0: CTPanic::TPanicParams* panicParams=static_cast(aPanicParams); sl@0: /* sl@0: * Drawing to a transparent window goes via the redraw store. In this sl@0: * situation parameters do not get checked during the original processing sl@0: * of the incoming graphics commands. They are only caught later when sl@0: * playing back from the redraw store. sl@0: */ sl@0: const TBool useTransWin = panicParams->iRedrawMode==EPanicRedrawModeTransRedraw; sl@0: /* sl@0: * We always do redraw drawing unless we are using a BackedUpWindow. sl@0: * Redraws can affect the way graphics commands are pre-processed, sl@0: * as with transparent windows they can also cause commands to get sl@0: * buffered in the redraw store and played back later. sl@0: */ sl@0: const TBool inRedraw = sl@0: panicParams->iRedrawMode==EPanicRedrawModeNormalRedraw || sl@0: panicParams->iRedrawMode==EPanicRedrawModeTransRedraw || sl@0: panicParams->iRedrawMode==EPanicRedrawModeInvisRedraw; sl@0: /* sl@0: * Drawing to an invisible window skips some of the code where errors sl@0: * are caught. Particularly text drawing commands that skip the actual sl@0: * drawing, but still process the update of the justification, this sl@0: * has the potential of missing parameter checks made during the actual sl@0: * drawing, but being caught out when processing the justification update. sl@0: */ sl@0: const TBool invisWin = panicParams->iRedrawMode==EPanicRedrawModeInvisRedraw; sl@0: sl@0: RWsSession ws; sl@0: User::LeaveIfError(ws.Connect()); sl@0: sl@0: CWsScreenDevice* scrdev=new(ELeave) CWsScreenDevice(ws); sl@0: User::LeaveIfError(scrdev->Construct(panicParams->iScreen)); sl@0: sl@0: RWindowGroup group(ws); sl@0: User::LeaveIfError(group.Construct(888)); sl@0: group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close sl@0: RDrawableWindow* drawWin; sl@0: RWindow rwin(ws); sl@0: RBackedUpWindow bwin(ws); sl@0: TBool needsValidating=EFalse; sl@0: if (useTransWin || inRedraw || invisWin) sl@0: { sl@0: drawWin=&rwin; sl@0: needsValidating=ETrue; sl@0: User::LeaveIfError(rwin.Construct(group,1)); sl@0: if (useTransWin) sl@0: { sl@0: rwin.SetTransparencyAlphaChannel(); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: // EPanicRedrawModeBackedUpWindow case sl@0: drawWin=&bwin; sl@0: User::LeaveIfError(bwin.Construct(group, EGray4, 1)); sl@0: } sl@0: const TSize testWinSize(100,100); sl@0: User::LeaveIfError(drawWin->SetSizeErr(testWinSize)); sl@0: if (invisWin) sl@0: drawWin->SetPosition(TPoint(-testWinSize.iWidth,-testWinSize.iHeight)); sl@0: drawWin->Activate(); sl@0: CWindowGc* gc; sl@0: scrdev->CreateContext(gc); sl@0: gc->Activate(*drawWin); sl@0: CFbsFont* font; sl@0: User::LeaveIfError(scrdev->GetNearestFontToDesignHeightInTwips((CFont*&)font,TFontSpec())); sl@0: TInt ret=DoGraphicsPanicTest(ws,rwin,drawWin,gc,font,aInt,panicParams->iSubTest,inRedraw,needsValidating); sl@0: if (ret!=EWsExitReasonFinished && invisWin) sl@0: { sl@0: /* sl@0: * Some functions are totally skipped on invisible windows, parameter sl@0: * errors will be harmlessly ignored in these case. To make the test sl@0: * pass we re-do the tests with the window now visible. The purpose sl@0: * of the invisible draw tests was not to check the client is always sl@0: * panicked doing illegal draws to invisible windows, but to make sure sl@0: * they had no harmful side effects. sl@0: */ sl@0: drawWin->SetPosition(TPoint(0,0)); sl@0: gc->Reset(); sl@0: ret=DoGraphicsPanicTest(ws,rwin,drawWin,gc,font,aInt,panicParams->iSubTest,inRedraw,needsValidating); sl@0: } sl@0: return(ret); sl@0: } sl@0: LOCAL_C TInt DoMiscPanicTest(TInt aSubTest, TAny* ) sl@0: { sl@0: const TInt KNumPanicFuncsPerMode=EWsClOpLastEnumValue; sl@0: const TInt KNumPanicFuncModes=6; sl@0: const TInt KNumPanicSendTests=KNumPanicFuncsPerMode*KNumPanicFuncModes; sl@0: const TInt KNumRandGarbageTests=500; sl@0: if (aSubTest==(KNumPanicSendTests+KNumRandGarbageTests)) sl@0: return(EWsExitReasonFinished); sl@0: RWsSessionHacker wshacker; sl@0: User::LeaveIfError(wshacker.Connect()); sl@0: if (aSubTest(0xDEAD),100); sl@0: TIpcArgs ipcArgs; sl@0: ipcArgs.Set(0,&badDesc); sl@0: if (msgFunc&EPanicWservMessAsynchronousService) sl@0: { sl@0: sendItErr=wshacker.PanicItSend(msgFunc,ipcArgs); sl@0: msgFunc&=~EPanicWservMessAsynchronousService; sl@0: } sl@0: sendItErr=wshacker.PanicItSendReceive(msgFunc,ipcArgs); sl@0: } sl@0: if (sendItErr==KErrNotSupported) sl@0: wshacker.PanicItSendReceive(EWservMessCommandBuffer); // Should always panic sl@0: } sl@0: else sl@0: { sl@0: // Fill Wserv buffer with random garbage sl@0: RWsBufferHacker* hacker=reinterpret_cast(wshacker.WsBuffer()); sl@0: TInt64 seed=aSubTest; sl@0: TInt retries=0; sl@0: const TInt KMaxRandPanicRetrys=1000; sl@0: do sl@0: { sl@0: const TInt maxLen=hacker->iBuf.MaxLength()-1; sl@0: TInt writeLen=1+Math::Rand(seed)%maxLen; sl@0: while(writeLen--) sl@0: { sl@0: TUint8 randData=static_cast(Math::Rand(seed)); sl@0: hacker->iBuf.Append(randData); sl@0: } sl@0: wshacker.Flush(); sl@0: retries++; sl@0: } while(retriesConstruct((TInt)aScreenNumber)); sl@0: sl@0: switch(aInt) sl@0: { sl@0: case 1: sl@0: ws.ComputeMode((RWsSession::TComputeMode)543); sl@0: break; sl@0: } sl@0: ws.Flush(); sl@0: return(EWsExitReasonBad); sl@0: } sl@0: sl@0: #if defined(_DEBUG) && defined(__WINS__) sl@0: LOCAL_C TInt DoCKPanicTest(TInt aInt, TAny *aScreenNumber) sl@0: { sl@0: RWsSession ws; sl@0: User::LeaveIfError(ws.Connect()); sl@0: // use correct screen sl@0: // sl@0: CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); sl@0: User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); sl@0: sl@0: RWindowGroup group(ws); sl@0: group.Construct(888); sl@0: group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close sl@0: switch(aInt) sl@0: { sl@0: case 1: sl@0: group.CancelCaptureKey(345); sl@0: break; sl@0: } sl@0: ws.Flush(); sl@0: return(EWsExitReasonBad); sl@0: } sl@0: #endif sl@0: sl@0: LOCAL_C TInt DoEventPanicTest(TInt aInt, TAny *aScreenNumber) sl@0: { sl@0: RWsSession ws; sl@0: User::LeaveIfError(ws.Connect()); sl@0: // use correct screen sl@0: // sl@0: CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); sl@0: User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); sl@0: sl@0: sl@0: switch(aInt) sl@0: { sl@0: case 1: sl@0: TRequestStatus stat; sl@0: ws.EventReady(&stat); sl@0: ws.EventReady(&stat); sl@0: User::After(15000000); //15secs sl@0: break; sl@0: } sl@0: ws.Flush(); sl@0: return(EWsExitReasonBad); sl@0: } sl@0: sl@0: LOCAL_C TInt DoTBufPtrTests(TInt aInt, TAny *aScreenNumber) sl@0: { sl@0: RWsSession ws; sl@0: User::LeaveIfError(ws.Connect()); sl@0: // use correct screen sl@0: // sl@0: CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); sl@0: User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); sl@0: sl@0: switch(aInt) sl@0: { sl@0: case 1: sl@0: { sl@0: TWsClCmdLoadAnimDll dt; sl@0: dt.length=600; sl@0: ws.TestWrite(ws.WsHandle(),EWsClOpCreateAnimDll,&dt,sizeof(dt)); sl@0: } sl@0: break; sl@0: case 2: sl@0: { sl@0: TInt len=600; sl@0: ws.TestWrite(ws.WsHandle(),EWsClOpLogMessage,&len,sizeof(len)); sl@0: } sl@0: break; sl@0: case 3: sl@0: { sl@0: RWindowGroup group(ws); sl@0: group.Construct(888); sl@0: group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close sl@0: TWsWinCmdSetName dt; sl@0: dt.length=600; sl@0: dt.ptr=NULL; sl@0: ws.TestWrite(group.WsHandle(),EWsWinOpSetName,&dt,sizeof(dt)); sl@0: } sl@0: break; sl@0: case 4: sl@0: { sl@0: RWindowGroup group(ws); sl@0: group.Construct(888); sl@0: group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close sl@0: TWsWinCmdSetName dt; sl@0: dt.length=600; sl@0: dt.ptr=(TDesC *)0x1234; sl@0: ws.TestWrite(group.WsHandle(),EWsWinOpSetName,&dt,sizeof(dt)); sl@0: } sl@0: break; sl@0: } sl@0: ws.Flush(); sl@0: return(EWsExitReasonBad); sl@0: } sl@0: sl@0: #if defined(_DEBUG) && defined(__WINS__) sl@0: LOCAL_C TInt DoMismatchedCancelCaptureTest(TInt aInt, TAny *aScreenNumber) sl@0: { sl@0: RWsSession ws; sl@0: User::LeaveIfError(ws.Connect()); sl@0: // use correct screen sl@0: CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); sl@0: User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); sl@0: RWindowGroup group(ws); sl@0: User::LeaveIfError(group.Construct(888)); sl@0: group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close sl@0: RWindow win(ws); sl@0: User::LeaveIfError(win.Construct(group, 1)); sl@0: win.Activate(); sl@0: TInt capture; sl@0: sl@0: switch (aInt) sl@0: { sl@0: case CTPanic::ECancelCaptureKey: sl@0: // Create a capture that is not matched to CancelCaptureKey() sl@0: capture = group.CaptureLongKey(' ','a',0,0,2,ELongCaptureNormal); sl@0: ws.Flush(); sl@0: group.CancelCaptureKey(capture); sl@0: break; sl@0: case CTPanic::ECancelCaptureKeyUpAndDowns: sl@0: // Create a capture that is not matched to CancelCaptureKeyUpAndDowns() sl@0: capture = group.CaptureKey('A',0,0); sl@0: ws.Flush(); sl@0: group.CancelCaptureKeyUpAndDowns(capture); sl@0: break; sl@0: case CTPanic::ECancelCaptureLongKey: sl@0: // Create a capture that is not matched to CancelCaptureLongKey() sl@0: capture = group.CaptureKeyUpAndDowns(EStdKeySpace,0,0); sl@0: ws.Flush(); sl@0: group.CancelCaptureLongKey(capture); sl@0: break; sl@0: } sl@0: sl@0: ws.Flush(); sl@0: return(EWsExitReasonBad); sl@0: } sl@0: #endif // _DEBUG sl@0: sl@0: class ROverrideProtectionInRSessionBase : public RWsSession sl@0: { sl@0: public: sl@0: inline TInt SendReceive(TInt aFunction,TAny *aPtr) const {return(RSessionBase::SendReceive(aFunction,TIpcArgs(aPtr)));}; sl@0: }; sl@0: sl@0: LOCAL_C TInt DoMultiInitPanicTest(TInt , TAny *aScreenNumber) sl@0: { sl@0: ROverrideProtectionInRSessionBase ws; sl@0: User::LeaveIfError(ws.Connect()); sl@0: sl@0: // use correct screen sl@0: // sl@0: CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); sl@0: User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); sl@0: sl@0: RWindowGroup group(ws); sl@0: group.Construct(888); sl@0: group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close sl@0: ws.Flush(); sl@0: ws.SendReceive(EWservMessInit,NULL); sl@0: sl@0: return(EWsExitReasonBad); sl@0: } sl@0: sl@0: LOCAL_C TInt DoSpritePanicTestL(TInt aTest, TAny *aScreenNumber) sl@0: { sl@0: RWsSession ws; sl@0: User::LeaveIfError(ws.Connect()); sl@0: // use correct screen sl@0: // sl@0: CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); sl@0: User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); sl@0: sl@0: RWindowGroup group(ws); sl@0: User::LeaveIfError(group.Construct(889)); sl@0: group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close sl@0: RBlankWindow win(ws); sl@0: User::LeaveIfError(win.Construct(group,898)); sl@0: RWsPointerCursor* cursor=(RWsPointerCursor*)&win; sl@0: switch (aTest) sl@0: { sl@0: case 1: sl@0: win.SetCustomPointerCursor(*cursor); sl@0: break; sl@0: case 2: sl@0: ws.SetSystemPointerCursor(*cursor,0); sl@0: break; sl@0: case 3: sl@0: { sl@0: RAnimDll animDll=RAnimDll(ws); sl@0: User::LeaveIfError(animDll.Load(KAnimDLLName)); sl@0: RTestAnim anim=RTestAnim(animDll); sl@0: RWsSprite* sprite=(RWsSprite*)&win; sl@0: User::LeaveIfError(anim.Construct(*sprite,EAnimTypeSprite,TPtrC8())); sl@0: } sl@0: break; sl@0: case 4: sl@0: { sl@0: CFbsBitmap* bitmap=new(ELeave) CFbsBitmap; sl@0: CleanupStack::PushL(bitmap); sl@0: User::LeaveIfError(bitmap->Load(TEST_BITMAP_NAME,0)); sl@0: win.SetExtent(TPoint(),TSize(150,250)); sl@0: win.SetVisible(ETrue); sl@0: win.Activate(); sl@0: RWsSprite sprite(ws); sl@0: User::LeaveIfError(sprite.Construct(win,TPoint(),0)); sl@0: TSpriteMember member; sl@0: member.iMaskBitmap=NULL; sl@0: member.iInvertMask=EFalse; sl@0: member.iDrawMode=CGraphicsContext::EDrawModePEN; sl@0: member.iOffset=TPoint(); sl@0: member.iInterval=TTimeIntervalMicroSeconds32(0); sl@0: member.iBitmap=bitmap; sl@0: User::LeaveIfError(sprite.AppendMember(member)); sl@0: User::LeaveIfError(sprite.Activate()); sl@0: User::After(1000000); //1 sec sl@0: User::LeaveIfError(bitmap->Resize(bitmap->SizeInPixels() + TSize(200,200))); sl@0: User::After(1000000); //1 sec sl@0: CleanupStack::Pop(bitmap); sl@0: break; sl@0: } sl@0: } sl@0: ws.Flush(); sl@0: return(EWsExitReasonBad); sl@0: } sl@0: sl@0: #ifdef __WINS__ sl@0: LOCAL_C TInt DoDoubleConstructionTestL(TInt aTest, TAny *aScreenNumber) sl@0: { sl@0: RWsSession ws; sl@0: User::LeaveIfError(ws.Connect()); sl@0: sl@0: // use correct screen sl@0: // sl@0: CWsScreenDevice* screen = new(ELeave) CWsScreenDevice(ws); sl@0: User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); sl@0: sl@0: RWindowGroup group(ws); sl@0: User::LeaveIfError(group.Construct(890, EFalse)); sl@0: RBlankWindow bwin(ws); sl@0: User::LeaveIfError(bwin.Construct(group,900)); sl@0: sl@0: switch (aTest) sl@0: { sl@0: case 1: sl@0: { sl@0: RWsSprite sprite = RWsSprite(ws); sl@0: User::LeaveIfError(sprite.Construct(bwin,TPoint(),0)); sl@0: sprite.Construct(bwin,TPoint(),0); //should panic sl@0: sprite.Close(); sl@0: } sl@0: break; sl@0: case 2: sl@0: { sl@0: RWsPointerCursor cursor(ws); sl@0: User::LeaveIfError(cursor.Construct(0)); sl@0: cursor.Construct(0); //should panic sl@0: cursor.Close(); sl@0: } sl@0: break; sl@0: case 3: sl@0: { sl@0: RSoundPlugIn click(ws); sl@0: User::LeaveIfError(click.Construct()); sl@0: click.Construct(); //should panic sl@0: click.Close(); sl@0: } sl@0: break; sl@0: case 4: sl@0: { sl@0: RWindowGroup windowgroup(ws); sl@0: User::LeaveIfError(windowgroup.Construct(901)); sl@0: windowgroup.Construct(902); //should panic sl@0: windowgroup.Close(); sl@0: } sl@0: break; sl@0: case 5: sl@0: { sl@0: RWindow win(ws); sl@0: User::LeaveIfError(win.Construct(group,902)); sl@0: win.Construct(group,903); //should panic sl@0: win.Close(); sl@0: } sl@0: break; sl@0: case 6: sl@0: { sl@0: RBlankWindow win(ws); sl@0: User::LeaveIfError(win.Construct(group,902)); sl@0: win.Construct(group,903); //should panic sl@0: win.Close(); sl@0: } sl@0: break; sl@0: case 7: sl@0: { sl@0: RBackedUpWindow win(ws); sl@0: User::LeaveIfError(win.Construct(group,EGray4,902)); sl@0: win.Construct(group,EGray4,903); //should panic sl@0: win.Close(); sl@0: } sl@0: break; sl@0: case 8: sl@0: { sl@0: RAnimDll animDll=RAnimDll(ws); sl@0: User::LeaveIfError(animDll.Load(KAnimDLLName)); sl@0: animDll.Load(KAnimDLLName); //should panic sl@0: animDll.Close(); sl@0: } sl@0: break; sl@0: case 9: sl@0: { sl@0: CWindowGc *gc = new(ELeave) CWindowGc(screen); sl@0: User::LeaveIfError(gc->Construct()); sl@0: gc->Construct(); //should panic sl@0: delete gc; sl@0: } sl@0: break; sl@0: case 10: sl@0: { sl@0: CWsScreenDevice* screendevice = new (ELeave) CWsScreenDevice(ws); sl@0: User::LeaveIfError(screendevice->Construct()); sl@0: screendevice->Construct(); //should panic sl@0: delete screendevice; sl@0: } sl@0: break; sl@0: default: sl@0: break; sl@0: } sl@0: ws.Flush(); sl@0: return(EWsExitReasonBad); sl@0: } sl@0: #endif sl@0: sl@0: /** Checks that activating a sprite without members will panic. sl@0: */ sl@0: LOCAL_C TInt DoTestSpriteActivatePanicL(TInt aTest, TAny *aScreenNumber) sl@0: { sl@0: RWsSession ws; sl@0: User::LeaveIfError(ws.Connect()); sl@0: CWsScreenDevice* screen = new(ELeave) CWsScreenDevice(ws); sl@0: User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); sl@0: RWindowGroup group(ws); sl@0: User::LeaveIfError(group.Construct(891, EFalse, screen)); sl@0: RBlankWindow bwin(ws); sl@0: User::LeaveIfError(bwin.Construct(group,892)); sl@0: sl@0: switch(aTest) sl@0: { sl@0: case 1: sl@0: { sl@0: RWsSprite sprite = RWsSprite(ws); sl@0: User::LeaveIfError(sprite.Construct(group,TPoint(),0)); sl@0: sprite.Activate(); //should panic here sl@0: sprite.Close(); sl@0: } sl@0: break; sl@0: case 2: sl@0: { sl@0: RWsSprite sprite = RWsSprite(ws); sl@0: User::LeaveIfError(sprite.Construct(bwin,TPoint(),0)); sl@0: sprite.Activate(); //should panic here sl@0: sprite.Close(); sl@0: } sl@0: break; sl@0: } sl@0: return(EWsExitReasonBad); sl@0: } sl@0: sl@0: /** Checks that activating a RWindow before calling EnableAdvancedPointers will panic the client. sl@0: */ sl@0: LOCAL_C TInt DoTestAdvancePointerActivatePanicL(TInt /*aTest*/,TAny *aScreenNumber) sl@0: { sl@0: RWsSession ws; sl@0: User::LeaveIfError(ws.Connect()); sl@0: sl@0: CWsScreenDevice *scrdev=new(ELeave) CWsScreenDevice(ws); sl@0: User::LeaveIfError(scrdev->Construct((TInt)aScreenNumber)); sl@0: sl@0: RWindowGroup group(ws); sl@0: User::LeaveIfError(group.Construct(888)); sl@0: RWindow win(ws); sl@0: User::LeaveIfError(win.Construct(group, 1)); sl@0: win.Activate(); sl@0: win.EnableAdvancedPointers(); // This will panic sl@0: ws.Flush(); sl@0: return(EWsExitReasonBad); sl@0: } sl@0: sl@0: sl@0: LOCAL_C TInt DoMoveToGroupPanicTestL(TInt aTest, TAny *aScreenNumber) sl@0: { sl@0: RWsSession ws; sl@0: User::LeaveIfError(ws.Connect()); sl@0: // use correct screen sl@0: // sl@0: CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); sl@0: User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); sl@0: sl@0: RWindowGroup group(ws); sl@0: User::LeaveIfError(group.Construct(887)); sl@0: group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close sl@0: TInt id=group.Identifier(); sl@0: switch (aTest) sl@0: { sl@0: case 1: sl@0: { sl@0: RWindowTreeNode* win=&group; sl@0: ((RWindowBase*)win)->MoveToGroup(id); sl@0: } sl@0: break; sl@0: case 2: sl@0: { sl@0: RBlankWindow win1(ws); sl@0: User::LeaveIfError(win1.Construct(group,878)); sl@0: RBlankWindow win2(ws); sl@0: User::LeaveIfError(win2.Construct(win1,788)); sl@0: win2.MoveToGroup(id); sl@0: } sl@0: break; sl@0: } sl@0: ws.Flush(); sl@0: return(EWsExitReasonBad); sl@0: } sl@0: sl@0: LOCAL_C TInt DoGetEventPanicTestL(TInt aTest, TAny *aScreenNumber) sl@0: { sl@0: RWsSession ws; sl@0: User::LeaveIfError(ws.Connect()); sl@0: switch(aTest) sl@0: { sl@0: case 1: sl@0: { sl@0: TPckgBuf event; sl@0: ws.TestWrite(ws.WsHandle(),EWsClOpGetEvent,&event,0); sl@0: } sl@0: break; sl@0: case 2: sl@0: { sl@0: CWsScreenDevice* screen=new(ELeave) CWsScreenDevice(ws); sl@0: User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); sl@0: RWindowGroup group(ws); sl@0: User::LeaveIfError(group.Construct(555)); // trigger a focus changed event sl@0: TRequestStatus stat; sl@0: ws.EventReady(&stat); sl@0: User::WaitForRequest(stat); sl@0: TPtrC8 badDesc(reinterpret_cast(0xDEAD),100); sl@0: ws.TestWrite(ws.WsHandle(),EWsClOpGetEvent,&badDesc,0); sl@0: } sl@0: break; sl@0: } sl@0: ws.Flush(); sl@0: return(EWsExitReasonBad); sl@0: } sl@0: sl@0: LOCAL_C TInt DoWinHandlePanicTestL(TInt aTest, TAny *) sl@0: { sl@0: RWsSession ws; sl@0: User::LeaveIfError(ws.Connect()); sl@0: RWindowGroup group1(ws); sl@0: RWindowGroup group2(ws); sl@0: RWindow win1(ws); sl@0: RWindow win2(ws); sl@0: switch(aTest) sl@0: { sl@0: case 1: sl@0: User::LeaveIfError(group1.Construct(888)); sl@0: User::LeaveIfError(group2.Construct(888)); sl@0: break; sl@0: case 2: sl@0: User::LeaveIfError(group1.Construct(777)); sl@0: User::LeaveIfError(win1.Construct(group1,888)); sl@0: User::LeaveIfError(win2.Construct(group1,888)); sl@0: break; sl@0: case 3: sl@0: User::LeaveIfError(group1.Construct(777)); sl@0: User::LeaveIfError(win1.Construct(group1,777)); sl@0: break; sl@0: case 4: sl@0: User::LeaveIfError(group1.Construct(777)); sl@0: User::LeaveIfError(win1.Construct(group1,0)); sl@0: break; sl@0: } sl@0: ws.Flush(); sl@0: return(EWsExitReasonBad); sl@0: } sl@0: sl@0: #ifdef __WINS__ sl@0: LOCAL_C TInt DoDeleteScreenPanicTestL(TInt aTest, TAny *aScreenNumber) sl@0: /** sl@0: * Test examples of use of the 'screen device deleted' panic for group windows. sl@0: * This is issued to panic the client, if they make API calls to RWindowGroup after having deleted sl@0: * the CWsScreenDevice with which that window group is associated. sl@0: */ sl@0: { sl@0: RWsSession ws; sl@0: User::LeaveIfError(ws.Connect()); sl@0: // point to correct screen sl@0: CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); sl@0: User::LeaveIfError(screen->Construct((TInt)aScreenNumber)); sl@0: sl@0: RWindowGroup group(ws); sl@0: User::LeaveIfError(group.Construct(888)); sl@0: group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close sl@0: switch(aTest) sl@0: { sl@0: // Test 1: deleting screen then modifying screen change events is illegal sl@0: case 1: sl@0: { sl@0: delete screen, screen=NULL; sl@0: group.EnableScreenChangeEvents(); sl@0: break; sl@0: } sl@0: // Test 2: deleting screen then setting window group name is illegal sl@0: case 2: sl@0: { sl@0: delete screen, screen=NULL; sl@0: _LIT(KPanicTest, "PanicTest"); sl@0: group.SetName(KPanicTest); sl@0: break; sl@0: } sl@0: } sl@0: ws.Flush(); sl@0: return(EWsExitReasonBad); sl@0: } sl@0: #endif sl@0: sl@0: LOCAL_C TInt DoUnInitPanicTest(TInt , TAny *) sl@0: { sl@0: // Creating a client session outside the test harness for panicking sl@0: // before initialisation as the test harness initialises the one it creates. sl@0: TVersion version(0,0,0); sl@0: _LIT(KServerName, "!Windowserver"); sl@0: sl@0: RUnInitalisedConnect myUnInit; sl@0: sl@0: User::LeaveIfError(myUnInit.Connect(KServerName(), version)); sl@0: myUnInit.Send(EWservMessCommandBuffer); sl@0: sl@0: return(EWsExitReasonBad); sl@0: } sl@0: sl@0: void CTPanic::TestScreenDevicePanicsL() sl@0: { sl@0: TEST(iTest->TestWsPanicL(&DoScreenDevicePanicTest,EWservPanicBitmap,1,(TAny*)iTest->iScreenNumber)); sl@0: sl@0: TEST(iTest->TestWsPanicL(&DoScreenDevicePanicTest,EWservPanicBitmap,2,(TAny*)iTest->iScreenNumber)); sl@0: } sl@0: sl@0: void CTPanic::TestMiscPanicsL() sl@0: { sl@0: TBool finished=EFalse; sl@0: TInt index=0; sl@0: while(!finished) sl@0: { sl@0: const TBool result = iTest->TestWsPanicL(&DoMiscPanicTest, EWservNoPanic, index, NULL, &finished); sl@0: if(!result) sl@0: { sl@0: INFO_PRINTF2(_L("TestMiscPanicsL %d failed"), index); sl@0: TEST(result); sl@0: } sl@0: index++; sl@0: } sl@0: } sl@0: sl@0: void CTPanic::LogHeapInfo() sl@0: { sl@0: _LIT(KInfoHeapSummary," WsHeap - Count=%d,Total=%d,Free=%d,Max free=%d"); sl@0: TPckgBuf heapInfo; sl@0: TheClient->iWs.DebugInfo(EWsDebugInfoHeap,heapInfo); sl@0: TBuf<256> infoBuf; sl@0: infoBuf.Format(KInfoHeapSummary,heapInfo().iCount,heapInfo().iTotal,heapInfo().iAvailable,heapInfo().iLargestAvailable); sl@0: INFO_PRINTF1(infoBuf); sl@0: } sl@0: sl@0: void CTPanic::TestGraphicsPanicsL(TClientPanic aExitReason, TInt aIndex, CTPanic::TPanicParams* aPanicParams) sl@0: { sl@0: TBool finished=EFalse; sl@0: aPanicParams->iSubTest=0; sl@0: sl@0: // uncomment to show which test is being run sl@0: INFO_PRINTF3(_L("GraphicsPanicTest %d, mode=%d"),aIndex,aPanicParams->iRedrawMode); sl@0: RDebug::Print(_L("GraphicsPanicTest %d, mode=%d"),aIndex,aPanicParams->iRedrawMode); sl@0: do sl@0: { sl@0: // uncomment for detailed view of which sub-test failed sl@0: LogHeapInfo(); sl@0: INFO_PRINTF4(_L("GraphicsPanicTest %d/%d, mode=%d"),aIndex,aPanicParams->iSubTest,aPanicParams->iRedrawMode); sl@0: RDebug::Print(_L("GraphicsPanicTest %d/%d, mode=%d"),aIndex,aPanicParams->iSubTest,aPanicParams->iRedrawMode); sl@0: TEST(iTest->TestWsPanicL(&GraphicsPanicTest,aExitReason,aIndex,aPanicParams,&finished)); sl@0: aPanicParams->iSubTest++; sl@0: } while(!finished); sl@0: iTest->CloseAllPanicWindows(); sl@0: } sl@0: sl@0: void CTPanic::TestGraphicsPanicsL(TPanicRedrawMode aRedrawMode) sl@0: { sl@0: CTPanic::TPanicParams pp; sl@0: pp.iScreen=iTest->iScreenNumber; sl@0: pp.iRedrawMode=aRedrawMode; sl@0: static TClientPanic expectedPanics[]= sl@0: { sl@0: EWservPanicBufferPtr, sl@0: EWservPanicBitmap, sl@0: EWservPanicBitmap, sl@0: EWservPanicBitmap, sl@0: EWservPanicOpcode, sl@0: EWservPanicBadPolyData, sl@0: EWservPanicBadPolyData, sl@0: EWservPanicOpcode, sl@0: EWservPanicGcActive, sl@0: EWservPanicNoFont, sl@0: EWservPanicNoBrush, sl@0: EWservPanicDescriptor, sl@0: EWservPanicFont, sl@0: EWservNoPanic, // Marks the end of the list sl@0: }; sl@0: TInt panicIndex=0; sl@0: TClientPanic expectedPanic; sl@0: while((expectedPanic=expectedPanics[panicIndex++])!=EWservNoPanic) sl@0: { sl@0: TestGraphicsPanicsL(expectedPanic,panicIndex,&pp); sl@0: } sl@0: } sl@0: sl@0: void CTPanic::TestGraphicsPanicsL() sl@0: { sl@0: TestGraphicsPanicsL(EPanicRedrawModeBackedUpWindow); sl@0: TestGraphicsPanicsL(EPanicRedrawModeNormalRedraw); sl@0: if (TransparencySupportedL()==KErrNone) sl@0: { sl@0: TestGraphicsPanicsL(EPanicRedrawModeTransRedraw); sl@0: } sl@0: TestGraphicsPanicsL(EPanicRedrawModeInvisRedraw); sl@0: } sl@0: sl@0: void CTPanic::TestDeletedParentPanicsL() sl@0: { sl@0: TEST(iTest->TestWsPanicL(&DoDeletedParentTest,EWservPanicParentDeleted,1,(TAny*)iTest->iScreenNumber)); sl@0: } sl@0: sl@0: void CTPanic::TestHandleReUseL() sl@0: { sl@0: for (TInt ii=2;ii<6;++ii) sl@0: { sl@0: TEST(iTest->TestWsPanicL(&DoHandleReUse,EWservPanicHandle,ii,(TAny*)iTest->iScreenNumber)); sl@0: } sl@0: } sl@0: sl@0: void CTPanic::TestComputeModePanicsL() sl@0: { sl@0: TEST(iTest->TestWsPanicL(&DoCMPanicTest,EWservPanicSetComputeMode,1,(TAny*)iTest->iScreenNumber)); sl@0: } sl@0: sl@0: void CTPanic::TestCaptureKeyPanicsL() sl@0: { sl@0: // Run this test in debug on emulator only. sl@0: // On a debug ROM the release version of the wserv.exe is included so the test can't be run as no panic happens. sl@0: #if defined(_DEBUG) && defined(__WINS__) sl@0: TEST(iTest->TestWsPanicL(&DoCKPanicTest,EWservPanicDestroy,1,(TAny*)iTest->iScreenNumber)); sl@0: #endif sl@0: } sl@0: sl@0: void CTPanic::TestEventPanicsL() sl@0: { sl@0: TEST(iTest->TestWsPanicL(&DoEventPanicTest,EWservPanicReadOutstanding,1,(TAny*)iTest->iScreenNumber)); sl@0: } sl@0: sl@0: void CTPanic::TestTPtrPanicsL() sl@0: { sl@0: TEST(iTest->TestWsPanicL(&DoTBufPtrTests,EWservPanicBufferPtr,1,(TAny*)iTest->iScreenNumber)); sl@0: } sl@0: sl@0: void CTPanic::TestOpcodePanicsL() sl@0: { sl@0: TInt param=1; sl@0: TBool finishTest = EFalse; sl@0: while(!finishTest) sl@0: { sl@0: TEST(iTest->TestWsPanicL(&DoOpcodeTests,EWservPanicOpcode,param,(TAny*)iTest->iScreenNumber,&finishTest)); sl@0: param++; sl@0: } sl@0: } sl@0: sl@0: void CTPanic::TestMultiInitPanicL() sl@0: { sl@0: TEST(iTest->TestWsPanicL(&DoMultiInitPanicTest,EWservPanicReInitialise,0,(TAny*)iTest->iScreenNumber)); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0472 sl@0: sl@0: @SYMDEF DEF118618 sl@0: sl@0: @SYMTestCaseDesc Test defect fixes to system panics sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Check that various defect fixes to system panics are correct. sl@0: Also verify that reconstructing a closed object will succeed. sl@0: sl@0: @SYMTestExpectedResults Panics respond correctly sl@0: */ sl@0: void CTPanic::TestDoubleConstructionL() sl@0: { sl@0: #ifdef __WINS__ sl@0: for(TInt test=1;test<11;test++) sl@0: { sl@0: TEST(iTest->TestW32PanicL(&DoDoubleConstructionTestL,EW32PanicGraphicDoubleConstruction,test,NULL)); sl@0: } sl@0: TestDoubleConstructionNoPanic(); sl@0: #endif sl@0: } sl@0: sl@0: /** Verifies the following scenario is valid: sl@0: 1. Create some wserv client-side objects. sl@0: 2. Call Close on them. sl@0: 3. Reconstruct them and they shouldn't panic this time. */ sl@0: void CTPanic::TestDoubleConstructionNoPanic() sl@0: { sl@0: RWsSession ws; sl@0: User::LeaveIfError(ws.Connect()); sl@0: sl@0: RWindowGroup group(ws); sl@0: User::LeaveIfError(group.Construct(890, EFalse)); sl@0: RBlankWindow bwin(ws); sl@0: User::LeaveIfError(bwin.Construct(group,900)); sl@0: sl@0: //RWsSprite sl@0: RWsSprite sprite(ws); sl@0: TEST(KErrNone == sprite.Construct(bwin,TPoint(0,0),0)); sl@0: sprite.Close(); sl@0: TEST(KErrNone == sprite.Construct(bwin,TPoint(0,0),0)); sl@0: sprite.Close(); sl@0: sl@0: //RWsPointerCursor sl@0: RWsPointerCursor cursor(ws); sl@0: TEST(KErrNone == cursor.Construct(0)); sl@0: cursor.Close(); sl@0: TEST(KErrNone == cursor.Construct(0)); sl@0: cursor.Close(); sl@0: sl@0: //RSoundPlugIn sl@0: RSoundPlugIn click(ws); sl@0: TEST(KErrNone == click.Construct()); sl@0: click.Close(); sl@0: TEST(KErrNone == click.Construct()); sl@0: click.Close(); sl@0: sl@0: //RWindowGroup sl@0: RWindowGroup windowgroup(ws); sl@0: TEST(KErrNone ==windowgroup.Construct(901)); sl@0: windowgroup.Close(); sl@0: TEST(KErrNone ==windowgroup.Construct(901)); sl@0: windowgroup.Close(); sl@0: sl@0: //RWindow sl@0: RWindow win1(ws); sl@0: TEST(KErrNone == win1.Construct(group,902)); sl@0: win1.Close(); sl@0: TEST(KErrNone == win1.Construct(group,902)); sl@0: win1.Close(); sl@0: sl@0: //RBlankWindow sl@0: RBlankWindow win2(ws); sl@0: TEST(KErrNone == win2.Construct(group,902)); sl@0: win2.Close(); sl@0: TEST(KErrNone == win2.Construct(group,902)); sl@0: win2.Close(); sl@0: sl@0: //RBackedUpWindow sl@0: RBackedUpWindow win3(ws); sl@0: TEST(KErrNone == win3.Construct(group,EGray4,902)); sl@0: win3.Close(); sl@0: TEST(KErrNone == win3.Construct(group,EGray4,902)); sl@0: win3.Close(); sl@0: sl@0: //RAnimDll sl@0: RAnimDll animDll=RAnimDll(ws); sl@0: TEST(KErrNone == animDll.Load(KAnimDLLName)); sl@0: animDll.Close(); sl@0: TEST(KErrNone == animDll.Load(KAnimDLLName)); sl@0: animDll.Close(); sl@0: sl@0: group.Close(); sl@0: bwin.Close(); sl@0: ws.Close(); sl@0: } sl@0: sl@0: void CTPanic::TestSpritePanicsL() sl@0: { sl@0: for(TInt test=1;test<4;test++) sl@0: { sl@0: TEST(iTest->TestWsPanicL(&DoSpritePanicTestL,EWservPanicSprite,test,(TAny*)iTest->iScreenNumber)); sl@0: } sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0475 sl@0: sl@0: @SYMDEF DEF118616 sl@0: sl@0: @SYMTestCaseDesc Test defect fixes to system panics sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Check that various defect fixes to system panics are correct. sl@0: sl@0: @SYMTestExpectedResults Panics respond correctly sl@0: */ sl@0: void CTPanic::TestSpriteActivatePanicL() sl@0: { sl@0: for(TInt test=1;test<3;test++) sl@0: { sl@0: TEST(iTest->TestWsPanicL(&DoTestSpriteActivatePanicL,EWservPanicNoSpriteMember,test,NULL)); sl@0: } sl@0: } sl@0: sl@0: void CTPanic::TestMoveToGroupPanicsL() sl@0: { sl@0: TEST(iTest->TestWsPanicL(&DoMoveToGroupPanicTestL,EWservPanicOpcode,1,(TAny*)iTest->iScreenNumber)); sl@0: TEST(iTest->TestWsPanicL(&DoMoveToGroupPanicTestL,EWservPanicNotTopClient,2,(TAny*)iTest->iScreenNumber)); sl@0: } sl@0: sl@0: void CTPanic::TestDeleteScreenPanicL() sl@0: { sl@0: #ifdef __WINS__ sl@0: TEST(iTest->TestWsPanicL(&DoDeleteScreenPanicTestL,EWservPanicGroupWinScreenDeviceDeleted,1,(TAny*)iTest->iScreenNumber)); sl@0: TEST(iTest->TestWsPanicL(&DoDeleteScreenPanicTestL,EWservPanicGroupWinScreenDeviceDeleted,2,(TAny*)iTest->iScreenNumber)); sl@0: #endif sl@0: } sl@0: sl@0: void CTPanic::TestWinHandleErrors() sl@0: { sl@0: #ifdef __WINS__ sl@0: TEST(iTest->TestWsPanicL(&DoWinHandlePanicTestL,EWservPanicDuplicateHandle,1)); sl@0: TEST(iTest->TestWsPanicL(&DoWinHandlePanicTestL,EWservPanicDuplicateHandle,2)); sl@0: TEST(iTest->TestWsPanicL(&DoWinHandlePanicTestL,EWservPanicDuplicateHandle,3)); sl@0: #endif sl@0: TEST(iTest->TestWsPanicL(&DoWinHandlePanicTestL,EWservPanicNullHandle,4)); sl@0: } sl@0: sl@0: void CTPanic::TestGetEventErrors() sl@0: { sl@0: TEST(iTest->TestWsPanicL(&DoGetEventPanicTestL,EWservPanicUnsignalledEventData,1,(TAny*)iTest->iScreenNumber)); sl@0: TEST(iTest->TestWsPanicL(&DoGetEventPanicTestL,EWservPanicDescriptor,2,(TAny*)iTest->iScreenNumber)); sl@0: } sl@0: sl@0: void CTPanic::TestUnInitPanicL() sl@0: { sl@0: TEST(iTest->TestWsPanicL(&DoUnInitPanicTest,EWservPanicUninitialisedClient,0,(TAny*)iTest->iScreenNumber)); sl@0: } sl@0: sl@0: void CTPanic::TestEnableAdvancePointerActivatePanicL() sl@0: { sl@0: TEST(iTest->TestWsPanicL(&DoTestAdvancePointerActivatePanicL,EWservPanicUnableToEnableAdvPointer, 0, (TAny*)iTest->iScreenNumber)); sl@0: } sl@0: sl@0: void CTPanic::ConstructL() sl@0: { sl@0: TheGc->Activate(*BaseWin->Win()); sl@0: TheGc->Clear(); sl@0: TheGc->SetBrushColor(TRgb::Gray16(12)); sl@0: TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: TheGc->SetPenStyle(CGraphicsContext::ENullPen); sl@0: TheGc->DrawRect(TRect(BaseWin->Win()->Size())); sl@0: TheGc->Deactivate(); sl@0: TheGc->Activate(*TestWin->Win()); sl@0: TheGc->Clear(); sl@0: TheGc->SetBrushColor(TRgb::Gray16(4)); sl@0: TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: TheGc->SetPenStyle(CGraphicsContext::ENullPen); sl@0: TheGc->DrawRect(TRect(TestWin->Win()->Size())); sl@0: TheGc->Deactivate(); sl@0: // sl@0: _LIT(KReportFullRom,"Warning full ROM, EikSrv present, panic dialogs may interfere with tests"); sl@0: _LIT(KReportGoodRom,"ROM OK, No EikSrv present"); sl@0: if (iTest->IsFullRomL()) sl@0: { sl@0: INFO_PRINTF1(KReportFullRom); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(KReportGoodRom); sl@0: } sl@0: } sl@0: sl@0: void CTPanic::TestAlphaBlendingPanicL() sl@0: { sl@0: INFO_PRINTF1(_L("Masked transparency support has been removed.")); sl@0: } sl@0: sl@0: void CTPanic::TestMismatchedCaptureCancelPanicL() sl@0: { sl@0: // Run this test in debug on emulator only. sl@0: // On a debug ROM the release version of the wserv.exe is included so the test can't be run as no panic happens. sl@0: #if defined(_DEBUG) && defined(__WINS__) sl@0: TEST(iTest->TestWsPanicL(DoMismatchedCancelCaptureTest,EWservPanicDestroy,ECancelCaptureKey,(TAny*)iTest->iScreenNumber)); sl@0: TEST(iTest->TestWsPanicL(DoMismatchedCancelCaptureTest,EWservPanicDestroy,ECancelCaptureKeyUpAndDowns,(TAny*)iTest->iScreenNumber)); sl@0: TEST(iTest->TestWsPanicL(DoMismatchedCancelCaptureTest,EWservPanicDestroy,ECancelCaptureLongKey,(TAny*)iTest->iScreenNumber)); sl@0: #endif sl@0: } sl@0: sl@0: void CTPanic::RunTestCaseL(TInt /*aCurTestCase*/) sl@0: { sl@0: ((CTPanicStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); sl@0: switch(++iTest->iState) sl@0: { sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0259 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Test various system panics sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Check that various system panics respond correctly sl@0: sl@0: @SYMTestExpectedResults Panics respond correctly sl@0: */ sl@0: case 1: sl@0: { sl@0: ((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0259")); sl@0: iTest->LogSubTest(_L("TestCaptureKeyPanicsL")); sl@0: TestCaptureKeyPanicsL(); sl@0: } sl@0: break; sl@0: case 2: sl@0: { sl@0: iTest->LogSubTest(_L("TestEventPanicsL")); sl@0: TestEventPanicsL(); sl@0: } sl@0: break; sl@0: case 3: sl@0: { sl@0: iTest->LogSubTest(_L("TestComputeModePanicsL")); sl@0: TestComputeModePanicsL(); sl@0: } sl@0: break; sl@0: case 4: sl@0: { sl@0: #ifdef __WINS__ sl@0: // Only running this under WINS as the tests are a bit excessive, firing off all sorts of illegal sl@0: // opcode/flag combinations, as well as buffers of random data. sl@0: // Currently on ARM builds they're failing with KErrOutOfMemory, probably running out of handles sl@0: // somewhere in the OS. sl@0: iTest->LogSubTest(_L("TestMiscPanicsL")); sl@0: TestMiscPanicsL(); sl@0: #endif sl@0: } sl@0: break; sl@0: case 5: sl@0: { sl@0: iTest->LogSubTest(_L("TestGraphicsPanicsL")); sl@0: TestGraphicsPanicsL(); sl@0: } sl@0: break; sl@0: case 6: sl@0: { sl@0: iTest->LogSubTest(_L("TestTPtrPanicsL")); sl@0: TestTPtrPanicsL(); sl@0: } sl@0: break; sl@0: case 7: sl@0: { sl@0: iTest->LogSubTest(_L("TestOpcodePanicsL")); sl@0: TestOpcodePanicsL(); sl@0: } sl@0: break; sl@0: case 8: sl@0: { sl@0: iTest->LogSubTest(_L("TestScreenDevicePanicsL")); sl@0: TestScreenDevicePanicsL(); sl@0: } sl@0: break; sl@0: case 9: sl@0: { sl@0: iTest->LogSubTest(_L("TestMultiInitPanicL")); sl@0: TestMultiInitPanicL(); sl@0: } sl@0: break; sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0260 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Test various system panics sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Check that various system panics respond correctly sl@0: sl@0: @SYMTestExpectedResults Panics respond correctly sl@0: */ sl@0: case 10: sl@0: { sl@0: ((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0260")); sl@0: iTest->LogSubTest(_L("Panic 2")); sl@0: TestSpritePanicsL(); sl@0: TestMoveToGroupPanicsL(); sl@0: } sl@0: break; sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0261 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Test defect fixes to system panics sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Check that various defect fixes to system panics are correct sl@0: sl@0: @SYMTestExpectedResults Panics respond correctly sl@0: */ sl@0: case 11: sl@0: { sl@0: ((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0261")); sl@0: _LIT(KPanicTest,"Defect Fixes (Pan.3)"); sl@0: iTest->LogSubTest(KPanicTest); sl@0: TestDeletedParentPanicsL(); sl@0: TestHandleReUseL(); sl@0: TestDeleteScreenPanicL(); // DEF069809 sl@0: } sl@0: break; sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-097969-0001 sl@0: sl@0: @SYMDEF DEF097969 sl@0: sl@0: @SYMTestCaseDesc Test defect fixes to system panics sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Check that various defect fixes to system panics are correct sl@0: sl@0: @SYMTestExpectedResults Panics respond correctly sl@0: */ sl@0: case 12: sl@0: { sl@0: ((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-097969-0001")); sl@0: _LIT(KPanicTest,"Server panic defect Fix (Pan.4)"); sl@0: iTest->LogSubTest(KPanicTest); sl@0: TestUnInitPanicL(); // DEF097969 sl@0: } sl@0: break; sl@0: sl@0: case 13: sl@0: { sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0501 sl@0: */ sl@0: ((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0501")); sl@0: _LIT(KPanicTest,"AlphaBlending Bitmap panic defect Fix (Pan.5)"); sl@0: iTest->LogSubTest(KPanicTest); sl@0: TestAlphaBlendingPanicL(); // DEF112916 sl@0: } sl@0: break; sl@0: case 14: sl@0: { sl@0: ((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0472")); sl@0: _LIT(KPanicTest,"Double construction panic test"); sl@0: iTest->LogSubTest(KPanicTest); sl@0: TestDoubleConstructionL(); // DEF118618 sl@0: } sl@0: break; sl@0: case 15: sl@0: { sl@0: ((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0475")); sl@0: _LIT(KPanicTest, "RWsSprite Activate() without members panic test"); sl@0: iTest->LogSubTest(KPanicTest); sl@0: TestSpriteActivatePanicL(); //DEF118616 sl@0: } sl@0: break; sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0497 sl@0: sl@0: @SYMDEF DEF133776 sl@0: sl@0: @SYMTestCaseDesc Test that a debug only panic occurs when an attempt sl@0: is made to cancel a key capture using the wrong cancel capture API. sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Check that calling the each RWindowGroup::CancelCapture***() API sl@0: using the handle returned from a mismatched RWindowGroup::Capture***() call causes sl@0: a debug only panic. Tests each of the three RWindowGroup::CancelCapture***() APIs. sl@0: sl@0: @SYMTestExpectedResults Panics respond correctly in debug only. sl@0: */ sl@0: case 16: sl@0: { sl@0: ((CTPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0497")); sl@0: _LIT(KPanicTest,"TestMismatchedCaptureCancelPanicL"); sl@0: iTest->LogSubTest(KPanicTest); sl@0: TestMismatchedCaptureCancelPanicL(); sl@0: } sl@0: break; sl@0: #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA sl@0: case 17: sl@0: { sl@0: _LIT(KPanicTest, "Non-Redraw Drawing inside Redrawer Panic Test"); sl@0: iTest->LogSubTest(KPanicTest); sl@0: TestNonRedrawRedrawerL(); sl@0: } sl@0: break; sl@0: case 18: sl@0: { sl@0: _LIT(KPanicTest, "Enable advanced pointer Panic Test"); sl@0: iTest->LogSubTest(KPanicTest); sl@0: TestEnableAdvancePointerActivatePanicL(); sl@0: } sl@0: break; sl@0: sl@0: #endif sl@0: default: sl@0: ((CTPanicStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); sl@0: ((CTPanicStep*)iStep)->CloseTMSGraphicsStep(); sl@0: TestComplete(); sl@0: break; sl@0: } sl@0: ((CTPanicStep*)iStep)->RecordTestResultL(); sl@0: } sl@0: sl@0: #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA sl@0: LOCAL_C TInt DoTestNonRedrawRedrawerL(TInt /* aInt */, TAny * /* aPtr */) sl@0: { sl@0: CActiveScheduler* scheduler = new (ELeave) CActiveScheduler(); sl@0: CleanupStack::PushL(scheduler); sl@0: CActiveScheduler::Install(scheduler); sl@0: sl@0: RWsSession session; sl@0: User::LeaveIfError(session.Connect()); sl@0: sl@0: CWsScreenDevice *screenDevice = new (ELeave)CWsScreenDevice(session); sl@0: User::LeaveIfError(screenDevice->Construct ()); sl@0: CWindowGc *gc; sl@0: User::LeaveIfError(screenDevice->CreateContext(gc)); sl@0: sl@0: CNonRedrawWin *nonRedrawWin=CNonRedrawWin::NewL(session, gc); sl@0: nonRedrawWin->Invalidate(); sl@0: CActiveScheduler::Start(); sl@0: User::After(2000000); // so the Redrawer has a chance to run sl@0: CActiveScheduler::Stop(); sl@0: delete gc; sl@0: delete screenDevice; sl@0: session.Close(); sl@0: CleanupStack::PopAndDestroy(scheduler); sl@0: return(EWsExitReasonBad); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0121808 sl@0: @SYMDEF DEF121808: No more Non-Redraw drawing for NGA (test added during DEF134308) sl@0: @SYMTestCaseDesc Test defect fixes to system panics sl@0: @SYMTestPriority High sl@0: @SYMTestStatus Implemented sl@0: @SYMTestActions Check that WServ panics a client which uses Non-Redraw drawing in the Redrawer. sl@0: @SYMTestExpectedResults Panics respond correctly sl@0: */ sl@0: void CTPanic::TestNonRedrawRedrawerL() sl@0: { sl@0: TEST(iTest->TestWsPanicL(&DoTestNonRedrawRedrawerL,EWservPanicWindowBeginRedrawNotCalled,NULL,NULL)); sl@0: } sl@0: sl@0: CNonRedrawWin::CRedrawer::CRedrawer(CNonRedrawWin* aWd) : sl@0: CActive(CActive::EPriorityStandard), iWd(aWd){ sl@0: CActiveScheduler::Add(this); sl@0: HandleRedrawEvent(); sl@0: } sl@0: sl@0: CNonRedrawWin::CRedrawer::~CRedrawer(){ sl@0: Cancel(); sl@0: } sl@0: sl@0: void CNonRedrawWin::CRedrawer::HandleRedrawEvent(){ sl@0: iWd->GetSession().RedrawReady(&iStatus); sl@0: SetActive(); sl@0: } sl@0: sl@0: void CNonRedrawWin::CRedrawer::RunL(){ sl@0: TWsRedrawEvent redrawEvent; sl@0: iWd->GetSession().GetRedraw(redrawEvent); sl@0: iWd->Redraw(); sl@0: HandleRedrawEvent(); sl@0: } sl@0: sl@0: void CNonRedrawWin::CRedrawer::DoCancel(){ sl@0: iWd->GetSession().RedrawReadyCancel(); sl@0: } sl@0: sl@0: CNonRedrawWin* CNonRedrawWin::NewL(RWsSession &aSession, CWindowGc *aGc){ sl@0: CNonRedrawWin* self=new(ELeave)CNonRedrawWin(aSession, aGc); sl@0: CleanupStack::PushL(self); sl@0: self->ConstrucL(); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: CNonRedrawWin::CNonRedrawWin(RWsSession &aSession, CWindowGc *aGc): sl@0: iSession(aSession), iGc(aGc){} sl@0: sl@0: CNonRedrawWin::~CNonRedrawWin(){ sl@0: delete iRedrawer; sl@0: iWd.Close(); sl@0: iWdGrp.Close(); sl@0: } sl@0: sl@0: void CNonRedrawWin::Redraw(){ sl@0: // This is a Non-Redraw Drawing Redrawer; BeginRedraw()/EndRedraw() sl@0: // have been intentionally omitted. sl@0: iGc->Activate(iWd); sl@0: iGc->SetBrushColor(TRgb(255,0,0)); sl@0: iGc->SetPenColor(KRgbBlue); sl@0: iGc->SetPenSize(TSize(10,20)); sl@0: iGc->DrawRect(TRect(TPoint(10,10),TPoint(50,50))); sl@0: iGc->Deactivate(); sl@0: iSession.Finish(); sl@0: } sl@0: sl@0: RWsSession &CNonRedrawWin::GetSession(){return iSession;} sl@0: sl@0: void CNonRedrawWin::Invalidate(){iWd.Invalidate();} sl@0: sl@0: void CNonRedrawWin::ConstrucL(){ sl@0: iWdGrp=RWindowGroup(iSession); sl@0: iWdGrp.Construct((TUint32)this,ETrue); sl@0: _LIT(KWndGrpName,"NonRedrawWndGrp"); sl@0: iWdGrp.SetName(KWndGrpName); sl@0: iWd=RWindow(iSession); sl@0: iWd.Construct(iWdGrp, 0x101); sl@0: User::LeaveIfError(iWd.SetExtentErr(TPoint(0,0),TSize(150,150))); sl@0: iWd.SetBackgroundColor(KRgbWhite); sl@0: iWd.SetOrdinalPosition(0); sl@0: iWd.Activate(); sl@0: iRedrawer=new(ELeave) CRedrawer(this); sl@0: } sl@0: #endif sl@0: sl@0: TInt RUnInitalisedConnect::Connect(const TDesC &aName, const TVersion &aVersion) sl@0: { sl@0: return CreateSession(aName, aVersion, 255); sl@0: } sl@0: sl@0: TInt RUnInitalisedConnect::Send(const TInt aMsg) sl@0: { sl@0: return SendReceive(aMsg); sl@0: } sl@0: sl@0: __WS_CONSTRUCT_STEP__(Panic) sl@0: #pragma warning( disable : 4505 )