os/graphics/windowing/windowserver/test/tauto/THeartBeat.CPP
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // Test the Wserv heart beat switch on and off
    15 // 
    16 //
    17 
    18 /**
    19  @file
    20  @test
    21  @internalComponent - Internal Symbian test code
    22 */
    23 
    24 #include "THeartBeat.h"
    25 #include <w32debug.h>
    26 
    27 CTHeartBeatTest::CTHeartBeatTest(CTestStep* aStep) :
    28 	CTWsGraphicsBase(aStep)
    29 	{
    30 	}
    31 
    32 CTHeartBeatTest::~CTHeartBeatTest()
    33 	{
    34 	iAnimDll.Close();
    35 	delete iHbTestWin;
    36 	}
    37 
    38 void CTHeartBeatTest::ConstructL()
    39 	{
    40 	TSize screenSize=TheClient->iGroup->Size();
    41 	TInt winWidth=(screenSize.iWidth/3)-10;
    42 	TInt winHeight=screenSize.iHeight-10;
    43 	iHbTestWin=new(ELeave) CAnimWindow(EFalse, CAnimWindow::ERedraw);
    44 	iHbTestWin->ConstructL(TPoint(screenSize.iWidth/3*2+5,5),TSize(winWidth,winHeight));
    45 	iAnimDll=RAnimDll(TheClient->iWs);
    46 	User::LeaveIfError(iAnimDll.Load(KAnimDLLName));
    47 	}
    48 
    49 void CTHeartBeatTest::SetCursor(const TPoint& aPos,const TSize& aSize, TUint aFlags/*=0*/)
    50 	{ // Default aFlags=0 gives a flashing cursor
    51 	TTextCursor tc;
    52 	tc.iType=TTextCursor::ETypeRectangle;
    53 	tc.iHeight=aSize.iHeight;
    54 	tc.iAscent=aSize.iHeight*4/5;
    55 	tc.iWidth=aSize.iWidth;
    56 	tc.iFlags=aFlags;	
    57 	tc.iColor=KRgbGreen;
    58 	TheClient->iGroup->GroupWin()->SetTextCursor(*iHbTestWin->BaseWin(),TPoint(aPos.iX,aPos.iY+tc.iAscent),tc);
    59 	}
    60 
    61 TBool CTHeartBeatTest::SetAutoHeartBeatPauseState(TBool aState) const
    62 	{
    63 	return(TheClient->iWs.DebugInfo(EWsDebugSetAutoHeartBeatPauseState,aState));
    64 	}
    65 
    66 TBool CTHeartBeatTest::GetHeartBeatTimerState() const
    67 	{
    68 	return(TheClient->iWs.DebugInfo(EWsDebugHeartBeatState));
    69 	}
    70 
    71 void CTHeartBeatTest::CancelTextCursor()
    72 	{
    73 	TheClient->iGroup->GroupWin()->CancelTextCursor();
    74 	}
    75 
    76 void CTHeartBeatTest::TestTextCursorTimerL()
    77 	{
    78 	TEST(!GetHeartBeatTimerState());
    79 	SetCursor(TPoint(0,0),TSize(10,10));
    80 	TEST(GetHeartBeatTimerState());
    81 	CancelTextCursor();
    82 	TEST(!GetHeartBeatTimerState());
    83 //
    84 	TPoint testCursorPos;
    85 	TSize testCursorSize(10,10);
    86 	SetCursor(testCursorPos,testCursorSize);
    87 	TEST(GetHeartBeatTimerState());
    88 	iHbTestWin->BaseWin()->SetVisible(EFalse);
    89 	TEST(!GetHeartBeatTimerState());
    90 	iHbTestWin->BaseWin()->SetVisible(ETrue);
    91 	TEST(GetHeartBeatTimerState());
    92 //
    93 // Cover the cursor and check heartbeat disabled
    94 	RWindow coverCursor(TheClient->iWs);
    95 	CleanupClosePushL(coverCursor);
    96 	User::LeaveIfError(coverCursor.Construct(*iHbTestWin->BaseWin(), 0xBADBAD));
    97 	coverCursor.SetExtent(testCursorPos,testCursorSize);
    98 	coverCursor.Activate();
    99 	TEST(!GetHeartBeatTimerState());
   100 // Now fractionally expose the cursor and check heartbeat re-enabled
   101 	coverCursor.SetExtent(testCursorPos+TPoint(1,1),testCursorSize);
   102 	TEST(GetHeartBeatTimerState());
   103 // Re-cover it
   104 	coverCursor.SetExtent(testCursorPos,testCursorSize);
   105 	TEST(!GetHeartBeatTimerState());
   106 // Enlarge cursor to expose itself then check heartbeat
   107 	SetCursor(testCursorPos,TSize(testCursorSize.iWidth+1,testCursorSize.iHeight));
   108 	TEST(GetHeartBeatTimerState());
   109 // Shrink cursor then check heartbeat
   110 	SetCursor(testCursorPos,testCursorSize);
   111 	TEST(!GetHeartBeatTimerState());
   112 // Turn off auto heart beat pausing, should turn timer back on
   113 	SetAutoHeartBeatPauseState(EFalse);
   114 	TEST(GetHeartBeatTimerState());
   115 // With auto pausing enabled covering/uncovering the cursor should have no effect,
   116 // timer will always be on
   117 	coverCursor.SetVisible(EFalse);
   118 	TEST(GetHeartBeatTimerState());
   119 	coverCursor.SetVisible(ETrue);
   120 	TEST(GetHeartBeatTimerState());
   121 // Re-enable auto-pause should turn timer back off
   122 	SetAutoHeartBeatPauseState(ETrue);
   123 	TEST(!GetHeartBeatTimerState());
   124 // Destroy covering window and check heartbeat re-enabled
   125 	CleanupStack::PopAndDestroy(&coverCursor);
   126 	TEST(GetHeartBeatTimerState());
   127 // Check using no flash flag turns timer off
   128 	SetCursor(testCursorPos,testCursorSize,TTextCursor::EFlagNoFlash);
   129 	TEST(!GetHeartBeatTimerState());
   130 // and turning no flash flag off turns timer back on
   131 	SetCursor(testCursorPos,testCursorSize);
   132 	TEST(GetHeartBeatTimerState());
   133 // Preparing for switch off should disable the heartbeat until another event is received
   134 	TheClient->iWs.PrepareForSwitchOff();
   135 	TEST(!GetHeartBeatTimerState());
   136 // Any event should wake the hearbeat back up again
   137 	TRawEvent rawEvent;
   138 	rawEvent.Set(TRawEvent::EPointerMove,0,0);
   139 	TheClient->iWs.SimulateRawEvent(rawEvent);
   140 	TEST(GetHeartBeatTimerState());
   141 //
   142 	CancelTextCursor();
   143 	TEST(!GetHeartBeatTimerState());
   144 // Check heartbeat still off as expected
   145 	TheClient->iWs.PrepareForSwitchOff();
   146 	TEST(!GetHeartBeatTimerState());
   147 // Check when hearbeat not required that it's not turned back when coming out of PrepareForSwitchOff() mode.
   148 	TheClient->iWs.SimulateRawEvent(rawEvent);
   149 	TheClient->Flush();
   150 	TEST(!GetHeartBeatTimerState());
   151 	}
   152 
   153 void CTHeartBeatTest::doTestActiveInactiveEvents(TBool aCursorOn, TBool aAutoPauseOn)
   154 	{
   155 	SetAutoHeartBeatPauseState(aAutoPauseOn);
   156 	if (aCursorOn)
   157 		SetCursor(TPoint(0,0),TSize(10,10));
   158 // Should disable timer, regardless of other states
   159 	TRawEvent event;
   160 	event.Set(TRawEvent::EInactive);
   161 	UserSvr::AddEvent(event);
   162 	TEST(!GetHeartBeatTimerState());
   163 // ...and switch it back on
   164 	event.Set(TRawEvent::EActive);
   165 	UserSvr::AddEvent(event);
   166 	TBool testResult1=EFalse;
   167 	if (aAutoPauseOn)
   168 		testResult1=aCursorOn; // Only on if cursor is on without auto pause enabled
   169 	else
   170 		testResult1=ETrue; // Always on if auto pause disabled
   171 	TBool hbState=GetHeartBeatTimerState();
   172 	if ((!hbState)!=(!testResult1))
   173 		{
   174 		_LIT(KLog,"Fail in TestActiveInactiveEvents(%d.%d)  HBState=%d result=%d");
   175 		LOG_MESSAGE5(KLog,aCursorOn,aAutoPauseOn,hbState,testResult1);
   176 		}
   177 	TEST((!GetHeartBeatTimerState())==(!testResult1));		//Works with any positive value for True
   178 //
   179 	if (aCursorOn)
   180 		CancelTextCursor();
   181 	}
   182 
   183 void CTHeartBeatTest::TestActiveInactiveEvents()
   184 	{
   185 	doTestActiveInactiveEvents(EFalse,EFalse);
   186 	doTestActiveInactiveEvents(ETrue,EFalse);
   187 	doTestActiveInactiveEvents(EFalse,ETrue);
   188 	doTestActiveInactiveEvents(ETrue,ETrue);
   189 	}
   190 
   191 void CTHeartBeatTest::FailCursorHbTest(const TDesC& aErrorBase, const TDesC* aExtraText, TBool aHbState, TBool aHbCheckState)
   192 	{
   193 	TBuf<256> error(aErrorBase);
   194 	if (aExtraText)
   195 		{
   196 		error.Append(*aExtraText);
   197 		}
   198 	_LIT(KHbErrorAppendFmt," HB=%d (Testing for %d)");
   199 	error.AppendFormat(KHbErrorAppendFmt,aHbState,aHbCheckState);
   200 	LOG_MESSAGE(error);
   201 	TEST(EFalse);
   202 	}
   203 
   204 TBool CTHeartBeatTest::ChangeTransAndCheckHeartBeat(TInt aTestMode, RWindow& aTransWin, const TRect& aGraphicRect, TInt aExtraWinTestMode, const TDesC* aErrorMsg, TBool aSetVisibleAfterTransUpdate)
   205 	{
   206 	TRect cursorRect(aGraphicRect);
   207 	cursorRect.Move(iHbTestWin->BaseWin()->InquireOffset(aTransWin));
   208 	TRect winRect(aTransWin.Size());
   209 	__ASSERT_ALWAYS(winRect.Contains(cursorRect.iTl) && winRect.Contains(cursorRect.iBr),AutoPanic(EAutoPanicHeartBeatCursorRect));
   210 //
   211 	TRegionFix<8> transRegion;
   212 	TBool heartBeatCheck=EFalse;
   213 	switch(aTestMode)
   214 		{
   215 		case ECursorTransWinTestModeFullTrans:
   216 			transRegion.AddRect(winRect);
   217 			heartBeatCheck=ETrue;
   218 			break;
   219 		case ECursorTransWinTestNoTrans:
   220 			break;
   221 		case ECursorTransWinTestPartialTransCoveringCursor:
   222 			transRegion.AddRect(winRect);
   223 			transRegion.SubRect(cursorRect);
   224 			break;
   225 		case ECursorTransWinTestPartialTransExposingCursor:
   226 			transRegion.AddRect(cursorRect);
   227 			heartBeatCheck=ETrue;
   228 			break;
   229 		default:
   230 			ASSERT(EFalse);
   231 		}
   232 	TBool invisHeartBeatCheck=ETrue;
   233 	switch(aExtraWinTestMode)
   234 		{
   235 		case ECursorTransWinTestNoTrans:
   236 		case ECursorTransWinTestPartialTransCoveringCursor:
   237 			heartBeatCheck=EFalse;
   238 			invisHeartBeatCheck=EFalse;
   239 			break;
   240 		default:
   241 			break;
   242 		}
   243 //
   244 	ASSERT(!transRegion.CheckError());
   245 	if (aSetVisibleAfterTransUpdate)
   246 		aTransWin.SetVisible(EFalse);
   247 	aTransWin.SetTransparentRegion(transRegion);
   248 	if (aSetVisibleAfterTransUpdate)
   249 		aTransWin.SetVisible(ETrue);
   250 //
   251 	TBool testSuccess=ETrue;
   252 	TBool heartBeatState=GetHeartBeatTimerState();
   253 	TBool failed1stTest=EFalse;
   254 	if ((!heartBeatState)!=(!heartBeatCheck))		//Works with any positive value for True
   255 		{
   256 		failed1stTest=ETrue;
   257 		_LIT(KFailedHbTest,"Failed ");
   258 		FailCursorHbTest(KFailedHbTest,aErrorMsg,heartBeatState,heartBeatCheck);
   259 		testSuccess=EFalse;
   260 		}
   261 //
   262 	aTransWin.SetVisible(EFalse);
   263 	heartBeatState=GetHeartBeatTimerState();
   264 	_LIT(KGoingInvisAfterTestAppend," after %S");
   265 	TBuf<256> errorExtra;
   266 	if (aErrorMsg)
   267 		{
   268 		errorExtra.Format(KGoingInvisAfterTestAppend,aErrorMsg);
   269 		}
   270 	if ((!heartBeatState)!=(!invisHeartBeatCheck))		//Works with any positive value for True
   271 		{
   272 		_LIT(KFailedGoingInvis,"Failed setting trans win invisible");
   273 		FailCursorHbTest(KFailedGoingInvis,&errorExtra,heartBeatState,invisHeartBeatCheck);
   274 		testSuccess=EFalse;
   275 		}
   276 //
   277 	aTransWin.SetVisible(ETrue);
   278 	heartBeatState=GetHeartBeatTimerState();
   279 	if (!failed1stTest && (!heartBeatState)!=(!heartBeatCheck))		//Works with any positive value for True
   280 		{
   281 		_LIT(KFailedResettingVis,"Failed re-setting trans win visible");
   282 		FailCursorHbTest(KFailedResettingVis,&errorExtra,heartBeatState,heartBeatCheck);
   283 		testSuccess=EFalse;
   284 		}
   285 	return(testSuccess);
   286 	}
   287 
   288 void CTHeartBeatTest::LoopThroughTransWinTestModes(RWindow& aTransWin, const TRect& aGraphicRect, TInt aExtraWinTestMode)
   289 	{
   290 	TBuf<256> error;
   291 	for(TInt setVisMode=0;setVisMode<2;setVisMode++)
   292 		{
   293 		if (setVisMode==0)
   294 			continue;	// zzz setinvis/makevis needed to flush out changes it seems
   295 		const TBool setVisibleAfterTransUpdate=setVisMode>0;
   296 		for(TInt startTestMode=0;startTestMode<ENumCursorTransWinTestModes;startTestMode++)
   297 			{
   298 			if (startTestMode==ECursorTransWinTestNoTrans)
   299 				continue;// zzz bugged trans win problem
   300 			_LIT(KTcHbModeSetFail,"setting test mode %d (vis mode %d)");
   301 			error.Format(KTcHbModeSetFail,startTestMode,setVisibleAfterTransUpdate);
   302 			for(TInt switchToTestMode=0;switchToTestMode<ENumCursorTransWinTestModes;switchToTestMode++)
   303 				{
   304 				if (switchToTestMode==ECursorTransWinTestNoTrans)
   305 					continue;// zzz bugged trans win problem
   306 				if (startTestMode==switchToTestMode)
   307 					continue;
   308 				if (ChangeTransAndCheckHeartBeat(startTestMode, aTransWin, aGraphicRect, aExtraWinTestMode, &error, setVisibleAfterTransUpdate))
   309 					{
   310 					_LIT(KTcHbModeSwitchFail,"switching from test mode %d to %d (vis mode %d)");
   311 					error.Format(KTcHbModeSwitchFail, startTestMode, switchToTestMode, setVisibleAfterTransUpdate);
   312 					ChangeTransAndCheckHeartBeat(switchToTestMode, aTransWin, aGraphicRect, aExtraWinTestMode, &error, setVisibleAfterTransUpdate);
   313 					}
   314 				}
   315 			}
   316 		ChangeTransAndCheckHeartBeat(0, aTransWin, aGraphicRect, aExtraWinTestMode, NULL, setVisibleAfterTransUpdate);
   317 		}
   318 	}
   319 
   320 void CTHeartBeatTest::RunTransWinTestsL(const TRect& aGraphicRect)
   321 	{
   322 // Test a variety of patterns of changing the layout of transparent windows over the cursor
   323 // cause the heartbeat state to be modified accordingly.
   324 //
   325 // Each transparent window has four specific states to test:
   326 // i) Transparency area is the whole window
   327 // ii) Partial transparency that exposes the cursor
   328 // iii) Partial transparency that covers the cursor
   329 // iv) Empty transparent region, i.e. totally opaque
   330 //
   331 // We need to test various transitions between these states, first on a single window, then
   332 // in a various layouts with transparent windows layered over each other.
   333 //
   334 	RWindow transWin1(TheClient->iWs);
   335 	User::LeaveIfError(transWin1.Construct(*TheClient->iGroup->GroupWin(),0xDEADBAD1));
   336 	CleanupClosePushL(transWin1);
   337 	if (transWin1.SetTransparencyFactor(TRgb::Gray256(128))!=KErrNone)
   338 		{	// Transparency not enabled, skip tests
   339 		CleanupStack::PopAndDestroy(&transWin1);
   340 		return;
   341 		}
   342 	transWin1.Activate();
   343 	TEST(GetHeartBeatTimerState());
   344 // First simply check activating default full screen transparent window doesn't disable the heartbeat
   345 	_LIT(KBasicTransCursorTests,"Running basic transparent window cursor heartbeat tests");
   346 	LOG_MESSAGE(KBasicTransCursorTests);
   347 	LoopThroughTransWinTestModes(transWin1, aGraphicRect, ECursorTransWinTestNA);
   348 //
   349 //  Lots of test code disabled due to bugs in handling of transparent window regions
   350 // See DEF110677, hopefully when the issues in there are addressed the rest of the
   351 // test code here can be enabled
   352 //  See sections marked with zzz for places where certain tests are disabled, once DEF110677
   353 // is marked as fixed these sections should be re-enabled and if problems still occur they
   354 // need to be investigated.
   355 //
   356 //
   357 // Now check more complex modes with two transparent windows over the test window
   358 	RWindow transWin2(TheClient->iWs);
   359 	User::LeaveIfError(transWin2.Construct(*TheClient->iGroup->GroupWin(),0xDEADBAD2));
   360 	CleanupClosePushL(transWin2);
   361 	User::LeaveIfError(transWin2.SetTransparencyFactor(TRgb::Gray256(128)));
   362 	TSize screenSize=TheClient->iGroup->Size();
   363 	screenSize.iWidth-=10;
   364 	transWin1.SetExtent(TPoint(0,0),screenSize);
   365 	transWin2.SetExtent(TPoint(10,0),screenSize);
   366 	transWin2.Activate();
   367 	for(TInt win1OrdPos=0;win1OrdPos<2;win1OrdPos++)
   368 		{
   369 		transWin1.SetOrdinalPosition(win1OrdPos);
   370 		_LIT(KOrdinalTransCursorTests,"Running tests with transwin1 ordinal pos=%d");
   371 		LOG_MESSAGE2(KOrdinalTransCursorTests,win1OrdPos);
   372 		for(TInt topWinTestMode=0;topWinTestMode<ENumCursorTransWinTestModes;topWinTestMode++)
   373 			{
   374 			if (topWinTestMode==ECursorTransWinTestNoTrans)
   375 				continue;// zzz bugged transparent window problem
   376 			if (topWinTestMode==ECursorTransWinTestPartialTransCoveringCursor)
   377 				continue;// zzz bugged transparent window problem
   378 			_LIT(KTopTransWinCursorTest,"Setting top trans win mode %d");
   379 			TBuf<256> msg;
   380 			msg.Format(KTopTransWinCursorTest,topWinTestMode);
   381 			LOG_MESSAGE(msg);
   382 			ChangeTransAndCheckHeartBeat(0, transWin2, aGraphicRect, topWinTestMode, NULL, ETrue);
   383 			LoopThroughTransWinTestModes(transWin1, aGraphicRect, topWinTestMode);
   384 			}
   385 		}
   386 	ChangeTransAndCheckHeartBeat(0, transWin2, aGraphicRect, 0, NULL, ETrue);
   387 	CleanupStack::PopAndDestroy(&transWin2);
   388 	TEST(GetHeartBeatTimerState());
   389 //
   390 	CleanupStack::PopAndDestroy(&transWin1);
   391 	TEST(GetHeartBeatTimerState());
   392 	}
   393 
   394 void CTHeartBeatTest::TestTextCursorTimerTransL()
   395 	{
   396 	TSize testWinSize(iHbTestWin->BaseWin()->Size());
   397 	TRect cursorRect(testWinSize.iWidth/4,testWinSize.iHeight/3,testWinSize.iWidth*3/4,testWinSize.iHeight*2/3);
   398 	TEST(!GetHeartBeatTimerState());
   399 	SetCursor(cursorRect.iTl,cursorRect.Size());
   400 	TEST(GetHeartBeatTimerState());
   401 	RunTransWinTestsL(cursorRect);
   402 	CancelTextCursor();
   403 	TEST(!GetHeartBeatTimerState());
   404 	}
   405 
   406 void CTHeartBeatTest::TestHeartBeatStopStart(TBool aHeartbeatStateOff,TBool aHeartbeatStateOn,const TDesC& aOffText,const TDesC& aOnText)
   407 	{
   408 	TEST(!aHeartbeatStateOff);
   409 	if (aHeartbeatStateOff)
   410 		LOG_MESSAGE2(_L("%S failed to disable heartbeat timer"),&aOffText);
   411 	TEST(aHeartbeatStateOn);
   412 	if (!aHeartbeatStateOn)
   413 		LOG_MESSAGE2(_L("%S failed to re-enable heartbeat timer"),&aOnText);
   414 	}
   415 
   416 void CTHeartBeatTest::TestAnimDllL(TBool aSpriteMode, TUint aSpriteFlags)
   417 	{
   418 	RTestAnim anim(iAnimDll);
   419 	TEST(!GetHeartBeatTimerState());
   420 	TSize testWinSize(iHbTestWin->BaseWin()->Size());
   421 	TRect animRect(1,1,testWinSize.iWidth/3,testWinSize.iWidth/5);
   422 	TPckgC<TRect> rectPckg(animRect);
   423 	RWsSprite sprite(TheClient->iWs);
   424 	CleanupClosePushL(sprite);
   425 	if (aSpriteMode)
   426 		{
   427 		sprite.Construct(*iHbTestWin->BaseWin(),TPoint(),aSpriteFlags);
   428 		CFbsBitmap* bitmap1=new(ELeave) CFbsBitmap();
   429 		CleanupStack::PushL(bitmap1);
   430 		CFbsBitmap* bitmap2=new(ELeave) CFbsBitmap();
   431 		CleanupStack::PushL(bitmap2);
   432 		CFbsBitmap* bitmap3=new(ELeave) CFbsBitmap();
   433 		CleanupStack::PushL(bitmap3);
   434 		TSize animSize(animRect.Size());
   435 		User::LeaveIfError(bitmap1->Create(TSize(animSize.iWidth/2,animSize.iHeight/2),EGray4));
   436 		User::LeaveIfError(bitmap2->Create(TSize(animSize.iWidth,animSize.iHeight/3),EGray4));
   437 		User::LeaveIfError(bitmap3->Create(TSize(animSize.iWidth/3,animSize.iHeight),EGray4));
   438 //
   439 		TSpriteMember member1;
   440 		member1.iMaskBitmap=NULL;
   441 		member1.iInvertMask=EFalse;
   442 		member1.iDrawMode=CGraphicsContext::EDrawModePEN;
   443 		member1.iOffset=TPoint();
   444 		member1.iInterval=TTimeIntervalMicroSeconds32(1);
   445 		member1.iBitmap=bitmap1;
   446 		member1.iMaskBitmap=bitmap1;
   447 		sprite.AppendMember(member1);
   448 //
   449 		TSpriteMember member2;
   450 		member2.iInvertMask=EFalse;
   451 		member2.iDrawMode=CGraphicsContext::EDrawModeXOR;
   452 		member2.iOffset=TPoint(1,2);
   453 		member2.iInterval=TTimeIntervalMicroSeconds32(2);
   454 		member2.iBitmap=bitmap2;
   455 		member2.iMaskBitmap=bitmap2;
   456 		sprite.AppendMember(member2);
   457 //
   458 		TSpriteMember member3;
   459 		member3.iInvertMask=ETrue;
   460 		member3.iDrawMode=CGraphicsContext::EDrawModeOR;
   461 		member3.iOffset=TPoint(3,4);
   462 		member3.iInterval=TTimeIntervalMicroSeconds32(3);
   463 		member3.iBitmap=bitmap3;
   464 		member3.iMaskBitmap=bitmap3;
   465 		sprite.AppendMember(member3);
   466 //
   467 		User::LeaveIfError(anim.Construct(sprite,EAnimTypeSprite,rectPckg));
   468 		CleanupStack::PopAndDestroy(3,bitmap1);
   469 		}
   470 	else
   471 		{
   472 		User::LeaveIfError(anim.Construct(*iHbTestWin->BaseWin(),EAnimTypeTest3,rectPckg));
   473 		}
   474 	CleanupClosePushL(anim);
   475 	TEST(GetHeartBeatTimerState());
   476 
   477 	// Cover up the window with the animation and check this disables the heartbeat timer.
   478 	RBlankWindow blankwin1(TheClient->iWs);
   479 	User::LeaveIfError(blankwin1.Construct(*TheClient->iGroup->GroupWin(),123));
   480 	TPoint winOffset(iHbTestWin->BaseWin()->InquireOffset(*TheClient->iGroup->GroupWin()));
   481 	if (aSpriteMode)
   482 		blankwin1.SetExtent(winOffset,testWinSize);
   483 	else
   484 		blankwin1.SetExtent(winOffset+animRect.iTl,animRect.Size());
   485 	blankwin1.Activate();
   486 	TBool heartbeatStateOff=GetHeartBeatTimerState();
   487 	TEST(!heartbeatStateOff);
   488 	if (heartbeatStateOff)
   489 		{
   490 		LOG_MESSAGE(_L("Covering window failed to disable heartbeat timer"));
   491 		}
   492 	TBool heartbeatStateOn;
   493 	if (!aSpriteMode)
   494 		{
   495 		// Resize the anim so it becomes visible, then shrink back down again
   496 		animRect.iBr.iX++;
   497 		anim.Command(EADllSetRect,rectPckg);
   498 		heartbeatStateOn=GetHeartBeatTimerState();
   499 		animRect.iBr.iX--;
   500 		anim.Command(EADllSetRect,rectPckg);
   501 		heartbeatStateOff=GetHeartBeatTimerState();
   502 		TestHeartBeatStopStart(heartbeatStateOff,heartbeatStateOn,_L("Shrinking anim"),_L("Growing anim"));
   503 		}
   504 //
   505 	blankwin1.Close();
   506 	heartbeatStateOn=GetHeartBeatTimerState();
   507 	TEST(heartbeatStateOn);
   508 	if (!heartbeatStateOn)
   509 		{
   510 		LOG_MESSAGE(_L("Un-covering window failed to disable heartbeat timer"));
   511 		}
   512 
   513 	// Put a transparent window over the animation and check the heartbeat timer is not disabled
   514 	RWindow transWin(TheClient->iWs);
   515 	User::LeaveIfError(transWin.Construct(*TheClient->iGroup->GroupWin(),123));
   516 	if (transWin.SetTransparencyFactor(TRgb::Gray256(128))==KErrNone)
   517 		{
   518 		transWin.Activate();
   519 		heartbeatStateOn=GetHeartBeatTimerState();
   520 		TEST(heartbeatStateOn);
   521 		if (!heartbeatStateOn)
   522 			LOG_MESSAGE(_L("Transparent window caused heartbeat timer to be disabled"));
   523 		TRegionFix<1> emptyRegion;
   524 		transWin.SetTransparentRegion(emptyRegion);
   525 		heartbeatStateOff=GetHeartBeatTimerState();
   526 		TRegionFix<1> fullRegion(transWin.Size());
   527 		transWin.SetTransparentRegion(fullRegion);
   528 		heartbeatStateOn=GetHeartBeatTimerState();
   529 		TestHeartBeatStopStart(heartbeatStateOff,heartbeatStateOn,_L("Making covering window opaque"),_L("Making covering window transparent"));
   530 		if (aSpriteMode)
   531 			{
   532 			RBlankWindow blankwin2(TheClient->iWs);
   533 			User::LeaveIfError(blankwin2.Construct(*iHbTestWin->BaseWin(),1234));
   534 			blankwin2.Activate();
   535 			heartbeatStateOn=GetHeartBeatTimerState();
   536 			// With ESpriteNoChildClip the heartbeat should still be on as the sprite will still be visible
   537 			// Without it blankwin2 will cover up the sprite and cancel the heartbeat
   538 			TBool heartBeatCheck=aSpriteFlags&ESpriteNoChildClip;
   539 			TEST((!heartbeatStateOn)==(!heartBeatCheck));		//Works with any positive value for True
   540 			blankwin2.Close();
   541 			}
   542 		transWin.SetTransparentRegion(emptyRegion);
   543 		heartbeatStateOff=GetHeartBeatTimerState();
   544 		transWin.Close();
   545 		heartbeatStateOn=GetHeartBeatTimerState();
   546 		TestHeartBeatStopStart(heartbeatStateOff,heartbeatStateOn,_L("Making covering window opaque"),_L("Un-covering window"));
   547 		}
   548 	else
   549 		transWin.Close();
   550 
   551 	// Make the window with the animation invisible and check this disables the heartbeat timer.
   552 	iHbTestWin->BaseWin()->SetVisible(EFalse);
   553 	heartbeatStateOff=GetHeartBeatTimerState();
   554 	iHbTestWin->BaseWin()->SetVisible(ETrue);
   555 	heartbeatStateOn=GetHeartBeatTimerState();
   556 	TestHeartBeatStopStart(heartbeatStateOff,heartbeatStateOn,_L("Making window invisible"),_L("Making window visible"));
   557 
   558 	// Move the window with the animation off screen and check this disables the heartbeat timer.
   559 	TSize screenSize=TheClient->iGroup->Size();
   560 	TPoint oldPos(iHbTestWin->BaseWin()->Position());
   561 	iHbTestWin->BaseWin()->SetPosition(screenSize.AsPoint());
   562 	heartbeatStateOff=GetHeartBeatTimerState();
   563 	iHbTestWin->BaseWin()->SetPosition(oldPos);
   564 	heartbeatStateOn=GetHeartBeatTimerState();
   565 	TestHeartBeatStopStart(heartbeatStateOff,heartbeatStateOn,_L("Moving window offscreen"),_L("Moving window back onscreen"));
   566 	TEST(GetHeartBeatTimerState());
   567 	CleanupStack::PopAndDestroy(&anim);
   568 	TEST(!GetHeartBeatTimerState());
   569 	CleanupStack::PopAndDestroy(&sprite);
   570 	}
   571 
   572 void CTHeartBeatTest::TestAnimDllTransL()
   573 	{
   574 	RTestAnim anim(iAnimDll);
   575 	TSize testWinSize(iHbTestWin->BaseWin()->Size());
   576 	TRect animRect(testWinSize.iWidth/4,testWinSize.iHeight/3,testWinSize.iWidth*3/4,testWinSize.iHeight*2/3);
   577 	TPckgBuf<TRect> rectPckg;
   578 	rectPckg()=animRect;
   579 	TEST(!GetHeartBeatTimerState());
   580 	User::LeaveIfError(anim.Construct(*iHbTestWin->BaseWin(),EAnimTypeTest3,rectPckg));
   581 	CleanupClosePushL(anim);
   582 	TEST(GetHeartBeatTimerState());
   583 //
   584 	RunTransWinTestsL(animRect);
   585 //
   586 	CleanupStack::PopAndDestroy(&anim);
   587 	TEST(!GetHeartBeatTimerState());
   588 	}
   589 
   590 void CTHeartBeatTest::RunTestCaseL(TInt /*aCurTestCase*/)
   591 	{
   592 	
   593 	switch(++iTest->iState)
   594 		{
   595 		case 1:
   596 /**
   597 @SYMTestCaseID		GRAPHICS-WSERV-0568
   598 */
   599 			((CTHeartBeatTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0568"));
   600 			_LIT(KTestTextCursorTimer,"Basic heartbeat timer test");
   601 			iTest->LogSubTest(KTestTextCursorTimer);
   602 			TestTextCursorTimerL();
   603 			break;
   604 		case 2:
   605 /**
   606 @SYMTestCaseID		GRAPHICS-WSERV-0569
   607 */
   608 			((CTHeartBeatTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0569"));
   609 			_LIT(KTestTextCursorTimerTrans,"Heartbeat timer test with transparent windows");
   610 			iTest->LogSubTest(KTestTextCursorTimerTrans);
   611 			TestTextCursorTimerTransL();
   612 			break;
   613 		case 3:
   614 /**
   615 @SYMTestCaseID		GRAPHICS-WSERV-0570
   616 */
   617 			((CTHeartBeatTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0570"));
   618 			_LIT(KTestAnimDll1,"Anim DLL Heartbeat check (Win)");
   619 			iTest->LogSubTest(KTestAnimDll1);
   620 			TestAnimDllL(EFalse,0);
   621 			break;
   622 		case 4:
   623 /**
   624 @SYMTestCaseID		GRAPHICS-WSERV-0571
   625 */
   626 			((CTHeartBeatTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0571"));
   627 			_LIT(KTestAnimDll2,"Anim DLL Heartbeat check (Sprite)");
   628 			iTest->LogSubTest(KTestAnimDll2);
   629 			TestAnimDllL(ETrue,0);
   630 			TestAnimDllL(ETrue,ESpriteNoChildClip);
   631 			break;
   632 		case 5:
   633 /**
   634 @SYMTestCaseID		GRAPHICS-WSERV-0572
   635 */
   636 			((CTHeartBeatTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0572"));
   637 			_LIT(KTestAnimDllTrans,"Anim DLL Heartbeat check with transparent windows");
   638 			iTest->LogSubTest(KTestAnimDllTrans);
   639 			TestAnimDllTransL();
   640 			break;
   641 		case 6:
   642 /**
   643 @SYMTestCaseID		GRAPHICS-WSERV-0573
   644 */
   645 			((CTHeartBeatTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0573"));
   646 			_LIT(KTestActiveInactiveEvents,"Handling of TRawEvent::EInactive and EActive");
   647 			iTest->LogSubTest(KTestActiveInactiveEvents);
   648 			TestActiveInactiveEvents();
   649 			break;
   650 		default:
   651 			((CTHeartBeatTestStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
   652 			((CTHeartBeatTestStep*)iStep)->CloseTMSGraphicsStep();
   653 			TestComplete();
   654 			break;
   655 		}
   656 	((CTHeartBeatTestStep*)iStep)->RecordTestResultL();
   657 	}
   658 
   659 __WS_CONSTRUCT_STEP__(HeartBeatTest)