sl@0: // Copyright (c) 2007-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: // Test the Wserv heart beat switch on and off 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 "THeartBeat.h" sl@0: #include sl@0: sl@0: CTHeartBeatTest::CTHeartBeatTest(CTestStep* aStep) : sl@0: CTWsGraphicsBase(aStep) sl@0: { sl@0: } sl@0: sl@0: CTHeartBeatTest::~CTHeartBeatTest() sl@0: { sl@0: iAnimDll.Close(); sl@0: delete iHbTestWin; sl@0: } sl@0: sl@0: void CTHeartBeatTest::ConstructL() sl@0: { sl@0: TSize screenSize=TheClient->iGroup->Size(); sl@0: TInt winWidth=(screenSize.iWidth/3)-10; sl@0: TInt winHeight=screenSize.iHeight-10; sl@0: iHbTestWin=new(ELeave) CAnimWindow(EFalse, CAnimWindow::ERedraw); sl@0: iHbTestWin->ConstructL(TPoint(screenSize.iWidth/3*2+5,5),TSize(winWidth,winHeight)); sl@0: iAnimDll=RAnimDll(TheClient->iWs); sl@0: User::LeaveIfError(iAnimDll.Load(KAnimDLLName)); sl@0: } sl@0: sl@0: void CTHeartBeatTest::SetCursor(const TPoint& aPos,const TSize& aSize, TUint aFlags/*=0*/) sl@0: { // Default aFlags=0 gives a flashing cursor sl@0: TTextCursor tc; sl@0: tc.iType=TTextCursor::ETypeRectangle; sl@0: tc.iHeight=aSize.iHeight; sl@0: tc.iAscent=aSize.iHeight*4/5; sl@0: tc.iWidth=aSize.iWidth; sl@0: tc.iFlags=aFlags; sl@0: tc.iColor=KRgbGreen; sl@0: TheClient->iGroup->GroupWin()->SetTextCursor(*iHbTestWin->BaseWin(),TPoint(aPos.iX,aPos.iY+tc.iAscent),tc); sl@0: } sl@0: sl@0: TBool CTHeartBeatTest::SetAutoHeartBeatPauseState(TBool aState) const sl@0: { sl@0: return(TheClient->iWs.DebugInfo(EWsDebugSetAutoHeartBeatPauseState,aState)); sl@0: } sl@0: sl@0: TBool CTHeartBeatTest::GetHeartBeatTimerState() const sl@0: { sl@0: return(TheClient->iWs.DebugInfo(EWsDebugHeartBeatState)); sl@0: } sl@0: sl@0: void CTHeartBeatTest::CancelTextCursor() sl@0: { sl@0: TheClient->iGroup->GroupWin()->CancelTextCursor(); sl@0: } sl@0: sl@0: void CTHeartBeatTest::TestTextCursorTimerL() sl@0: { sl@0: TEST(!GetHeartBeatTimerState()); sl@0: SetCursor(TPoint(0,0),TSize(10,10)); sl@0: TEST(GetHeartBeatTimerState()); sl@0: CancelTextCursor(); sl@0: TEST(!GetHeartBeatTimerState()); sl@0: // sl@0: TPoint testCursorPos; sl@0: TSize testCursorSize(10,10); sl@0: SetCursor(testCursorPos,testCursorSize); sl@0: TEST(GetHeartBeatTimerState()); sl@0: iHbTestWin->BaseWin()->SetVisible(EFalse); sl@0: TEST(!GetHeartBeatTimerState()); sl@0: iHbTestWin->BaseWin()->SetVisible(ETrue); sl@0: TEST(GetHeartBeatTimerState()); sl@0: // sl@0: // Cover the cursor and check heartbeat disabled sl@0: RWindow coverCursor(TheClient->iWs); sl@0: CleanupClosePushL(coverCursor); sl@0: User::LeaveIfError(coverCursor.Construct(*iHbTestWin->BaseWin(), 0xBADBAD)); sl@0: coverCursor.SetExtent(testCursorPos,testCursorSize); sl@0: coverCursor.Activate(); sl@0: TEST(!GetHeartBeatTimerState()); sl@0: // Now fractionally expose the cursor and check heartbeat re-enabled sl@0: coverCursor.SetExtent(testCursorPos+TPoint(1,1),testCursorSize); sl@0: TEST(GetHeartBeatTimerState()); sl@0: // Re-cover it sl@0: coverCursor.SetExtent(testCursorPos,testCursorSize); sl@0: TEST(!GetHeartBeatTimerState()); sl@0: // Enlarge cursor to expose itself then check heartbeat sl@0: SetCursor(testCursorPos,TSize(testCursorSize.iWidth+1,testCursorSize.iHeight)); sl@0: TEST(GetHeartBeatTimerState()); sl@0: // Shrink cursor then check heartbeat sl@0: SetCursor(testCursorPos,testCursorSize); sl@0: TEST(!GetHeartBeatTimerState()); sl@0: // Turn off auto heart beat pausing, should turn timer back on sl@0: SetAutoHeartBeatPauseState(EFalse); sl@0: TEST(GetHeartBeatTimerState()); sl@0: // With auto pausing enabled covering/uncovering the cursor should have no effect, sl@0: // timer will always be on sl@0: coverCursor.SetVisible(EFalse); sl@0: TEST(GetHeartBeatTimerState()); sl@0: coverCursor.SetVisible(ETrue); sl@0: TEST(GetHeartBeatTimerState()); sl@0: // Re-enable auto-pause should turn timer back off sl@0: SetAutoHeartBeatPauseState(ETrue); sl@0: TEST(!GetHeartBeatTimerState()); sl@0: // Destroy covering window and check heartbeat re-enabled sl@0: CleanupStack::PopAndDestroy(&coverCursor); sl@0: TEST(GetHeartBeatTimerState()); sl@0: // Check using no flash flag turns timer off sl@0: SetCursor(testCursorPos,testCursorSize,TTextCursor::EFlagNoFlash); sl@0: TEST(!GetHeartBeatTimerState()); sl@0: // and turning no flash flag off turns timer back on sl@0: SetCursor(testCursorPos,testCursorSize); sl@0: TEST(GetHeartBeatTimerState()); sl@0: // Preparing for switch off should disable the heartbeat until another event is received sl@0: TheClient->iWs.PrepareForSwitchOff(); sl@0: TEST(!GetHeartBeatTimerState()); sl@0: // Any event should wake the hearbeat back up again sl@0: TRawEvent rawEvent; sl@0: rawEvent.Set(TRawEvent::EPointerMove,0,0); sl@0: TheClient->iWs.SimulateRawEvent(rawEvent); sl@0: TEST(GetHeartBeatTimerState()); sl@0: // sl@0: CancelTextCursor(); sl@0: TEST(!GetHeartBeatTimerState()); sl@0: // Check heartbeat still off as expected sl@0: TheClient->iWs.PrepareForSwitchOff(); sl@0: TEST(!GetHeartBeatTimerState()); sl@0: // Check when hearbeat not required that it's not turned back when coming out of PrepareForSwitchOff() mode. sl@0: TheClient->iWs.SimulateRawEvent(rawEvent); sl@0: TheClient->Flush(); sl@0: TEST(!GetHeartBeatTimerState()); sl@0: } sl@0: sl@0: void CTHeartBeatTest::doTestActiveInactiveEvents(TBool aCursorOn, TBool aAutoPauseOn) sl@0: { sl@0: SetAutoHeartBeatPauseState(aAutoPauseOn); sl@0: if (aCursorOn) sl@0: SetCursor(TPoint(0,0),TSize(10,10)); sl@0: // Should disable timer, regardless of other states sl@0: TRawEvent event; sl@0: event.Set(TRawEvent::EInactive); sl@0: UserSvr::AddEvent(event); sl@0: TEST(!GetHeartBeatTimerState()); sl@0: // ...and switch it back on sl@0: event.Set(TRawEvent::EActive); sl@0: UserSvr::AddEvent(event); sl@0: TBool testResult1=EFalse; sl@0: if (aAutoPauseOn) sl@0: testResult1=aCursorOn; // Only on if cursor is on without auto pause enabled sl@0: else sl@0: testResult1=ETrue; // Always on if auto pause disabled sl@0: TBool hbState=GetHeartBeatTimerState(); sl@0: if ((!hbState)!=(!testResult1)) sl@0: { sl@0: _LIT(KLog,"Fail in TestActiveInactiveEvents(%d.%d) HBState=%d result=%d"); sl@0: LOG_MESSAGE5(KLog,aCursorOn,aAutoPauseOn,hbState,testResult1); sl@0: } sl@0: TEST((!GetHeartBeatTimerState())==(!testResult1)); //Works with any positive value for True sl@0: // sl@0: if (aCursorOn) sl@0: CancelTextCursor(); sl@0: } sl@0: sl@0: void CTHeartBeatTest::TestActiveInactiveEvents() sl@0: { sl@0: doTestActiveInactiveEvents(EFalse,EFalse); sl@0: doTestActiveInactiveEvents(ETrue,EFalse); sl@0: doTestActiveInactiveEvents(EFalse,ETrue); sl@0: doTestActiveInactiveEvents(ETrue,ETrue); sl@0: } sl@0: sl@0: void CTHeartBeatTest::FailCursorHbTest(const TDesC& aErrorBase, const TDesC* aExtraText, TBool aHbState, TBool aHbCheckState) sl@0: { sl@0: TBuf<256> error(aErrorBase); sl@0: if (aExtraText) sl@0: { sl@0: error.Append(*aExtraText); sl@0: } sl@0: _LIT(KHbErrorAppendFmt," HB=%d (Testing for %d)"); sl@0: error.AppendFormat(KHbErrorAppendFmt,aHbState,aHbCheckState); sl@0: LOG_MESSAGE(error); sl@0: TEST(EFalse); sl@0: } sl@0: sl@0: TBool CTHeartBeatTest::ChangeTransAndCheckHeartBeat(TInt aTestMode, RWindow& aTransWin, const TRect& aGraphicRect, TInt aExtraWinTestMode, const TDesC* aErrorMsg, TBool aSetVisibleAfterTransUpdate) sl@0: { sl@0: TRect cursorRect(aGraphicRect); sl@0: cursorRect.Move(iHbTestWin->BaseWin()->InquireOffset(aTransWin)); sl@0: TRect winRect(aTransWin.Size()); sl@0: __ASSERT_ALWAYS(winRect.Contains(cursorRect.iTl) && winRect.Contains(cursorRect.iBr),AutoPanic(EAutoPanicHeartBeatCursorRect)); sl@0: // sl@0: TRegionFix<8> transRegion; sl@0: TBool heartBeatCheck=EFalse; sl@0: switch(aTestMode) sl@0: { sl@0: case ECursorTransWinTestModeFullTrans: sl@0: transRegion.AddRect(winRect); sl@0: heartBeatCheck=ETrue; sl@0: break; sl@0: case ECursorTransWinTestNoTrans: sl@0: break; sl@0: case ECursorTransWinTestPartialTransCoveringCursor: sl@0: transRegion.AddRect(winRect); sl@0: transRegion.SubRect(cursorRect); sl@0: break; sl@0: case ECursorTransWinTestPartialTransExposingCursor: sl@0: transRegion.AddRect(cursorRect); sl@0: heartBeatCheck=ETrue; sl@0: break; sl@0: default: sl@0: ASSERT(EFalse); sl@0: } sl@0: TBool invisHeartBeatCheck=ETrue; sl@0: switch(aExtraWinTestMode) sl@0: { sl@0: case ECursorTransWinTestNoTrans: sl@0: case ECursorTransWinTestPartialTransCoveringCursor: sl@0: heartBeatCheck=EFalse; sl@0: invisHeartBeatCheck=EFalse; sl@0: break; sl@0: default: sl@0: break; sl@0: } sl@0: // sl@0: ASSERT(!transRegion.CheckError()); sl@0: if (aSetVisibleAfterTransUpdate) sl@0: aTransWin.SetVisible(EFalse); sl@0: aTransWin.SetTransparentRegion(transRegion); sl@0: if (aSetVisibleAfterTransUpdate) sl@0: aTransWin.SetVisible(ETrue); sl@0: // sl@0: TBool testSuccess=ETrue; sl@0: TBool heartBeatState=GetHeartBeatTimerState(); sl@0: TBool failed1stTest=EFalse; sl@0: if ((!heartBeatState)!=(!heartBeatCheck)) //Works with any positive value for True sl@0: { sl@0: failed1stTest=ETrue; sl@0: _LIT(KFailedHbTest,"Failed "); sl@0: FailCursorHbTest(KFailedHbTest,aErrorMsg,heartBeatState,heartBeatCheck); sl@0: testSuccess=EFalse; sl@0: } sl@0: // sl@0: aTransWin.SetVisible(EFalse); sl@0: heartBeatState=GetHeartBeatTimerState(); sl@0: _LIT(KGoingInvisAfterTestAppend," after %S"); sl@0: TBuf<256> errorExtra; sl@0: if (aErrorMsg) sl@0: { sl@0: errorExtra.Format(KGoingInvisAfterTestAppend,aErrorMsg); sl@0: } sl@0: if ((!heartBeatState)!=(!invisHeartBeatCheck)) //Works with any positive value for True sl@0: { sl@0: _LIT(KFailedGoingInvis,"Failed setting trans win invisible"); sl@0: FailCursorHbTest(KFailedGoingInvis,&errorExtra,heartBeatState,invisHeartBeatCheck); sl@0: testSuccess=EFalse; sl@0: } sl@0: // sl@0: aTransWin.SetVisible(ETrue); sl@0: heartBeatState=GetHeartBeatTimerState(); sl@0: if (!failed1stTest && (!heartBeatState)!=(!heartBeatCheck)) //Works with any positive value for True sl@0: { sl@0: _LIT(KFailedResettingVis,"Failed re-setting trans win visible"); sl@0: FailCursorHbTest(KFailedResettingVis,&errorExtra,heartBeatState,heartBeatCheck); sl@0: testSuccess=EFalse; sl@0: } sl@0: return(testSuccess); sl@0: } sl@0: sl@0: void CTHeartBeatTest::LoopThroughTransWinTestModes(RWindow& aTransWin, const TRect& aGraphicRect, TInt aExtraWinTestMode) sl@0: { sl@0: TBuf<256> error; sl@0: for(TInt setVisMode=0;setVisMode<2;setVisMode++) sl@0: { sl@0: if (setVisMode==0) sl@0: continue; // zzz setinvis/makevis needed to flush out changes it seems sl@0: const TBool setVisibleAfterTransUpdate=setVisMode>0; sl@0: for(TInt startTestMode=0;startTestModeiWs); sl@0: User::LeaveIfError(transWin1.Construct(*TheClient->iGroup->GroupWin(),0xDEADBAD1)); sl@0: CleanupClosePushL(transWin1); sl@0: if (transWin1.SetTransparencyFactor(TRgb::Gray256(128))!=KErrNone) sl@0: { // Transparency not enabled, skip tests sl@0: CleanupStack::PopAndDestroy(&transWin1); sl@0: return; sl@0: } sl@0: transWin1.Activate(); sl@0: TEST(GetHeartBeatTimerState()); sl@0: // First simply check activating default full screen transparent window doesn't disable the heartbeat sl@0: _LIT(KBasicTransCursorTests,"Running basic transparent window cursor heartbeat tests"); sl@0: LOG_MESSAGE(KBasicTransCursorTests); sl@0: LoopThroughTransWinTestModes(transWin1, aGraphicRect, ECursorTransWinTestNA); sl@0: // sl@0: // Lots of test code disabled due to bugs in handling of transparent window regions sl@0: // See DEF110677, hopefully when the issues in there are addressed the rest of the sl@0: // test code here can be enabled sl@0: // See sections marked with zzz for places where certain tests are disabled, once DEF110677 sl@0: // is marked as fixed these sections should be re-enabled and if problems still occur they sl@0: // need to be investigated. sl@0: // sl@0: // sl@0: // Now check more complex modes with two transparent windows over the test window sl@0: RWindow transWin2(TheClient->iWs); sl@0: User::LeaveIfError(transWin2.Construct(*TheClient->iGroup->GroupWin(),0xDEADBAD2)); sl@0: CleanupClosePushL(transWin2); sl@0: User::LeaveIfError(transWin2.SetTransparencyFactor(TRgb::Gray256(128))); sl@0: TSize screenSize=TheClient->iGroup->Size(); sl@0: screenSize.iWidth-=10; sl@0: transWin1.SetExtent(TPoint(0,0),screenSize); sl@0: transWin2.SetExtent(TPoint(10,0),screenSize); sl@0: transWin2.Activate(); sl@0: for(TInt win1OrdPos=0;win1OrdPos<2;win1OrdPos++) sl@0: { sl@0: transWin1.SetOrdinalPosition(win1OrdPos); sl@0: _LIT(KOrdinalTransCursorTests,"Running tests with transwin1 ordinal pos=%d"); sl@0: LOG_MESSAGE2(KOrdinalTransCursorTests,win1OrdPos); sl@0: for(TInt topWinTestMode=0;topWinTestMode msg; sl@0: msg.Format(KTopTransWinCursorTest,topWinTestMode); sl@0: LOG_MESSAGE(msg); sl@0: ChangeTransAndCheckHeartBeat(0, transWin2, aGraphicRect, topWinTestMode, NULL, ETrue); sl@0: LoopThroughTransWinTestModes(transWin1, aGraphicRect, topWinTestMode); sl@0: } sl@0: } sl@0: ChangeTransAndCheckHeartBeat(0, transWin2, aGraphicRect, 0, NULL, ETrue); sl@0: CleanupStack::PopAndDestroy(&transWin2); sl@0: TEST(GetHeartBeatTimerState()); sl@0: // sl@0: CleanupStack::PopAndDestroy(&transWin1); sl@0: TEST(GetHeartBeatTimerState()); sl@0: } sl@0: sl@0: void CTHeartBeatTest::TestTextCursorTimerTransL() sl@0: { sl@0: TSize testWinSize(iHbTestWin->BaseWin()->Size()); sl@0: TRect cursorRect(testWinSize.iWidth/4,testWinSize.iHeight/3,testWinSize.iWidth*3/4,testWinSize.iHeight*2/3); sl@0: TEST(!GetHeartBeatTimerState()); sl@0: SetCursor(cursorRect.iTl,cursorRect.Size()); sl@0: TEST(GetHeartBeatTimerState()); sl@0: RunTransWinTestsL(cursorRect); sl@0: CancelTextCursor(); sl@0: TEST(!GetHeartBeatTimerState()); sl@0: } sl@0: sl@0: void CTHeartBeatTest::TestHeartBeatStopStart(TBool aHeartbeatStateOff,TBool aHeartbeatStateOn,const TDesC& aOffText,const TDesC& aOnText) sl@0: { sl@0: TEST(!aHeartbeatStateOff); sl@0: if (aHeartbeatStateOff) sl@0: LOG_MESSAGE2(_L("%S failed to disable heartbeat timer"),&aOffText); sl@0: TEST(aHeartbeatStateOn); sl@0: if (!aHeartbeatStateOn) sl@0: LOG_MESSAGE2(_L("%S failed to re-enable heartbeat timer"),&aOnText); sl@0: } sl@0: sl@0: void CTHeartBeatTest::TestAnimDllL(TBool aSpriteMode, TUint aSpriteFlags) sl@0: { sl@0: RTestAnim anim(iAnimDll); sl@0: TEST(!GetHeartBeatTimerState()); sl@0: TSize testWinSize(iHbTestWin->BaseWin()->Size()); sl@0: TRect animRect(1,1,testWinSize.iWidth/3,testWinSize.iWidth/5); sl@0: TPckgC rectPckg(animRect); sl@0: RWsSprite sprite(TheClient->iWs); sl@0: CleanupClosePushL(sprite); sl@0: if (aSpriteMode) sl@0: { sl@0: sprite.Construct(*iHbTestWin->BaseWin(),TPoint(),aSpriteFlags); sl@0: CFbsBitmap* bitmap1=new(ELeave) CFbsBitmap(); sl@0: CleanupStack::PushL(bitmap1); sl@0: CFbsBitmap* bitmap2=new(ELeave) CFbsBitmap(); sl@0: CleanupStack::PushL(bitmap2); sl@0: CFbsBitmap* bitmap3=new(ELeave) CFbsBitmap(); sl@0: CleanupStack::PushL(bitmap3); sl@0: TSize animSize(animRect.Size()); sl@0: User::LeaveIfError(bitmap1->Create(TSize(animSize.iWidth/2,animSize.iHeight/2),EGray4)); sl@0: User::LeaveIfError(bitmap2->Create(TSize(animSize.iWidth,animSize.iHeight/3),EGray4)); sl@0: User::LeaveIfError(bitmap3->Create(TSize(animSize.iWidth/3,animSize.iHeight),EGray4)); sl@0: // sl@0: TSpriteMember member1; sl@0: member1.iMaskBitmap=NULL; sl@0: member1.iInvertMask=EFalse; sl@0: member1.iDrawMode=CGraphicsContext::EDrawModePEN; sl@0: member1.iOffset=TPoint(); sl@0: member1.iInterval=TTimeIntervalMicroSeconds32(1); sl@0: member1.iBitmap=bitmap1; sl@0: member1.iMaskBitmap=bitmap1; sl@0: sprite.AppendMember(member1); sl@0: // sl@0: TSpriteMember member2; sl@0: member2.iInvertMask=EFalse; sl@0: member2.iDrawMode=CGraphicsContext::EDrawModeXOR; sl@0: member2.iOffset=TPoint(1,2); sl@0: member2.iInterval=TTimeIntervalMicroSeconds32(2); sl@0: member2.iBitmap=bitmap2; sl@0: member2.iMaskBitmap=bitmap2; sl@0: sprite.AppendMember(member2); sl@0: // sl@0: TSpriteMember member3; sl@0: member3.iInvertMask=ETrue; sl@0: member3.iDrawMode=CGraphicsContext::EDrawModeOR; sl@0: member3.iOffset=TPoint(3,4); sl@0: member3.iInterval=TTimeIntervalMicroSeconds32(3); sl@0: member3.iBitmap=bitmap3; sl@0: member3.iMaskBitmap=bitmap3; sl@0: sprite.AppendMember(member3); sl@0: // sl@0: User::LeaveIfError(anim.Construct(sprite,EAnimTypeSprite,rectPckg)); sl@0: CleanupStack::PopAndDestroy(3,bitmap1); sl@0: } sl@0: else sl@0: { sl@0: User::LeaveIfError(anim.Construct(*iHbTestWin->BaseWin(),EAnimTypeTest3,rectPckg)); sl@0: } sl@0: CleanupClosePushL(anim); sl@0: TEST(GetHeartBeatTimerState()); sl@0: sl@0: // Cover up the window with the animation and check this disables the heartbeat timer. sl@0: RBlankWindow blankwin1(TheClient->iWs); sl@0: User::LeaveIfError(blankwin1.Construct(*TheClient->iGroup->GroupWin(),123)); sl@0: TPoint winOffset(iHbTestWin->BaseWin()->InquireOffset(*TheClient->iGroup->GroupWin())); sl@0: if (aSpriteMode) sl@0: blankwin1.SetExtent(winOffset,testWinSize); sl@0: else sl@0: blankwin1.SetExtent(winOffset+animRect.iTl,animRect.Size()); sl@0: blankwin1.Activate(); sl@0: TBool heartbeatStateOff=GetHeartBeatTimerState(); sl@0: TEST(!heartbeatStateOff); sl@0: if (heartbeatStateOff) sl@0: { sl@0: LOG_MESSAGE(_L("Covering window failed to disable heartbeat timer")); sl@0: } sl@0: TBool heartbeatStateOn; sl@0: if (!aSpriteMode) sl@0: { sl@0: // Resize the anim so it becomes visible, then shrink back down again sl@0: animRect.iBr.iX++; sl@0: anim.Command(EADllSetRect,rectPckg); sl@0: heartbeatStateOn=GetHeartBeatTimerState(); sl@0: animRect.iBr.iX--; sl@0: anim.Command(EADllSetRect,rectPckg); sl@0: heartbeatStateOff=GetHeartBeatTimerState(); sl@0: TestHeartBeatStopStart(heartbeatStateOff,heartbeatStateOn,_L("Shrinking anim"),_L("Growing anim")); sl@0: } sl@0: // sl@0: blankwin1.Close(); sl@0: heartbeatStateOn=GetHeartBeatTimerState(); sl@0: TEST(heartbeatStateOn); sl@0: if (!heartbeatStateOn) sl@0: { sl@0: LOG_MESSAGE(_L("Un-covering window failed to disable heartbeat timer")); sl@0: } sl@0: sl@0: // Put a transparent window over the animation and check the heartbeat timer is not disabled sl@0: RWindow transWin(TheClient->iWs); sl@0: User::LeaveIfError(transWin.Construct(*TheClient->iGroup->GroupWin(),123)); sl@0: if (transWin.SetTransparencyFactor(TRgb::Gray256(128))==KErrNone) sl@0: { sl@0: transWin.Activate(); sl@0: heartbeatStateOn=GetHeartBeatTimerState(); sl@0: TEST(heartbeatStateOn); sl@0: if (!heartbeatStateOn) sl@0: LOG_MESSAGE(_L("Transparent window caused heartbeat timer to be disabled")); sl@0: TRegionFix<1> emptyRegion; sl@0: transWin.SetTransparentRegion(emptyRegion); sl@0: heartbeatStateOff=GetHeartBeatTimerState(); sl@0: TRegionFix<1> fullRegion(transWin.Size()); sl@0: transWin.SetTransparentRegion(fullRegion); sl@0: heartbeatStateOn=GetHeartBeatTimerState(); sl@0: TestHeartBeatStopStart(heartbeatStateOff,heartbeatStateOn,_L("Making covering window opaque"),_L("Making covering window transparent")); sl@0: if (aSpriteMode) sl@0: { sl@0: RBlankWindow blankwin2(TheClient->iWs); sl@0: User::LeaveIfError(blankwin2.Construct(*iHbTestWin->BaseWin(),1234)); sl@0: blankwin2.Activate(); sl@0: heartbeatStateOn=GetHeartBeatTimerState(); sl@0: // With ESpriteNoChildClip the heartbeat should still be on as the sprite will still be visible sl@0: // Without it blankwin2 will cover up the sprite and cancel the heartbeat sl@0: TBool heartBeatCheck=aSpriteFlags&ESpriteNoChildClip; sl@0: TEST((!heartbeatStateOn)==(!heartBeatCheck)); //Works with any positive value for True sl@0: blankwin2.Close(); sl@0: } sl@0: transWin.SetTransparentRegion(emptyRegion); sl@0: heartbeatStateOff=GetHeartBeatTimerState(); sl@0: transWin.Close(); sl@0: heartbeatStateOn=GetHeartBeatTimerState(); sl@0: TestHeartBeatStopStart(heartbeatStateOff,heartbeatStateOn,_L("Making covering window opaque"),_L("Un-covering window")); sl@0: } sl@0: else sl@0: transWin.Close(); sl@0: sl@0: // Make the window with the animation invisible and check this disables the heartbeat timer. sl@0: iHbTestWin->BaseWin()->SetVisible(EFalse); sl@0: heartbeatStateOff=GetHeartBeatTimerState(); sl@0: iHbTestWin->BaseWin()->SetVisible(ETrue); sl@0: heartbeatStateOn=GetHeartBeatTimerState(); sl@0: TestHeartBeatStopStart(heartbeatStateOff,heartbeatStateOn,_L("Making window invisible"),_L("Making window visible")); sl@0: sl@0: // Move the window with the animation off screen and check this disables the heartbeat timer. sl@0: TSize screenSize=TheClient->iGroup->Size(); sl@0: TPoint oldPos(iHbTestWin->BaseWin()->Position()); sl@0: iHbTestWin->BaseWin()->SetPosition(screenSize.AsPoint()); sl@0: heartbeatStateOff=GetHeartBeatTimerState(); sl@0: iHbTestWin->BaseWin()->SetPosition(oldPos); sl@0: heartbeatStateOn=GetHeartBeatTimerState(); sl@0: TestHeartBeatStopStart(heartbeatStateOff,heartbeatStateOn,_L("Moving window offscreen"),_L("Moving window back onscreen")); sl@0: TEST(GetHeartBeatTimerState()); sl@0: CleanupStack::PopAndDestroy(&anim); sl@0: TEST(!GetHeartBeatTimerState()); sl@0: CleanupStack::PopAndDestroy(&sprite); sl@0: } sl@0: sl@0: void CTHeartBeatTest::TestAnimDllTransL() sl@0: { sl@0: RTestAnim anim(iAnimDll); sl@0: TSize testWinSize(iHbTestWin->BaseWin()->Size()); sl@0: TRect animRect(testWinSize.iWidth/4,testWinSize.iHeight/3,testWinSize.iWidth*3/4,testWinSize.iHeight*2/3); sl@0: TPckgBuf rectPckg; sl@0: rectPckg()=animRect; sl@0: TEST(!GetHeartBeatTimerState()); sl@0: User::LeaveIfError(anim.Construct(*iHbTestWin->BaseWin(),EAnimTypeTest3,rectPckg)); sl@0: CleanupClosePushL(anim); sl@0: TEST(GetHeartBeatTimerState()); sl@0: // sl@0: RunTransWinTestsL(animRect); sl@0: // sl@0: CleanupStack::PopAndDestroy(&anim); sl@0: TEST(!GetHeartBeatTimerState()); sl@0: } sl@0: sl@0: void CTHeartBeatTest::RunTestCaseL(TInt /*aCurTestCase*/) sl@0: { sl@0: sl@0: switch(++iTest->iState) sl@0: { sl@0: case 1: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0568 sl@0: */ sl@0: ((CTHeartBeatTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0568")); sl@0: _LIT(KTestTextCursorTimer,"Basic heartbeat timer test"); sl@0: iTest->LogSubTest(KTestTextCursorTimer); sl@0: TestTextCursorTimerL(); sl@0: break; sl@0: case 2: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0569 sl@0: */ sl@0: ((CTHeartBeatTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0569")); sl@0: _LIT(KTestTextCursorTimerTrans,"Heartbeat timer test with transparent windows"); sl@0: iTest->LogSubTest(KTestTextCursorTimerTrans); sl@0: TestTextCursorTimerTransL(); sl@0: break; sl@0: case 3: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0570 sl@0: */ sl@0: ((CTHeartBeatTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0570")); sl@0: _LIT(KTestAnimDll1,"Anim DLL Heartbeat check (Win)"); sl@0: iTest->LogSubTest(KTestAnimDll1); sl@0: TestAnimDllL(EFalse,0); sl@0: break; sl@0: case 4: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0571 sl@0: */ sl@0: ((CTHeartBeatTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0571")); sl@0: _LIT(KTestAnimDll2,"Anim DLL Heartbeat check (Sprite)"); sl@0: iTest->LogSubTest(KTestAnimDll2); sl@0: TestAnimDllL(ETrue,0); sl@0: TestAnimDllL(ETrue,ESpriteNoChildClip); sl@0: break; sl@0: case 5: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0572 sl@0: */ sl@0: ((CTHeartBeatTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0572")); sl@0: _LIT(KTestAnimDllTrans,"Anim DLL Heartbeat check with transparent windows"); sl@0: iTest->LogSubTest(KTestAnimDllTrans); sl@0: TestAnimDllTransL(); sl@0: break; sl@0: case 6: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0573 sl@0: */ sl@0: ((CTHeartBeatTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0573")); sl@0: _LIT(KTestActiveInactiveEvents,"Handling of TRawEvent::EInactive and EActive"); sl@0: iTest->LogSubTest(KTestActiveInactiveEvents); sl@0: TestActiveInactiveEvents(); sl@0: break; sl@0: default: sl@0: ((CTHeartBeatTestStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); sl@0: ((CTHeartBeatTestStep*)iStep)->CloseTMSGraphicsStep(); sl@0: TestComplete(); sl@0: break; sl@0: } sl@0: ((CTHeartBeatTestStep*)iStep)->RecordTestResultL(); sl@0: } sl@0: sl@0: __WS_CONSTRUCT_STEP__(HeartBeatTest)