1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/windowing/windowserver/test/tauto/THeartBeat.CPP Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,659 @@
1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Test the Wserv heart beat switch on and off
1.18 +//
1.19 +//
1.20 +
1.21 +/**
1.22 + @file
1.23 + @test
1.24 + @internalComponent - Internal Symbian test code
1.25 +*/
1.26 +
1.27 +#include "THeartBeat.h"
1.28 +#include <w32debug.h>
1.29 +
1.30 +CTHeartBeatTest::CTHeartBeatTest(CTestStep* aStep) :
1.31 + CTWsGraphicsBase(aStep)
1.32 + {
1.33 + }
1.34 +
1.35 +CTHeartBeatTest::~CTHeartBeatTest()
1.36 + {
1.37 + iAnimDll.Close();
1.38 + delete iHbTestWin;
1.39 + }
1.40 +
1.41 +void CTHeartBeatTest::ConstructL()
1.42 + {
1.43 + TSize screenSize=TheClient->iGroup->Size();
1.44 + TInt winWidth=(screenSize.iWidth/3)-10;
1.45 + TInt winHeight=screenSize.iHeight-10;
1.46 + iHbTestWin=new(ELeave) CAnimWindow(EFalse, CAnimWindow::ERedraw);
1.47 + iHbTestWin->ConstructL(TPoint(screenSize.iWidth/3*2+5,5),TSize(winWidth,winHeight));
1.48 + iAnimDll=RAnimDll(TheClient->iWs);
1.49 + User::LeaveIfError(iAnimDll.Load(KAnimDLLName));
1.50 + }
1.51 +
1.52 +void CTHeartBeatTest::SetCursor(const TPoint& aPos,const TSize& aSize, TUint aFlags/*=0*/)
1.53 + { // Default aFlags=0 gives a flashing cursor
1.54 + TTextCursor tc;
1.55 + tc.iType=TTextCursor::ETypeRectangle;
1.56 + tc.iHeight=aSize.iHeight;
1.57 + tc.iAscent=aSize.iHeight*4/5;
1.58 + tc.iWidth=aSize.iWidth;
1.59 + tc.iFlags=aFlags;
1.60 + tc.iColor=KRgbGreen;
1.61 + TheClient->iGroup->GroupWin()->SetTextCursor(*iHbTestWin->BaseWin(),TPoint(aPos.iX,aPos.iY+tc.iAscent),tc);
1.62 + }
1.63 +
1.64 +TBool CTHeartBeatTest::SetAutoHeartBeatPauseState(TBool aState) const
1.65 + {
1.66 + return(TheClient->iWs.DebugInfo(EWsDebugSetAutoHeartBeatPauseState,aState));
1.67 + }
1.68 +
1.69 +TBool CTHeartBeatTest::GetHeartBeatTimerState() const
1.70 + {
1.71 + return(TheClient->iWs.DebugInfo(EWsDebugHeartBeatState));
1.72 + }
1.73 +
1.74 +void CTHeartBeatTest::CancelTextCursor()
1.75 + {
1.76 + TheClient->iGroup->GroupWin()->CancelTextCursor();
1.77 + }
1.78 +
1.79 +void CTHeartBeatTest::TestTextCursorTimerL()
1.80 + {
1.81 + TEST(!GetHeartBeatTimerState());
1.82 + SetCursor(TPoint(0,0),TSize(10,10));
1.83 + TEST(GetHeartBeatTimerState());
1.84 + CancelTextCursor();
1.85 + TEST(!GetHeartBeatTimerState());
1.86 +//
1.87 + TPoint testCursorPos;
1.88 + TSize testCursorSize(10,10);
1.89 + SetCursor(testCursorPos,testCursorSize);
1.90 + TEST(GetHeartBeatTimerState());
1.91 + iHbTestWin->BaseWin()->SetVisible(EFalse);
1.92 + TEST(!GetHeartBeatTimerState());
1.93 + iHbTestWin->BaseWin()->SetVisible(ETrue);
1.94 + TEST(GetHeartBeatTimerState());
1.95 +//
1.96 +// Cover the cursor and check heartbeat disabled
1.97 + RWindow coverCursor(TheClient->iWs);
1.98 + CleanupClosePushL(coverCursor);
1.99 + User::LeaveIfError(coverCursor.Construct(*iHbTestWin->BaseWin(), 0xBADBAD));
1.100 + coverCursor.SetExtent(testCursorPos,testCursorSize);
1.101 + coverCursor.Activate();
1.102 + TEST(!GetHeartBeatTimerState());
1.103 +// Now fractionally expose the cursor and check heartbeat re-enabled
1.104 + coverCursor.SetExtent(testCursorPos+TPoint(1,1),testCursorSize);
1.105 + TEST(GetHeartBeatTimerState());
1.106 +// Re-cover it
1.107 + coverCursor.SetExtent(testCursorPos,testCursorSize);
1.108 + TEST(!GetHeartBeatTimerState());
1.109 +// Enlarge cursor to expose itself then check heartbeat
1.110 + SetCursor(testCursorPos,TSize(testCursorSize.iWidth+1,testCursorSize.iHeight));
1.111 + TEST(GetHeartBeatTimerState());
1.112 +// Shrink cursor then check heartbeat
1.113 + SetCursor(testCursorPos,testCursorSize);
1.114 + TEST(!GetHeartBeatTimerState());
1.115 +// Turn off auto heart beat pausing, should turn timer back on
1.116 + SetAutoHeartBeatPauseState(EFalse);
1.117 + TEST(GetHeartBeatTimerState());
1.118 +// With auto pausing enabled covering/uncovering the cursor should have no effect,
1.119 +// timer will always be on
1.120 + coverCursor.SetVisible(EFalse);
1.121 + TEST(GetHeartBeatTimerState());
1.122 + coverCursor.SetVisible(ETrue);
1.123 + TEST(GetHeartBeatTimerState());
1.124 +// Re-enable auto-pause should turn timer back off
1.125 + SetAutoHeartBeatPauseState(ETrue);
1.126 + TEST(!GetHeartBeatTimerState());
1.127 +// Destroy covering window and check heartbeat re-enabled
1.128 + CleanupStack::PopAndDestroy(&coverCursor);
1.129 + TEST(GetHeartBeatTimerState());
1.130 +// Check using no flash flag turns timer off
1.131 + SetCursor(testCursorPos,testCursorSize,TTextCursor::EFlagNoFlash);
1.132 + TEST(!GetHeartBeatTimerState());
1.133 +// and turning no flash flag off turns timer back on
1.134 + SetCursor(testCursorPos,testCursorSize);
1.135 + TEST(GetHeartBeatTimerState());
1.136 +// Preparing for switch off should disable the heartbeat until another event is received
1.137 + TheClient->iWs.PrepareForSwitchOff();
1.138 + TEST(!GetHeartBeatTimerState());
1.139 +// Any event should wake the hearbeat back up again
1.140 + TRawEvent rawEvent;
1.141 + rawEvent.Set(TRawEvent::EPointerMove,0,0);
1.142 + TheClient->iWs.SimulateRawEvent(rawEvent);
1.143 + TEST(GetHeartBeatTimerState());
1.144 +//
1.145 + CancelTextCursor();
1.146 + TEST(!GetHeartBeatTimerState());
1.147 +// Check heartbeat still off as expected
1.148 + TheClient->iWs.PrepareForSwitchOff();
1.149 + TEST(!GetHeartBeatTimerState());
1.150 +// Check when hearbeat not required that it's not turned back when coming out of PrepareForSwitchOff() mode.
1.151 + TheClient->iWs.SimulateRawEvent(rawEvent);
1.152 + TheClient->Flush();
1.153 + TEST(!GetHeartBeatTimerState());
1.154 + }
1.155 +
1.156 +void CTHeartBeatTest::doTestActiveInactiveEvents(TBool aCursorOn, TBool aAutoPauseOn)
1.157 + {
1.158 + SetAutoHeartBeatPauseState(aAutoPauseOn);
1.159 + if (aCursorOn)
1.160 + SetCursor(TPoint(0,0),TSize(10,10));
1.161 +// Should disable timer, regardless of other states
1.162 + TRawEvent event;
1.163 + event.Set(TRawEvent::EInactive);
1.164 + UserSvr::AddEvent(event);
1.165 + TEST(!GetHeartBeatTimerState());
1.166 +// ...and switch it back on
1.167 + event.Set(TRawEvent::EActive);
1.168 + UserSvr::AddEvent(event);
1.169 + TBool testResult1=EFalse;
1.170 + if (aAutoPauseOn)
1.171 + testResult1=aCursorOn; // Only on if cursor is on without auto pause enabled
1.172 + else
1.173 + testResult1=ETrue; // Always on if auto pause disabled
1.174 + TBool hbState=GetHeartBeatTimerState();
1.175 + if ((!hbState)!=(!testResult1))
1.176 + {
1.177 + _LIT(KLog,"Fail in TestActiveInactiveEvents(%d.%d) HBState=%d result=%d");
1.178 + LOG_MESSAGE5(KLog,aCursorOn,aAutoPauseOn,hbState,testResult1);
1.179 + }
1.180 + TEST((!GetHeartBeatTimerState())==(!testResult1)); //Works with any positive value for True
1.181 +//
1.182 + if (aCursorOn)
1.183 + CancelTextCursor();
1.184 + }
1.185 +
1.186 +void CTHeartBeatTest::TestActiveInactiveEvents()
1.187 + {
1.188 + doTestActiveInactiveEvents(EFalse,EFalse);
1.189 + doTestActiveInactiveEvents(ETrue,EFalse);
1.190 + doTestActiveInactiveEvents(EFalse,ETrue);
1.191 + doTestActiveInactiveEvents(ETrue,ETrue);
1.192 + }
1.193 +
1.194 +void CTHeartBeatTest::FailCursorHbTest(const TDesC& aErrorBase, const TDesC* aExtraText, TBool aHbState, TBool aHbCheckState)
1.195 + {
1.196 + TBuf<256> error(aErrorBase);
1.197 + if (aExtraText)
1.198 + {
1.199 + error.Append(*aExtraText);
1.200 + }
1.201 + _LIT(KHbErrorAppendFmt," HB=%d (Testing for %d)");
1.202 + error.AppendFormat(KHbErrorAppendFmt,aHbState,aHbCheckState);
1.203 + LOG_MESSAGE(error);
1.204 + TEST(EFalse);
1.205 + }
1.206 +
1.207 +TBool CTHeartBeatTest::ChangeTransAndCheckHeartBeat(TInt aTestMode, RWindow& aTransWin, const TRect& aGraphicRect, TInt aExtraWinTestMode, const TDesC* aErrorMsg, TBool aSetVisibleAfterTransUpdate)
1.208 + {
1.209 + TRect cursorRect(aGraphicRect);
1.210 + cursorRect.Move(iHbTestWin->BaseWin()->InquireOffset(aTransWin));
1.211 + TRect winRect(aTransWin.Size());
1.212 + __ASSERT_ALWAYS(winRect.Contains(cursorRect.iTl) && winRect.Contains(cursorRect.iBr),AutoPanic(EAutoPanicHeartBeatCursorRect));
1.213 +//
1.214 + TRegionFix<8> transRegion;
1.215 + TBool heartBeatCheck=EFalse;
1.216 + switch(aTestMode)
1.217 + {
1.218 + case ECursorTransWinTestModeFullTrans:
1.219 + transRegion.AddRect(winRect);
1.220 + heartBeatCheck=ETrue;
1.221 + break;
1.222 + case ECursorTransWinTestNoTrans:
1.223 + break;
1.224 + case ECursorTransWinTestPartialTransCoveringCursor:
1.225 + transRegion.AddRect(winRect);
1.226 + transRegion.SubRect(cursorRect);
1.227 + break;
1.228 + case ECursorTransWinTestPartialTransExposingCursor:
1.229 + transRegion.AddRect(cursorRect);
1.230 + heartBeatCheck=ETrue;
1.231 + break;
1.232 + default:
1.233 + ASSERT(EFalse);
1.234 + }
1.235 + TBool invisHeartBeatCheck=ETrue;
1.236 + switch(aExtraWinTestMode)
1.237 + {
1.238 + case ECursorTransWinTestNoTrans:
1.239 + case ECursorTransWinTestPartialTransCoveringCursor:
1.240 + heartBeatCheck=EFalse;
1.241 + invisHeartBeatCheck=EFalse;
1.242 + break;
1.243 + default:
1.244 + break;
1.245 + }
1.246 +//
1.247 + ASSERT(!transRegion.CheckError());
1.248 + if (aSetVisibleAfterTransUpdate)
1.249 + aTransWin.SetVisible(EFalse);
1.250 + aTransWin.SetTransparentRegion(transRegion);
1.251 + if (aSetVisibleAfterTransUpdate)
1.252 + aTransWin.SetVisible(ETrue);
1.253 +//
1.254 + TBool testSuccess=ETrue;
1.255 + TBool heartBeatState=GetHeartBeatTimerState();
1.256 + TBool failed1stTest=EFalse;
1.257 + if ((!heartBeatState)!=(!heartBeatCheck)) //Works with any positive value for True
1.258 + {
1.259 + failed1stTest=ETrue;
1.260 + _LIT(KFailedHbTest,"Failed ");
1.261 + FailCursorHbTest(KFailedHbTest,aErrorMsg,heartBeatState,heartBeatCheck);
1.262 + testSuccess=EFalse;
1.263 + }
1.264 +//
1.265 + aTransWin.SetVisible(EFalse);
1.266 + heartBeatState=GetHeartBeatTimerState();
1.267 + _LIT(KGoingInvisAfterTestAppend," after %S");
1.268 + TBuf<256> errorExtra;
1.269 + if (aErrorMsg)
1.270 + {
1.271 + errorExtra.Format(KGoingInvisAfterTestAppend,aErrorMsg);
1.272 + }
1.273 + if ((!heartBeatState)!=(!invisHeartBeatCheck)) //Works with any positive value for True
1.274 + {
1.275 + _LIT(KFailedGoingInvis,"Failed setting trans win invisible");
1.276 + FailCursorHbTest(KFailedGoingInvis,&errorExtra,heartBeatState,invisHeartBeatCheck);
1.277 + testSuccess=EFalse;
1.278 + }
1.279 +//
1.280 + aTransWin.SetVisible(ETrue);
1.281 + heartBeatState=GetHeartBeatTimerState();
1.282 + if (!failed1stTest && (!heartBeatState)!=(!heartBeatCheck)) //Works with any positive value for True
1.283 + {
1.284 + _LIT(KFailedResettingVis,"Failed re-setting trans win visible");
1.285 + FailCursorHbTest(KFailedResettingVis,&errorExtra,heartBeatState,heartBeatCheck);
1.286 + testSuccess=EFalse;
1.287 + }
1.288 + return(testSuccess);
1.289 + }
1.290 +
1.291 +void CTHeartBeatTest::LoopThroughTransWinTestModes(RWindow& aTransWin, const TRect& aGraphicRect, TInt aExtraWinTestMode)
1.292 + {
1.293 + TBuf<256> error;
1.294 + for(TInt setVisMode=0;setVisMode<2;setVisMode++)
1.295 + {
1.296 + if (setVisMode==0)
1.297 + continue; // zzz setinvis/makevis needed to flush out changes it seems
1.298 + const TBool setVisibleAfterTransUpdate=setVisMode>0;
1.299 + for(TInt startTestMode=0;startTestMode<ENumCursorTransWinTestModes;startTestMode++)
1.300 + {
1.301 + if (startTestMode==ECursorTransWinTestNoTrans)
1.302 + continue;// zzz bugged trans win problem
1.303 + _LIT(KTcHbModeSetFail,"setting test mode %d (vis mode %d)");
1.304 + error.Format(KTcHbModeSetFail,startTestMode,setVisibleAfterTransUpdate);
1.305 + for(TInt switchToTestMode=0;switchToTestMode<ENumCursorTransWinTestModes;switchToTestMode++)
1.306 + {
1.307 + if (switchToTestMode==ECursorTransWinTestNoTrans)
1.308 + continue;// zzz bugged trans win problem
1.309 + if (startTestMode==switchToTestMode)
1.310 + continue;
1.311 + if (ChangeTransAndCheckHeartBeat(startTestMode, aTransWin, aGraphicRect, aExtraWinTestMode, &error, setVisibleAfterTransUpdate))
1.312 + {
1.313 + _LIT(KTcHbModeSwitchFail,"switching from test mode %d to %d (vis mode %d)");
1.314 + error.Format(KTcHbModeSwitchFail, startTestMode, switchToTestMode, setVisibleAfterTransUpdate);
1.315 + ChangeTransAndCheckHeartBeat(switchToTestMode, aTransWin, aGraphicRect, aExtraWinTestMode, &error, setVisibleAfterTransUpdate);
1.316 + }
1.317 + }
1.318 + }
1.319 + ChangeTransAndCheckHeartBeat(0, aTransWin, aGraphicRect, aExtraWinTestMode, NULL, setVisibleAfterTransUpdate);
1.320 + }
1.321 + }
1.322 +
1.323 +void CTHeartBeatTest::RunTransWinTestsL(const TRect& aGraphicRect)
1.324 + {
1.325 +// Test a variety of patterns of changing the layout of transparent windows over the cursor
1.326 +// cause the heartbeat state to be modified accordingly.
1.327 +//
1.328 +// Each transparent window has four specific states to test:
1.329 +// i) Transparency area is the whole window
1.330 +// ii) Partial transparency that exposes the cursor
1.331 +// iii) Partial transparency that covers the cursor
1.332 +// iv) Empty transparent region, i.e. totally opaque
1.333 +//
1.334 +// We need to test various transitions between these states, first on a single window, then
1.335 +// in a various layouts with transparent windows layered over each other.
1.336 +//
1.337 + RWindow transWin1(TheClient->iWs);
1.338 + User::LeaveIfError(transWin1.Construct(*TheClient->iGroup->GroupWin(),0xDEADBAD1));
1.339 + CleanupClosePushL(transWin1);
1.340 + if (transWin1.SetTransparencyFactor(TRgb::Gray256(128))!=KErrNone)
1.341 + { // Transparency not enabled, skip tests
1.342 + CleanupStack::PopAndDestroy(&transWin1);
1.343 + return;
1.344 + }
1.345 + transWin1.Activate();
1.346 + TEST(GetHeartBeatTimerState());
1.347 +// First simply check activating default full screen transparent window doesn't disable the heartbeat
1.348 + _LIT(KBasicTransCursorTests,"Running basic transparent window cursor heartbeat tests");
1.349 + LOG_MESSAGE(KBasicTransCursorTests);
1.350 + LoopThroughTransWinTestModes(transWin1, aGraphicRect, ECursorTransWinTestNA);
1.351 +//
1.352 +// Lots of test code disabled due to bugs in handling of transparent window regions
1.353 +// See DEF110677, hopefully when the issues in there are addressed the rest of the
1.354 +// test code here can be enabled
1.355 +// See sections marked with zzz for places where certain tests are disabled, once DEF110677
1.356 +// is marked as fixed these sections should be re-enabled and if problems still occur they
1.357 +// need to be investigated.
1.358 +//
1.359 +//
1.360 +// Now check more complex modes with two transparent windows over the test window
1.361 + RWindow transWin2(TheClient->iWs);
1.362 + User::LeaveIfError(transWin2.Construct(*TheClient->iGroup->GroupWin(),0xDEADBAD2));
1.363 + CleanupClosePushL(transWin2);
1.364 + User::LeaveIfError(transWin2.SetTransparencyFactor(TRgb::Gray256(128)));
1.365 + TSize screenSize=TheClient->iGroup->Size();
1.366 + screenSize.iWidth-=10;
1.367 + transWin1.SetExtent(TPoint(0,0),screenSize);
1.368 + transWin2.SetExtent(TPoint(10,0),screenSize);
1.369 + transWin2.Activate();
1.370 + for(TInt win1OrdPos=0;win1OrdPos<2;win1OrdPos++)
1.371 + {
1.372 + transWin1.SetOrdinalPosition(win1OrdPos);
1.373 + _LIT(KOrdinalTransCursorTests,"Running tests with transwin1 ordinal pos=%d");
1.374 + LOG_MESSAGE2(KOrdinalTransCursorTests,win1OrdPos);
1.375 + for(TInt topWinTestMode=0;topWinTestMode<ENumCursorTransWinTestModes;topWinTestMode++)
1.376 + {
1.377 + if (topWinTestMode==ECursorTransWinTestNoTrans)
1.378 + continue;// zzz bugged transparent window problem
1.379 + if (topWinTestMode==ECursorTransWinTestPartialTransCoveringCursor)
1.380 + continue;// zzz bugged transparent window problem
1.381 + _LIT(KTopTransWinCursorTest,"Setting top trans win mode %d");
1.382 + TBuf<256> msg;
1.383 + msg.Format(KTopTransWinCursorTest,topWinTestMode);
1.384 + LOG_MESSAGE(msg);
1.385 + ChangeTransAndCheckHeartBeat(0, transWin2, aGraphicRect, topWinTestMode, NULL, ETrue);
1.386 + LoopThroughTransWinTestModes(transWin1, aGraphicRect, topWinTestMode);
1.387 + }
1.388 + }
1.389 + ChangeTransAndCheckHeartBeat(0, transWin2, aGraphicRect, 0, NULL, ETrue);
1.390 + CleanupStack::PopAndDestroy(&transWin2);
1.391 + TEST(GetHeartBeatTimerState());
1.392 +//
1.393 + CleanupStack::PopAndDestroy(&transWin1);
1.394 + TEST(GetHeartBeatTimerState());
1.395 + }
1.396 +
1.397 +void CTHeartBeatTest::TestTextCursorTimerTransL()
1.398 + {
1.399 + TSize testWinSize(iHbTestWin->BaseWin()->Size());
1.400 + TRect cursorRect(testWinSize.iWidth/4,testWinSize.iHeight/3,testWinSize.iWidth*3/4,testWinSize.iHeight*2/3);
1.401 + TEST(!GetHeartBeatTimerState());
1.402 + SetCursor(cursorRect.iTl,cursorRect.Size());
1.403 + TEST(GetHeartBeatTimerState());
1.404 + RunTransWinTestsL(cursorRect);
1.405 + CancelTextCursor();
1.406 + TEST(!GetHeartBeatTimerState());
1.407 + }
1.408 +
1.409 +void CTHeartBeatTest::TestHeartBeatStopStart(TBool aHeartbeatStateOff,TBool aHeartbeatStateOn,const TDesC& aOffText,const TDesC& aOnText)
1.410 + {
1.411 + TEST(!aHeartbeatStateOff);
1.412 + if (aHeartbeatStateOff)
1.413 + LOG_MESSAGE2(_L("%S failed to disable heartbeat timer"),&aOffText);
1.414 + TEST(aHeartbeatStateOn);
1.415 + if (!aHeartbeatStateOn)
1.416 + LOG_MESSAGE2(_L("%S failed to re-enable heartbeat timer"),&aOnText);
1.417 + }
1.418 +
1.419 +void CTHeartBeatTest::TestAnimDllL(TBool aSpriteMode, TUint aSpriteFlags)
1.420 + {
1.421 + RTestAnim anim(iAnimDll);
1.422 + TEST(!GetHeartBeatTimerState());
1.423 + TSize testWinSize(iHbTestWin->BaseWin()->Size());
1.424 + TRect animRect(1,1,testWinSize.iWidth/3,testWinSize.iWidth/5);
1.425 + TPckgC<TRect> rectPckg(animRect);
1.426 + RWsSprite sprite(TheClient->iWs);
1.427 + CleanupClosePushL(sprite);
1.428 + if (aSpriteMode)
1.429 + {
1.430 + sprite.Construct(*iHbTestWin->BaseWin(),TPoint(),aSpriteFlags);
1.431 + CFbsBitmap* bitmap1=new(ELeave) CFbsBitmap();
1.432 + CleanupStack::PushL(bitmap1);
1.433 + CFbsBitmap* bitmap2=new(ELeave) CFbsBitmap();
1.434 + CleanupStack::PushL(bitmap2);
1.435 + CFbsBitmap* bitmap3=new(ELeave) CFbsBitmap();
1.436 + CleanupStack::PushL(bitmap3);
1.437 + TSize animSize(animRect.Size());
1.438 + User::LeaveIfError(bitmap1->Create(TSize(animSize.iWidth/2,animSize.iHeight/2),EGray4));
1.439 + User::LeaveIfError(bitmap2->Create(TSize(animSize.iWidth,animSize.iHeight/3),EGray4));
1.440 + User::LeaveIfError(bitmap3->Create(TSize(animSize.iWidth/3,animSize.iHeight),EGray4));
1.441 +//
1.442 + TSpriteMember member1;
1.443 + member1.iMaskBitmap=NULL;
1.444 + member1.iInvertMask=EFalse;
1.445 + member1.iDrawMode=CGraphicsContext::EDrawModePEN;
1.446 + member1.iOffset=TPoint();
1.447 + member1.iInterval=TTimeIntervalMicroSeconds32(1);
1.448 + member1.iBitmap=bitmap1;
1.449 + member1.iMaskBitmap=bitmap1;
1.450 + sprite.AppendMember(member1);
1.451 +//
1.452 + TSpriteMember member2;
1.453 + member2.iInvertMask=EFalse;
1.454 + member2.iDrawMode=CGraphicsContext::EDrawModeXOR;
1.455 + member2.iOffset=TPoint(1,2);
1.456 + member2.iInterval=TTimeIntervalMicroSeconds32(2);
1.457 + member2.iBitmap=bitmap2;
1.458 + member2.iMaskBitmap=bitmap2;
1.459 + sprite.AppendMember(member2);
1.460 +//
1.461 + TSpriteMember member3;
1.462 + member3.iInvertMask=ETrue;
1.463 + member3.iDrawMode=CGraphicsContext::EDrawModeOR;
1.464 + member3.iOffset=TPoint(3,4);
1.465 + member3.iInterval=TTimeIntervalMicroSeconds32(3);
1.466 + member3.iBitmap=bitmap3;
1.467 + member3.iMaskBitmap=bitmap3;
1.468 + sprite.AppendMember(member3);
1.469 +//
1.470 + User::LeaveIfError(anim.Construct(sprite,EAnimTypeSprite,rectPckg));
1.471 + CleanupStack::PopAndDestroy(3,bitmap1);
1.472 + }
1.473 + else
1.474 + {
1.475 + User::LeaveIfError(anim.Construct(*iHbTestWin->BaseWin(),EAnimTypeTest3,rectPckg));
1.476 + }
1.477 + CleanupClosePushL(anim);
1.478 + TEST(GetHeartBeatTimerState());
1.479 +
1.480 + // Cover up the window with the animation and check this disables the heartbeat timer.
1.481 + RBlankWindow blankwin1(TheClient->iWs);
1.482 + User::LeaveIfError(blankwin1.Construct(*TheClient->iGroup->GroupWin(),123));
1.483 + TPoint winOffset(iHbTestWin->BaseWin()->InquireOffset(*TheClient->iGroup->GroupWin()));
1.484 + if (aSpriteMode)
1.485 + blankwin1.SetExtent(winOffset,testWinSize);
1.486 + else
1.487 + blankwin1.SetExtent(winOffset+animRect.iTl,animRect.Size());
1.488 + blankwin1.Activate();
1.489 + TBool heartbeatStateOff=GetHeartBeatTimerState();
1.490 + TEST(!heartbeatStateOff);
1.491 + if (heartbeatStateOff)
1.492 + {
1.493 + LOG_MESSAGE(_L("Covering window failed to disable heartbeat timer"));
1.494 + }
1.495 + TBool heartbeatStateOn;
1.496 + if (!aSpriteMode)
1.497 + {
1.498 + // Resize the anim so it becomes visible, then shrink back down again
1.499 + animRect.iBr.iX++;
1.500 + anim.Command(EADllSetRect,rectPckg);
1.501 + heartbeatStateOn=GetHeartBeatTimerState();
1.502 + animRect.iBr.iX--;
1.503 + anim.Command(EADllSetRect,rectPckg);
1.504 + heartbeatStateOff=GetHeartBeatTimerState();
1.505 + TestHeartBeatStopStart(heartbeatStateOff,heartbeatStateOn,_L("Shrinking anim"),_L("Growing anim"));
1.506 + }
1.507 +//
1.508 + blankwin1.Close();
1.509 + heartbeatStateOn=GetHeartBeatTimerState();
1.510 + TEST(heartbeatStateOn);
1.511 + if (!heartbeatStateOn)
1.512 + {
1.513 + LOG_MESSAGE(_L("Un-covering window failed to disable heartbeat timer"));
1.514 + }
1.515 +
1.516 + // Put a transparent window over the animation and check the heartbeat timer is not disabled
1.517 + RWindow transWin(TheClient->iWs);
1.518 + User::LeaveIfError(transWin.Construct(*TheClient->iGroup->GroupWin(),123));
1.519 + if (transWin.SetTransparencyFactor(TRgb::Gray256(128))==KErrNone)
1.520 + {
1.521 + transWin.Activate();
1.522 + heartbeatStateOn=GetHeartBeatTimerState();
1.523 + TEST(heartbeatStateOn);
1.524 + if (!heartbeatStateOn)
1.525 + LOG_MESSAGE(_L("Transparent window caused heartbeat timer to be disabled"));
1.526 + TRegionFix<1> emptyRegion;
1.527 + transWin.SetTransparentRegion(emptyRegion);
1.528 + heartbeatStateOff=GetHeartBeatTimerState();
1.529 + TRegionFix<1> fullRegion(transWin.Size());
1.530 + transWin.SetTransparentRegion(fullRegion);
1.531 + heartbeatStateOn=GetHeartBeatTimerState();
1.532 + TestHeartBeatStopStart(heartbeatStateOff,heartbeatStateOn,_L("Making covering window opaque"),_L("Making covering window transparent"));
1.533 + if (aSpriteMode)
1.534 + {
1.535 + RBlankWindow blankwin2(TheClient->iWs);
1.536 + User::LeaveIfError(blankwin2.Construct(*iHbTestWin->BaseWin(),1234));
1.537 + blankwin2.Activate();
1.538 + heartbeatStateOn=GetHeartBeatTimerState();
1.539 + // With ESpriteNoChildClip the heartbeat should still be on as the sprite will still be visible
1.540 + // Without it blankwin2 will cover up the sprite and cancel the heartbeat
1.541 + TBool heartBeatCheck=aSpriteFlags&ESpriteNoChildClip;
1.542 + TEST((!heartbeatStateOn)==(!heartBeatCheck)); //Works with any positive value for True
1.543 + blankwin2.Close();
1.544 + }
1.545 + transWin.SetTransparentRegion(emptyRegion);
1.546 + heartbeatStateOff=GetHeartBeatTimerState();
1.547 + transWin.Close();
1.548 + heartbeatStateOn=GetHeartBeatTimerState();
1.549 + TestHeartBeatStopStart(heartbeatStateOff,heartbeatStateOn,_L("Making covering window opaque"),_L("Un-covering window"));
1.550 + }
1.551 + else
1.552 + transWin.Close();
1.553 +
1.554 + // Make the window with the animation invisible and check this disables the heartbeat timer.
1.555 + iHbTestWin->BaseWin()->SetVisible(EFalse);
1.556 + heartbeatStateOff=GetHeartBeatTimerState();
1.557 + iHbTestWin->BaseWin()->SetVisible(ETrue);
1.558 + heartbeatStateOn=GetHeartBeatTimerState();
1.559 + TestHeartBeatStopStart(heartbeatStateOff,heartbeatStateOn,_L("Making window invisible"),_L("Making window visible"));
1.560 +
1.561 + // Move the window with the animation off screen and check this disables the heartbeat timer.
1.562 + TSize screenSize=TheClient->iGroup->Size();
1.563 + TPoint oldPos(iHbTestWin->BaseWin()->Position());
1.564 + iHbTestWin->BaseWin()->SetPosition(screenSize.AsPoint());
1.565 + heartbeatStateOff=GetHeartBeatTimerState();
1.566 + iHbTestWin->BaseWin()->SetPosition(oldPos);
1.567 + heartbeatStateOn=GetHeartBeatTimerState();
1.568 + TestHeartBeatStopStart(heartbeatStateOff,heartbeatStateOn,_L("Moving window offscreen"),_L("Moving window back onscreen"));
1.569 + TEST(GetHeartBeatTimerState());
1.570 + CleanupStack::PopAndDestroy(&anim);
1.571 + TEST(!GetHeartBeatTimerState());
1.572 + CleanupStack::PopAndDestroy(&sprite);
1.573 + }
1.574 +
1.575 +void CTHeartBeatTest::TestAnimDllTransL()
1.576 + {
1.577 + RTestAnim anim(iAnimDll);
1.578 + TSize testWinSize(iHbTestWin->BaseWin()->Size());
1.579 + TRect animRect(testWinSize.iWidth/4,testWinSize.iHeight/3,testWinSize.iWidth*3/4,testWinSize.iHeight*2/3);
1.580 + TPckgBuf<TRect> rectPckg;
1.581 + rectPckg()=animRect;
1.582 + TEST(!GetHeartBeatTimerState());
1.583 + User::LeaveIfError(anim.Construct(*iHbTestWin->BaseWin(),EAnimTypeTest3,rectPckg));
1.584 + CleanupClosePushL(anim);
1.585 + TEST(GetHeartBeatTimerState());
1.586 +//
1.587 + RunTransWinTestsL(animRect);
1.588 +//
1.589 + CleanupStack::PopAndDestroy(&anim);
1.590 + TEST(!GetHeartBeatTimerState());
1.591 + }
1.592 +
1.593 +void CTHeartBeatTest::RunTestCaseL(TInt /*aCurTestCase*/)
1.594 + {
1.595 +
1.596 + switch(++iTest->iState)
1.597 + {
1.598 + case 1:
1.599 +/**
1.600 +@SYMTestCaseID GRAPHICS-WSERV-0568
1.601 +*/
1.602 + ((CTHeartBeatTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0568"));
1.603 + _LIT(KTestTextCursorTimer,"Basic heartbeat timer test");
1.604 + iTest->LogSubTest(KTestTextCursorTimer);
1.605 + TestTextCursorTimerL();
1.606 + break;
1.607 + case 2:
1.608 +/**
1.609 +@SYMTestCaseID GRAPHICS-WSERV-0569
1.610 +*/
1.611 + ((CTHeartBeatTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0569"));
1.612 + _LIT(KTestTextCursorTimerTrans,"Heartbeat timer test with transparent windows");
1.613 + iTest->LogSubTest(KTestTextCursorTimerTrans);
1.614 + TestTextCursorTimerTransL();
1.615 + break;
1.616 + case 3:
1.617 +/**
1.618 +@SYMTestCaseID GRAPHICS-WSERV-0570
1.619 +*/
1.620 + ((CTHeartBeatTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0570"));
1.621 + _LIT(KTestAnimDll1,"Anim DLL Heartbeat check (Win)");
1.622 + iTest->LogSubTest(KTestAnimDll1);
1.623 + TestAnimDllL(EFalse,0);
1.624 + break;
1.625 + case 4:
1.626 +/**
1.627 +@SYMTestCaseID GRAPHICS-WSERV-0571
1.628 +*/
1.629 + ((CTHeartBeatTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0571"));
1.630 + _LIT(KTestAnimDll2,"Anim DLL Heartbeat check (Sprite)");
1.631 + iTest->LogSubTest(KTestAnimDll2);
1.632 + TestAnimDllL(ETrue,0);
1.633 + TestAnimDllL(ETrue,ESpriteNoChildClip);
1.634 + break;
1.635 + case 5:
1.636 +/**
1.637 +@SYMTestCaseID GRAPHICS-WSERV-0572
1.638 +*/
1.639 + ((CTHeartBeatTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0572"));
1.640 + _LIT(KTestAnimDllTrans,"Anim DLL Heartbeat check with transparent windows");
1.641 + iTest->LogSubTest(KTestAnimDllTrans);
1.642 + TestAnimDllTransL();
1.643 + break;
1.644 + case 6:
1.645 +/**
1.646 +@SYMTestCaseID GRAPHICS-WSERV-0573
1.647 +*/
1.648 + ((CTHeartBeatTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0573"));
1.649 + _LIT(KTestActiveInactiveEvents,"Handling of TRawEvent::EInactive and EActive");
1.650 + iTest->LogSubTest(KTestActiveInactiveEvents);
1.651 + TestActiveInactiveEvents();
1.652 + break;
1.653 + default:
1.654 + ((CTHeartBeatTestStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
1.655 + ((CTHeartBeatTestStep*)iStep)->CloseTMSGraphicsStep();
1.656 + TestComplete();
1.657 + break;
1.658 + }
1.659 + ((CTHeartBeatTestStep*)iStep)->RecordTestResultL();
1.660 + }
1.661 +
1.662 +__WS_CONSTRUCT_STEP__(HeartBeatTest)