sl@0: // Copyright (c) 1996-2009 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: // sl@0: sl@0: /** sl@0: @file sl@0: @test sl@0: @internalComponent - Internal Symbian test code sl@0: */ sl@0: sl@0: #include "TSPRITE.H" sl@0: sl@0: CTTSprite::CTTSprite(CTestStep* aStep): sl@0: CTWsGraphicsBase(aStep) sl@0: { sl@0: INFO_PRINTF1(_L("Testing TSprite functions")); sl@0: } sl@0: sl@0: void CTTSprite::SetUpMember(TSpriteMember &aMember) sl@0: { sl@0: aMember.iMaskBitmap=NULL; sl@0: aMember.iInvertMask=EFalse; sl@0: aMember.iDrawMode=CGraphicsContext::EDrawModePEN; sl@0: aMember.iOffset=TPoint(); sl@0: aMember.iInterval=TTimeIntervalMicroSeconds32(0); sl@0: aMember.iBitmap=&iBitmap; sl@0: } sl@0: sl@0: void CTTSprite::SetUpPointerCursorL(RWsPointerCursor &aCursor, RWsSession &aSession) sl@0: { sl@0: aCursor=RWsPointerCursor(aSession); sl@0: TSpriteMember member; sl@0: SetUpMember(member); sl@0: User::LeaveIfError(aCursor.Construct(0)); sl@0: User::LeaveIfError(aCursor.AppendMember(member)); sl@0: User::LeaveIfError(aCursor.Activate()); sl@0: } sl@0: sl@0: void CTTSprite::SetUpSpriteL(RWsSprite &aSprite, RWsSession &aSession, RWindowTreeNode &aWindow,TInt aFlags/*=0*/) sl@0: { sl@0: aSprite=RWsSprite(aSession); sl@0: User::LeaveIfError(aSprite.Construct(aWindow,TPoint(),aFlags)); sl@0: TSpriteMember member; sl@0: SetUpMember(member); sl@0: User::LeaveIfError(aSprite.AppendMember(member)); sl@0: User::LeaveIfError(aSprite.Activate()); sl@0: } sl@0: sl@0: void CTTSprite::ConstructL() sl@0: { sl@0: User::LeaveIfError(iBitmap.Load(TEST_BITMAP_NAME,0)); sl@0: } sl@0: sl@0: CTTSprite::~CTTSprite() sl@0: { sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0018 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc General cursor tests involving a sprite sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Carries out cursor and window tests before updating sl@0: a cursor's member with a sprite sl@0: sl@0: @SYMTestExpectedResults When the cursor member is update returns KErrArgument sl@0: */ sl@0: sl@0: void CTTSprite::GeneralTestsL() sl@0: { sl@0: // sl@0: // Close cursor while still active on a window sl@0: // sl@0: sl@0: RWindow win(TheClient->iWs); sl@0: win.Construct(*TheClient->iGroup->GroupWin(),1); sl@0: win.Activate(); sl@0: SetUpPointerCursorL(iCursor1,TheClient->iWs); sl@0: win.SetCustomPointerCursor(iCursor1); sl@0: iCursor1.Close(); sl@0: // sl@0: // Close window while cursor active on it sl@0: // sl@0: SetUpPointerCursorL(iCursor1,TheClient->iWs); sl@0: win.SetCustomPointerCursor(iCursor1); sl@0: win.Close(); sl@0: iCursor1.Close(); sl@0: sl@0: // sl@0: // Close session with: sl@0: // An open cursor active on a window & A closed cursor active on another window sl@0: // sl@0: RWsSession ws; sl@0: User::LeaveIfError(ws.Connect()); sl@0: // use correct screen sl@0: // sl@0: ws.SetFocusScreen(iTest->iScreenNumber); sl@0: CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); sl@0: CleanupStack::PushL(screen); sl@0: User::LeaveIfError(screen->Construct(0)); sl@0: sl@0: RWindowGroup group(ws); sl@0: User::LeaveIfError(group.Construct(123)); sl@0: group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close sl@0: RWindow win2(ws); sl@0: User::LeaveIfError(win2.Construct(group, 1)); sl@0: win2.Activate(); sl@0: RWindow win3(ws); sl@0: User::LeaveIfError(win3.Construct(group, 2)); sl@0: win3.Activate(); sl@0: // sl@0: SetUpPointerCursorL(iCursor1,ws); sl@0: SetUpPointerCursorL(iCursor2,ws); sl@0: win2.SetCustomPointerCursor(iCursor1); sl@0: win3.SetCustomPointerCursor(iCursor2); sl@0: // sl@0: TSpriteMember member; sl@0: member.iBitmap=member.iMaskBitmap=NULL; sl@0: TInt err = iCursor1.UpdateMember(9999,member); sl@0: TEST(err==KErrArgument); sl@0: if (err!=KErrArgument) sl@0: INFO_PRINTF3(_L("iCursor1.UpdateMember(9999,member) return value - Expected: %d, Actual: %d"), KErrArgument, err); sl@0: sl@0: iCursor1.Close(); sl@0: sl@0: CleanupStack::PopAndDestroy(screen); sl@0: ws.Close(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0019 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Construct a sprite in a group window sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Creates a sprite in a group window sl@0: sl@0: @SYMTestExpectedResults The sprite is created without error sl@0: */ sl@0: void CTTSprite::GroupWindowSpritesL() sl@0: { sl@0: RWsSprite sprite1; sl@0: RWsSprite sprite2; sl@0: SetUpSpriteL(sprite1,TheClient->iWs,*TheClient->iGroup->GroupWin()); sl@0: SetUpSpriteL(sprite2,TheClient->iWs,*TheClient->iGroup->GroupWin()); sl@0: TheClient->iWs.Flush(); sl@0: sprite2.Close(); sl@0: sprite1.Close(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0020 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Constructs a number of different sprites in different windows sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Creates many sprites in three different windows and the checks sl@0: the sprites can be manipulated sl@0: sl@0: @SYMTestExpectedResults The sprite are created and manipulated without error sl@0: */ sl@0: #define NUM_SPRITES 8 sl@0: void CTTSprite::LotsSpritesL() sl@0: { sl@0: CTBlankWindow* win=new(ELeave) CTBlankWindow(); sl@0: CTBlankWindow* win2=new(ELeave) CTBlankWindow(); sl@0: TSize size(100,120); sl@0: win->ConstructL(*TheClient->iGroup); sl@0: win2->ConstructL(*win); sl@0: win2->SetExt(TPoint(100,100),size); sl@0: win2->SetColor(TRgb::Gray4(2)); sl@0: RWindowBase window=*win->BaseWin(); sl@0: RWindowBase window2=*win2->BaseWin(); sl@0: window.Activate(); sl@0: window2.Activate(); sl@0: RWsSprite sprite[NUM_SPRITES]; sl@0: TInt ii; sl@0: //TheClient->iWs.SetAutoFlush(ETrue); sl@0: for (ii=0;iiiWs,window); sl@0: sprite[4].Close(); sl@0: sprite[2].SetPosition(TPoint(20,20)); sl@0: sprite[0].Close(); sl@0: win2->SetExt(TPoint(80,100),size); sl@0: sprite[6].SetPosition(TPoint(60,120)); sl@0: sprite[7].Close(); sl@0: sprite[5].SetPosition(TPoint(100,120)); sl@0: sprite[3].Close(); sl@0: SetUpSpriteL(sprite[7],TheClient->iWs,window); sl@0: sprite[7].SetPosition(TPoint(80,150)); sl@0: sprite[1].Close(); sl@0: win2->SetExt(TPoint(60,110),size); sl@0: sprite[5].SetPosition(TPoint(50,40)); sl@0: sprite[7].Close(); sl@0: SetUpSpriteL(sprite[0],TheClient->iWs,window); sl@0: sprite[0].SetPosition(TPoint(55,65)); sl@0: sprite[6].Close(); sl@0: win2->SetExt(TPoint(40,90),size); sl@0: sprite[2].SetPosition(TPoint(80,45)); sl@0: sprite[5].Close(); sl@0: sprite[0].SetPosition(TPoint(90,60)); sl@0: sprite[2].Close(); sl@0: SetUpSpriteL(sprite[2],TheClient->iWs,window); sl@0: sprite[2].SetPosition(TPoint(70,80)); sl@0: sprite[0].Close(); sl@0: win2->SetExt(TPoint(20,80),size); sl@0: sprite[2].SetPosition(TPoint(600,200)); sl@0: sprite[2].Close(); sl@0: SetUpSpriteL(sprite[0],TheClient->iWs,window2,ESpriteFlash); sl@0: sprite[0].SetPosition(TPoint(0,25)); sl@0: SetUpSpriteL(sprite[1],TheClient->iWs,window2,ESpriteFlash); sl@0: SetUpSpriteL(sprite[2],TheClient->iWs,window2,ESpriteFlash); sl@0: sprite[2].SetPosition(TPoint(25,0)); sl@0: win2->SetExt(TPoint(40,70),size); sl@0: CTBlankWindow* win3=new(ELeave) CTBlankWindow(); sl@0: win3->ConstructL(*TheClient->iGroup); sl@0: win3->SetExt(TPoint(30,60),TSize(30,30)); sl@0: win3->SetColor(TRgb::Gray4(1)); sl@0: win3->BaseWin()->SetShadowHeight(10); sl@0: win3->BaseWin()->Activate(); sl@0: User::After(1000000); //1 sec so sprites has time to flash sl@0: delete win2; sl@0: delete win; sl@0: delete win3; sl@0: sprite[0].Close(); sl@0: sprite[1].Close(); sl@0: sprite[2].Close(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0021 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc General PointerCursor Tests sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Exercise the different pointercursor methods of a Window Server Session sl@0: sl@0: @SYMTestExpectedResults The methods are called without error sl@0: */ sl@0: void CTTSprite::GeneralPointerCursor() sl@0: { sl@0: if (!TestBase()->ConfigurationSupportsPointerEventTesting()) sl@0: { sl@0: INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing")); sl@0: return; sl@0: } sl@0: TInt currentSMode=TheClient->iScreen->CurrentScreenMode(); sl@0: TInt altSMode=-1; sl@0: if (TheClient->iScreen->NumScreenModes()>1) sl@0: altSMode=(currentSMode==1?0:1); sl@0: RWsSession &ws=TheClient->iWs; sl@0: TRect rect=ws.PointerCursorArea(); sl@0: TRect testRect1(TPoint(rect.iBr.iX/4,rect.iBr.iY/4),TSize(rect.Width()/2,rect.Height()/2)); sl@0: TRect testRect2(TPoint(rect.iBr.iX/3,rect.iBr.iY/3),TSize(2*rect.Width()/3,2*rect.Height()/3)); sl@0: ws.SetPointerCursorArea(testRect1); sl@0: TEST(ws.PointerCursorArea()==testRect1); sl@0: TEST(ws.PointerCursorArea(currentSMode)==testRect1); sl@0: ws.SetPointerCursorArea(currentSMode,testRect2); sl@0: TEST(ws.PointerCursorArea()==testRect2); sl@0: TEST(ws.PointerCursorArea(currentSMode)==testRect2); sl@0: ws.SetPointerCursorArea(rect); sl@0: TEST(ws.PointerCursorArea()==rect); sl@0: sl@0: if (altSMode>=0) sl@0: { sl@0: rect=ws.PointerCursorArea(altSMode); sl@0: testRect1.iTl.iX=rect.iBr.iX/4; sl@0: testRect1.iTl.iY=rect.iBr.iY/4; sl@0: testRect1.SetWidth(rect.Width()/2); sl@0: testRect1.SetHeight(rect.Height()/2); sl@0: ws.SetPointerCursorArea(altSMode,testRect1); sl@0: TEST(ws.PointerCursorArea(altSMode)==testRect1); sl@0: ws.SetPointerCursorArea(altSMode,rect); sl@0: TEST(ws.PointerCursorArea(altSMode)==rect); sl@0: } sl@0: TPointerCursorMode currentMode=ws.PointerCursorMode(); sl@0: TInt ii; sl@0: TInt err1; sl@0: for(ii=EPointerCursorFirstMode;ii<=EPointerCursorLastMode;ii++) sl@0: { sl@0: ws.SetPointerCursorMode(STATIC_CAST(TPointerCursorMode,ii)); sl@0: err1 = ws.PointerCursorMode(); sl@0: TEST(ii==err1); sl@0: if (ii!=err1) sl@0: INFO_PRINTF3(_L("ws.PointerCursorMode() return value - Expected: %d, Actual: %d"), ii, err1); sl@0: } sl@0: ws.SetPointerCursorMode(currentMode); sl@0: TEST(currentMode==ws.PointerCursorMode()); sl@0: TPoint point1(10,12); sl@0: TPoint point2(24,20); sl@0: ws.PointerCursorPosition(); sl@0: ws.SetPointerCursorPosition(point1); sl@0: TEST(ws.PointerCursorPosition()==point1); sl@0: ws.SetPointerCursorPosition(point2); sl@0: TEST(ws.PointerCursorPosition()==point2); sl@0: } sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0498 sl@0: sl@0: @SYMDEF PDEF137614 - Propagation to TB92 sl@0: sl@0: @SYMTestCaseDesc Test activating a pointer cursor sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Construct and activate a pointer cursor. sl@0: Check it is visible. sl@0: Deactivate it sl@0: Check it is removed sl@0: sl@0: sl@0: @SYMTestExpectedResults sl@0: The pointer cursor bitmp should be visible when activated and removed when deactivated. sl@0: */ sl@0: sl@0: void CTTSprite::PointerCursorVisibleL() sl@0: { sl@0: if (!TestBase()->ConfigurationSupportsPointerEventTesting()) sl@0: { sl@0: INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing")); sl@0: return; sl@0: } sl@0: sl@0: // The pointer events need time to have an affect on the wserv sl@0: static const TInt eventPropagationDelay = 100 * 1000; // 100 ms sl@0: sl@0: TInt screenNumber = TheClient->iScreen->GetScreenNumber(); sl@0: sl@0: if(screenNumber != 0) // pointer events only supported on emulator screen 0 sl@0: { sl@0: LOG_MESSAGE(_L("Pointer Cursor Visible only runs on screen 0")); sl@0: return; sl@0: } sl@0: sl@0: // set up objects used in test sl@0: // 50x50 red rectangle colour 24 sl@0: CFbsBitmap bitmap; sl@0: User::LeaveIfError(bitmap.Load(TEST_BITMAP_NAME, 8)); sl@0: sl@0: TSize bmSize = bitmap.SizeInPixels(); sl@0: TPoint bmSample = TPoint(bmSize.iWidth / 2, bmSize.iHeight / 2); sl@0: TRgb bmColour; sl@0: bitmap.GetPixel(bmColour, bmSample); sl@0: TEST(bmColour == KRgbRed); sl@0: sl@0: // single window, size of screen sl@0: RWindow win(TheClient->iWs); sl@0: User::LeaveIfError(win.Construct(*TheClient->iGroup->GroupWin(),1)); sl@0: win.Activate(); sl@0: sl@0: // setup cursor mode sl@0: TheClient->iWs.SetPointerCursorMode(EPointerCursorWindow); sl@0: sl@0: // setup cursor to contain single 50x50 red bitmap sl@0: RWsPointerCursor iCursor1 = RWsPointerCursor(TheClient->iWs); sl@0: TSpriteMember member; sl@0: SetUpMember(member); sl@0: member.iBitmap=&bitmap; sl@0: User::LeaveIfError(iCursor1.Construct(0)); sl@0: User::LeaveIfError(iCursor1.AppendMember(member)); sl@0: User::LeaveIfError(iCursor1.Activate()); sl@0: win.SetCustomPointerCursor(iCursor1); sl@0: iCursor1.UpdateMember(0); sl@0: sl@0: // draw a green rect, size of screen as defined background and wait till it is rendered sl@0: win.BeginRedraw(); sl@0: TheGc->Activate(win); sl@0: TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: TheGc->SetBrushColor(KRgbGreen); sl@0: TSize wSize = win.Size(); sl@0: TheGc->DrawRect(TRect(TPoint(0,0), wSize)); sl@0: TheGc->Deactivate(); sl@0: win.EndRedraw(); sl@0: TheClient->iWs.Finish(); sl@0: sl@0: // #### do test #### sl@0: // define locations of simulated pointer events and sample positions of where we expect to see the cursor sl@0: // The cursor will be moved and a check will be made to see if this has actually happened sl@0: sl@0: TPoint pos1(wSize.iWidth / 2, wSize.iHeight / 2); // top left of cursor at centre screen sl@0: TPoint sample1(pos1 + bmSample); // centre of sprite at pos1 sl@0: TPoint pos2 = pos1 - bmSize; // bottom right of cursor at centre screen sl@0: TPoint sample2 = pos2 + bmSample; // centre of sprite at pos2 sl@0: sl@0: TRgb pixel; sl@0: sl@0: // check initial state of screen at both sample positions sl@0: TheClient->iScreen->GetPixel(pixel, sample1); sl@0: TEST(pixel == KRgbGreen); sl@0: sl@0: TheClient->iScreen->GetPixel(pixel, sample2); sl@0: TEST(pixel == KRgbGreen); sl@0: sl@0: TRawEvent e; // to simulate pointer events sl@0: sl@0: // simulate button 1 down event at pos1 sl@0: e.Set(TRawEvent::EButton1Down, pos1.iX, pos1.iY); sl@0: e.SetDeviceNumber(screenNumber); sl@0: UserSvr::AddEvent(e); sl@0: sl@0: User::After(eventPropagationDelay); sl@0: sl@0: // check red cursor visible on top of background sl@0: TheClient->iScreen->GetPixel(pixel, sample1); sl@0: TEST(pixel == KRgbRed); sl@0: sl@0: // simulate button 1 up event sl@0: e.Set(TRawEvent::EButton1Up, pos1.iX, pos1.iY); sl@0: UserSvr::AddEvent(e); sl@0: User::After(eventPropagationDelay); sl@0: sl@0: // Move cursor away to pos2 sl@0: e.Set(TRawEvent::EButton1Down, pos2.iX, pos2.iY); sl@0: e.SetDeviceNumber(screenNumber); sl@0: UserSvr::AddEvent(e); sl@0: sl@0: User::After(eventPropagationDelay); sl@0: sl@0: // check cursor has left this position ... sl@0: TheClient->iScreen->GetPixel(pixel, sample1); sl@0: TEST(pixel == KRgbGreen); sl@0: // and arrived at the correct place sl@0: TheClient->iScreen->GetPixel(pixel, sample2); sl@0: TEST(pixel == KRgbRed); sl@0: sl@0: // simulate button 1 up event sl@0: e.Set(TRawEvent::EButton1Up, pos2.iX, pos2.iY); sl@0: UserSvr::AddEvent(e); sl@0: User::After(eventPropagationDelay); sl@0: sl@0: // remove the cursor sl@0: win.ClearPointerCursor(); sl@0: User::After(eventPropagationDelay); sl@0: sl@0: // check it has gone sl@0: TheClient->iScreen->GetPixel(pixel, sample2); sl@0: TEST(pixel == KRgbGreen); sl@0: sl@0: // #### clean up #### sl@0: iCursor1.Close(); sl@0: win.Close(); sl@0: } sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-CODEBASE-WSERV-0053-0001 sl@0: sl@0: @SYMPREQ PGM027 sl@0: sl@0: @SYMTestCaseDesc Tests RWsPointerCursor::UpdateMember APIs. sl@0: sl@0: @SYMTestPriority 1 sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions This test calls RWsPointerCursor::UpdateMember sl@0: sl@0: @SYMTestExpectedResults Should run properly with out any Panics. sl@0: sl@0: */ sl@0: void CTTSprite::SpriteUpdateMemberTestsL() sl@0: { sl@0: RWsPointerCursor iCursor1; sl@0: sl@0: CFbsBitmap bitmap; sl@0: bitmap.Load(TEST_BITMAP_NAME,0); sl@0: sl@0: RWindow win(TheClient->iWs); sl@0: win.Construct(*TheClient->iGroup->GroupWin(),1); sl@0: win.Activate(); sl@0: sl@0: iCursor1=RWsPointerCursor(TheClient->iWs); sl@0: TSpriteMember member; sl@0: SetUpMember(member); sl@0: member.iBitmap=&bitmap; sl@0: User::LeaveIfError(iCursor1.Construct(0)); sl@0: User::LeaveIfError(iCursor1.AppendMember(member)); sl@0: User::LeaveIfError(iCursor1.Activate()); sl@0: win.SetCustomPointerCursor(iCursor1); sl@0: iCursor1.UpdateMember(0); sl@0: sl@0: RWsPointerCursor iCursor2; sl@0: bitmap.Load(TEST_NEW_BITMAP_NAME,0); sl@0: iCursor2=RWsPointerCursor(TheClient->iWs); sl@0: User::LeaveIfError(iCursor2.Construct(0)); sl@0: User::LeaveIfError(iCursor2.AppendMember(member)); sl@0: User::LeaveIfError(iCursor2.Activate()); sl@0: win.SetCustomPointerCursor(iCursor2); sl@0: iCursor2.UpdateMember(1); sl@0: sl@0: iCursor1.Close(); sl@0: iCursor2.Close(); sl@0: win.Close(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-CODEBASE-WSERV-0054-0001 sl@0: sl@0: @SYMPREQ PGM027 sl@0: sl@0: @SYMTestCaseDesc Negative Tests RWsSpriteBase::UpdateMember API. sl@0: sl@0: @SYMTestPriority 1 sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions This test calls RWsPointerCursor::UpdateMember sl@0: sl@0: @SYMTestExpectedResults Should run properly with out any Panics. sl@0: sl@0: */ sl@0: void CTTSprite::SpriteUpdateMemberNegTestsL() sl@0: { sl@0: RWsPointerCursor iCursor1; sl@0: sl@0: CFbsBitmap bitmap; sl@0: bitmap.Load(TEST_BITMAP_NAME,0); sl@0: sl@0: RWindow win(TheClient->iWs); sl@0: win.Construct(*TheClient->iGroup->GroupWin(),1); sl@0: win.Activate(); sl@0: sl@0: iCursor1=RWsPointerCursor(TheClient->iWs); sl@0: TSpriteMember member; sl@0: SetUpMember(member); sl@0: member.iBitmap=&bitmap; sl@0: User::LeaveIfError(iCursor1.Construct(0)); sl@0: User::LeaveIfError(iCursor1.AppendMember(member)); sl@0: User::LeaveIfError(iCursor1.Activate()); sl@0: win.SetCustomPointerCursor(iCursor1); sl@0: iCursor1.UpdateMember(-100); sl@0: sl@0: RWsPointerCursor iCursor2; sl@0: bitmap.Load(TEST_NEW_BITMAP_NAME,0); sl@0: iCursor2=RWsPointerCursor(TheClient->iWs); sl@0: User::LeaveIfError(iCursor2.Construct(0)); sl@0: User::LeaveIfError(iCursor2.AppendMember(member)); sl@0: User::LeaveIfError(iCursor2.Activate()); sl@0: win.SetCustomPointerCursor(iCursor2); sl@0: iCursor2.UpdateMember(10000); sl@0: sl@0: iCursor1.Close(); sl@0: iCursor2.Close(); sl@0: win.Close(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-CODEBASE-WSERV-0055-0001 sl@0: sl@0: @SYMPREQ PGM027 sl@0: sl@0: @SYMTestCaseDesc Tests FindWindowGroupIdentifier API. sl@0: sl@0: @SYMTestPriority 1 sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Create windows session and call FindWindowGroupIdentifier \n sl@0: with different thread Id's both with valid thread ids and in valid thread id's. sl@0: sl@0: @SYMTestExpectedResults Should run properly. sl@0: sl@0: */ sl@0: void CTTSprite::FindWindowGroupThreadTestsL() sl@0: { sl@0: RThread proc; sl@0: TInt ident; sl@0: TUint64 id=proc.Id(); sl@0: RWsSession ws1; sl@0: User::LeaveIfError(ws1.Connect()); sl@0: CleanupClosePushL(ws1); sl@0: //Positive test for FindWindowGroupIdentifier sl@0: ident=ws1.FindWindowGroupIdentifier(0,id); sl@0: TEST(ws1.SetWindowGroupOrdinalPosition(ident,0)==KErrNone); sl@0: TEST(ws1.SetWindowGroupOrdinalPosition(ident,1)==KErrNone); sl@0: //Negative test for FindWindowGroupIdentifier sl@0: TInt ret=ws1.FindWindowGroupIdentifier(0,id+200); sl@0: TEST(ret==KErrNotFound); sl@0: #if defined __WINS__ || defined __WINSCW__ sl@0: ret=ws1.FindWindowGroupIdentifier(0,-200); sl@0: TEST(ret==KErrNotFound); sl@0: #endif//defined __WINS__ || defined __WINSCW__ sl@0: CleanupStack::PopAndDestroy(1, &ws1); sl@0: ws1.Close(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0462 sl@0: sl@0: @SYMDEF PDEF114190 sl@0: sl@0: @SYMTestCaseDesc Test sprite list cleanup when a window is deleted in low memory conditions sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Have a loop which increases the number of allocations in the server thread before failure; sl@0: Within the loop: sl@0: 1) Create a parent window and a child window of the parent; sl@0: 2) Create a sprite on the child window; sl@0: 3) Delete the parent window only, but not the child window; sl@0: 4) Create a testWindow and do redraw on this window; sl@0: 5) Do redraw on the testWindow. This testWindow's redraw will force checking the sprite list. sl@0: This would panic the client thread due to this defect because the sprite on the orphaned sl@0: window (which is the previous child window) is still in the sprite list; sl@0: 6) Delete all the windows involved. sl@0: sl@0: @SYMTestExpectedResults The sprite should be disabled when a window is deleted; sl@0: The client thread should not be panic'd. sl@0: The test should pass. sl@0: */ sl@0: void CTTSprite::SpriteOnWindowOrphanedTestsL() sl@0: { sl@0: TInt handles = 344; sl@0: TInt loop = 0; sl@0: TInt allocFailRate = 0; sl@0: TInt err = KErrNone; sl@0: sl@0: CFbsBitmap* bitmap = new(ELeave) CFbsBitmap; sl@0: CleanupStack::PushL(bitmap); sl@0: User::LeaveIfError(bitmap->Create(TSize(500, 500), EColor16MU)); sl@0: TSpriteMember spritemember; sl@0: spritemember.iBitmap = bitmap; sl@0: spritemember.iMaskBitmap = NULL; sl@0: sl@0: RWindowGroup group(TheClient->iWs); sl@0: RWindow parent1(TheClient->iWs); sl@0: RWindow child1(TheClient->iWs); sl@0: RWindow testWindow(TheClient->iWs); sl@0: RWsSprite sprite(TheClient->iWs); sl@0: sl@0: while (loop < 5) sl@0: { sl@0: TRect mainRect(TPoint(0,0), TSize(500,500)); sl@0: err = group.Construct(++handles, EFalse); sl@0: if (err == KErrNone) sl@0: { sl@0: TheClient->iWs.HeapSetFail(RHeap::EDeterministic, allocFailRate); sl@0: sl@0: //Create parent 1 sl@0: err = parent1.Construct(group,++handles); sl@0: if (err == KErrNone) sl@0: { sl@0: parent1.SetExtent(mainRect.iTl, mainRect.Size()); sl@0: parent1.EnableRedrawStore(ETrue); sl@0: parent1.Activate(); sl@0: } sl@0: } sl@0: sl@0: //Create child 1 sl@0: if (err == KErrNone) sl@0: { sl@0: TRect childRect(TPoint (10, 10), TSize (200, 150)); sl@0: err = child1.Construct(parent1,++handles); sl@0: if (err == KErrNone) sl@0: { sl@0: child1.SetExtent(childRect.iTl, childRect.Size()); sl@0: child1.SetBackgroundColor(TRgb(128,100,255,20)); sl@0: child1.Activate(); sl@0: } sl@0: } sl@0: sl@0: //Add sprite to child 1 sl@0: if (err == KErrNone) sl@0: { sl@0: err = sprite.Construct(child1,TPoint(10,10), 0); sl@0: if (err == KErrNone) sl@0: { sl@0: err = sprite.AppendMember(spritemember); sl@0: if (err == KErrNone) sl@0: err = sprite.Activate(); sl@0: } sl@0: } sl@0: sl@0: //Only delete parent 1, but not child 1 sl@0: parent1.Close(); sl@0: sl@0: if (err == KErrNone) sl@0: { sl@0: TRect testRect(TPoint(10, 30), TSize(200, 150)); sl@0: //Create testWindow sl@0: err = testWindow.Construct(group,++handles); sl@0: if (err == KErrNone) sl@0: { sl@0: testWindow.SetExtent(testRect.iTl, testRect.Size()); sl@0: testWindow.SetBackgroundColor(TRgb(128,100,255,20)); sl@0: testWindow.EnableRedrawStore(ETrue); sl@0: testWindow.Activate(); sl@0: testWindow.BeginRedraw(); sl@0: testWindow.EndRedraw(); sl@0: TheClient->Flush(); sl@0: } sl@0: } sl@0: TheClient->iWs.HeapSetFail(RAllocator::ENone, 0); sl@0: sl@0: sprite.Close(); sl@0: child1.Close(); sl@0: testWindow.Close(); sl@0: group.Close(); sl@0: ++allocFailRate; sl@0: loop = (err == KErrNone) ? loop + 1 : 0; sl@0: } sl@0: CleanupStack::PopAndDestroy(bitmap); sl@0: } sl@0: void CTTSprite::ResizeMemberL() sl@0: { sl@0: #ifndef __WINS__ sl@0: CTBlankWindow* win=new(ELeave) CTBlankWindow(); sl@0: CleanupStack::PushL(win); sl@0: win->ConstructL(*TheClient->iGroup); sl@0: win->SetExt(TPoint(),TSize(640,240)); sl@0: RWindowBase& window=*win->BaseWin(); sl@0: window.Activate(); sl@0: RWsSprite sprite(TheClient->iWs); sl@0: CleanupClosePushL(sprite); sl@0: User::LeaveIfError(sprite.Construct(window,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(250000); sl@0: member.iBitmap=&iBitmap; sl@0: User::LeaveIfError(sprite.AppendMember(member)); sl@0: User::LeaveIfError(sprite.AppendMember(member)); sl@0: User::LeaveIfError(sprite.Activate()); sl@0: User::After(1000000); // // Interval is 1 sec. sl@0: User::LeaveIfError(iBitmap.Resize(iBitmap.SizeInPixels() + TSize(100,100))); sl@0: User::After(1000000); // Interval is 1 sec. sl@0: CleanupStack::PopAndDestroy(&sprite); sl@0: CleanupStack::PopAndDestroy(win); sl@0: #endif // __WINS__ sl@0: } sl@0: sl@0: sl@0: void CTTSprite::SetUpSpriteL(RWsSprite &aSprite, RWindowTreeNode &aWindow,TPoint aPoint, TSpriteMember aMember, TInt aFlags/*=0*/) sl@0: { sl@0: User::LeaveIfError(aSprite.Construct(aWindow,aPoint,aFlags)); sl@0: User::LeaveIfError(aSprite.AppendMember(aMember)); sl@0: User::LeaveIfError(aSprite.Activate()); sl@0: } sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-00-0001 sl@0: sl@0: @SYMDEF PDEF117721 sl@0: sl@0: @SYMTestCaseDesc Test Screenrotation does not cause panic by sprite with NULL bitmap and NULL maskbitmap sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Defines two sprites and one with Null iBitmap and Null iMaskBitmap, then rotate the screen to 90 degrees sl@0: sl@0: @SYMTestExpectedResults the screen rotation will not cause wserv a panic sl@0: */ sl@0: void CTTSprite::RotateNullSpriteL() sl@0: { sl@0: if (TheClient->iScreen->NumScreenModes() < 2) sl@0: { sl@0: LOG_MESSAGE(_L("WARNING: Unable to rotate screen")); sl@0: return; sl@0: } sl@0: // Sprite Members sl@0: TSpriteMember spriteMember1,spriteMember2; sl@0: SetUpMember(spriteMember1); sl@0: SetUpMember(spriteMember2); sl@0: spriteMember2.iBitmap = NULL; sl@0: sl@0: // Create windows sl@0: RWindowGroup group(TheClient->iWs); sl@0: User::LeaveIfError(group.Construct(ENullWsHandle,EFalse)); //Creates a Group Window sl@0: CleanupClosePushL(group); sl@0: RBlankWindow win(TheClient->iWs); sl@0: User::LeaveIfError(win.Construct(group,ENullWsHandle)); //Creates a Blank Window sl@0: CleanupClosePushL(win); sl@0: win.SetVisible(ETrue); sl@0: win.SetColor(TRgb::Gray4(2)); sl@0: win.Activate(); sl@0: TheClient->Flush(); sl@0: sl@0: // Create Sprites sl@0: RWsSprite sprite1(TheClient->iWs); sl@0: CleanupClosePushL(sprite1); sl@0: SetUpSpriteL(sprite1, win,TPoint(20,70),spriteMember1,0); sl@0: RWsSprite sprite2(TheClient->iWs); sl@0: CleanupClosePushL(sprite2); sl@0: SetUpSpriteL(sprite2, win,TPoint(80,130),spriteMember2,0); sl@0: RWsSprite sprite3(TheClient->iWs); sl@0: CleanupClosePushL(sprite3); sl@0: SetUpSpriteL(sprite3, win,TPoint(2800,2130),spriteMember1,0); sl@0: TheClient->Flush(); sl@0: sl@0: // Get the original screen mode sl@0: CWsScreenDevice* device = TheClient->iScreen; sl@0: TInt originalScreenMode = device->CurrentScreenMode(); sl@0: TPixelsTwipsAndRotation originalModeSettings; sl@0: device->GetScreenModeSizeAndRotation(originalScreenMode,originalModeSettings); sl@0: sl@0: // Rotate screens sl@0: TPixelsAndRotation pixelsAndRotation; sl@0: device->SetScreenMode( 1 ); sl@0: device->GetDefaultScreenSizeAndRotation(pixelsAndRotation); sl@0: device->SetCurrentRotations(1,pixelsAndRotation.iRotation); sl@0: device->SetScreenSizeAndRotation(pixelsAndRotation); sl@0: User::After(1000000); sl@0: sl@0: CleanupStack::PopAndDestroy(5,&group); sl@0: // Restore the original screen mode sl@0: device->SetScreenMode(originalScreenMode); sl@0: device->SetCurrentRotations(originalScreenMode,originalModeSettings.iRotation); sl@0: device->SetScreenSizeAndRotation(originalModeSettings); sl@0: TheClient->Flush(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-GCE-0700 sl@0: sl@0: @SYMDEF DEF123129 sl@0: sl@0: @SYMTestCaseDesc Test activating a sprite twice does not cause the system to hang sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Construct a sprite and add a member to it. Activate twice. sl@0: sl@0: @SYMTestExpectedResults The test should terminate smoothly and it should not hang the system. sl@0: */ sl@0: void CTTSprite::DoubleActivateL() sl@0: { sl@0: RWsSession ws; sl@0: User::LeaveIfError(ws.Connect()); sl@0: CleanupClosePushL(ws); sl@0: sl@0: RWindowGroup group(ws); sl@0: User::LeaveIfError(group.Construct(890, EFalse)); sl@0: CleanupClosePushL(group); sl@0: sl@0: RWsSprite sprite = RWsSprite(ws); sl@0: User::LeaveIfError(sprite.Construct(group,TPoint(),0)); sl@0: CleanupClosePushL(sprite); sl@0: CFbsBitmap* bitmap=new(ELeave) CFbsBitmap; sl@0: CleanupStack::PushL(bitmap); sl@0: User::LeaveIfError(bitmap->Create(TSize(10,12),EColor256)); 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::LeaveIfError(sprite.Activate()); sl@0: sl@0: sprite.Close(); sl@0: CleanupStack::PopAndDestroy(4, &ws); sl@0: sl@0: group.Close(); sl@0: ws.Close(); sl@0: } sl@0: sl@0: void CTTSprite::RunTestCaseL(TInt /*aCurTestCase*/) sl@0: { sl@0: _LIT(KTest1, "General Tests"); sl@0: _LIT(KTest2, "Group Window Sprites Tests"); sl@0: _LIT(KTest3, "Lots Sprites Tests"); sl@0: _LIT(KTest4, "General Pointer Cursor Tests"); sl@0: _LIT(KTest5, "Pointer Cursor Visible Tests"); sl@0: _LIT(KTest6, "Update member tests"); sl@0: _LIT(KTest7, "Negative tests for Update member"); sl@0: _LIT(KTest8, "Window Group with Thread"); sl@0: _LIT(KTest9, "Resize Sprite Member Tests"); sl@0: _LIT(KTest10, "Rotate a NULL sprite"); sl@0: _LIT(KTest11, "Sprite On Window Orphaned Tests"); sl@0: _LIT(KTest12, "Sprite Double Activation Test"); sl@0: sl@0: ((CTTSpriteStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); sl@0: switch(++iTest->iState) sl@0: { sl@0: case 1: sl@0: ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0018")); sl@0: TheClient->iWs.SetFocusScreen(0); sl@0: iTest->LogSubTest(KTest1); sl@0: GeneralTestsL(); sl@0: break; sl@0: case 2: sl@0: ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0019")); sl@0: iTest->LogSubTest(KTest2); sl@0: GroupWindowSpritesL(); sl@0: break; sl@0: case 3: sl@0: ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0020")); sl@0: iTest->LogSubTest(KTest3); sl@0: LotsSpritesL(); sl@0: break; sl@0: case 4: sl@0: ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0021")); sl@0: iTest->LogSubTest(KTest4); sl@0: GeneralPointerCursor(); sl@0: break; sl@0: case 5: sl@0: ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0498")); sl@0: iTest->LogSubTest(KTest5); sl@0: TRAPD(err, PointerCursorVisibleL()); sl@0: TEST(err == KErrNone); sl@0: break; sl@0: case 6: sl@0: ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-CODEBASE-WSERV-0053-0001")); sl@0: iTest->LogSubTest(KTest6); sl@0: TRAP(err, SpriteUpdateMemberTestsL()); sl@0: TEST(err == KErrNone); sl@0: break; sl@0: case 7: sl@0: ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-CODEBASE-WSERV-0054-0001")); sl@0: iTest->LogSubTest(KTest7); sl@0: TRAP(err, SpriteUpdateMemberNegTestsL()); sl@0: TEST(err == KErrNone); sl@0: break; sl@0: case 8: sl@0: ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-CODEBASE-WSERV-0055-0001")); sl@0: iTest->LogSubTest(KTest8); sl@0: TRAP(err, FindWindowGroupThreadTestsL()); sl@0: TEST(err == KErrNone); sl@0: break; sl@0: case 9: sl@0: ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0526")); sl@0: iTest->LogSubTest(KTest9); sl@0: ResizeMemberL(); sl@0: break; sl@0: case 10: sl@0: ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-00-0001")); sl@0: iTest->LogSubTest(KTest10); sl@0: RotateNullSpriteL(); sl@0: break; sl@0: case 11: sl@0: ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0462")); sl@0: iTest->LogSubTest(KTest11); sl@0: SpriteOnWindowOrphanedTestsL(); sl@0: break; sl@0: case 12: sl@0: ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-GCE-0700")); sl@0: iTest->LogSubTest(KTest12); sl@0: DoubleActivateL(); sl@0: break; sl@0: default: sl@0: ((CTTSpriteStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); sl@0: ((CTTSpriteStep*)iStep)->CloseTMSGraphicsStep(); sl@0: TestComplete(); sl@0: break; sl@0: } sl@0: ((CTTSpriteStep*)iStep)->RecordTestResultL(); sl@0: } sl@0: sl@0: //-------------- sl@0: __WS_CONSTRUCT_STEP__(TSprite) sl@0: