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: // Out of memory tests 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: sl@0: #include "TOOM.H" sl@0: sl@0: sl@0: typedef COomFailBase *(*COmmCreate)(CTOom *aTest); sl@0: sl@0: COomFailBase *CreateOomConnect(CTOom *aTest) sl@0: {return(new(ELeave) COomConnect(aTest));} sl@0: sl@0: COomFailBase *CreateOomWindow(CTOom *aTest) sl@0: {return(new(ELeave) COomWindow(aTest));} sl@0: sl@0: COomFailBase *CreateOomWindowGroup(CTOom *aTest) sl@0: {return(new(ELeave) COomWindowGroup(aTest));} sl@0: sl@0: COomFailBase *CreateOomBackedUpWindow(CTOom *aTest) sl@0: {return(new(ELeave) COomBackedUpWindow(aTest));} sl@0: sl@0: COomFailBase *CreateOomBackupResize(CTOom *aTest) sl@0: {return(new(ELeave) COomBackupResize(aTest));} sl@0: sl@0: COomFailBase *CreateOomBlankWindow(CTOom *aTest) sl@0: {return(new(ELeave) COomBlankWindow(aTest));} sl@0: sl@0: COomFailBase *CreateOomGc(CTOom *aTest) sl@0: {return(new(ELeave) COomGc(aTest));} sl@0: sl@0: COomFailBase *CreateOomScreenDevice(CTOom *aTest) sl@0: {return(new(ELeave) COomScreenDevice(aTest));} sl@0: sl@0: COomFailBase *CreateOomPointerBuffer(CTOom *aTest) sl@0: {return(new(ELeave) COomPointerBuffer(aTest));} sl@0: sl@0: COomFailBase *CreateOomPolygon(CTOom *aTest) sl@0: {return(new(ELeave) COomPolygon(aTest));} sl@0: sl@0: COomFailBase *CreateOomPriorityKey(CTOom *aTest) sl@0: {return(new(ELeave) COomPriorityKey(aTest));} sl@0: sl@0: COomFailBase *CreateOomCaptureKey(CTOom *aTest) sl@0: {return(new(ELeave) COomCaptureKey(aTest));} sl@0: sl@0: COomFailBase *CreateOomCaptureKeyUpDown(CTOom *aTest) sl@0: {return(new(ELeave) COomCaptureKeyUpDown(aTest));} sl@0: sl@0: COomFailBase *CreateOomLongKeyCapture(CTOom *aTest) sl@0: {return(new(ELeave) COomLongKeyCapture(aTest));} sl@0: sl@0: COomFailBase *CreateOomHotKey(CTOom *aTest) sl@0: {return(new(ELeave) COomHotKey(aTest));} sl@0: sl@0: COomFailBase *CreateOomGroupName(CTOom *aTest) sl@0: {return(new(ELeave) COomGroupName(aTest));} sl@0: sl@0: COomFailBase *CreateOomMessageSend(CTOom *aTest) sl@0: {return(new(ELeave) COomMessageSend(aTest));} sl@0: sl@0: COomFailBase *CreateOomMessageFetch(CTOom *aTest) sl@0: {return(new(ELeave) COomMessageFetch(aTest));} sl@0: sl@0: COomFailBase *CreateOomSprite(CTOom *aTest) sl@0: {return(new(ELeave) COomSprite(aTest));} sl@0: sl@0: COomFailBase *CreateOomPointerCursor(CTOom *aTest) sl@0: {return(new(ELeave) COomPointerCursor(aTest));} sl@0: sl@0: COomFailBase *CreateOomCopyScreen(CTOom *aTest) sl@0: {return(new(ELeave) COomCopyScreen(aTest));} sl@0: sl@0: COomFailBase *CreateOomRequestEvents(CTOom *aTest) sl@0: {return(new(ELeave) COomRequestEvents(aTest));} sl@0: sl@0: COomFailBase *CreateOomCustomTextCursor(CTOom *aTest) sl@0: {return(new(ELeave) COomCustomTextCursor(aTest));} sl@0: sl@0: COomFailBase *CreateOomTranspWindow(CTOom *aTest) sl@0: {return(new(ELeave) COomTranspWindow(aTest));} sl@0: sl@0: COomFailBase *CreateOomObscuredWindow(CTOom *aTest) sl@0: {return(new(ELeave) COomObscuredWindow(aTest));} sl@0: sl@0: COmmCreate CreateOomFailTest[]={ sl@0: CreateOomConnect, sl@0: CreateOomWindow, sl@0: CreateOomWindowGroup, sl@0: CreateOomBackedUpWindow, sl@0: CreateOomBackupResize, sl@0: CreateOomBlankWindow, sl@0: CreateOomGc, sl@0: CreateOomScreenDevice, sl@0: CreateOomPointerBuffer, sl@0: CreateOomPolygon, sl@0: CreateOomPriorityKey, sl@0: CreateOomCaptureKey, sl@0: CreateOomCaptureKeyUpDown, sl@0: CreateOomLongKeyCapture, sl@0: CreateOomHotKey, sl@0: CreateOomGroupName, sl@0: CreateOomSprite, sl@0: CreateOomPointerCursor, sl@0: CreateOomCopyScreen, sl@0: CreateOomRequestEvents, sl@0: CreateOomMessageSend, sl@0: CreateOomMessageFetch, sl@0: CreateOomCustomTextCursor, sl@0: CreateOomTranspWindow, sl@0: CreateOomObscuredWindow, sl@0: }; sl@0: sl@0: // sl@0: // Individual out of memory test classes // sl@0: // sl@0: sl@0: COomFailBase::COomFailBase(CTOom *aTest) : iTest(aTest) sl@0: {} sl@0: sl@0: void COomFailBase::ConstructL() sl@0: { sl@0: iTest->INFO_PRINTF1(TestName()); sl@0: } sl@0: sl@0: void COomFailBase::PreFail() sl@0: {} sl@0: sl@0: void COomFailBase::ClearUpL() sl@0: {} sl@0: sl@0: void COomFailBase::Flush() sl@0: { sl@0: iWs.Flush(); sl@0: } sl@0: sl@0: COomConnect::COomConnect(CTOom *aTest) : COomFailBase(aTest) sl@0: {} sl@0: sl@0: TOomTestName COomConnect::TestName() sl@0: { sl@0: return(_L("Connect")); sl@0: } sl@0: sl@0: /** Creates a wserv session, connects and creates CWsScreenDevice object sl@0: */ sl@0: TInt COomConnect::Fail() sl@0: { sl@0: TInt err = iWs.Connect(); sl@0: if (err!=KErrNone) sl@0: return err; sl@0: sl@0: TRAP(err, iDummyScreen = new (ELeave) CWsScreenDevice(iWs)); sl@0: if (err!=KErrNone) sl@0: { sl@0: iWs.Close(); sl@0: return err; sl@0: } sl@0: sl@0: if ((err=iDummyScreen->Construct(iTest->ScreenNumber()))!=KErrNone) sl@0: { sl@0: delete iDummyScreen; sl@0: iDummyScreen = NULL; sl@0: iWs.Close(); sl@0: return err; sl@0: } sl@0: sl@0: return err; sl@0: } sl@0: sl@0: void COomConnect::ClearUpL() sl@0: { sl@0: if (iDummyScreen) sl@0: { sl@0: delete iDummyScreen; sl@0: iDummyScreen = NULL; sl@0: } sl@0: iWs.Close(); sl@0: } sl@0: sl@0: // sl@0: sl@0: COomSetup::COomSetup(CTOom *aTest) : COomFailBase(aTest) sl@0: {} sl@0: sl@0: void COomSetup::ConstructL() sl@0: { sl@0: COomFailBase::ConstructL(); sl@0: User::LeaveIfError(iWs.Connect()); sl@0: iDummyScreen = new (ELeave) CWsScreenDevice(iWs); sl@0: User::LeaveIfError(iDummyScreen->Construct(iTest->ScreenNumber())); sl@0: sl@0: iWinGroup=RWindowGroup(iWs); sl@0: iWinGroup.Construct(556); sl@0: iWinGroup.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close sl@0: } sl@0: sl@0: COomSetup::~COomSetup() sl@0: { sl@0: iWinGroup.Close(); sl@0: delete iDummyScreen; sl@0: iDummyScreen = NULL; sl@0: sl@0: iTest->TEST(iWs.ResourceCount()==0); sl@0: if (iWs.ResourceCount()!=0) sl@0: iTest->INFO_PRINTF3(_L("iWs.ResourceCount() return value - Expected: %d, Actual: %d"), 0, iWs.ResourceCount()); sl@0: sl@0: iWs.Close(); sl@0: } sl@0: sl@0: // sl@0: sl@0: COomWindowGroup::COomWindowGroup(CTOom *aTest) : COomSetup(aTest) sl@0: {} sl@0: sl@0: TOomTestName COomWindowGroup::TestName() sl@0: { sl@0: return(_L("Window Group")); sl@0: } sl@0: sl@0: /** Creates a RWindowGroup object sl@0: */ sl@0: TInt COomWindowGroup::Fail() sl@0: { sl@0: iFailWinGroup=RWindowGroup(iWs); sl@0: return(iFailWinGroup.Construct(987)); sl@0: } sl@0: sl@0: void COomWindowGroup::ClearUpL() sl@0: { sl@0: iFailWinGroup.Close(); sl@0: } sl@0: sl@0: // sl@0: sl@0: COomWindow::COomWindow(CTOom *aTest) : COomSetup(aTest) sl@0: {} sl@0: sl@0: TOomTestName COomWindow::TestName() sl@0: { sl@0: return(_L("Window")); sl@0: } sl@0: sl@0: /** Creates a RWindow object sl@0: */ sl@0: TInt COomWindow::Fail() sl@0: { sl@0: iFailWin=RWindow(iWs); sl@0: return(iFailWin.Construct(iWinGroup,11)); sl@0: } sl@0: sl@0: void COomWindow::ClearUpL() sl@0: { sl@0: iFailWin.Close(); sl@0: } sl@0: sl@0: // sl@0: sl@0: COomBackedUpWindow::COomBackedUpWindow(CTOom *aTest) : COomSetup(aTest) sl@0: {} sl@0: sl@0: TOomTestName COomBackedUpWindow::TestName() sl@0: { sl@0: return(_L("Backed up window")); sl@0: } sl@0: sl@0: /** Creates a RBackedUpWindow object sl@0: */ sl@0: TInt COomBackedUpWindow::Fail() sl@0: { sl@0: iFailWin=RBackedUpWindow(iWs); sl@0: return(iFailWin.Construct(iWinGroup,EGray16,22)); sl@0: } sl@0: sl@0: void COomBackedUpWindow::ClearUpL() sl@0: { sl@0: iFailWin.Close(); sl@0: } sl@0: sl@0: // sl@0: sl@0: COomBackupResize::COomBackupResize(CTOom *aTest) : COomSetup(aTest) sl@0: {} sl@0: sl@0: COomBackupResize::~COomBackupResize() sl@0: { sl@0: iFailWin.Close(); sl@0: } sl@0: sl@0: TOomTestName COomBackupResize::TestName() sl@0: { sl@0: return(_L("Resize backed up window")); sl@0: } sl@0: sl@0: void COomBackupResize::ConstructL() sl@0: { sl@0: COomSetup::ConstructL(); sl@0: iFailWin=RBackedUpWindow(iWs); sl@0: User::LeaveIfError(iFailWin.Construct(iWinGroup,EGray16,33)); sl@0: User::LeaveIfError(iFailWin.SetSizeErr(TSize(10,10))); sl@0: iFailWin.Activate(); sl@0: } sl@0: sl@0: /** Sets the size of previously created backed-up window sl@0: */ sl@0: TInt COomBackupResize::Fail() sl@0: { sl@0: return(iFailWin.SetSizeErr(TSize(100,100))); sl@0: } sl@0: sl@0: void COomBackupResize::ClearUpL() sl@0: //Virtual fn declared in CoomFailBase. This is the only one that can leave, I think, but one is enough sl@0: { sl@0: User::LeaveIfError(iFailWin.SetSizeErr(TSize(10,10))); sl@0: } sl@0: sl@0: // sl@0: sl@0: COomBlankWindow::COomBlankWindow(CTOom *aTest) : COomSetup(aTest) sl@0: {} sl@0: sl@0: TOomTestName COomBlankWindow::TestName() sl@0: { sl@0: return(_L("Blank window")); sl@0: } sl@0: sl@0: /** Creates a RBlankWindow object sl@0: */ sl@0: TInt COomBlankWindow::Fail() sl@0: { sl@0: iFailWin=RBlankWindow(iWs); sl@0: return(iFailWin.Construct(iWinGroup,44)); sl@0: } sl@0: sl@0: void COomBlankWindow::ClearUpL() sl@0: { sl@0: iFailWin.Close(); sl@0: } sl@0: sl@0: // sl@0: sl@0: COomPointerBuffer::COomPointerBuffer(CTOom *aTest) : COomSetup(aTest) sl@0: {} sl@0: sl@0: COomPointerBuffer::~COomPointerBuffer() sl@0: { sl@0: iFailWin.Close(); sl@0: } sl@0: sl@0: TOomTestName COomPointerBuffer::TestName() sl@0: { sl@0: return(_L("Pointer buffer")); sl@0: } sl@0: sl@0: void COomPointerBuffer::ConstructL() sl@0: { sl@0: COomSetup::ConstructL(); sl@0: iFailWin=RBackedUpWindow(iWs); sl@0: User::LeaveIfError(iFailWin.Construct(iWinGroup,EGray16,55)); sl@0: User::LeaveIfError(iFailWin.SetSizeErr(TSize(10,10))); sl@0: iFailWin.Activate(); sl@0: } sl@0: sl@0: /** Allocates a buffer for storing pointer movements for previously created backed-up window sl@0: */ sl@0: TInt COomPointerBuffer::Fail() sl@0: { sl@0: return(iFailWin.AllocPointerMoveBuffer(10,0)); sl@0: } sl@0: sl@0: void COomPointerBuffer::ClearUpL() sl@0: { sl@0: iFailWin.FreePointerMoveBuffer(); sl@0: } sl@0: sl@0: // sl@0: sl@0: COomPriorityKey::COomPriorityKey(CTOom *aTest) : COomSetup(aTest) sl@0: {} sl@0: sl@0: COomPriorityKey::~COomPriorityKey() sl@0: { sl@0: } sl@0: sl@0: TOomTestName COomPriorityKey::TestName() sl@0: { sl@0: return(_L("Priority key")); sl@0: } sl@0: sl@0: void COomPriorityKey::ConstructL() sl@0: { sl@0: COomSetup::ConstructL(); sl@0: } sl@0: sl@0: /** Adds a priority key for a previously created window group sl@0: */ sl@0: TInt COomPriorityKey::Fail() sl@0: { sl@0: return(iWinGroup.AddPriorityKey(1,0,0)); sl@0: } sl@0: sl@0: void COomPriorityKey::ClearUpL() sl@0: { sl@0: iWinGroup.RemovePriorityKey(1,0,0); sl@0: } sl@0: sl@0: // sl@0: sl@0: COomCaptureKeyBase::COomCaptureKeyBase(CTOom *aTest) : COomSetup(aTest) sl@0: {} sl@0: sl@0: COomCaptureKeyBase::~COomCaptureKeyBase() sl@0: {} sl@0: sl@0: void COomCaptureKeyBase::ConstructL() sl@0: { sl@0: COomSetup::ConstructL(); sl@0: } sl@0: sl@0: COomCaptureKey::COomCaptureKey(CTOom *aTest) : COomCaptureKeyBase(aTest) sl@0: {} sl@0: sl@0: COomCaptureKey::~COomCaptureKey() sl@0: { sl@0: } sl@0: sl@0: TOomTestName COomCaptureKey::TestName() sl@0: { sl@0: return(_L("Capture key")); sl@0: } sl@0: sl@0: /** Requests a capture keys for a previously created window group sl@0: */ sl@0: TInt COomCaptureKey::Fail() sl@0: { sl@0: for (iIndex=0;iIndex<(TInt)(sizeof(iCapKey)/sizeof(iCapKey[0]));iIndex++) sl@0: { sl@0: TInt ret=iWinGroup.CaptureKey('a',0,0); sl@0: if (ret<0) sl@0: return(ret); sl@0: iCapKey[iIndex]=ret; sl@0: } sl@0: return(KErrNone); sl@0: } sl@0: sl@0: void COomCaptureKey::ClearUpL() sl@0: { sl@0: for (TInt index=0;index params(_L8("SomeParams")); sl@0: return(iWs.SendMessageToWindowGroup(iWinGroup2.Identifier(),TUid::Uid(123),params)); sl@0: } sl@0: sl@0: void COomMessageSend::ClearUpL() sl@0: { sl@0: iWinGroup2.Close(); sl@0: } sl@0: sl@0: // sl@0: sl@0: COomMessageFetch::COomMessageFetch(CTOom *aTest) : COomSetup(aTest) sl@0: {} sl@0: sl@0: COomMessageFetch::~COomMessageFetch() sl@0: { sl@0: } sl@0: sl@0: TOomTestName COomMessageFetch::TestName() sl@0: { sl@0: return(_L("MessageFetch")); sl@0: } sl@0: sl@0: void COomMessageFetch::ConstructL() sl@0: { sl@0: COomSetup::ConstructL(); sl@0: } sl@0: sl@0: #define CLIENT_HANDLE 555 sl@0: #define UID_VALUE 123 sl@0: #define MESSAGE_LEN 0x20 sl@0: void COomMessageFetch::PreFail() sl@0: { sl@0: iWinGroup2=RWindowGroup(iWs); sl@0: iWinGroup2.Construct(CLIENT_HANDLE); sl@0: iWinGroup2.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close sl@0: TBuf8 params(_L8("SomeParams")); sl@0: TBool retVal = iWs.SendMessageToWindowGroup(iWinGroup2.Identifier(),TUid::Uid(UID_VALUE),params); sl@0: iTest->TEST(retVal==KErrNone); sl@0: if (retVal!=KErrNone) sl@0: iTest->INFO_PRINTF3(_L("iWs.SendMessageToWindowGroup() return value - Expected: %d, Actual: %d"), KErrNone, retVal); sl@0: } sl@0: sl@0: /** Fetches a message sl@0: */ sl@0: TInt COomMessageFetch::Fail() sl@0: { sl@0: TWsEvent event; sl@0: TPtr8 ptr(NULL,0); sl@0: TUid uid; sl@0: event.SetType(EEventMessageReady); sl@0: event.SetHandle(CLIENT_HANDLE); sl@0: event.SetTimeNow(); sl@0: SEventMessageReady& eventMessageReady=*(SEventMessageReady*)event.EventData(); sl@0: eventMessageReady.iWindowGroupIdentifier=iWinGroup2.Identifier(); sl@0: eventMessageReady.iMessageUid=TUid::Uid(UID_VALUE); sl@0: eventMessageReady.iMessageParametersSize=MESSAGE_LEN; sl@0: TInt ret=TheClient->iWs.FetchMessage(uid,ptr,event); sl@0: if (ret==KErrNone) sl@0: User::Free((TAny *)ptr.Ptr()); sl@0: return(ret); sl@0: } sl@0: sl@0: void COomMessageFetch::ClearUpL() sl@0: { sl@0: iWinGroup2.Close(); sl@0: } sl@0: sl@0: // sl@0: sl@0: COomRequestEvents::COomRequestEvents(CTOom *aTest) : COomSetup(aTest) sl@0: {} sl@0: sl@0: COomRequestEvents::~COomRequestEvents() sl@0: { sl@0: } sl@0: sl@0: TOomTestName COomRequestEvents::TestName() sl@0: { sl@0: return(_L("Request events")); sl@0: } sl@0: sl@0: void COomRequestEvents::ConstructL() sl@0: { sl@0: COomSetup::ConstructL(); sl@0: } sl@0: sl@0: /** Enables window group change events and modifier change events sl@0: */ sl@0: TInt COomRequestEvents::Fail() sl@0: { sl@0: TInt err; sl@0: if ((err=iWinGroup.EnableOnEvents())==KErrNone) sl@0: if ((err=iWinGroup.EnableGroupChangeEvents())==KErrNone) sl@0: err=iWinGroup.EnableModifierChangedEvents(EModifierCapsLock,EEventControlAlways); sl@0: return(err); sl@0: } sl@0: sl@0: void COomRequestEvents::ClearUpL() sl@0: { sl@0: iWinGroup.DisableOnEvents(); sl@0: iWinGroup.DisableGroupChangeEvents(); sl@0: iWinGroup.DisableModifierChangedEvents(); sl@0: } sl@0: sl@0: // sl@0: sl@0: COomCopyScreen::COomCopyScreen(CTOom *aTest) : COomSetup(aTest) sl@0: {} sl@0: sl@0: TOomTestName COomCopyScreen::TestName() sl@0: { sl@0: return(_L("Copy screen")); sl@0: } sl@0: sl@0: COomCopyScreen::~COomCopyScreen() sl@0: { sl@0: delete iScrDev; sl@0: delete iBitmap; sl@0: } sl@0: sl@0: void COomCopyScreen::ConstructL() sl@0: { sl@0: COomSetup::ConstructL(); sl@0: iScrDev=new(ELeave) CWsScreenDevice(iWs); sl@0: User::LeaveIfError(iScrDev->Construct(iTest->ScreenNumber())); sl@0: iBitmap=new(ELeave) CFbsBitmap(); sl@0: User::LeaveIfError(iBitmap->Create(TSize(100,100),EGray4)); sl@0: } sl@0: sl@0: /** Copies screen to bitmap sl@0: */ sl@0: TInt COomCopyScreen::Fail() sl@0: { sl@0: TInt ret=iScrDev->CopyScreenToBitmap(iBitmap); sl@0: if (ret==KErrNone) sl@0: ret=iScrDev->CopyScreenToBitmap(iBitmap,TRect(10,10,50,50)); sl@0: return(ret); sl@0: } sl@0: sl@0: void COomCopyScreen::ClearUpL() sl@0: { sl@0: } sl@0: sl@0: // sl@0: sl@0: COomSpriteBase::COomSpriteBase(CTOom *aTest) : COomSetup(aTest) sl@0: {} sl@0: sl@0: COomSpriteBase::~COomSpriteBase() sl@0: { sl@0: iWin.Close(); sl@0: delete iBitmap; sl@0: delete iMask; sl@0: delete iBitmap2; sl@0: delete iMask2; sl@0: } sl@0: sl@0: void COomSpriteBase::ConstructL() sl@0: { sl@0: COomSetup::ConstructL(); sl@0: iWin=RWindow(iWs); sl@0: User::LeaveIfError(iWin.Construct(iWinGroup,33)); sl@0: User::LeaveIfError(iWin.SetSizeErr(TSize(100,100))); sl@0: iWin.Activate(); sl@0: iBitmap=new(ELeave) CFbsBitmap(); sl@0: User::LeaveIfError(iBitmap->Create(TSize(10,10),EGray4)); sl@0: iBitmap2=new(ELeave) CFbsBitmap(); sl@0: User::LeaveIfError(iBitmap2->Create(TSize(40,40),EGray4)); sl@0: iMask=new(ELeave) CFbsBitmap(); sl@0: User::LeaveIfError(iMask->Create(TSize(10,10),EGray4)); sl@0: iMask2=new(ELeave) CFbsBitmap(); sl@0: User::LeaveIfError(iMask2->Create(TSize(40,40),EGray4)); sl@0: } sl@0: sl@0: // sl@0: sl@0: COomSprite::COomSprite(CTOom *aTest) : COomSpriteBase(aTest) sl@0: {} sl@0: sl@0: TOomTestName COomSprite::TestName() sl@0: { sl@0: return(_L("Sprites")); sl@0: } sl@0: sl@0: /** Creates a sprite. sl@0: */ sl@0: TInt COomSprite::Fail() sl@0: { sl@0: iSprite=RWsSprite(iWs); sl@0: TInt err=iSprite.Construct(iWin,TPoint(10,10),0); sl@0: if (err==KErrNone) sl@0: { sl@0: TSpriteMember sprite; sl@0: sprite.iBitmap=iBitmap; sl@0: sprite.iMaskBitmap=iMask; sl@0: sprite.iInvertMask=EFalse; sl@0: sprite.iDrawMode=CGraphicsContext::EDrawModePEN; sl@0: sprite.iOffset=TPoint(0,0); sl@0: sprite.iInterval=TTimeIntervalMicroSeconds32(100000); sl@0: if ((err=iSprite.AppendMember(sprite))==KErrNone) sl@0: if ((err=iSprite.Activate())==KErrNone) sl@0: { sl@0: sprite.iBitmap=iBitmap2; // Bigger bitmap to force resize of bitmap sl@0: sprite.iMaskBitmap=iMask2; sl@0: if ((err=iSprite.AppendMember(sprite))==KErrNone) sl@0: err=iSprite.UpdateMember(1,sprite); sl@0: } sl@0: } sl@0: return(err); sl@0: } sl@0: sl@0: void COomSprite::ClearUpL() sl@0: { sl@0: iSprite.Close(); sl@0: } sl@0: sl@0: // sl@0: sl@0: COomPointerCursor::COomPointerCursor(CTOom *aTest) : COomSpriteBase(aTest) sl@0: {} sl@0: sl@0: TOomTestName COomPointerCursor::TestName() sl@0: { sl@0: return(_L("Pointer cursor")); sl@0: } sl@0: sl@0: /** Creates a pointer cursor. sl@0: */ sl@0: TInt COomPointerCursor::Fail() sl@0: { sl@0: iPointerCursor=RWsPointerCursor(iWs); sl@0: TInt err=iPointerCursor.Construct(0); sl@0: if (err==KErrNone) sl@0: { sl@0: TSpriteMember sprite; sl@0: sprite.iBitmap=iBitmap; sl@0: sprite.iMaskBitmap=iMask; sl@0: sprite.iInvertMask=EFalse; sl@0: sprite.iDrawMode=CGraphicsContext::EDrawModePEN; sl@0: sprite.iOffset=TPoint(0,0); sl@0: sprite.iInterval=TTimeIntervalMicroSeconds32(100000); sl@0: if ((err=iPointerCursor.AppendMember(sprite))==KErrNone) sl@0: if ((err=iPointerCursor.Activate())==KErrNone) sl@0: { sl@0: sprite.iBitmap=iBitmap2; // Bigger bitmap to force resize of bitmap sl@0: sprite.iMaskBitmap=iMask2; sl@0: if ((err=iPointerCursor.AppendMember(sprite))==KErrNone) sl@0: err=iPointerCursor.UpdateMember(1,sprite); sl@0: } sl@0: } sl@0: return(err); sl@0: } sl@0: sl@0: void COomPointerCursor::ClearUpL() sl@0: { sl@0: iPointerCursor.Close(); sl@0: } sl@0: sl@0: // sl@0: sl@0: COomGc::COomGc(CTOom *aTest) : COomSetup(aTest) sl@0: {} sl@0: sl@0: COomGc::~COomGc() sl@0: { sl@0: delete iScrDev; sl@0: } sl@0: sl@0: TOomTestName COomGc::TestName() sl@0: { sl@0: return(_L("Graphic Context")); sl@0: } sl@0: sl@0: void COomGc::ConstructL() sl@0: { sl@0: COomSetup::ConstructL(); sl@0: iScrDev=new(ELeave) CWsScreenDevice(iWs); sl@0: User::LeaveIfError(iScrDev->Construct(iTest->ScreenNumber())); sl@0: } sl@0: sl@0: /** Creates a graphical context for a previously created screen device. sl@0: */ sl@0: TInt COomGc::Fail() sl@0: { sl@0: TRAPD(err,iFailGc=new(ELeave) CWindowGc(iScrDev)); sl@0: if (err!=KErrNone) sl@0: return(err); sl@0: return(iFailGc->Construct()); sl@0: } sl@0: sl@0: void COomGc::ClearUpL() sl@0: { sl@0: delete iFailGc; sl@0: iFailGc=NULL; sl@0: } sl@0: sl@0: // sl@0: sl@0: COomPolygon::COomPolygon(CTOom *aTest) : COomSetup(aTest), iPnts(5) sl@0: {} sl@0: sl@0: COomPolygon::~COomPolygon() sl@0: { sl@0: delete iGc; sl@0: delete iScrDev; sl@0: iWin.Close(); sl@0: } sl@0: sl@0: TOomTestName COomPolygon::TestName() sl@0: { sl@0: return(_L("Polygon")); sl@0: } sl@0: sl@0: void COomPolygon::ConstructL() sl@0: { sl@0: COomSetup::ConstructL(); sl@0: iScrDev=new(ELeave) CWsScreenDevice(iWs); sl@0: User::LeaveIfError(iScrDev->Construct(iTest->ScreenNumber())); sl@0: User::LeaveIfError(iScrDev->CreateContext(iGc)); sl@0: iWin=RBackedUpWindow(iWs); sl@0: User::LeaveIfError(iWin.Construct(iWinGroup,EGray16,33)); sl@0: User::LeaveIfError(iWin.SetSizeErr(TSize(40,40))); sl@0: iWin.Activate(); sl@0: TInt index; sl@0: for(index=0;index<20;index+=2) sl@0: iPnts.AppendL(TPoint(20+index,index)); sl@0: for(index=0;index<20;index+=2) sl@0: iPnts.AppendL(TPoint(40-index,20+index)); sl@0: for(index=0;index<20;index+=2) sl@0: iPnts.AppendL(TPoint(20-index,40-index)); sl@0: for(index=0;index<20;index+=2) sl@0: iPnts.AppendL(TPoint(index,20-index)); sl@0: } sl@0: sl@0: /** Draws a polygon. sl@0: */ sl@0: TInt COomPolygon::Fail() sl@0: { sl@0: iGc->Activate(iWin); sl@0: iGc->Clear(); sl@0: iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: iGc->SetBrushColor(TRgb::Gray4(2)); sl@0: iGc->SetPenColor(TRgb::Gray4(0)); sl@0: TInt err=iGc->DrawPolygon(&iPnts,CGraphicsContext::EAlternate); sl@0: if (err!=KErrNone) sl@0: return(err); sl@0: err=iGc->DrawPolygon(&iPnts,CGraphicsContext::EWinding); sl@0: if (err!=KErrNone) sl@0: return(err); sl@0: return(KErrNone); sl@0: } sl@0: sl@0: void COomPolygon::ClearUpL() sl@0: { sl@0: iGc->Deactivate(); sl@0: } sl@0: sl@0: // sl@0: sl@0: COomScreenDevice::COomScreenDevice(CTOom *aTest) : COomSetup(aTest) sl@0: {} sl@0: sl@0: TOomTestName COomScreenDevice::TestName() sl@0: { sl@0: return(_L("Screen device")); sl@0: } sl@0: sl@0: /** Creates a screen device handle. sl@0: */ sl@0: TInt COomScreenDevice::Fail() sl@0: { sl@0: TRAPD(err,iScrDev=new(ELeave) CWsScreenDevice(iWs)); sl@0: if (err!=KErrNone) sl@0: return(err); sl@0: return(iScrDev->Construct(iTest->ScreenNumber())); sl@0: } sl@0: sl@0: void COomScreenDevice::ClearUpL() sl@0: { sl@0: delete iScrDev; sl@0: iScrDev=NULL; sl@0: } sl@0: sl@0: // sl@0: sl@0: COomCustomTextCursor::COomCustomTextCursor(CTOom *aTest) : COomSetup(aTest) sl@0: {} sl@0: sl@0: COomCustomTextCursor::~COomCustomTextCursor() sl@0: { sl@0: delete iMemberArray; sl@0: delete iBitmap; sl@0: } sl@0: sl@0: TOomTestName COomCustomTextCursor::TestName() sl@0: { sl@0: return(_L("Custom Text Cursor")); sl@0: } sl@0: sl@0: void COomCustomTextCursor::ConstructL() sl@0: { sl@0: COomSetup::ConstructL(); sl@0: sl@0: iBitmap = new(ELeave) CFbsBitmap; sl@0: User::LeaveIfError(iBitmap->Load(TEST_BITMAP_NAME, EMbmWsautotestBmp1)); sl@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 = iBitmap; sl@0: sl@0: iMemberArray = new(ELeave) CArrayFixFlat(1); sl@0: iMemberArray->AppendL(member); sl@0: } sl@0: sl@0: /** Adds a custom text cursor to the server's list of cursors. sl@0: */ sl@0: TInt COomCustomTextCursor::Fail() sl@0: { sl@0: TInt err = TheClient->iWs.SetCustomTextCursor(0x98765432, iMemberArray->Array(), 0, RWsSession::ECustomTextCursorAlignTop); sl@0: if (err == KErrAlreadyExists) sl@0: return KErrNone; sl@0: else sl@0: return err; sl@0: } sl@0: sl@0: void COomCustomTextCursor::ClearUpL() sl@0: { sl@0: } sl@0: sl@0: COomTranspWindow::COomTranspWindow(CTOom *aTest) : COomSetup(aTest) sl@0: {} sl@0: sl@0: COomTranspWindow::~COomTranspWindow() sl@0: { sl@0: delete iBackgroundWin; sl@0: delete iFirst; sl@0: delete iSecond; sl@0: sl@0: delete iFbsBitmap; sl@0: delete iWsBitmap; sl@0: delete iFbsBitmapDevice; sl@0: delete iFbsBitmapGc; sl@0: delete iWsBitmapDevice; sl@0: delete iWsBitmapGc; sl@0: } sl@0: sl@0: TOomTestName COomTranspWindow::TestName() sl@0: { sl@0: return(_L("Transparent Window")); sl@0: } sl@0: sl@0: void COomTranspWindow::ConstructL() sl@0: { sl@0: COomSetup::ConstructL(); sl@0: sl@0: iTransparencyEnabled = (TransparencySupportedL() == KErrNone); sl@0: if(!iTransparencyEnabled) sl@0: return; sl@0: sl@0: iFbsBitmap = new (ELeave) CFbsBitmap; sl@0: sl@0: // Do the creation sl@0: const TSize KSizeForBitmap(10,10); sl@0: iFbsBitmap->Create(KSizeForBitmap,EGray256); sl@0: sl@0: // Fill the bitmap with a colour sl@0: iFbsBitmapDevice=CFbsBitmapDevice::NewL(iFbsBitmap); sl@0: sl@0: iFbsBitmapDevice->CreateContext(iFbsBitmapGc); sl@0: sl@0: iFbsBitmapGc->SetPenStyle(CGraphicsContext::ENullPen); sl@0: iFbsBitmapGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: iFbsBitmapGc->SetBrushColor(128); sl@0: iFbsBitmapGc->DrawRect(TRect(KSizeForBitmap)); sl@0: sl@0: // Create a CWsBitmap, and fill it with a colour sl@0: iWsBitmap = new (ELeave) CWsBitmap(TheClient->iWs); sl@0: sl@0: // Do the creation sl@0: iWsBitmap->Create(KSizeForBitmap,EGray256); sl@0: sl@0: // Fill the bitmap with a colour sl@0: iWsBitmapDevice=CFbsBitmapDevice::NewL(iWsBitmap); sl@0: sl@0: iWsBitmapDevice->CreateContext(iWsBitmapGc); sl@0: iWsBitmapGc->SetPenStyle(CGraphicsContext::ENullPen); sl@0: iWsBitmapGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: iWsBitmapGc->SetBrushColor(128); sl@0: iWsBitmapGc->DrawRect(TRect(KSizeForBitmap)); sl@0: } sl@0: sl@0: sl@0: /** Does nothing if transparency is not enabled. Creates a blank window with sl@0: * two transparent child-windows. Tests setting the transparency via a factor, CFbsBitmap sl@0: * or a CWsBitmap, and changing from one to the other. sl@0: * Changes child-windows' sizes and toggles their visibility. sl@0: */ sl@0: TInt COomTranspWindow::Fail() sl@0: { sl@0: if(!iTransparencyEnabled) sl@0: return KErrNone; sl@0: TSize scrSize(TheClient->iScreen->SizeInPixels()); sl@0: TRAPD(res, iBackgroundWin = new (ELeave) CBlankWindow(TRgb(0,0,238))); sl@0: if(res != KErrNone) sl@0: { sl@0: return res; sl@0: } sl@0: sl@0: TDisplayMode mode=EColor256; sl@0: TRAP(res, iBackgroundWin->SetUpL(TPoint(50,50),scrSize-TSize(100,100),TheClient->iGroup,*TheClient->iGc,&mode)); sl@0: if(res != KErrNone) sl@0: { sl@0: return res; sl@0: } sl@0: sl@0: TheClient->Flush(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: sl@0: iBackgroundWin->Win()->SetBackgroundColor(TRgb(51,204,51)); sl@0: iBackgroundWin->Invalidate(); sl@0: sl@0: TheClient->Flush(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: sl@0: TRect thePos1(20, 20, 60, 60); sl@0: TRect thePos2(100, 40, 160, 80); sl@0: TRAP(res, iFirst = CTransWindow::NewL(iBackgroundWin, TRgb(255,0,0,128),&mode)); sl@0: if(res != KErrNone) sl@0: { sl@0: return res; sl@0: } sl@0: sl@0: TRAP(res, iSecond = CTransWindow::NewL(iBackgroundWin, TRgb(255,0,0,128),&mode)); sl@0: if(res != KErrNone) sl@0: { sl@0: return res; sl@0: } sl@0: sl@0: TRAP(res, iFirst->SetExtL(thePos1.iTl,thePos1.Size())); sl@0: if(res != KErrNone) sl@0: { sl@0: return res; sl@0: } sl@0: sl@0: TRAP(res, iSecond->SetExtL(thePos2.iTl,thePos2.Size())); sl@0: if(res != KErrNone) sl@0: { sl@0: return res; sl@0: } sl@0: sl@0: res=SetTransparencyTesting(); sl@0: if(res != KErrNone) sl@0: { sl@0: return res; sl@0: } sl@0: sl@0: TheClient->Flush(); sl@0: //TheClient->WaitForRedrawsToFinish(); sl@0: sl@0: iFirst->Activate(); sl@0: iFirst->AssignGC(*TheClient->iGc); sl@0: sl@0: iSecond->Activate(); sl@0: iSecond->AssignGC(*TheClient->iGc); sl@0: sl@0: iFirst->Win()->SetBackgroundColor(TRgb(0, 0, 255)); sl@0: iSecond->Win()->SetBackgroundColor(TRgb(0, 0, 255)); sl@0: iFirst->Invalidate(); sl@0: iSecond->Invalidate(); sl@0: sl@0: iFirst->AdjustSize(150,10, 0); sl@0: iSecond->AdjustSize(150,10, 0); sl@0: sl@0: TheClient->Flush(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: sl@0: iFirst->ToggleVisibility(); sl@0: iSecond->ToggleVisibility(); sl@0: sl@0: TheClient->Flush(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: sl@0: iFirst->AdjustSize(200,10, 0); sl@0: iSecond->AdjustSize(200,10, 0); sl@0: sl@0: iFirst->ToggleVisibility(); sl@0: iSecond->ToggleVisibility(); sl@0: sl@0: TheClient->Flush(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: sl@0: return KErrNone; sl@0: } sl@0: sl@0: sl@0: // This function tests setting the transparency via a factor, CFbsBitmap sl@0: // or a CWsBitmap, and changing from one to the other. sl@0: TInt COomTranspWindow::SetTransparencyTesting() sl@0: { sl@0: TInt res; sl@0: TLogMessageText buf; sl@0: sl@0: // Need all nine transitions, from the 3 ways to the same 3 ways. sl@0: // The ways are Factor, CWsBitmap, CFbsBitmap sl@0: const TRgb KTransparencyFactor(128,128,128); sl@0: res=iFirst->Win()->SetTransparencyFactor(KTransparencyFactor); sl@0: if (res!=KErrNone) sl@0: { sl@0: buf=_L("test failure!! with SetTransparencyFactor -1"); sl@0: TheClient->LogMessage(buf); sl@0: return res; sl@0: } sl@0: sl@0: res=iFirst->Win()->SetTransparencyBitmap(*iFbsBitmap); sl@0: if (res!=KErrNone) sl@0: { sl@0: buf=_L("test failure!! with SetTransparencyBitmap - fbs -2"); sl@0: TheClient->LogMessage(buf); sl@0: return res; sl@0: } sl@0: sl@0: res=iFirst->Win()->SetTransparencyWsBitmap(*iWsBitmap); sl@0: if (res!=KErrNone) sl@0: { sl@0: buf=_L("test failure!! with SetTransparencyBitmap - Ws -3"); sl@0: TheClient->LogMessage(buf); sl@0: return res; sl@0: } sl@0: sl@0: res=iFirst->Win()->SetTransparencyFactor(KTransparencyFactor); sl@0: if (res!=KErrNone) sl@0: { sl@0: buf=_L("test failure!! with SetTransparencyBitmap - fbs -4"); sl@0: TheClient->LogMessage(buf); sl@0: return res; sl@0: } sl@0: res=iFirst->Win()->SetTransparencyWsBitmap(*iWsBitmap); sl@0: if (res!=KErrNone) sl@0: { sl@0: buf=_L("test failure!! with SetTransparencyBitmap - Ws -5"); sl@0: TheClient->LogMessage(buf); sl@0: return res; sl@0: } sl@0: res=iFirst->Win()->SetTransparencyWsBitmap(*iWsBitmap); sl@0: if (res!=KErrNone) sl@0: { sl@0: buf=_L("test failure!! with SetTransparencyBitmap - Ws -6"); sl@0: TheClient->LogMessage(buf); sl@0: return res; sl@0: } sl@0: sl@0: res=iFirst->Win()->SetTransparencyBitmap(*iFbsBitmap); sl@0: if (res!=KErrNone) sl@0: { sl@0: buf=_L("test failure!! with SetTransparencyBitmap - fbs -7"); sl@0: TheClient->LogMessage(buf); sl@0: return res; sl@0: } sl@0: sl@0: res=iFirst->Win()->SetTransparencyBitmap(*iFbsBitmap); sl@0: if (res!=KErrNone) sl@0: { sl@0: buf=_L("test failure!! with SetTransparencyBitmap - fbs -8"); sl@0: TheClient->LogMessage(buf); sl@0: return res; sl@0: } sl@0: sl@0: res=iFirst->Win()->SetTransparencyFactor(KTransparencyFactor); sl@0: if (res!=KErrNone) sl@0: { sl@0: buf=_L("test failure!! with SetTransparencyFactor -9"); sl@0: TheClient->LogMessage(buf); sl@0: return res; sl@0: } sl@0: sl@0: res=iFirst->Win()->SetTransparencyFactor(KTransparencyFactor); sl@0: if (res!=KErrNone) sl@0: { sl@0: buf=_L("test failure!! with SetTransparencyFactor -10"); sl@0: TheClient->LogMessage(buf); sl@0: return res; sl@0: } sl@0: sl@0: return res; sl@0: } sl@0: sl@0: void COomTranspWindow::ClearUpL() sl@0: { sl@0: delete iFirst; sl@0: iFirst = NULL; sl@0: delete iSecond; sl@0: iSecond = NULL; sl@0: delete iBackgroundWin; sl@0: iBackgroundWin = NULL; sl@0: } sl@0: sl@0: // sl@0: sl@0: CWindowWithOneLine* CWindowWithOneLine::NewL(CTWinBase& aParent, const TRect& aExtent) sl@0: { sl@0: CWindowWithOneLine* self = new(ELeave) CWindowWithOneLine; sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(aParent); sl@0: const TSize screenSize(TheClient->iScreen->SizeInPixels()); sl@0: self->SetExtL(aExtent.iTl, aExtent.Size()); sl@0: self->AssignGC(*TheClient->iGc); sl@0: self->Activate(); sl@0: self->DrawNow(); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: void CWindowWithOneLine::Draw() sl@0: { sl@0: iGc->DrawLine(TPoint(0,0), TPoint(Size().iWidth, Size().iHeight)); sl@0: } sl@0: sl@0: // sl@0: sl@0: COomObscuredWindow::COomObscuredWindow(CTOom *aTest) : COomSetup(aTest) sl@0: {} sl@0: sl@0: TOomTestName COomObscuredWindow::TestName() sl@0: { sl@0: return(_L("Obscured window")); sl@0: } sl@0: sl@0: TInt COomObscuredWindow::Fail() sl@0: { sl@0: TRAPD(err, DoFailL()); sl@0: return err; sl@0: } sl@0: sl@0: sl@0: void COomObscuredWindow::DoFailL() sl@0: { sl@0: #ifdef __WINS__ sl@0: RDebug::Print(_L("COomObscuredWindow::DoFailL - enter")); sl@0: #endif sl@0: const TRect extent(20, 20, 100, 100); sl@0: CBlankWindow* backgroundWindow = new(ELeave) CBlankWindow(TRgb(12, 23, 34)); sl@0: CleanupStack::PushL(backgroundWindow); sl@0: TDisplayMode mode = EColor16MAP; sl@0: backgroundWindow->SetUpL(extent.iTl, extent.Size(), TheClient->iGroup, *TheClient->iGc, &mode); sl@0: sl@0: CWindowWithOneLine* window = CWindowWithOneLine::NewL(*backgroundWindow, extent); sl@0: CleanupStack::PushL(window); sl@0: #ifdef __WINS__ sl@0: RDebug::Print(_L("COomObscuredWindow - WaitForRedrawsToFinish - 1")); sl@0: #endif sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: sl@0: CBlankWindow* obscuringWindow = new(ELeave) CBlankWindow(TRgb(255, 0, 0)); sl@0: CleanupStack::PushL(obscuringWindow); sl@0: obscuringWindow->SetUpL(extent.iTl, extent.Size(), backgroundWindow, *TheClient->iGc, &mode); sl@0: sl@0: TheClient->Flush(); sl@0: #ifdef __WINS__ sl@0: RDebug::Print(_L("COomObscuredWindow - WaitForRedrawsToFinish - 2")); sl@0: #endif sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: sl@0: window->Invalidate(); sl@0: sl@0: for(TInt i = 0; i < 50; i++) sl@0: { sl@0: RWindow anotherWin(iWs); sl@0: User::LeaveIfError(anotherWin.Construct(iWinGroup, 11)); sl@0: anotherWin.Close(); sl@0: sl@0: if(i % 4) sl@0: window->Invalidate(); sl@0: sl@0: TheClient->Flush(); sl@0: #ifdef __WINS__ sl@0: RDebug::Print(_L("COomObscuredWindow - WaitForRedrawsToFinish - 3 - %d"), i); sl@0: #endif sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: } sl@0: sl@0: TheClient->Flush(); sl@0: #ifdef __WINS__ sl@0: RDebug::Print(_L("COomObscuredWindow - WaitForRedrawsToFinish - 4")); sl@0: #endif sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: sl@0: CleanupStack::PopAndDestroy(obscuringWindow); sl@0: CleanupStack::PopAndDestroy(window); sl@0: CleanupStack::PopAndDestroy(backgroundWindow); sl@0: #ifdef __WINS__ sl@0: RDebug::Print(_L("COomObscuredWindow::DoFailL - exit")); sl@0: #endif sl@0: } sl@0: sl@0: void COomObscuredWindow::ClearUpL() sl@0: { sl@0: } sl@0: sl@0: // sl@0: sl@0: CTOom::CTOom(CTestStep* aStep) : CTWsGraphicsBase(aStep) sl@0: { sl@0: iState = 0; sl@0: } sl@0: sl@0: const TDesC& CTOom::TestName() const sl@0: { sl@0: _LIT(KTestName,"CTOom"); sl@0: return(KTestName()); sl@0: } sl@0: sl@0: void CTOom::DoOomTestL(COomFailBase *aOomTest) sl@0: { sl@0: //TLogMessageText buf; sl@0: TEST(aOomTest!=NULL); sl@0: if (aOomTest==NULL) sl@0: INFO_PRINTF1(_L("aOomTest - Expected: Not Null, Actual: NULL")); sl@0: sl@0: TRAPD(ret1,aOomTest->ConstructL()); sl@0: TEST(ret1==KErrNone); sl@0: if (ret1!=KErrNone) sl@0: INFO_PRINTF3(_L("aOomTest->ConstructL() return value - Expected: %d, Actual: %d"), KErrNone, ret1); sl@0: sl@0: aOomTest->Flush(); sl@0: __UHEAP_MARK; sl@0: // TInt oldCount=TheClient->iWs.HeapCount(); sl@0: for(TInt mode=0;mode<3;mode++) sl@0: { sl@0: /*buf.Format(_L("OOMTest[%d] Mode=%d"),iState,mode), sl@0: TheClient->LogMessage(buf);*/ sl@0: TInt successCount=0; sl@0: for(TInt count=1;;count++) sl@0: { sl@0: TInt ret; sl@0: aOomTest->PreFail(); sl@0: if (mode==0) sl@0: TheClient->iWs.HeapSetFail(RHeap::EDeterministic,count); sl@0: else if (mode==1) sl@0: TheClient->iWs.HeapSetBurstFail(RHeap::EBurstFailNext, count, KMaxTUint16); sl@0: else if (mode==3) sl@0: { sl@0: __UHEAP_SETFAIL(RHeap::EDeterministic,count); //Leavescan will complain about EFailNext, although it isn't a leaving function sl@0: } sl@0: ret=aOomTest->Fail(); sl@0: if (mode==0) sl@0: TheClient->iWs.HeapSetFail(RHeap::ENone,0); sl@0: else if (mode==1) sl@0: TheClient->iWs.HeapSetBurstFail(RHeap::ENone, 0, 0); sl@0: else if (mode==2) sl@0: { sl@0: __UHEAP_RESET; sl@0: } sl@0: aOomTest->ClearUpL(); //In just 1 case this could leave... sl@0: aOomTest->Flush(); sl@0: if (ret==KErrNone) sl@0: { sl@0: if (successCount==10) sl@0: break; sl@0: successCount++; sl@0: } sl@0: else sl@0: { sl@0: /*if (successCount>0) sl@0: { sl@0: buf.Format(_L("[%d,%d] Count=%d, MaxSuccess=%d"),iState,mode,count,successCount); sl@0: TheClient->LogMessage(buf); sl@0: }*/ sl@0: successCount=0; sl@0: /*if (ret!=KErrNoMemory) sl@0: { sl@0: buf.Format(_L("[%d,%d] Fail, Count=%d, Error=%d"),iState,mode,count,ret); sl@0: TheClient->LogMessage(buf); sl@0: }*/ sl@0: TEST(ret==KErrNoMemory); sl@0: if (ret!=KErrNoMemory) sl@0: INFO_PRINTF3(_L("aOomTest->Fail() return value - Expected: %d, Actual: %d"), KErrNoMemory, ret); sl@0: sl@0: } sl@0: } sl@0: /*buf.Format(_L("[%d,%d] LastCount=%d"),iState,mode,count), sl@0: TheClient->LogMessage(buf);*/ sl@0: } sl@0: // TEST(oldCount>=TheClient->iWs.HeapCount()); sl@0: __UHEAP_MARKEND; sl@0: delete aOomTest; sl@0: /*buf.Format(_L("OOMTest[%d] Finished"),iState); sl@0: TheClient->LogMessage(buf);*/ sl@0: } sl@0: sl@0: void CTOom::ConstructL() sl@0: { sl@0: iShieldWin=RBlankWindow(TheClient->iWs); sl@0: User::LeaveIfError(iShieldWin.Construct(*(TheClient->iGroup->GroupWin()),1)); sl@0: // iShieldWin.SetOrdinalPosition(0,-1); sl@0: iShieldWin.Activate(); sl@0: } sl@0: sl@0: CTOom::~CTOom() sl@0: { sl@0: iShieldWin.Close(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0124 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Out of memory tests sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Uses deterministic heap failure mode to test WSERV classes against out-of-memory errors. sl@0: Sets and unsets deterministic mode using both RWsSession.HeapSetFail() methods and sl@0: __UHEAP_SETFAIL/__UHEAP_RESET macros (doing this both client and WSERV threads are tested). sl@0: On each step the test creates a failure object and repeatedly asks it to do some work (calling Fail() method). sl@0: A failure object is an object which encapsulates some allocation functionality inside it's Fail() method. sl@0: The test is performed for 23 different failure objects that do the following: sl@0: 1. Creates a wserv session, connects and creates CWsScreenDevice object. sl@0: 2. Creates a RWindowGroup object. sl@0: 3. Creates a RWindow object. sl@0: 4. Creates a RBackedUpWindow object. sl@0: 5. Sets the size of previously created backed-up window. sl@0: 6. Creates a RBlankWindow object. sl@0: 7. Allocates a buffer for storing pointer movements for a previously created backed-up window. sl@0: 8. Adds a priority key for a previously created window group. sl@0: 9. Requests a capture keys for a previously created window group. sl@0: 10. Requests the capture of key-up and key-down events for a previously created window group. sl@0: 11. Sets hot key for the session. sl@0: 12. Sets the window group's name. sl@0: 13. Sends a message to another window group. sl@0: 14. Fetches a message. sl@0: 15. Enables window group change events and modifier change events. sl@0: 16. Copies screen to bitmap. sl@0: 17. Creates a sprite. sl@0: 18. Creates a pointer cursor. sl@0: 19. Creates a graphical context for a previously created screen device. sl@0: 20. Draws a polygon. sl@0: 21. Creates a screen device handle. sl@0: 22. Adds a custom text cursor to the server's list of cursors. sl@0: 23. Does nothing if transparency is not enabled. Creates a blank window with sl@0: two transparent child-windows. Tests setting the transparency via a factor, CFbsBitmap sl@0: or a CWsBitmap, and changing from one to the other. sl@0: Changes child-windows' sizes and toggles their visibility. sl@0: sl@0: sl@0: @SYMTestExpectedResults The test checks that the creation failure objects doesn't fail and their's work either causes no errors or causes KErrNoMemory error. sl@0: */ sl@0: void CTOom::RunTestCaseL(TInt /*aCurTestCase*/) sl@0: { sl@0: ((CTOomStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0124")); sl@0: if (iState==0) sl@0: { sl@0: // commented by Anton Golovko, 01.03.2006 while converting to TEF sl@0: // the code below prevented the test to do anything. sl@0: // if (iTest->IsFullRomL()) sl@0: // { sl@0: // TestComplete(); sl@0: // return; sl@0: // } sl@0: iOldCount=TheClient->iWs.HeapCount(); sl@0: } sl@0: else if (iState==sizeof(CreateOomFailTest)/sizeof(CreateOomFailTest[0])) sl@0: { sl@0: iTest->CloseAllPanicWindows(); sl@0: TInt heapCount=TheClient->iWs.HeapCount(); sl@0: if (heapCount>iOldCount) sl@0: { sl@0: TEST(iOldCount>=heapCount-184); //For some uninvestigated reason 184 object get allocated on the server side, partly because of INFO_PRINTF1 sl@0: if (iOldCount=heapCount-174 - Expected: %d, Actual: %d"), heapCount-184, iOldCount); sl@0: sl@0: } sl@0: ((CTOomStep*)iStep)->CloseTMSGraphicsStep(); sl@0: TestComplete(); sl@0: return; sl@0: } sl@0: DoOomTestL(CreateOomFailTest[iState++](this)); sl@0: ((CTOomStep*)iStep)->RecordTestResultL(); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: __WS_CONSTRUCT_STEP__(Oom) sl@0: