windowing/windowserver/test/tauto/TEvent.CPP
changeset 103 2717213c588a
child 116 171fae344dd4
equal deleted inserted replaced
98:bf7481649c98 103:2717213c588a
       
     1 // Copyright (c) 1996-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 window server events
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @test
       
    21  @internalComponent - Internal Symbian test code
       
    22 */
       
    23 
       
    24 #ifndef __INIPARSER_H__
       
    25 #define __INIPARSER_H__
       
    26 #endif // __INIPARSER_H__
       
    27 
       
    28 #include "PARSEINIDATA.H"
       
    29 #include "TEVENT.H"
       
    30 #include "W32CLICK.H"
       
    31 #include <w32debug.h>
       
    32 #include <hal.h>
       
    33 
       
    34 #define FAIL_LOGGING on
       
    35 //#define DETAILED
       
    36 #define LOGGING 1	//Uncomment this when there is a fail so that you get more logging
       
    37 
       
    38 _LIT(KKeyClickPluginDll, "click.dll");
       
    39 
       
    40 CTQueueClient::CTQueueClient(CTEventTest *aTest) : iTest(aTest)
       
    41 	{
       
    42 	}
       
    43 
       
    44 CTQueueClient::~CTQueueClient()
       
    45 	{
       
    46 	CloseEventTestGroupOnSecondScreen();
       
    47 	iGroup->GroupWin()->EnableReceiptOfFocus(EFalse);
       
    48 	delete iChildWin;
       
    49 	delete iWin;
       
    50 
       
    51 	}
       
    52 
       
    53 void CTQueueClient::ConstructL(TBool aCreateChild)
       
    54 	{
       
    55 	CTClient::ConstructL();
       
    56 	iGroup=new(ELeave) CTQueueWindowGroup(this);
       
    57 	iGroup->ConstructL();
       
    58 	iWin=new(ELeave) CTBackedUpWin(EGray4);
       
    59 	iWin->ConstructExtLD(*iGroup,TPoint(EWinPositionX,EWinPositionY),TSize(EWinWidth,EWinHeight));
       
    60 	iWin->Activate();
       
    61 	if (aCreateChild)
       
    62 		{
       
    63 		iChildWin=new(ELeave) CTBackedUpWin(EGray4);
       
    64 		iChildWin->ConstructExtLD(*iWin,ChildTopLeft(),ChildSize());
       
    65 		iChildWin->Activate();
       
    66 		}
       
    67 	iWs.Flush();
       
    68 	}
       
    69 
       
    70 void CTQueueClient::ConstructEventHandlerL()
       
    71 	{
       
    72 	iEventHandler=new(ELeave) CTQueueTestEvent(&iWs, iTest);
       
    73 	((CTQueueTestEvent *)iEventHandler)->ConstructL();
       
    74 	}
       
    75 
       
    76 TInt CTQueueClient::WindowGroupIdentifier()
       
    77 	{
       
    78 	return(iGroup->GroupWin()->Identifier());
       
    79 	}
       
    80 
       
    81 CTWinBase* CTQueueClient::GetHandle(TPoint& aPos)
       
    82 	{
       
    83 	if (iCapturing)
       
    84 		return iChildWin;
       
    85 	if (iChildWin && TRect(ChildTopLeft(),ChildSize()).Contains(aPos))
       
    86 	//if (iChildWin && TRect(TPoint(),ChildSize()).Contains(aPos))
       
    87 		{
       
    88 		aPos-=ChildTopLeft();
       
    89 		if (iChildCapturing)
       
    90 			iCapturing=ETrue;
       
    91 		return iChildWin;
       
    92 		}
       
    93 	return iWin;
       
    94 	}
       
    95 
       
    96 void CTQueueClient::AddExpectedEvent(TWsEvent &aEvent)
       
    97 	{
       
    98 #if defined(DETAILED)
       
    99 	_LIT(KLog,"   Adding Event Type=%d");
       
   100 	TLogMessageText buf;
       
   101 	buf.Format(KLog,aEvent.Type());
       
   102 	LogMessage(buf);
       
   103 #endif
       
   104 	((CTQueueTestEvent *)iEventHandler)->AddExpectedEvent(aEvent);
       
   105 	}
       
   106 
       
   107 void CTQueueClient::SetChildCapture(TInt aCaptureFlags)
       
   108 	{
       
   109 	if (!iChildWin)
       
   110 		return;
       
   111 	iChildWin->BaseWin()->SetPointerCapture(aCaptureFlags);
       
   112 	if (aCaptureFlags|RWindowBase::TCaptureFlagEnabled)
       
   113 		iChildCapturing=ETrue;
       
   114 	}
       
   115 //
       
   116 
       
   117 CTQueueTestEvent::CTQueueTestEvent(RWsSession *aWs, CTEventTest *aTest) : CTEvent(aWs)
       
   118 	{
       
   119 	iTest = aTest;
       
   120 	iCheckTimeStamp = EFalse;
       
   121 	iLastEventError = EFalse;
       
   122 	}
       
   123 
       
   124 void CTQueueTestEvent::ConstructL()
       
   125 	{
       
   126 	CTEventBase::Construct();
       
   127 	iEventBuffer.SetLengthL(EEventBufferSize);
       
   128 	iRedrawType=iTest->TestBase()->RedrawStoreTypeL();
       
   129 	}
       
   130 
       
   131 void CTQueueTestEvent::TestL(TInt aTest)
       
   132 	{
       
   133 	if (!aTest)
       
   134 		{
       
   135 		iTest->Failed();
       
   136 		User::Leave(ETestFailed);
       
   137 		}
       
   138 	}
       
   139 
       
   140 //#define FAIL_LOGGING yes
       
   141 void CTQueueTestEvent::doRunL()
       
   142 	{
       
   143 	TWsEvent wsEvent;
       
   144 	iWs->GetEvent(wsEvent);
       
   145 	TWsEvent expectedEvent;
       
   146 
       
   147 #if defined(FAIL_LOGGING)
       
   148 	TInt eType,wsHan,eHan,wsKeyCode,eKeyCode,wsKeyRepeat,eKeyRepeat,wsKeyScan,eKeyScan;
       
   149 	TLogMessageText buf;
       
   150 	_LIT(KStartString,"AUTO  EventTestFail ");
       
   151 #endif
       
   152 	TInt wsType=wsEvent.Type();
       
   153 	if (wsEvent.Type()==EEventNull)
       
   154 		TestL(wsEvent.Handle()==0);
       
   155 	else
       
   156 		{
       
   157 		TInt count=iEventBuffer.Count();
       
   158 		if (count==0 && wsType==EEventFocusGained)
       
   159 			goto End;
       
   160 		if (iLastEventError
       
   161 			&& (iRedrawType==EPartialRedraw_FullRedrawSupport || iRedrawType==EPartialRedraw_PreserveStoredCmds)
       
   162 			&& wsEvent.Type()==EEventErrorMessage /*&& expectedEvent.Type()!=EEventErrorMessage*/)		//Should really check if the next expected event is an error but there is no way to do this without removing it from the buffer
       
   163 			{
       
   164 		#if defined(DETAILED)
       
   165 			_LIT(KLog,"Skip Duplicate Error Message");
       
   166 			iTest->LOG_MESSAGE(KLog);
       
   167 		#endif
       
   168 			return;		//Ignore repeated error events
       
   169 			}
       
   170 		do	{
       
   171 			TestL(iEventBuffer.Remove(&expectedEvent));	//Loop needed for REL Build with DEB WSERV and W32
       
   172 		#if defined(DETAILED)
       
   173 			_LIT(KLog,"Skip event while waiting for error message");
       
   174 			if (expectedEvent.Type()==EEventErrorMessage && wsEvent.Type()!=expectedEvent.Type())
       
   175 				iTest->LOG_MESSAGE(KLog);
       
   176 		#endif
       
   177 			} while (expectedEvent.Type()==EEventErrorMessage && wsEvent.Type()!=expectedEvent.Type());
       
   178 		++iEventCount;		//iEventSet
       
   179 	#if defined(FAIL_LOGGING)
       
   180 		wsType=wsEvent.Type(),eType=expectedEvent.Type(),wsHan=wsEvent.Handle(),eHan=expectedEvent.Handle();
       
   181 		if (wsType!=eType)
       
   182 			{
       
   183 			_LIT(KEventDiff,"Count=%d  Events Differ Exp=%d  Act=%d");
       
   184 			buf.Copy(KStartString);
       
   185 			buf.AppendFormat(KEventDiff,iEventCount,eType,wsType);
       
   186 			iTest->LOG_MESSAGE(buf);
       
   187 			}
       
   188 		else
       
   189 			{
       
   190 		#if defined(DETAILED)
       
   191 			_LIT(KLog," Count=%d  Event Type=%d");
       
   192 			iTest->LOG_MESSAGE3(KLog,iEventCount,wsType);
       
   193 		#endif
       
   194 			}
       
   195 		if (wsHan!=eHan)
       
   196 			{
       
   197 			_LIT(KHandlesDiff,"Count=%d  Handles Differ");
       
   198 			buf.Copy(KStartString);
       
   199 			buf.AppendFormat(KHandlesDiff,iEventCount);
       
   200 			iTest->LOG_MESSAGE(buf);
       
   201 			}
       
   202 	#endif
       
   203 		TestL(wsEvent.Type()==expectedEvent.Type() && wsEvent.Handle()==expectedEvent.Handle());
       
   204 		}		
       
   205 	iLastEventError=(wsEvent.Type()==EEventErrorMessage);
       
   206 	switch(wsEvent.Type())
       
   207 		{
       
   208 		case EEventKey:
       
   209 		#if defined(FAIL_LOGGING)
       
   210 			wsKeyCode=wsEvent.Key()->iCode,eKeyCode=expectedEvent.Key()->iCode;
       
   211 			if (wsKeyCode!=eKeyCode)
       
   212 				{
       
   213 				_LIT(KKeysDiff,"Count=%d  Key Code Exp=%d (%c)  Act=%d (%c)");
       
   214 				buf.Copy(KStartString);
       
   215 				buf.AppendFormat(KKeysDiff,iEventCount,iEventCount,eKeyCode,eKeyCode,wsKeyCode,wsKeyCode);
       
   216 				iTest->LOG_MESSAGE(buf);
       
   217 				}
       
   218 			wsKeyRepeat=wsEvent.Key()->iRepeats,eKeyRepeat=expectedEvent.Key()->iRepeats;
       
   219 			if ((wsKeyRepeat>0)!=(eKeyRepeat>0) || wsKeyRepeat<eKeyRepeat)
       
   220 				{
       
   221 				_LIT(KKeysRepDiff,"Count=%d  Key Repeat Exp=%d  Act=%d");
       
   222 				buf.Copy(KStartString);
       
   223 				buf.AppendFormat(KKeysRepDiff,iEventCount,eKeyRepeat,wsKeyRepeat);
       
   224 				iTest->LOG_MESSAGE(buf);
       
   225 				}
       
   226 		#endif
       
   227 			TestL(wsEvent.Key()->iCode==expectedEvent.Key()->iCode && wsEvent.Key()->iRepeats>=expectedEvent.Key()->iRepeats
       
   228 								&& (wsEvent.Key()->iRepeats>0)==(expectedEvent.Key()->iRepeats>0));		//Fall Through
       
   229 		case EEventKeyDown:
       
   230 		case EEventKeyUp:
       
   231 		#if defined(FAIL_LOGGING)
       
   232 			wsKeyScan=wsEvent.Key()->iScanCode,eKeyScan=expectedEvent.Key()->iScanCode;
       
   233 			if (wsKeyScan!=eKeyScan)
       
   234 				{
       
   235 				_LIT(KScanDiff,"Count=%d  Scan Code Exp=%d (%c)  Act=%d (%c)");
       
   236 				buf.Copy(KStartString);
       
   237 				buf.AppendFormat(KScanDiff,iEventCount,eKeyScan,eKeyScan,wsKeyScan,wsKeyScan);
       
   238 				iTest->LOG_MESSAGE(buf);
       
   239 				}
       
   240 		#endif
       
   241 			TestL(wsEvent.Key()->iScanCode==expectedEvent.Key()->iScanCode);
       
   242 			break;
       
   243 		case EEventModifiersChanged:
       
   244 			{
       
   245 			TBool changeModifiersOK=(wsEvent.ModifiersChanged()->iChangedModifiers
       
   246 																==expectedEvent.ModifiersChanged()->iChangedModifiers);
       
   247 			TBool modifiersOK=((wsEvent.ModifiersChanged()->iModifiers&wsEvent.ModifiersChanged()->iChangedModifiers)==
       
   248 						(expectedEvent.ModifiersChanged()->iModifiers&wsEvent.ModifiersChanged()->iChangedModifiers));
       
   249 		#if defined(FAIL_LOGGING)
       
   250 			if (!changeModifiersOK || !modifiersOK)
       
   251 				{
       
   252 				_LIT(KModDiff,"Count=%d  Modifiers");
       
   253 				buf.Copy(KStartString);
       
   254 				buf.AppendFormat(KModDiff,iEventCount);
       
   255 				iTest->LOG_MESSAGE(buf);
       
   256 				}
       
   257 		#endif
       
   258 			TestL(changeModifiersOK);
       
   259 			TestL(modifiersOK);
       
   260 			}
       
   261 			break;
       
   262 		case EEventPointer:
       
   263 		case EEventDragDrop:
       
   264 			{
       
   265 		#if defined(FAIL_LOGGING)
       
   266 			TInt expectedType=expectedEvent.Pointer()->iType, actualType=wsEvent.Pointer()->iType;
       
   267 			TPoint expectedPos=expectedEvent.Pointer()->iPosition, actualPos=wsEvent.Pointer()->iPosition;
       
   268 			if (actualType!=expectedType)
       
   269 				{
       
   270 				_LIT(KPointerDiff,"Count=%d  Pointer Type Exp=%d  Act=%d");
       
   271 				buf.Copy(KStartString);
       
   272 				buf.AppendFormat(KPointerDiff,iEventCount,expectedType,actualType);
       
   273 				iTest->LOG_MESSAGE(buf);
       
   274 				}
       
   275 			if (actualPos!=expectedPos)
       
   276 				{
       
   277 				_LIT(KPointerPosDiff,"Count=%d  Pointer Pos E=(%d,%d)  A=(%d,%d)");
       
   278 				buf.Copy(KStartString);
       
   279 				buf.AppendFormat(KPointerPosDiff,iEventCount,expectedPos.iX,expectedPos.iY
       
   280 																,actualPos.iX,actualPos.iY);
       
   281 				iTest->LOG_MESSAGE(buf);
       
   282 				}
       
   283 		#endif
       
   284 			TestL(wsEvent.Pointer()->iType==expectedEvent.Pointer()->iType);
       
   285 			TestL(wsEvent.Pointer()->iPosition==expectedEvent.Pointer()->iPosition);
       
   286 			TInt count=iEventBuffer.Count();count++;			//Dummy line to help in debugging.
       
   287 			}
       
   288 			break;
       
   289 		case EEventWindowVisibilityChanged:
       
   290 			{
       
   291 		#if defined(FAIL_LOGGING)
       
   292 			TUint expectedFlags=expectedEvent.VisibilityChanged()->iFlags;
       
   293 			TUint actualFlags=wsEvent.VisibilityChanged()->iFlags;
       
   294 			if (actualFlags!=expectedFlags)
       
   295 				{
       
   296 				_LIT(KVisibilityDiff,"Count=%d  Visibility Flags Exp=%d  Act=%d");
       
   297 				buf.Copy(KStartString);
       
   298 				buf.AppendFormat(KVisibilityDiff,iEventCount,expectedFlags,actualFlags);
       
   299 				iTest->LOG_MESSAGE(buf);
       
   300 				}
       
   301 		#endif
       
   302 			TestL(wsEvent.VisibilityChanged()->iFlags==expectedEvent.VisibilityChanged()->iFlags);
       
   303 			TInt count=iEventBuffer.Count();count++;			//Dummy line to help in debugging.
       
   304 			}
       
   305 			break;
       
   306 		case EEventMessageReady:
       
   307 			{
       
   308 			const SEventMessageReady message = *(SEventMessageReady*)wsEvent.EventData();
       
   309 			TestL(message.iMessageUid== TUid::Uid(123));
       
   310 			}
       
   311 			break;
       
   312 		default:;
       
   313 		}
       
   314 	if(iCheckTimeStamp)
       
   315 		{
       
   316 		const TInt KOffset=100000; //0.1secs
       
   317 		TInt64 offset = expectedEvent.Time().Int64() - wsEvent.Time().Int64();
       
   318 		#if defined(FAIL_LOGGING)
       
   319 			if(Abs(offset)<KOffset)
       
   320 				{
       
   321 				_LIT(KTimeStampDiff,"Count=%d  Offset=%d, ExpectedTime=%d, WServEventTime=%d");
       
   322 				buf.Copy(KStartString);
       
   323 				buf.AppendFormat(KTimeStampDiff,iEventCount,offset,expectedEvent.Time().Int64(),wsEvent.Time().Int64());
       
   324 				iTest->LOG_MESSAGE(buf);
       
   325 				}
       
   326 		#endif
       
   327 		TestL(Abs(offset)<KOffset);
       
   328 		}
       
   329 	End:
       
   330 	if (iEventBuffer.Count()==0)
       
   331 	    {
       
   332 		TRAPD(err, iTest->NextSetOfEventsL());		//Not allowed to leave
       
   333 		if(err != KErrNone)
       
   334 		    {
       
   335             buf.Copy(KStartString);
       
   336             buf.AppendFormat(_L("Subtest does not follow rules set by TEvent test framework, leave code: %d"), err);
       
   337             iTest->TEST(EFalse);
       
   338             iTest->LOG_MESSAGE(buf);
       
   339             User::Leave(err);
       
   340 		    }
       
   341 	    }
       
   342 	
       
   343 	}
       
   344 
       
   345 void CTQueueTestEvent::AddExpectedEvent(TWsEvent &aEvent)
       
   346 	{
       
   347 	if(iCheckTimeStamp)
       
   348 		{
       
   349 		static_cast<TWsQTEvent&>(aEvent).Time().UniversalTime();
       
   350 		}
       
   351 	iEventBuffer.Add(&aEvent);
       
   352 	}
       
   353 
       
   354 TInt CTQueueTestEvent::EventsLeft()
       
   355 	{
       
   356 	return iEventBuffer.Count();
       
   357 	}
       
   358 //
       
   359 
       
   360 CTQueueWindowGroup::CTQueueWindowGroup(CTClient *aClient) : CTWindowGroup(aClient)
       
   361 	{}
       
   362 
       
   363 void CTQueueWindowGroup::ConstructL()
       
   364 	{
       
   365 	CTWindowGroup::ConstructL();
       
   366 	User::LeaveIfError(iGroupWin.EnableOnEvents(EEventControlAlways));
       
   367 	User::LeaveIfError(iGroupWin.EnableGroupChangeEvents());
       
   368 	}
       
   369 
       
   370 //
       
   371 
       
   372 /**
       
   373  Closes and deletes anim DLL.
       
   374  @param aAnimDll Pointer to the anim Dll to be closed and deleted
       
   375  */
       
   376 LOCAL_C void DestroyAnimDll(TAny* aAnimDll)
       
   377 	{
       
   378 	(static_cast<RAnimDll*>(aAnimDll))->Destroy();
       
   379 	}
       
   380 
       
   381 /**
       
   382  Destroys an REventAnimBase derived anim
       
   383  @param aAnim REventAnimBase derived client-side handle to anim
       
   384  */
       
   385 LOCAL_C void DestroyAnim(TAny* aAnim)
       
   386 	{
       
   387 	(static_cast<REventAnimBase*>(aAnim))->Destroy();
       
   388 	}
       
   389 
       
   390 /**
       
   391  Loads the DLL containing the test anims and pushes it onto the cleanup stack.
       
   392  This function leaves if the operation was unsuccessful.
       
   393  @return A pointer to the DLL containing test anims
       
   394  */
       
   395 RAnimDll* REventAnimBase::LoadL()
       
   396 	{
       
   397 	RAnimDll* animDll=new(ELeave) RAnimDll(TheClient->iWs);
       
   398 	CleanupStack::PushL(TCleanupItem(DestroyAnimDll,animDll));
       
   399 	User::LeaveIfError(animDll->Load(KAnimDLLName));
       
   400 	CleanupStack::Pop(animDll);
       
   401 	return animDll;
       
   402 	}
       
   403 
       
   404 /**
       
   405  Closes the client-side handle to the anim, destroys the DLL and deletes itself.
       
   406  */
       
   407 void REventAnimBase::Destroy()
       
   408 	{
       
   409 	Close();
       
   410 	delete this;
       
   411 	}
       
   412 
       
   413 /**
       
   414  Resets server-side state of anim
       
   415  */
       
   416 void REventAnimBase::Reset()
       
   417 	{
       
   418 	CommandReply(EADllReset);
       
   419 	}
       
   420 
       
   421 /**
       
   422  @return Under non-error conditions, returns 0.
       
   423  Under error conditions, returns the number of events received
       
   424  since the first unexpected event was sent.
       
   425  */
       
   426 TInt REventAnimBase::ErrorCode()
       
   427 	{
       
   428 	return CommandReply(EADllErrorCode);
       
   429 	}
       
   430 
       
   431 /**
       
   432  @return The number of events received by the anim since it was last reset.
       
   433  */
       
   434 TInt REventAnimBase::NumberOfEventsReceived()
       
   435 	{
       
   436 	return CommandReply(EADllNumberOfEventsReceived);
       
   437 	}
       
   438 
       
   439 /**
       
   440  Adds an expected event to the list of events expected by the anim.
       
   441  @param aEat Indicates if event is expected to be eaten (ETrue 'indicates expected to be eaten')
       
   442  @param aEvent The expected event
       
   443  @return KErrNone if succcessful, othewise error code.
       
   444  */
       
   445 TInt REventAnimBase::AddExpectedEvent(TBool aEat, const TRawEvent& aEvent)
       
   446 	{
       
   447 	TAnimRawEvent event;
       
   448 	event.iRawEvent=aEvent;
       
   449 	event.iEat=aEat;
       
   450 	return AddExpectedEvent(event);
       
   451 	}
       
   452 
       
   453 /**
       
   454  Adds an expected event to the list of events expected by the anim.
       
   455  @param aEvent The expected event
       
   456  @return KErrNone if succcessful, othewise error code.
       
   457  */
       
   458 TInt REventAnimBase::AddExpectedEvent(const TAnimRawEvent& aEvent)
       
   459 	{
       
   460 	TPckgBuf<TAnimRawEvent> param;
       
   461 	param()=aEvent;
       
   462 	return CommandReply(EADllAddExpectedEvent,param);
       
   463 	}
       
   464 
       
   465 //
       
   466 
       
   467 /**
       
   468  Loads the DLL containing the event test anim and creates an anim for event tests
       
   469  @param aWin the base window to which the anim is associated (this anim is a Window anim)
       
   470  @return A pointer to the new REventAnim
       
   471  */
       
   472 REventAnim* REventAnim::NewL(RWindowBase* aWin, RAnimDll* aDll, REventAnimBase::EAnimationType aType/*=EEventAnim*/)
       
   473 	{
       
   474 	REventAnim* self=new(ELeave) REventAnim(aDll);
       
   475 	CleanupStack::PushL(TCleanupItem(DestroyAnim,self));
       
   476 	User::LeaveIfError(self->Construct(*aWin,(aType == EEventAnim ? EAnimTypeEventTest : EAnimTypeEventPostingTest), TPtrC8()));
       
   477 	CleanupStack::Pop(self);
       
   478 	return self;
       
   479 	}
       
   480 
       
   481 /**
       
   482  Checks if the anim has received the correct events, and resets the sever-side state of the anim
       
   483  @return positive value if events did not match expected showing the first event that didn't match.
       
   484          negative value if there were the wrong number of events showing the number of events there were
       
   485          0 if correct number of events and they all match
       
   486  */
       
   487 TInt REventAnim::TestFail(TInt aNoEvents)
       
   488 	{
       
   489 	TInt events=CommandReply(EADllErrorCode);
       
   490 	if (events>0)
       
   491 		return events;
       
   492 	events=CommandReply(EADllNoEventsAndReset);
       
   493 	if (events==aNoEvents)
       
   494 		return 0;
       
   495 	return -events;
       
   496 	}
       
   497 
       
   498 //
       
   499 /**
       
   500  Loads the DLL containing the event test anim and creates an anim for event handler removal tests
       
   501  @param aWin the base window to which the anim is associated (this anim is a Window anim)
       
   502  @return A pointer to the new REventAnim
       
   503  */
       
   504 RRemovableAnim* RRemovableAnim::NewLC(RWindowBase* aWin, RAnimDll* aDll)
       
   505 	{
       
   506 	RRemovableAnim* self=new(ELeave) RRemovableAnim(aDll);
       
   507 	CleanupStack::PushL(TCleanupItem(DestroyAnim,self));
       
   508 	User::LeaveIfError(self->Construct(*aWin,EAnimTypeRemovableAnim,TPtrC8()));
       
   509 	return self;
       
   510 	}
       
   511 
       
   512 /**
       
   513  Sets the lifetime of the anim. This anim will remove itself from the
       
   514  event handler list after receiving this number of events.
       
   515  @return The lifetime of the anim
       
   516  */
       
   517 TInt RRemovableAnim::SetEventHandlerLifetime(TInt aEventCount)
       
   518 	{
       
   519 	TPckgBuf<TInt> param;
       
   520 	param()=aEventCount;
       
   521 	return CommandReply(EADllSetEventHandlerLifetime, param);
       
   522 	}
       
   523 
       
   524 /**
       
   525  Retrieves the lifetime of the anim. This anim will remove itself from the
       
   526  event handler list after receiving this number of events.
       
   527  @return The lifetime of the anim
       
   528  */
       
   529 TInt RRemovableAnim::EventHandlerLifetime()
       
   530 	{
       
   531 	return CommandReply(EADllEventHandlerLifetime);
       
   532 	}
       
   533 /**
       
   534  Adds the anim to the list of event handlers.
       
   535  This anim should receive any subsequent events.
       
   536  @return KErrNone on successful addition.
       
   537  */
       
   538 TInt RRemovableAnim::AddToEventHandlers()
       
   539 	{
       
   540 	return CommandReply(EADllAddToEventHandlers);
       
   541 	}
       
   542 
       
   543 /**
       
   544  Removes the anim from the list of event handlers.
       
   545  This anim should not receive any subsequent events.
       
   546  @return KErrNone on successful removal.
       
   547  */
       
   548 TInt RRemovableAnim::RemoveFromEventHandlers()
       
   549 	{
       
   550 	return CommandReply(EADllRemoveFromEventHandlers);
       
   551 	}
       
   552 
       
   553 /**
       
   554  Tests if the anim has received the correct number of events, and that
       
   555  the events received are all the correct events.
       
   556  @param aNoEvents The total expected number of events since it was last reset/constructed.
       
   557  @return ETrue if the anim has received the expected events.
       
   558  */
       
   559 TBool RRemovableAnim::TestPassed()
       
   560 	{
       
   561 	return CommandReply(EADllTestPassed);
       
   562 	}
       
   563 
       
   564 //
       
   565 
       
   566 CTEventTest::CTEventTest(CTestStep* aStep) : CTWsGraphicsBase(aStep)
       
   567 	{
       
   568 	INFO_PRINTF1(_L("Testing Event functions"));
       
   569 	}
       
   570 
       
   571 CTEventTest::~CTEventTest()
       
   572 	{
       
   573 	delete iBlankWin;
       
   574 	iBackingWindow.Close();
       
   575 	delete iVisWins1;
       
   576 	delete iVisWins2;
       
   577 	delete iVisWins3;
       
   578 	delete iTransWin;
       
   579 	delete iQueueClient;
       
   580 	if (iAnim)
       
   581 		iAnim->Destroy();
       
   582 	delete iEventTestGroup2;		//Just in case it doesn't get deleted normally
       
   583 	delete iEventTestGroup3;		//Just in case it doesn't get deleted normally
       
   584 	delete iEventTestGroup4;        //Just in case it doesn't get deleted normally
       
   585 	if (iPtrPluginLoaded)
       
   586 	    {
       
   587 	    iClick.Unload();
       
   588 	    }
       
   589 	iClick.Close();
       
   590 	if (iTurnBackOnCapsLock)
       
   591 		{
       
   592 		TheClient->iWs.SetModifierState(EModifierCapsLock,ETurnOnModifier);
       
   593 		}
       
   594 	if (iRemovableAnims)
       
   595 		{
       
   596 		EventHandlerRemoval_DestroyAllAnims();
       
   597 		iRemovableAnims->Close();
       
   598 		delete iRemovableAnims;
       
   599 		}
       
   600 	if (iAnimDll)
       
   601 		{
       
   602 		iAnimDll->Destroy();
       
   603 		}
       
   604 #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS	
       
   605 #ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA  	
       
   606 	if (!iSurfaceId.IsNull())
       
   607 	    {
       
   608 	    iSurfaceManager.CloseSurface(iSurfaceId);
       
   609 	    }
       
   610 	iSurfaceManager.Close();
       
   611 	if(iTimeOutCallback)
       
   612 	    {
       
   613 	    iTimeOutCallback->Cancel();
       
   614 	    delete iTimeOutCallback;
       
   615 	    }
       
   616 #endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
       
   617 #endif // SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
       
   618 	}
       
   619 
       
   620 void CTEventTest::ConstructL()
       
   621 	{
       
   622     _LIT(KWsIniFile, "z:\\system\\data\\wsini.ini");
       
   623     CIniData* iniData = CIniData::NewL(KWsIniFile, ' ');
       
   624     _LIT( KWsiniYShifting, "YSHIFTING");
       
   625     iniData->FindVar(KWsiniYShifting, iYOffset);
       
   626     delete iniData;
       
   627 	TheClient->iScreen->SetAppScreenMode(0);
       
   628 	TheClient->iScreen->SetScreenMode(0);						// in mode 0 TheClient->iScreen->SizeInPixels() 
       
   629 	iPhysicalScreenSize = TheClient->iScreen->SizeInPixels();	// is equal to physical screen size
       
   630 	BaseWin->Invalidate();
       
   631 	BaseWin->Win()->BeginRedraw();
       
   632 	TheGc->Activate(*BaseWin->Win());
       
   633 	TheGc->SetBrushColor(TRgb::Gray16(12));
       
   634 	TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   635 	TheGc->SetPenStyle(CGraphicsContext::ENullPen);
       
   636 	TheGc->DrawRect(TRect(BaseWin->Win()->Size()));
       
   637 	TheGc->Deactivate();
       
   638 	BaseWin->Win()->EndRedraw();
       
   639 	TheGc->Activate(*TestWin->Win());
       
   640 	TheGc->SetBrushColor(TRgb::Gray16(4));
       
   641 	TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   642 	TheGc->SetPenStyle(CGraphicsContext::ENullPen);
       
   643 	TheGc->DrawRect(TRect(TestWin->Win()->Size()));
       
   644 	TheGc->Deactivate();
       
   645 	iBackingWindow=RBlankWindow(TheClient->iWs);
       
   646 	iBackingWindow.Construct(*TheClient->iGroup->WinTreeNode(),ENullWsHandle);
       
   647 	iBackingWindow.SetColor(TRgb(0,0xDD,0xDD));
       
   648 	iBackingWindow.SetOrdinalPosition(-1,-25);
       
   649 	iBackingWindow.Activate();
       
   650 	iBlankWin=new(ELeave) CTBlankWindow();
       
   651 	iBlankWin->ConstructL(*TheClient->iGroup);
       
   652 	User::LeaveIfError(iBlankWin->BaseWin()->SetRequiredDisplayMode(EColor256));
       
   653 	iBlankWin->SetExt(TPoint(),iPhysicalScreenSize);
       
   654 	iBlankWin->SetVisible(EFalse);
       
   655 	iBlankWin->Activate();
       
   656 	CArrayFixFlat<TInt> *rotations=new(ELeave) CArrayFixFlat<TInt>(1);
       
   657 	iNumScrModes=TheClient->iScreen->NumScreenModes();
       
   658 	TInt modes=Min(2,iNumScrModes);
       
   659 	TInt mode;
       
   660 	TInt rot;
       
   661 	CleanupStack::PushL(rotations);
       
   662 	for (mode=0;mode<modes;++mode)
       
   663 		{
       
   664 		User::LeaveIfError(TheClient->iScreen->GetRotationsList(mode,rotations));
       
   665 		for (rot=rotations->Count()-1;rot>=0;--rot)
       
   666 			{
       
   667 			iScreenModeTests|=(1<<(*rotations)[rot]);
       
   668 			}
       
   669 		}
       
   670 	if (CheckScalingSupportedOrNot())
       
   671 		iScreenModeTests|=EDoScale;
       
   672 
       
   673 	iClick=RSoundPlugIn(TheClient->iWs);
       
   674 	User::LeaveIfError(iClick.Construct(TUid::Uid(CLICK_THIRD_UID)));
       
   675     TBool ptrPluginLoadable = EFalse;
       
   676     iClick.IsLoaded(ptrPluginLoadable);
       
   677     if (ptrPluginLoadable)
       
   678         {
       
   679         User::LeaveIfError(iClick.Load(KKeyClickPluginDll));
       
   680         iPtrPluginLoaded = ETrue;
       
   681         }
       
   682 	CleanupStack::PopAndDestroy();
       
   683 	if (TheClient->iWs.GetModifierState()&EModifierCapsLock)
       
   684 		{
       
   685 		iTurnBackOnCapsLock=ETrue;
       
   686 		TheClient->iWs.SetModifierState(EModifierCapsLock,ETurnOffModifier);
       
   687 		}
       
   688 	iAnimDll = REventAnimBase::LoadL();
       
   689 	TInt mods=TheClient->iWs.GetModifierState();
       
   690 	if (mods&EModifierCapsLock)
       
   691 		iTest->SimulateKeyDownUp(EStdKeyCapsLock);
       
   692 	if (mods&EModifierNumLock)
       
   693 		iTest->SimulateKeyDownUp(EStdKeyNumLock);
       
   694 	//Make sure all the keys we test are in the up state
       
   695 	iTest->SimulateKeyDownUp(EStdKeyLeftShift);
       
   696 	iTest->SimulateKeyDownUp(EStdKeyRightShift);
       
   697 	iTest->SimulateKeyDownUp(EStdKeyLeftFunc);
       
   698 	iTest->SimulateKeyDownUp(EStdKeyLeftCtrl);
       
   699 	iTest->SimulateKeyDownUp(EStdKeyRightCtrl);
       
   700 	mods=TheClient->iWs.GetModifierState();
       
   701 	_LIT(KLog,"Initial Modifiers state 0x%x (ideally should be zero)");
       
   702 	LOG_MESSAGE2(KLog,mods);
       
   703 	iTest->DelayIfFullRomL();
       
   704 
       
   705 #if !defined(TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA)
       
   706 	// 2d or 3d pointer?
       
   707 	if(HAL::Get(HALData::EPointer3D,iIs3DPointer)!=KErrNone)
       
   708 		{
       
   709 		iIs3DPointer=EFalse;
       
   710 		}
       
   711 #endif		
       
   712 	}
       
   713 
       
   714 void CTEventTest::Failed()
       
   715 	{
       
   716 #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS	
       
   717 #ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA  	
       
   718    if(iTimeOutCallback)
       
   719         {
       
   720         iTimeOutCallback->Cancel();
       
   721         iTimeOutCallback->Deque();
       
   722         delete iTimeOutCallback;
       
   723         iTimeOutCallback = NULL;
       
   724         }
       
   725     TEST(EFalse);
       
   726 #endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
       
   727 #endif // SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
       
   728 	CActiveScheduler::Stop();
       
   729 	iFailed=ETrue;
       
   730 	}
       
   731 
       
   732 void CTEventTest::CheckTimeInterval(const TTimeIntervalMicroSeconds32 &aTime,TInt aCheckTime)
       
   733 	{
       
   734 	TEST(aTime.Int()==aCheckTime);
       
   735 	if (aTime.Int()!=aCheckTime)
       
   736 		INFO_PRINTF3(_L("aTime.Int()==aCheckTime - Expected: %d, Actual: %d"), aCheckTime, aTime.Int());
       
   737 	}
       
   738 
       
   739 void CTEventTest::KeyRepeatRate(TInt aInitialRepeat, TInt aRepeat)
       
   740 	{
       
   741 	TheClient->iWs.SetKeyboardRepeatRate(TTimeIntervalMicroSeconds32(aInitialRepeat), TTimeIntervalMicroSeconds32(aRepeat));
       
   742 	TTimeIntervalMicroSeconds32 initialTime;
       
   743 	TTimeIntervalMicroSeconds32 time;
       
   744 	TheClient->iWs.GetKeyboardRepeatRate(initialTime,time);
       
   745 	CheckTimeInterval(initialTime,aInitialRepeat);
       
   746 	CheckTimeInterval(time,aRepeat);
       
   747 	}
       
   748 
       
   749 void CTEventTest::DoubleClickSettings(TInt aInterval, TInt aDistance)
       
   750 	{
       
   751 	TheClient->iWs.SetDoubleClick(TTimeIntervalMicroSeconds32(aInterval), aDistance);
       
   752 	TTimeIntervalMicroSeconds32 interval;
       
   753 	TInt distance;
       
   754 	TheClient->iWs.GetDoubleClickSettings(interval, distance);
       
   755 	CheckTimeInterval(interval,aInterval);
       
   756 	TEST(aDistance==distance);
       
   757 	if (aDistance!=distance)
       
   758 		INFO_PRINTF3(_L("aDistance==distance - Expected: %d, Actual: %d"), distance, aDistance);
       
   759 	}
       
   760 
       
   761 TInt EventCancelFunc(TAny* aClient)
       
   762 	{
       
   763 	TWsQTEvent event;
       
   764 	event.SetType(EEventModifiersChanged);
       
   765 	((TModifiersChangedEvent *)event.EventData())->iChangedModifiers=0;
       
   766 	((TModifiersChangedEvent *)event.EventData())->iModifiers=0;
       
   767 	TheClient->iWs.SendEventToWindowGroup(TheClient->iGroup->GroupWin()->Identifier(),event);
       
   768 //
       
   769 	TRequestStatus status;
       
   770 	((CTClient *)aClient)->iWs.EventReady(&status);
       
   771 	((CTClient *)aClient)->iWs.EventReadyCancel();
       
   772 	User::WaitForRequest(status);
       
   773 	return(KErrNone);
       
   774 	}
       
   775 
       
   776 void CTEventTest::General()
       
   777 	{
       
   778 	TWsQTEvent event;
       
   779 	event.SetType(EEventModifiersChanged);
       
   780 	((TModifiersChangedEvent *)event.EventData())->iChangedModifiers=0;
       
   781 	((TModifiersChangedEvent *)event.EventData())->iModifiers=0;
       
   782 	TheClient->iWs.SendEventToWindowGroup(TheClient->iGroup->GroupWin()->Identifier(),event);
       
   783 	TCallBack callBack(EventCancelFunc,TheClient);
       
   784 	TheClient->SetCancelFunction(callBack);
       
   785 //
       
   786 	TTimeIntervalMicroSeconds32 oldInitialTime;
       
   787 	TTimeIntervalMicroSeconds32 oldTime;
       
   788 	TheClient->iWs.GetKeyboardRepeatRate(oldInitialTime,oldTime);
       
   789 //
       
   790 	KeyRepeatRate(EKeyboardInitialRepeat1, EKeyboardRepeat1);
       
   791 	KeyRepeatRate(EKeyboardInitialRepeat2, EKeyboardRepeat2);
       
   792 	KeyRepeatRate(EKeyboardInitialRepeat3+200, EKeyboardRepeat3); // Max initial repeat with normal keyboard repeat value
       
   793 	KeyRepeatRate(EKeyboardInitialRepeat3, EKeyboardRepeat7+200); // Max key and initial repeat
       
   794 	KeyRepeatRateNegTest(EKeyboardInitialRepeat4, EKeyboardRepeat4); // -ve initial repeat
       
   795 	KeyRepeatRateNegTest(EKeyboardInitialRepeat2, EKeyboardRepeat6); // -ve keyboard repeat
       
   796 	#if defined __WINS__ || defined __WINSCW__
       
   797 	KeyRepeatRateNegTest(EKeyboardInitialRepeat3+400, EKeyboardRepeat5); // More than max initial repeat
       
   798 	#endif//defined __WINS__ || defined __WINSCW__
       
   799 	DoubleClickSettings(EDoubleClickTime1,EDoubleClickGap1);
       
   800 	DoubleClickSettings(EDoubleClickTime2,EDoubleClickGap2);
       
   801 	TheClient->iWs.SetKeyboardRepeatRate(oldInitialTime,oldTime);
       
   802 //
       
   803 	}
       
   804 
       
   805 #define UNIQUE_PRIORITY 123
       
   806 void CTEventTest::General2()
       
   807 	{
       
   808 	RWindowGroup& group=*TheClient->iGroup->GroupWin();
       
   809 	TInt priority=group.OrdinalPriority();
       
   810 	TInt position=group.OrdinalPosition();
       
   811 	TInt priorityGain=TheClient->iWs.GetWindowGroupOrdinalPriority(group.Identifier())-priority;
       
   812 	group.SetOrdinalPosition(0,UNIQUE_PRIORITY);
       
   813 	TWsQTEvent event;
       
   814 	event.SetType(EEventModifiersChanged);
       
   815 	((TModifiersChangedEvent *)event.EventData())->iChangedModifiers=0;
       
   816 	((TModifiersChangedEvent *)event.EventData())->iModifiers=0;
       
   817 	TheClient->iWs.SendEventToAllWindowGroups(UNIQUE_PRIORITY+priorityGain,event);
       
   818 	TCallBack callBack(EventCancelFunc,TheClient);
       
   819 	TheClient->SetCancelFunction(callBack);
       
   820 	group.SetOrdinalPosition(position,priority);
       
   821 	}
       
   822 
       
   823 void CTEventTest::AddExpectedKey(TInt aEventCode, TInt aScanCode, TInt aCode/*=0*/, TInt aRepeats/*=0*/, TUint aModifiers/*=0*/)
       
   824 	{
       
   825 	TPckgBuf<TWsEvent> evtPkg;
       
   826 	TWsEvent& event=evtPkg();
       
   827 	if (aEventCode==EEventKey && aCode==0)
       
   828 		aCode=aScanCode;
       
   829 	event.SetType(aEventCode);
       
   830 	event.SetHandle((TInt)iQueueClient->iGroup);
       
   831 	event.Key()->iCode=aCode;
       
   832 	event.Key()->iScanCode=aScanCode;
       
   833 	event.Key()->iModifiers=aModifiers;
       
   834 	event.Key()->iRepeats=aRepeats;
       
   835 	iQueueClient->AddExpectedEvent(event);
       
   836 	if (iAddToClick)
       
   837 		iClick.CommandReply(EClickEventAdd,evtPkg);
       
   838 	}
       
   839 
       
   840 void CTEventTest::AddExpectedKeyDownUp(TInt aScanCode, TInt aCode/*=0*/, TInt aRepeats/*=0*/, TUint aModifiers/*=0*/)
       
   841 	{
       
   842 	__ASSERT_DEBUG(aScanCode<'a' || aScanCode>'z',AutoPanic(EAutoPanicScanCapital));
       
   843 	AddExpectedKey(EEventKeyDown,aScanCode,0,aRepeats,aModifiers);
       
   844 	AddExpectedKey(EEventKey,aScanCode,aCode,aRepeats,aModifiers);
       
   845 	AddExpectedKey(EEventKeyUp,aScanCode,0,aRepeats,aModifiers);
       
   846 	}
       
   847 
       
   848 void CTEventTest::AddExpectedEvent(TInt aEventCode, CTWinBase* aWin)
       
   849 	{
       
   850 	TWsQTEvent event;
       
   851 	event.iType=aEventCode;
       
   852 	event.iHandle=REINTERPRET_CAST(TInt,aWin);
       
   853 	iQueueClient->AddExpectedEvent(event);
       
   854 	}
       
   855 
       
   856 void CTEventTest::AddExpectedEvent(TInt aEventCode, RWindowGroup* aWindow)
       
   857 	{
       
   858 	TWsQTEvent event;
       
   859 	event.iType=aEventCode;
       
   860 	event.iHandle=(TUint32)aWindow;
       
   861 	iQueueClient->AddExpectedEvent(event);
       
   862 	}
       
   863 
       
   864 void CTEventTest::AddExpectedEvent(TInt aEventCode)
       
   865 	{
       
   866 	AddExpectedEvent(aEventCode,iQueueClient->iGroup);
       
   867 	}
       
   868 
       
   869 void CTEventTest::AddExpectedErrorMessage(TWsErrorMessage::TErrorCategory aCategory, TInt aError)
       
   870 	{
       
   871 	TWsQTEvent event;
       
   872 	event.iType=EEventErrorMessage;
       
   873 	event.iHandle=(TInt)iQueueClient->iGroup;
       
   874 	event.ErrorMessage()->iErrorCategory=aCategory;
       
   875 	event.ErrorMessage()->iError=aError;
       
   876 	iQueueClient->AddExpectedEvent(event);
       
   877 	}
       
   878 
       
   879 void CTEventTest::CalculatePointerEvent(TWsEvent& aEvent,TPointerEvent::TType aType, TPoint aPos)
       
   880 	{
       
   881 #if !defined(TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA)
       
   882 	TAdvancedPointerEvent& ptrEvent=*aEvent.Pointer();
       
   883 	aEvent.SetType(EEventPointer);
       
   884 	ptrEvent.iParentPosition=aPos;
       
   885 	// SetHandle must be done after iParentPosition is set, but before iPosition is set.
       
   886 	aEvent.SetHandle(reinterpret_cast<TInt>(iQueueClient->GetHandle(aPos)));	
       
   887 	const TPoint3D point3D(aPos.iX, aPos.iY, 0);
       
   888 	const TInt pointerEventModifiers=0;
       
   889 	const TUint8 pointerNumber=0;
       
   890 	aEvent.InitAdvancedPointerEvent(aType,pointerEventModifiers,point3D,pointerNumber);
       
   891 #else	
       
   892 	TPointerEvent& ptrEvent=*aEvent.Pointer();
       
   893 	aEvent.SetType(EEventPointer);
       
   894 	ptrEvent.iParentPosition=aPos;		//Must be done before next line
       
   895 	aEvent.SetHandle(REINTERPRET_CAST(TInt,iQueueClient->GetHandle(aPos)));
       
   896 	ptrEvent.iType=aType;
       
   897 	ptrEvent.iModifiers=0;
       
   898 	ptrEvent.iPosition=aPos;
       
   899 #endif
       
   900 	}
       
   901 
       
   902 void CTEventTest::CalculatePointerCaptureEvent(TWsEvent& aEvent, TPointerEvent::TType aType, TPoint aPos, TInt aHandle)
       
   903 	{
       
   904 	TPointerEvent& ptrEvent=*aEvent.Pointer();
       
   905 	aEvent.SetType(EEventPointer);
       
   906 	ptrEvent.iParentPosition=aPos;		//Must be done before next line
       
   907 	if(iVisWins1 && iVisWins2)
       
   908 		{
       
   909 		if (TRect(iQueueClient->ChildTopLeft(),iQueueClient->ChildSize()).Contains(aPos) &&
       
   910 			!TRect(iQueueClient->ChildTopLeft()+TPoint(15,15),iQueueClient->ChildSize()).Contains(aPos))
       
   911 			{
       
   912 			aPos-=iQueueClient->ChildTopLeft();	//Pointer is on the first window
       
   913 			aEvent.SetHandle((TInt)iVisWins1);
       
   914 			}
       
   915 		else if (TRect(iQueueClient->ChildTopLeft()+TPoint(15,15),iQueueClient->ChildSize()).Contains(aPos))
       
   916 			{
       
   917 			aPos-=(iQueueClient->ChildTopLeft()+TPoint(15,15));	//Pointer is on the second window
       
   918 			aEvent.SetHandle((TInt)iVisWins2);
       
   919 			}
       
   920 		else if (TRect(TPoint(EWinPositionX,EWinPositionY),TSize(EWinWidth,EWinHeight)).Contains(aPos))
       
   921 			{
       
   922 			aPos-=TPoint(EWinPositionX,EWinPositionY);	//Pointer is on the parent window
       
   923 			aEvent.SetHandle((TInt)iQueueClient->iWin);
       
   924 			}
       
   925 		else
       
   926 			{
       
   927 			aEvent.SetHandle((TInt)0);		//Pointer is not in the same window group
       
   928 			}
       
   929 		}
       
   930 	ptrEvent.iType=aType;
       
   931 	ptrEvent.iModifiers=0;
       
   932 	if(aHandle!=0 && aHandle!=aEvent.Handle())
       
   933 		{
       
   934 		aEvent.SetHandle(aHandle);
       
   935 		ptrEvent.iPosition=ptrEvent.iParentPosition-(iQueueClient->ChildTopLeft()+TPoint(15,15));
       
   936 		}
       
   937 	else
       
   938 		{
       
   939 		ptrEvent.iPosition=aPos;
       
   940 		}
       
   941 	}
       
   942 
       
   943 void CTEventTest::AddExpectedPointerCapture(TPointerEvent::TType aType, TPoint aPos, TInt aHandle)
       
   944 	{
       
   945 	TPckgBuf<TWsQTEvent> evtPkg;
       
   946 	CalculatePointerCaptureEvent(evtPkg(),aType,aPos,aHandle);
       
   947 	iQueueClient->AddExpectedEvent(evtPkg());
       
   948 	}
       
   949 
       
   950 void CTEventTest::AddExpectedPointer(TPointerEvent::TType aType, TPoint aPos)
       
   951 	{
       
   952 	TPckgBuf<TWsQTEvent> evtPkg;
       
   953 	CalculatePointerEvent(evtPkg(),aType,aPos);
       
   954 	iQueueClient->AddExpectedEvent(evtPkg());
       
   955 	if (iAddToClick)
       
   956 		{
       
   957 		evtPkg().Pointer()->iParentPosition+=TPoint(EWinPositionX,EWinPositionY);
       
   958 		iClick.CommandReply(EClickEventAdd,evtPkg);
       
   959 		}
       
   960 	}
       
   961 
       
   962 void CTEventTest::AddExpectedPointerClick(TPointerEvent::TType aType, TPoint aPos)
       
   963 	{
       
   964 	TPckgBuf<TWsQTEvent> evtPkg;
       
   965 	CalculatePointerEvent(evtPkg(),aType,aPos);
       
   966 	evtPkg().Pointer()->iParentPosition+=TPoint(EWinPositionX,EWinPositionY);
       
   967 	iClick.CommandReply(EClickEventAdd,evtPkg);
       
   968 	}
       
   969 
       
   970 void CTEventTest::AddExpectedPointerDownUp(TPoint aPos)
       
   971 	{
       
   972 	AddExpectedPointer(TPointerEvent::EButton1Down,aPos);
       
   973 	AddExpectedPointer(TPointerEvent::EButton1Up,aPos);
       
   974 	}
       
   975 
       
   976 void CTEventTest::AddExpectedPointerScr(TPointerEvent::TType aType, TPoint aPos)
       
   977 	{
       
   978 	AddExpectedPointer(aType,TPoint(aPos.iX-EWinPositionX,aPos.iY-EWinPositionY));
       
   979 	}
       
   980 
       
   981 void CTEventTest::AddExpectedPointerDownUpScr(TPoint aPos)
       
   982 	{
       
   983 	AddExpectedPointerDownUp(TPoint(aPos.iX-EWinPositionX,aPos.iY-EWinPositionY));
       
   984 	}
       
   985 
       
   986 void CTEventTest::AddExpectedModifiersChanged(TInt aChangedModifiers, TInt aModifiers)
       
   987 	{
       
   988 	TWsQTEvent event;
       
   989 	event.iType=EEventModifiersChanged;
       
   990 	event.iHandle=(TInt)iQueueClient->iGroup;
       
   991 	event.ModifiersChanged()->iChangedModifiers=aChangedModifiers;
       
   992 	event.ModifiersChanged()->iModifiers=aModifiers;
       
   993 	iQueueClient->AddExpectedEvent(event);
       
   994 	}
       
   995 
       
   996 void CTEventTest::AddExpectedEnterExit(TInt aEventCode, TPoint aPos)
       
   997 	{
       
   998 	AddExpectedEvent(aEventCode,iQueueClient->GetHandle(aPos));
       
   999 	}
       
  1000 
       
  1001 void CTEventTest::AddExpectedKeyAnim(TRawEvent::TType aEventCode, TInt aScanCode, TBool aEat)
       
  1002 	{
       
  1003 	TAnimRawEvent event;
       
  1004 	event.iRawEvent.Set(aEventCode,aScanCode);
       
  1005 	event.iEat=aEat;
       
  1006 	TInt retVal = iAnim->AddEvent(event);
       
  1007 	TEST(retVal==KErrNone);
       
  1008 	if (retVal!=KErrNone)
       
  1009 		INFO_PRINTF3(_L("iAnim->AddEvent(event) return value - Expected: %d, Actual: %d"), KErrNone, retVal);
       
  1010 
       
  1011 	if (!aEat)
       
  1012 		AddExpectedKey((aEventCode==TRawEvent::EKeyDown ? EEventKeyDown:EEventKeyUp),aScanCode);
       
  1013 	}
       
  1014 
       
  1015 void CTEventTest::AddExpectedPointerAnim(TRawEvent::TType aEventCode, TPoint aPoint, TBool aEat/*=ETrue*/)
       
  1016 	{
       
  1017 	TAnimRawEvent event;
       
  1018 	event.iRawEvent.Set(aEventCode,aPoint.iX,aPoint.iY);
       
  1019 	event.iEat=aEat;
       
  1020 
       
  1021 	TInt retVal = iAnim->AddEvent(event);
       
  1022 	TEST(retVal==KErrNone);
       
  1023 	if (retVal!=KErrNone)
       
  1024 		INFO_PRINTF3(_L("iAnim->AddEvent(event) return value - Expected: %d, Actual: %d"), KErrNone, retVal);
       
  1025 
       
  1026 	if (!aEat)
       
  1027 		AddExpectedPointer((aEventCode==TRawEvent::EButton1Down ? TPointerEvent::EButton1Down:TPointerEvent::EButton1Up)
       
  1028 																			,aPoint-TPoint(EWinPositionX,EWinPositionY));
       
  1029 	}
       
  1030 
       
  1031 void CTEventTest::AddExpectedVisibilityChange(TUint aFlags)
       
  1032 	{
       
  1033 	TWsQTEvent event;
       
  1034 	event.iType=EEventWindowVisibilityChanged;
       
  1035 	event.iHandle=(TInt)iVisWins1;
       
  1036 	event.VisibilityChanged()->iFlags=aFlags;
       
  1037 	iQueueClient->AddExpectedEvent(event);
       
  1038 	}
       
  1039 
       
  1040 void CTEventTest::AddExpectedVisibilityChange(TUint aFlags, CTBlankWindow* aWindow)
       
  1041     {
       
  1042     TWsQTEvent event;
       
  1043     event.iType=EEventWindowVisibilityChanged;
       
  1044     event.iHandle=(TInt)aWindow;
       
  1045     event.VisibilityChanged()->iFlags=aFlags;
       
  1046     iQueueClient->AddExpectedEvent(event);
       
  1047     }
       
  1048 
       
  1049 void CTEventTest::SimulatePointerWin(TRawEvent::TType aType, TInt aX, TInt aY)
       
  1050 	{
       
  1051 	SimulatePointer(aType,EWinPositionX+aX,EWinPositionY+aY+iYOffset);
       
  1052 	}
       
  1053 
       
  1054 void CTEventTest::SimulatePointerDownUpWin(TInt aX, TInt aY)
       
  1055 	{
       
  1056 	iTest->SimulatePointerDownUp(EWinPositionX+aX,EWinPositionY+aY+iYOffset);
       
  1057 	}
       
  1058 
       
  1059 void CTEventTest::SimulatePointer(TRawEvent::TType aType, TInt aX, TInt aY)
       
  1060     {
       
  1061     iTest->SimulatePointer(aType,aX,aY+iYOffset);
       
  1062     }
       
  1063 
       
  1064 #if !defined(TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA)
       
  1065 void CTEventTest::SimulateButton1DownWithSimulatedMove(TInt aX, TInt aY)
       
  1066 	{
       
  1067 	if(iIs3DPointer)
       
  1068 		{
       
  1069 		// With advanced pointer events we can have an XYInputType of Pointer coupled with 3DPointer
       
  1070 		// which now makes MovesAvailable return ETrue rahter than EFalse, which in turn stops the simulated
       
  1071 		// Emove from being generated.
       
  1072 		// So...
       
  1073 		// If MovesAvailable() returns ETrue, then this move will be used, and the WServ simulated move wont be generated
       
  1074 		// If MovesAvailable() returns EFalse, then this move will be filtered out, and the WServ simulated move will be generated		
       
  1075 		SimulatePointer(TRawEvent::EPointerMove,aX,aY);
       
  1076 		}
       
  1077 	// then the original button down event
       
  1078 	SimulatePointer(TRawEvent::EButton1Down,aX,aY);	
       
  1079 	}
       
  1080 #endif
       
  1081 
       
  1082 void CTEventTest::NextSetOfEventsL()
       
  1083 	{
       
  1084 	iQueueClient->ResetCount(iEventSet);
       
  1085 	switch (iTest->iState)
       
  1086 		{
       
  1087 	case 1:
       
  1088 		QueuePurge_NextSetOfEventsL();
       
  1089 		break;
       
  1090 	case 2:
       
  1091 		SendEventTest_NextSetOfEvents();
       
  1092 		break;
       
  1093 	case 4:
       
  1094 		InvisibleWindow_NextSetOfEvents();
       
  1095 		break;
       
  1096 	case 5:
       
  1097 		JavaAdditions_NextSetOfEvents();
       
  1098 		break;
       
  1099 	case 6:
       
  1100 		WinCap_NextSetOfEvents();
       
  1101 		break;
       
  1102 	case 7:
       
  1103 		XyInputType_NextSetOfEvents();
       
  1104 		break;
       
  1105 	case 8:
       
  1106 		MovingPointerCursor_NextSetOfEventsL();
       
  1107 		break;
       
  1108 	case 9:
       
  1109 		RotatedMode_NextSetOfEventsL();
       
  1110 		break;
       
  1111 	case 10:
       
  1112 		AnimEvent_NextSetOfEventsL();
       
  1113 		break;
       
  1114 	case 11:
       
  1115 		FocusChanged_NextSetOfEventsL();
       
  1116 		break;
       
  1117 	case 12:
       
  1118 		StopEvents_NextSetOfEventsL();
       
  1119 		break;
       
  1120 	case 13:
       
  1121 		VirtualKeyboard_NextSetOfEventsL();
       
  1122 		break;
       
  1123 	case 14:
       
  1124 		KeyClicks_NextSetOfEvents();
       
  1125 		break;
       
  1126 	case 15:
       
  1127 		CaptureLong_NextSetOfEventsL();
       
  1128 		break;
       
  1129 	case 16:
       
  1130 		Password_NextSetOfEvents();
       
  1131 		break;
       
  1132 	case 17:
       
  1133 		GroupListChanged_NextSetOfEventsL();
       
  1134 		break;
       
  1135 	case 18:
       
  1136 		RepeatableKeysL();
       
  1137 		break;
       
  1138 	case 19:
       
  1139 		ScreenScaling_NextSetOfEventsL();
       
  1140 		break;
       
  1141 	case 20:
       
  1142 		VisibilityChanged_NextSetOfEventsL();
       
  1143 		break;
       
  1144 	case 21:
       
  1145 		CheckTimeStamp_NextSetOfEventsL();
       
  1146 		break;
       
  1147 	case 22:
       
  1148 		PointerCapture_NextSetOfEventsL();
       
  1149 		break;
       
  1150 	case 23:
       
  1151 		EventHandlerRemoval_NextSetOfEventsL();
       
  1152 		break;	
       
  1153 	// Note that case 24 (which is KTest24) does not use NextSetOfEventsL()	
       
  1154 	case 25:
       
  1155 		MismatchedCapture_NextSetOfEventsL();
       
  1156 		break;
       
  1157 	case 26:
       
  1158 		PointerBufferPurge_NextSetOfEventsL();		
       
  1159 		break;	
       
  1160 	case 27:
       
  1161 	    RawEventRepeatTest_NextSetOfEventsL();
       
  1162 	    break;
       
  1163 	    
       
  1164 #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS	    
       
  1165 #ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA 	    
       
  1166     case 28:
       
  1167         SurfaceVisibilityChanged1_NextSetOfEventsL();
       
  1168         break;
       
  1169     case 29:
       
  1170         SurfaceVisibilityChanged2_NextSetOfEventsL();
       
  1171         break;
       
  1172     case 30:
       
  1173         SurfaceVisibilityChanged3_NextSetOfEventsL();
       
  1174         break;
       
  1175 #endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
       
  1176 #endif // SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
       
  1177         
       
  1178 	default:
       
  1179 		AutoPanic(EAutoPanicWrongTest);
       
  1180 		}
       
  1181 	}
       
  1182 
       
  1183 void CTEventTest::TriggerOomMessage(TTimeIntervalMinutes aPeriod)
       
  1184 	{
       
  1185 	TTime time;
       
  1186 	if (aPeriod.Int()!=0) // adjust time to affect Oom message triggering
       
  1187 		{
       
  1188 		time.HomeTime();
       
  1189 		User::SetHomeTime(time+aPeriod);
       
  1190 		}
       
  1191 	RBlankWindow win(TheClient->iWs);
       
  1192 	win.Construct(*(TheClient->iGroup->WinTreeNode()),1);
       
  1193 	win.SetColor(TRgb::Gray4(1));
       
  1194 	win.SetExtent(TPoint(10,10),TheClient->iGroup->Size()-TSize(20,20));
       
  1195 	TheClient->iWs.HeapSetFail(RHeap::EDeterministic,1);
       
  1196 	win.Activate();
       
  1197 	TheClient->iWs.Flush();
       
  1198 	TheClient->iWs.HeapSetFail(RHeap::ENone,0);
       
  1199 	if (aPeriod.Int()!=0)
       
  1200 		{
       
  1201 		time.HomeTime();
       
  1202 		User::SetHomeTime(time-aPeriod);
       
  1203 		}
       
  1204 	win.Close();
       
  1205 	}
       
  1206 
       
  1207 TBool CTEventTest::SetClickType(TClickOutputModes aType)
       
  1208 	{
       
  1209 	TPckgBuf<TInt> intPkg;
       
  1210 	intPkg()=aType;
       
  1211 	TInt err=iClick.CommandReply(EClickCommandSetOutput,intPkg);
       
  1212 	if (err!=KErrNone)
       
  1213 		Failed();
       
  1214 	return err;
       
  1215 	}
       
  1216 
       
  1217 void CTEventTest::CreateEventTestGroup()
       
  1218 	{
       
  1219 	iEventTestGroup=RWindowGroup(TheClient->iWs);
       
  1220 	iEventTestGroup.Construct(123, EFalse);
       
  1221 	iEventTestGroup.SetName(_L("Fred"));
       
  1222 	}
       
  1223 
       
  1224 void CTQueueClient::CreateEventTestGroupOnSecondScreenL()
       
  1225 	{
       
  1226 	const TInt KSndScreenNo=1;
       
  1227 	iSndScreen=new(ELeave) CWsScreenDevice(iWs);
       
  1228 	User::LeaveIfError(iSndScreen->Construct(KSndScreenNo));
       
  1229 	iWinGp1 = new(ELeave) RWindowGroup(iWs);
       
  1230 	User::LeaveIfError(iWinGp1->Construct((TUint32)iWinGp1,ETrue,iSndScreen));
       
  1231 	iWinGp2 = new (ELeave) RWindowGroup(iWs);
       
  1232 	User::LeaveIfError(iWinGp2->Construct((TUint32)iWinGp2,ETrue,iSndScreen));
       
  1233 	}
       
  1234 
       
  1235 void CTQueueClient::CloseEventTestGroupOnSecondScreen()
       
  1236 	{
       
  1237 	if(iWinGp1)
       
  1238 		{
       
  1239 		iWinGp1->Close();
       
  1240 		delete iWinGp1;
       
  1241 		iWinGp1=NULL;
       
  1242 		}
       
  1243 	if(iWinGp2)
       
  1244 		{
       
  1245 		iWinGp2->Close();
       
  1246 		delete iWinGp2;
       
  1247 		iWinGp2=NULL;
       
  1248 		}
       
  1249 	if(iSndScreen)
       
  1250 		{
       
  1251 		delete iSndScreen;
       
  1252 		iSndScreen = NULL;
       
  1253 		}
       
  1254 	}
       
  1255 
       
  1256 void CTEventTest::CloseEventTestGroup()
       
  1257 	{
       
  1258 	iEventTestGroup.Close();
       
  1259 	}
       
  1260 
       
  1261 void CTEventTest::CreateAndCloseEventTestGroup()
       
  1262 //
       
  1263 // Create and close a window group to test sending of group changed messages
       
  1264 //
       
  1265 	{
       
  1266 	CreateEventTestGroup();
       
  1267 	CloseEventTestGroup();
       
  1268 	}
       
  1269 
       
  1270 void CTEventTest::QueuePurge_NextSetOfEventsL()
       
  1271 	{
       
  1272 #if defined(LOGGING)
       
  1273 	TLogMessageText logMessageText;
       
  1274 	_LIT(KSet,"QueuePurge SetOfEvents: %d of 11");
       
  1275 	logMessageText.Format(KSet,iEventSet);
       
  1276 	TheClient->LogMessage(logMessageText);
       
  1277 #endif
       
  1278 	iTheClientFlush=TheClient->iWs.SetAutoFlush(ETrue);
       
  1279 	iQuequeClientFlush=iQueueClient->iWs.SetAutoFlush(ETrue);
       
  1280 	switch(iEventSet++)
       
  1281 		{
       
  1282 		case 0:
       
  1283 			iTest->SimulateKey(TRawEvent::EKeyDown,32);
       
  1284 			iTest->SimulateKey(TRawEvent::EKeyUp,32);
       
  1285 			CreateAndCloseEventTestGroup();
       
  1286 			SimulatePointer(TRawEvent::EButton1Down,10,20);
       
  1287 			SimulatePointer(TRawEvent::EButton1Up,20,30);
       
  1288 			iTest->SimulateEvent(TRawEvent::ESwitchOn);
       
  1289 			CreateAndCloseEventTestGroup();
       
  1290 		//
       
  1291 			AddExpectedEvent(EEventFocusGained);
       
  1292 			AddExpectedKey(EEventKeyDown,32);
       
  1293 			AddExpectedKey(EEventKeyUp,32);
       
  1294 			AddExpectedEvent(EEventWindowGroupsChanged);
       
  1295 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(10-EWinPositionX,20-EWinPositionY));
       
  1296 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(20-EWinPositionX,30-EWinPositionY));
       
  1297 			AddExpectedEvent(EEventSwitchOn);
       
  1298 			break;
       
  1299 		case 1:
       
  1300 			{
       
  1301 			for(TInt count=0;count<100;count++)
       
  1302 				{
       
  1303 				iTest->SimulateKey(TRawEvent::EKeyDown,'A'+(count%26));
       
  1304 				iTest->SimulateKey(TRawEvent::EKeyUp,'A'+(count%26));
       
  1305 				}
       
  1306 			for(TInt count2=0;count2<EMaxEventQueueSize/3;count2++)
       
  1307 				{
       
  1308 				AddExpectedKey(EEventKeyDown,'A'+(count2%26));
       
  1309 				AddExpectedKey(EEventKey,'A'+(count2%26),'a'+(count2%26));
       
  1310 				AddExpectedKey(EEventKeyUp,'A'+(count2%26));
       
  1311 				}
       
  1312 			AddExpectedKey(EEventKeyDown,'A'+(99%26));
       
  1313 			AddExpectedKey(EEventKeyUp,'A'+(99%26));
       
  1314 			}
       
  1315 			break;
       
  1316 		case 2:
       
  1317 			{
       
  1318 			User::LeaveIfError(iQueueClient->iGroup->GroupWin()->EnableModifierChangedEvents(0xFFFFFFFF, EEventControlOnlyWhenVisible));
       
  1319 			for(TInt count=0;count<20;count++)
       
  1320 				{
       
  1321 				iTest->SimulateEvent(TRawEvent::ESwitchOn);
       
  1322 				iTest->SimulateEvent(TRawEvent::ESwitchOn);
       
  1323 				iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeyLeftShift);
       
  1324 				iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeyRightShift);
       
  1325 				iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeyRightShift);
       
  1326 				iTest->SimulateEvent(TRawEvent::ESwitchOn);
       
  1327 				iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeyLeftShift);
       
  1328 				}
       
  1329 			for(TInt count2=0;count2<60;count2++)
       
  1330 				iTest->SimulateKey(TRawEvent::EKeyDown,'A');
       
  1331 			AddExpectedEvent(EEventSwitchOn);
       
  1332 			AddExpectedModifiersChanged(EModifierLeftShift|EModifierRightShift|EModifierShift,0);
       
  1333 			for(TInt count3=0;count3<EMaxEventQueueSize-2;count3++)
       
  1334 				AddExpectedKey(EEventKeyDown,'A');
       
  1335 			iQueueClient->iGroup->GroupWin()->DisableModifierChangedEvents();
       
  1336 			}
       
  1337 			break;
       
  1338 		case 3:
       
  1339 			{
       
  1340 			SimulatePointer(TRawEvent::EButton1Up,10,20);
       
  1341 			SimulatePointer(TRawEvent::EButton2Up,11,22);
       
  1342 			SimulatePointer(TRawEvent::EButton1Down,12,23);
       
  1343 			SimulatePointer(TRawEvent::EPointerMove,13,24);
       
  1344 			SimulatePointer(TRawEvent::EButton3Down,15,25);
       
  1345 			SimulatePointer(TRawEvent::EButton1Up,14,24);
       
  1346 			for(TInt count2=0;count2<60;count2++)
       
  1347 				iTest->SimulateKey(TRawEvent::EKeyDown,'A');
       
  1348 			SimulatePointer(TRawEvent::EButton3Up,15,25); // Should get stripped by unmatched purged down handling code
       
  1349 			iTest->SimulateKey(TRawEvent::EKeyUp,'A');	// To stop repeats
       
  1350 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(10-EWinPositionX,20-EWinPositionY));
       
  1351 			AddExpectedPointer(TPointerEvent::EButton2Up, TPoint(11-EWinPositionX,22-EWinPositionY));
       
  1352 			for(TInt count3=0;count3<EMaxEventQueueSize-2;count3++)
       
  1353 				AddExpectedKey(EEventKeyDown,'A');
       
  1354 			}
       
  1355 			break;
       
  1356 		case 4:
       
  1357 			{
       
  1358 			SimulatePointer(TRawEvent::EButton1Up,10,20);
       
  1359 			SimulatePointer(TRawEvent::EButton2Up,11,22);
       
  1360 			iTest->SimulateKey(TRawEvent::EKeyDown,'B');
       
  1361 			SimulatePointer(TRawEvent::EButton1Down,12,23);
       
  1362 			SimulatePointer(TRawEvent::EPointerMove,13,24);
       
  1363 			iTest->SimulateKey(TRawEvent::EKeyUp,'B');
       
  1364 			SimulatePointer(TRawEvent::EButton3Down,15,25);
       
  1365 			SimulatePointer(TRawEvent::EButton1Up,14,24);
       
  1366 			iQueueClient->iWs.PurgePointerEvents();
       
  1367 			iTest->SimulateEvent(TRawEvent::ESwitchOn);
       
  1368 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(10-EWinPositionX,20-EWinPositionY));
       
  1369 			AddExpectedPointer(TPointerEvent::EButton2Up, TPoint(11-EWinPositionX,22-EWinPositionY));
       
  1370 			AddExpectedKey(EEventKeyDown,'B');
       
  1371 			AddExpectedKey(EEventKey,'B','b');
       
  1372 			AddExpectedKey(EEventKeyUp,'B');
       
  1373 //			AddExpectedPointer(TPointerEvent::EButton3Down, TPoint(15-EWinPositionX,25-EWinPositionY));
       
  1374 			AddExpectedEvent(EEventSwitchOn);	// To check pointer events purged okay
       
  1375 			}
       
  1376 			break;
       
  1377 		case 5:
       
  1378 			CreateEventTestGroup();
       
  1379 			AddExpectedEvent(EEventWindowGroupsChanged);
       
  1380 			break;
       
  1381 		case 6:
       
  1382 			CloseEventTestGroup();
       
  1383 			AddExpectedEvent(EEventWindowGroupsChanged);
       
  1384 			break;
       
  1385 		case 7:
       
  1386 			iQueueClient->iGroup->GroupWin()->DisableGroupChangeEvents();
       
  1387 			CreateAndCloseEventTestGroup();
       
  1388 			iTest->SimulateEvent(TRawEvent::ESwitchOn);
       
  1389 			AddExpectedEvent(EEventSwitchOn);
       
  1390 			break;
       
  1391 		case 8:
       
  1392 			SimulatePointer(TRawEvent::EButton1Down,12,23);
       
  1393 			iQueueClient->iWs.PurgePointerEvents();
       
  1394 			SimulatePointer(TRawEvent::EButton1Up,13,24);
       
  1395 			SimulatePointer(TRawEvent::EButton2Down,12,23);
       
  1396 			iQueueClient->iWs.PurgePointerEvents();
       
  1397 			SimulatePointer(TRawEvent::EButton2Up,13,24);
       
  1398 			SimulatePointer(TRawEvent::EButton3Down,12,23);
       
  1399 			iQueueClient->iWs.PurgePointerEvents();
       
  1400 			SimulatePointer(TRawEvent::EButton3Up,13,24);
       
  1401 //
       
  1402 			SendEvent(EEventUser);
       
  1403 			AddExpectedEvent(EEventUser);
       
  1404 			break;
       
  1405 		case 9:
       
  1406 			{
       
  1407 			for(TInt count5=0;count5<500;count5++)
       
  1408 				{
       
  1409 				RWindowGroup group(TheClient->iWs);
       
  1410 				group.Construct(ENullWsHandle);
       
  1411 				group.EnableReceiptOfFocus(EFalse);
       
  1412 				group.Close();
       
  1413 				SimulatePointer(TRawEvent::EButton1Up,10,20);
       
  1414 				}
       
  1415 			for(TInt count4=0;count4<EMaxEventQueueSize;count4++)
       
  1416 				AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(10-EWinPositionX,20-EWinPositionY));
       
  1417 			}
       
  1418 			break;
       
  1419 		case 10:
       
  1420 			{
       
  1421 			RWindowGroup *group=iQueueClient->iGroup->GroupWin();
       
  1422 			User::LeaveIfError(group->EnableOnEvents(EEventControlOnlyWithKeyboardFocus));
       
  1423 			iTest->SimulateEvent(TRawEvent::ESwitchOn);
       
  1424 			SimulatePointer(TRawEvent::EButton3Down,EWinPositionX,EWinPositionY);
       
  1425 			AddExpectedEvent(EEventSwitchOn);
       
  1426 			AddExpectedPointer(TPointerEvent::EButton3Down, TPoint(0,0));
       
  1427 //
       
  1428 			group->SetOrdinalPosition(-1);
       
  1429 			TheClient->iWs.Finish();
       
  1430 			iTest->SimulateEvent(TRawEvent::ESwitchOn);	// Shouldn't get it as in background this time
       
  1431 			AddExpectedEvent(EEventFocusLost);
       
  1432 			group->SetOrdinalPosition(0);
       
  1433 			TheClient->iWs.Finish();
       
  1434 			AddExpectedEvent(EEventFocusGained);
       
  1435 //
       
  1436 			User::LeaveIfError(group->EnableOnEvents(EEventControlOnlyWhenVisible));
       
  1437 			User::LeaveIfError(group->EnableModifierChangedEvents(EModifierShift, EEventControlOnlyWhenVisible));
       
  1438 			iTest->SimulateEvent(TRawEvent::ESwitchOn);	// Should get this as window still visible
       
  1439 			AddExpectedEvent(EEventSwitchOn);
       
  1440 			iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeyLeftShift);	// Should get modifier changed event as window still visible
       
  1441 			AddExpectedModifiersChanged(EModifierShift,EModifierShift);
       
  1442 			AddExpectedKey(EEventKeyDown,EStdKeyLeftShift);
       
  1443 			SimulatePointer(TRawEvent::EButton1Down,EWinPositionX,EWinPositionY);
       
  1444 			SimulatePointer(TRawEvent::EButton1Up,EWinPositionX,EWinPositionY);
       
  1445 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(0,0));
       
  1446 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(0,0));
       
  1447 			iQueueClient->iWin->SetPos(TPoint(-EWinWidth,-EWinHeight));
       
  1448 			TheClient->iWs.Finish();
       
  1449 // The following two events shouldn't cause an on or mod changed event as the window is now hidden
       
  1450 			iTest->SimulateEvent(TRawEvent::ESwitchOn);
       
  1451 			iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeyLeftShift);
       
  1452 			AddExpectedKey(EEventKeyUp,EStdKeyLeftShift);
       
  1453 //
       
  1454 			iQueueClient->iWin->SetPos(TPoint(EWinPositionX,EWinPositionY));
       
  1455 			TheClient->iWs.Finish();
       
  1456 			}
       
  1457 			break;
       
  1458 		case 11:
       
  1459 			{
       
  1460 			RWindowGroup *group=iQueueClient->iGroup->GroupWin();
       
  1461 			SendEvent(EEventUser);
       
  1462 			AddExpectedEvent(EEventUser);
       
  1463 
       
  1464 			if(iTest->IsFullRomL())
       
  1465 				break;
       
  1466 //
       
  1467 // Test focus only messages when with and without focus
       
  1468 //
       
  1469 			User::LeaveIfError(group->EnableErrorMessages(EEventControlOnlyWithKeyboardFocus));
       
  1470 			TriggerOomMessage(TTimeIntervalMinutes(3));
       
  1471 			AddExpectedErrorMessage(TWsErrorMessage::EDrawingRegion,KErrNoMemory);
       
  1472 			SendEvent(EEventUser);
       
  1473 			AddExpectedEvent(EEventUser);
       
  1474 			group->SetOrdinalPosition(1);
       
  1475 			TriggerOomMessage(TTimeIntervalMinutes(3));
       
  1476 			AddExpectedEvent(EEventFocusLost);
       
  1477 			group->SetOrdinalPosition(0);
       
  1478 			AddExpectedEvent(EEventFocusGained);
       
  1479 			SendEvent(EEventUser+1);
       
  1480 			AddExpectedEvent(EEventUser+1);
       
  1481 //
       
  1482 // Test focus only messages when with visible and invisible
       
  1483 //
       
  1484 			User::LeaveIfError(group->EnableErrorMessages(EEventControlOnlyWhenVisible));
       
  1485 			TriggerOomMessage(TTimeIntervalMinutes(3));
       
  1486 			AddExpectedErrorMessage(TWsErrorMessage::EDrawingRegion,KErrNoMemory);
       
  1487 			iQueueClient->iWin->SetPos(TPoint(-EWinWidth,-EWinHeight));
       
  1488 			TriggerOomMessage(TTimeIntervalMinutes(3));
       
  1489 			SendEvent(EEventUser+2);
       
  1490 			AddExpectedEvent(EEventUser+2);
       
  1491 			iQueueClient->iWin->SetPos(TPoint(EWinPositionX,EWinPositionY));
       
  1492 //
       
  1493 // Check always mode sends an event
       
  1494 //
       
  1495 			User::LeaveIfError(group->EnableErrorMessages(EEventControlAlways));
       
  1496 			TriggerOomMessage(TTimeIntervalMinutes(3));
       
  1497 			AddExpectedErrorMessage(TWsErrorMessage::EDrawingRegion,KErrNoMemory);
       
  1498 //
       
  1499 			iQueueClient->iWin->SetPos(TPoint(-EWinWidth,-EWinHeight));
       
  1500 			TriggerOomMessage(TTimeIntervalMinutes(3));
       
  1501 			AddExpectedErrorMessage(TWsErrorMessage::EDrawingRegion,KErrNoMemory);
       
  1502 			iQueueClient->iWin->SetPos(TPoint(EWinPositionX,EWinPositionY));
       
  1503 //
       
  1504 			group->SetOrdinalPosition(1);
       
  1505 			AddExpectedEvent(EEventFocusLost);
       
  1506 			TriggerOomMessage(TTimeIntervalMinutes(3));
       
  1507 			AddExpectedErrorMessage(TWsErrorMessage::EDrawingRegion,KErrNoMemory);
       
  1508 			group->SetOrdinalPosition(0);
       
  1509 			AddExpectedEvent(EEventFocusGained);
       
  1510 //
       
  1511 // Check timing of OOM messages
       
  1512 //
       
  1513 			TriggerOomMessage(TTimeIntervalMinutes(3));
       
  1514 			AddExpectedErrorMessage(TWsErrorMessage::EDrawingRegion,KErrNoMemory);
       
  1515 			TriggerOomMessage(TTimeIntervalMinutes(0));
       
  1516 			User::After(TTimeIntervalMicroSeconds32(1100000));	// 1.1 second
       
  1517 			TriggerOomMessage(TTimeIntervalMinutes(0));
       
  1518 			SendEvent(EEventUser+3);
       
  1519 			AddExpectedEvent(EEventUser+3);
       
  1520 			TriggerOomMessage(TTimeIntervalMinutes(3));	// Forward by a 2 minutes plus the 1.1 from previous test should trigger an OOM event
       
  1521 			AddExpectedErrorMessage(TWsErrorMessage::EDrawingRegion,KErrNoMemory);
       
  1522 			SendEvent(EEventUser+4);
       
  1523 			AddExpectedEvent(EEventUser+4);
       
  1524 			TriggerOomMessage(TTimeIntervalMinutes(-1)); // Clock going backwards should trigger an event
       
  1525 			AddExpectedErrorMessage(TWsErrorMessage::EDrawingRegion,KErrNoMemory);
       
  1526 			User::After(TTimeIntervalMicroSeconds32(800000));	// 8/10ths of a second
       
  1527 			TriggerOomMessage(TTimeIntervalMinutes(0));	// Shouldn't trigger an event
       
  1528 			SendEvent(EEventUser+5);
       
  1529 			AddExpectedEvent(EEventUser+5);
       
  1530 			}
       
  1531 			break;
       
  1532 		default:
       
  1533 			TheClient->iWs.DebugInfo(EWsDebugSetEventQueueTest,ETrue);
       
  1534 			TRAPD(err, EventQueueExpansionTestL());
       
  1535 			if (err!=KErrNone)
       
  1536 				{
       
  1537 				iFailed=ETrue;
       
  1538 				}
       
  1539 			TheClient->iWs.DebugInfo(EWsDebugSetEventQueueTest,EFalse);
       
  1540 			CActiveScheduler::Stop();
       
  1541 			break;
       
  1542 		}
       
  1543 	TheClient->iWs.SetAutoFlush(iTheClientFlush);
       
  1544 	iQueueClient->iWs.SetAutoFlush(iQuequeClientFlush);
       
  1545 	}
       
  1546 
       
  1547 // Used for testing PDEF112243.
       
  1548 // Create RWsSession/RWindowGroup/RBlankWindow in a loop. In case of odd loop, 
       
  1549 // close the session which causes the previous window to gain focus. Also go 
       
  1550 // on adding events to the previous session. Along with some change in product
       
  1551 // code and this test code we get some space/memory before globaleventqueue, 
       
  1552 // which is the problem faced by licensee for this defect.
       
  1553 void CTEventTest::EventQueueExpansionTestL()
       
  1554 	{
       
  1555 	const TInt numClients = 5;
       
  1556 	TInt cliHanGrpWin = 777;
       
  1557 	TInt cliHanBlkWin = 888;
       
  1558 	TInt pushed=0;
       
  1559 	RWsSession wsSession[numClients];
       
  1560 	RWindowGroup groupWin[numClients];
       
  1561 	RBlankWindow blankWin[numClients];
       
  1562 	
       
  1563 	for (TInt i = 0; i < numClients; i++)
       
  1564 		{
       
  1565 		User::LeaveIfError(wsSession[i].Connect());
       
  1566 		CleanupClosePushL(wsSession[i]);
       
  1567 		
       
  1568 		groupWin[i] = RWindowGroup(wsSession[i]);
       
  1569 		User::LeaveIfError(groupWin[i].Construct(cliHanGrpWin++));
       
  1570 		CleanupClosePushL(groupWin[i]);
       
  1571 		groupWin[i].DefaultOwningWindow();
       
  1572 		
       
  1573 		blankWin[i] = RBlankWindow(wsSession[i]);
       
  1574 		User::LeaveIfError(blankWin[i].Construct(groupWin[i], cliHanBlkWin++));
       
  1575 		if (i%2 == 0)
       
  1576 			{
       
  1577 			CleanupClosePushL(blankWin[i]);
       
  1578 			pushed++;
       
  1579 			}
       
  1580 		blankWin[i].Activate();
       
  1581 		
       
  1582 		if (i%2 == 1)
       
  1583 			{
       
  1584 			CleanupStack::Pop(2, &wsSession[i]);
       
  1585 			wsSession[i].Close();
       
  1586 			
       
  1587 			TRawEvent rawEvent;
       
  1588 			for (TInt count=0; count < 40; count++)
       
  1589 				{
       
  1590 				rawEvent.Set(TRawEvent::EKeyDown,'A'+(i%26));
       
  1591 				wsSession[i-1].SimulateRawEvent(rawEvent);
       
  1592 
       
  1593 				rawEvent.Set(TRawEvent::EKeyUp,'A'+(i%26));
       
  1594 				wsSession[i-1].SimulateRawEvent(rawEvent);
       
  1595 				}
       
  1596 			}
       
  1597 		}
       
  1598 	CleanupStack::PopAndDestroy(pushed*3, &wsSession[0]);
       
  1599 	}
       
  1600 
       
  1601 void CTEventTest::doSendEvent(TWsEvent &aEvent)
       
  1602 	{
       
  1603 	iQueueClient->iWs.SendEventToWindowGroup(iQueueClient->WindowGroupIdentifier(),aEvent);
       
  1604 	}
       
  1605 
       
  1606 void CTEventTest::SendKey(TInt aEventCode, TInt aScanCode, TInt aCode/*=0*/, TInt iRepeats/*=0*/)
       
  1607 	{
       
  1608 	TWsEvent event;
       
  1609 	if (aEventCode==EEventKey && aCode==0)
       
  1610 		aCode=aScanCode;
       
  1611 	event.SetType(aEventCode);
       
  1612 	event.Key()->iCode=aCode;
       
  1613 	event.Key()->iScanCode=aScanCode;
       
  1614 	event.Key()->iModifiers=0;
       
  1615 	event.Key()->iRepeats=iRepeats;
       
  1616 	doSendEvent(event);
       
  1617 	}
       
  1618 
       
  1619 void CTEventTest::SendEvent(TInt aEventCode)
       
  1620 	{
       
  1621 	TWsQTEvent event;
       
  1622 	event.SetType(aEventCode);
       
  1623 	doSendEvent(event);
       
  1624 	}
       
  1625 
       
  1626 void CTEventTest::SimulateAndCheck(TPoint aOrigin,TSize aScale,TInt aXOffset,TInt aYOffset,TPointerEvent::TType aEventType,TRect aPointerCursorArea)
       
  1627 	{
       
  1628 	TPoint ptCheck=PhysicalToLogical(TPoint(aOrigin.iX+aXOffset,aOrigin.iY+aYOffset)-aOrigin,aScale);
       
  1629 	if (ptCheck.iX < aPointerCursorArea.iTl.iX)
       
  1630 		{
       
  1631 		ptCheck.iX=aPointerCursorArea.iTl.iX;
       
  1632 		}
       
  1633 	else if (ptCheck.iX > aPointerCursorArea.iBr.iX)
       
  1634 		{
       
  1635 		ptCheck.iX=aPointerCursorArea.iBr.iX;
       
  1636 		}
       
  1637 	if (ptCheck.iY < aPointerCursorArea.iTl.iY)
       
  1638 		{
       
  1639 		ptCheck.iY=aPointerCursorArea.iTl.iY;
       
  1640 		}
       
  1641 	else if (ptCheck.iY > aPointerCursorArea.iBr.iY)
       
  1642 		{
       
  1643 		ptCheck.iY=aPointerCursorArea.iBr.iY;
       
  1644 		}
       
  1645 	AddExpectedPointer(aEventType,TPoint(ptCheck.iX-EWinPositionX,ptCheck.iY-EWinPositionY));
       
  1646 	}
       
  1647 
       
  1648 void CTEventTest::CheckPointerCursorInDifferentScreenMode(TSizeMode aMode,TPoint aOrigin)
       
  1649 	{
       
  1650 	aMode.iOrigin=aOrigin;
       
  1651 	iQueueClient->iScreen->SetCurrentScreenModeAttributes(aMode);
       
  1652 	iQueueClient->iScreen->SetAppScreenMode(iCurrentMode);		//This makes the App pick up the new mode parameters
       
  1653 	TheClient->iScreen->SetAppScreenMode(iCurrentMode);			//Ditto
       
  1654 	iQueueClient->iScreen->SetScreenMode(iCurrentMode);			//This causes all the windows to be updated
       
  1655 
       
  1656 	//.. Tests the general pointer cursor area setting and getting
       
  1657 	RWsSession& ws=iQueueClient->iWs;
       
  1658 	TRect rect=ws.PointerCursorArea(iCurrentMode); //ws.PointerCursorArea() by default gets first screen mode's pointer cursor area so use other overloaded function
       
  1659 	TPoint origin=iQueueClient->iScreen->GetScreenModeOrigin(iCurrentMode);
       
  1660 	TSize scale=iQueueClient->iScreen->GetScreenModeScale(iCurrentMode);
       
  1661 	TSize fullScreenModeSize=iQueueClient->iScreen->SizeInPixels();
       
  1662 	TRect rect1(PhysicalToLogical(TPoint(),scale),PhysicalToLogical(fullScreenModeSize.AsPoint()-origin,scale));
       
  1663 	TRect rect2=rect1;
       
  1664 	rect2.Shrink(20,20);
       
  1665 	ws.SetPointerCursorArea(iCurrentMode,rect1);
       
  1666 	TEST(ws.PointerCursorArea(iCurrentMode)==rect1);
       
  1667 	ws.SetPointerCursorArea(iCurrentMode,rect2);
       
  1668 	TEST(ws.PointerCursorArea(iCurrentMode)==rect2);
       
  1669 	ws.SetPointerCursorArea(iCurrentMode,rect);
       
  1670 	TEST(ws.PointerCursorArea(iCurrentMode)==rect);
       
  1671 
       
  1672 	//.. Test events are restricted to correct pointer cursor area
       
  1673 	TRect rectPointerCursorArea(10,10,51,51);
       
  1674 	iQueueClient->iWs.SetPointerCursorArea(iCurrentMode,rectPointerCursorArea);
       
  1675 	TPoint screenModeOrigin=iQueueClient->iScreen->GetDefaultScreenModeOrigin();
       
  1676 
       
  1677 	SimulatePointer(TRawEvent::EButton1Down,screenModeOrigin.iX+5,screenModeOrigin.iY+5);
       
  1678 	SimulatePointer(TRawEvent::EButton1Up,screenModeOrigin.iX+25,screenModeOrigin.iY+25);
       
  1679 	SimulatePointer(TRawEvent::EButton1Down,screenModeOrigin.iX+50,screenModeOrigin.iY+50);
       
  1680 	SimulatePointer(TRawEvent::EButton1Up,screenModeOrigin.iX+75,screenModeOrigin.iY+75);
       
  1681 
       
  1682 	SimulatePointer(TRawEvent::EButton1Down,screenModeOrigin.iX+10,screenModeOrigin.iY+15);
       
  1683 	SimulatePointer(TRawEvent::EButton1Up,screenModeOrigin.iX+20,screenModeOrigin.iY+5);
       
  1684 	SimulatePointer(TRawEvent::EButton1Down,screenModeOrigin.iX+35,screenModeOrigin.iY+40);
       
  1685 	SimulatePointer(TRawEvent::EButton1Up,screenModeOrigin.iX+45,screenModeOrigin.iY+70);
       
  1686 
       
  1687 	SimulateAndCheck(screenModeOrigin,aMode.iScreenScale,5,5,TPointerEvent::EButton1Down,rectPointerCursorArea);
       
  1688 	SimulateAndCheck(screenModeOrigin,aMode.iScreenScale,25,25,TPointerEvent::EButton1Up,rectPointerCursorArea);
       
  1689 	SimulateAndCheck(screenModeOrigin,aMode.iScreenScale,50,50,TPointerEvent::EButton1Down,rectPointerCursorArea);
       
  1690 	SimulateAndCheck(screenModeOrigin,aMode.iScreenScale,75,75,TPointerEvent::EButton1Up,rectPointerCursorArea);
       
  1691 
       
  1692 	SimulateAndCheck(screenModeOrigin,aMode.iScreenScale,10,15,TPointerEvent::EButton1Down,rectPointerCursorArea);
       
  1693 	SimulateAndCheck(screenModeOrigin,aMode.iScreenScale,20,5,TPointerEvent::EButton1Up,rectPointerCursorArea);
       
  1694 	SimulateAndCheck(screenModeOrigin,aMode.iScreenScale,35,40,TPointerEvent::EButton1Down,rectPointerCursorArea);
       
  1695 	SimulateAndCheck(screenModeOrigin,aMode.iScreenScale,45,70,TPointerEvent::EButton1Up,rectPointerCursorArea);
       
  1696 	}
       
  1697 
       
  1698 void CTEventTest::SendEventTest_NextSetOfEvents()
       
  1699 	{
       
  1700 	TTimeIntervalMicroSeconds32 initialTime,time;
       
  1701 	TheClient->iWs.GetKeyboardRepeatRate(initialTime,time);
       
  1702 	switch(iEventSet++)
       
  1703 		{
       
  1704 		case 0:
       
  1705 			SendKey(EEventKeyDown,1);
       
  1706 			SendKey(EEventKeyDown,2);
       
  1707 			SendEvent(EEventUser);
       
  1708 			SendKey(EEventKeyUp,1);
       
  1709 			SendKey(EEventKeyUp,2);
       
  1710 			SendEvent(EEventUser+1);
       
  1711 			SendEvent(EEventUser+2);
       
  1712 //
       
  1713 			AddExpectedEvent(EEventFocusGained);
       
  1714 			AddExpectedKey(EEventKeyDown,1);
       
  1715 			AddExpectedKey(EEventKeyDown,2);
       
  1716 			AddExpectedEvent(EEventUser);
       
  1717 			AddExpectedKey(EEventKeyUp,1);
       
  1718 			AddExpectedKey(EEventKeyUp,2);
       
  1719 			AddExpectedEvent(EEventUser+1);
       
  1720 			AddExpectedEvent(EEventUser+2);
       
  1721 			break;
       
  1722 		case 1:
       
  1723 	#if defined(SCREEN_MODE_TESTING)
       
  1724 			if (iNumScrModes>1)
       
  1725 				{
       
  1726 				iQueueClient->iGroup->GroupWin()->EnableScreenChangeEvents();
       
  1727 
       
  1728 				if (SetClickType(EClickCheck))
       
  1729 					return;
       
  1730 				iAddToClick=ETrue;
       
  1731 
       
  1732 				iQueueClient->iScreen->SetScreenMode(1);
       
  1733 
       
  1734 				iAddToClick=EFalse;
       
  1735 				SetClickType(EClickNone);
       
  1736 
       
  1737 				AddExpectedEvent(EEventScreenDeviceChanged);
       
  1738 				SendEvent(EEventUser);
       
  1739 				AddExpectedEvent(EEventUser);
       
  1740 				iQueueClient->iGroup->GroupWin()->DisableScreenChangeEvents();
       
  1741 				if (iQueueClient->iScreen->ScreenModeEnforcement()==ESizeEnforcementPixelsAndRotation)
       
  1742 					AddExpectedEvent(EEventFocusLost);
       
  1743 				}
       
  1744 	#endif
       
  1745 			SendEvent(EEventUser+1);
       
  1746 			AddExpectedEvent(EEventUser+1);
       
  1747 			break;
       
  1748 		case 2:
       
  1749 	#if defined(SCREEN_MODE_TESTING)
       
  1750 			if (iNumScrModes>1)
       
  1751 				{
       
  1752 				iQueueClient->iGroup->GroupWin()->EnableScreenChangeEvents();
       
  1753 
       
  1754 				if (SetClickType(EClickCheck))
       
  1755 					return;
       
  1756 				iAddToClick=ETrue;
       
  1757 
       
  1758 				iQueueClient->iScreen->SetScreenMode(0);
       
  1759 				iQueueClient->iScreen->SetScreenMode(1);
       
  1760 				iQueueClient->iScreen->SetScreenMode(0);
       
  1761 
       
  1762 				iAddToClick=EFalse;
       
  1763 				SetClickType(EClickNone);
       
  1764 
       
  1765 				AddExpectedEvent(EEventScreenDeviceChanged);	// Only one event should get queued
       
  1766 				if (iQueueClient->iScreen->ScreenModeEnforcement()==ESizeEnforcementPixelsAndRotation)
       
  1767 					AddExpectedEvent(EEventFocusGained);
       
  1768 				SendEvent(EEventUser+2);
       
  1769 				AddExpectedEvent(EEventUser+2);
       
  1770 				iQueueClient->iGroup->GroupWin()->DisableScreenChangeEvents();
       
  1771 				}
       
  1772 	#endif
       
  1773 			SendEvent(EEventUser+3);
       
  1774 			AddExpectedEvent(EEventUser+3);
       
  1775 			break;
       
  1776 		case 3:
       
  1777 	#if defined(SCREEN_MODE_TESTING)
       
  1778 			if (iNumScrModes>1)
       
  1779 				{
       
  1780 				iQueueClient->iGroup->GroupWin()->EnableScreenChangeEvents();
       
  1781 				iQueueClient->iGroup->GroupWin()->DisableScreenChangeEvents();
       
  1782 
       
  1783 				if (SetClickType(EClickCheck))
       
  1784 					return;
       
  1785 				iAddToClick=ETrue;
       
  1786 
       
  1787 				iQueueClient->iScreen->SetScreenMode(0);
       
  1788 
       
  1789 				iAddToClick=EFalse;
       
  1790 				SetClickType(EClickNone);
       
  1791 
       
  1792 				SendEvent(EEventUser+1);
       
  1793 				AddExpectedEvent(EEventUser+1);
       
  1794 				}
       
  1795 	#endif
       
  1796 			SendEvent(EEventUser+4);
       
  1797 			AddExpectedEvent(EEventUser+4);
       
  1798 			break;
       
  1799 		case 4:
       
  1800 			iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace);
       
  1801 			TheClient->iWs.Flush();
       
  1802 			User::After(initialTime.Int()+time.Int()/3);
       
  1803 			iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace);
       
  1804 			AddExpectedKey(EEventKeyDown,EStdKeySpace);
       
  1805 			AddExpectedKey(EEventKey,EStdKeySpace,' ');
       
  1806 			AddExpectedKey(EEventKey,EStdKeySpace,' ',1);
       
  1807 			AddExpectedKey(EEventKeyUp,EStdKeySpace);
       
  1808 			break;
       
  1809 		case 5:			//To test sending a key event with iRepeats!=0
       
  1810 			iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace);
       
  1811 			TheClient->iWs.Flush();
       
  1812 			User::After(initialTime.Int()+time.Int()/3);
       
  1813 			SendKey(EEventKey,EStdKeyHome,EKeyHome,0);
       
  1814 			User::After(initialTime.Int()+time.Int()/3);
       
  1815 			SendKey(EEventKey,EStdKeyEnd,EKeyEnd,12345);
       
  1816 			User::After(initialTime.Int()+time.Int()/3);
       
  1817 			iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace);
       
  1818 			AddExpectedKey(EEventKeyDown,EStdKeySpace);
       
  1819 			AddExpectedKey(EEventKey,EStdKeySpace,' ');
       
  1820 			AddExpectedKey(EEventKey,EStdKeySpace,' ',1);
       
  1821 			AddExpectedKey(EEventKey,EStdKeyHome,EKeyHome);
       
  1822 			AddExpectedKey(EEventKey,EStdKeySpace,' ',1);
       
  1823 			AddExpectedKey(EEventKey,EStdKeyEnd,EKeyEnd,1);
       
  1824 			AddExpectedKey(EEventKeyUp,EStdKeySpace);
       
  1825 			break;
       
  1826 		default:
       
  1827 			CActiveScheduler::Stop();
       
  1828 			break;
       
  1829 		}
       
  1830 	TheClient->iWs.Flush();
       
  1831 	}
       
  1832 
       
  1833 void CTEventTest::InvisibleWindow_NextSetOfEvents()
       
  1834 	{
       
  1835 	switch(iEventSet++)
       
  1836 		{
       
  1837 		case 0:
       
  1838 			SimulatePointer(TRawEvent::EButton1Down,45,30);
       
  1839 			SimulatePointer(TRawEvent::EButton1Up,45,30);
       
  1840 			SimulatePointer(TRawEvent::EButton1Down,20,10);
       
  1841 			SimulatePointer(TRawEvent::EButton1Up,20,10);
       
  1842 			TheClient->iWs.Flush();
       
  1843 			iQueueClient->iChildWin->BaseWin()->SetVisible(EFalse);
       
  1844 			iQueueClient->iChildWin->BaseWin()->SetVisible(ETrue);
       
  1845 			iQueueClient->iWs.Flush();
       
  1846 			SimulatePointer(TRawEvent::EButton1Down,46,31);
       
  1847 			SimulatePointer(TRawEvent::EButton1Up,46,31);
       
  1848 			AddExpectedEvent(EEventFocusGained);
       
  1849 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(20-EWinPositionX,10-EWinPositionY));
       
  1850 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(20-EWinPositionX,10-EWinPositionY));
       
  1851 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(46-EWinPositionX,31-EWinPositionY));
       
  1852 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(46-EWinPositionX,31-EWinPositionY));
       
  1853 			break;
       
  1854 		case 1:
       
  1855 			SimulatePointer(TRawEvent::EButton1Down,21,11);
       
  1856 			SimulatePointer(TRawEvent::EButton1Up,21,11);
       
  1857 			SimulatePointer(TRawEvent::EButton1Down,44,30);
       
  1858 			SimulatePointer(TRawEvent::EButton1Up,44,30);
       
  1859 			TheClient->iWs.Flush();
       
  1860 			iQueueClient->iWin->BaseWin()->SetVisible(EFalse);
       
  1861 			iQueueClient->iWin->BaseWin()->SetVisible(ETrue);
       
  1862 			iQueueClient->iWs.Flush();
       
  1863 			SimulatePointer(TRawEvent::EButton1Down,19,12);
       
  1864 			SimulatePointer(TRawEvent::EButton1Up,19,12);
       
  1865 			SimulatePointer(TRawEvent::EButton1Down,47,32);
       
  1866 			SimulatePointer(TRawEvent::EButton1Up,47,32);
       
  1867 			/*AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(44-EWinPositionX,30-EWinPositionY));
       
  1868 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(44-EWinPositionX,30-EWinPositionY));*/
       
  1869 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(19-EWinPositionX,12-EWinPositionY));
       
  1870 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(19-EWinPositionX,12-EWinPositionY));
       
  1871 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(47-EWinPositionX,32-EWinPositionY));
       
  1872 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(47-EWinPositionX,32-EWinPositionY));
       
  1873 			break;
       
  1874 		default:
       
  1875 			CActiveScheduler::Stop();
       
  1876 			break;
       
  1877 		}
       
  1878 	TheClient->iWs.Flush();
       
  1879 	}
       
  1880 
       
  1881 #define TOP16A 0xAAAA0000
       
  1882 #define TOP16B 0x55550000
       
  1883 void CTEventTest::JavaAdditions_NextSetOfEvents()
       
  1884 	{
       
  1885 	switch(iEventSet++)
       
  1886 		{
       
  1887 		case 0:
       
  1888 			SimulatePointer(TRawEvent::EButton1Down,45,30);
       
  1889 			SimulatePointer(TRawEvent::EButton1Up,45,30);
       
  1890 			TheClient->iWs.Flush();
       
  1891 			iQueueClient->iWin->BaseWin()->PointerFilter(EPointerMoveEvents,EPointerGenerateSimulatedMove);
       
  1892 			iQueueClient->iWs.Flush();
       
  1893 #if !defined(TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA)
       
  1894 			SimulateButton1DownWithSimulatedMove(46,31);
       
  1895 #else
       
  1896 			SimulatePointer(TRawEvent::EButton1Down,46,31);
       
  1897 #endif			
       
  1898 			SimulatePointer(TRawEvent::EButton1Up,46,31);
       
  1899 			TheClient->iWs.Flush();
       
  1900 			iQueueClient->iWin->BaseWin()->PointerFilter(EPointerMoveEvents,0);
       
  1901 			iQueueClient->iWs.Flush();			
       
  1902 			SimulatePointer(TRawEvent::EButton1Down,20,10);
       
  1903 			SimulatePointer(TRawEvent::EButton1Up,20,10);
       
  1904 			TheClient->iWs.Flush();
       
  1905 			iQueueClient->iWin->BaseWin()->PointerFilter(EPointerMoveEvents,EPointerGenerateSimulatedMove);
       
  1906 			iQueueClient->iWs.Flush();
       
  1907 #if !defined(TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA)
       
  1908 			SimulateButton1DownWithSimulatedMove(21,11);
       
  1909 #else	
       
  1910 			SimulatePointer(TRawEvent::EButton1Down,21,11);			
       
  1911 #endif
       
  1912 			SimulatePointer(TRawEvent::EButton1Up,21,11);
       
  1913 			TheClient->iWs.Flush();
       
  1914 			iQueueClient->iWin->BaseWin()->PointerFilter(EPointerMoveEvents,EPointerMoveEvents);
       
  1915 			iQueueClient->iWs.Flush();				
       
  1916 			SimulatePointer(TRawEvent::EButton1Down,22,12);
       
  1917 			SimulatePointer(TRawEvent::EButton1Up,22,12);
       
  1918 			TheClient->iWs.Flush();
       
  1919 			iQueueClient->iWin->BaseWin()->PointerFilter(EPointerMoveEvents,EPointerGenerateSimulatedMove);
       
  1920 			iQueueClient->iWs.Flush();
       
  1921 #if !defined(TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA)
       
  1922 			SimulateButton1DownWithSimulatedMove(23,13);
       
  1923 #else			
       
  1924 			SimulatePointer(TRawEvent::EButton1Down,23,13);
       
  1925 #endif
       
  1926 			SimulatePointer(TRawEvent::EButton1Up,23,13);
       
  1927 			TheClient->iWs.Flush();
       
  1928 			iQueueClient->iWin->BaseWin()->PointerFilter(EPointerMoveEvents,EPointerFilterMove);
       
  1929 			iQueueClient->iWs.Flush();		
       
  1930 			SimulatePointer(TRawEvent::EButton1Down,24,14);
       
  1931 			SimulatePointer(TRawEvent::EButton1Up,24,14);
       
  1932 			AddExpectedEvent(EEventFocusGained);
       
  1933 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(45-EWinPositionX,30-EWinPositionY));
       
  1934 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(45-EWinPositionX,30-EWinPositionY));
       
  1935 			AddExpectedPointer(TPointerEvent::EMove, TPoint(46-EWinPositionX,31-EWinPositionY));
       
  1936 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(46-EWinPositionX,31-EWinPositionY));
       
  1937 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(46-EWinPositionX,31-EWinPositionY));
       
  1938 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(20-EWinPositionX,10-EWinPositionY));
       
  1939 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(20-EWinPositionX,10-EWinPositionY));
       
  1940 			AddExpectedPointer(TPointerEvent::EMove, TPoint(21-EWinPositionX,11-EWinPositionY));
       
  1941 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(21-EWinPositionX,11-EWinPositionY));
       
  1942 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(21-EWinPositionX,11-EWinPositionY));
       
  1943 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(22-EWinPositionX,12-EWinPositionY));
       
  1944 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(22-EWinPositionX,12-EWinPositionY));
       
  1945 			AddExpectedPointer(TPointerEvent::EMove, TPoint(23-EWinPositionX,13-EWinPositionY));
       
  1946 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(23-EWinPositionX,13-EWinPositionY));
       
  1947 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(23-EWinPositionX,13-EWinPositionY));
       
  1948 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(24-EWinPositionX,14-EWinPositionY));
       
  1949 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,14-EWinPositionY));
       
  1950 			break;
       
  1951 		#if defined(__WINS__)
       
  1952 		case 1:
       
  1953 			{
       
  1954 			RWindowGroup *group=iQueueClient->iGroup->GroupWin();
       
  1955 			group->SetOrdinalPosition(0);
       
  1956 			iTest->SimulateKey(TRawEvent::EKeyDown,'2'|TOP16A);
       
  1957 			iTest->SimulateKey(TRawEvent::EKeyUp,'2');
       
  1958 			TheClient->iWs.Flush();
       
  1959 			iQueueClient->iWs.SetRemoveKeyCode(EFalse);
       
  1960 			iQueueClient->iWs.Flush();
       
  1961 			iTest->SimulateKey(TRawEvent::EKeyDown,'3'|TOP16B);
       
  1962 			iTest->SimulateKey(TRawEvent::EKeyUp,'3');
       
  1963 			TheClient->iWs.Flush();
       
  1964 			iQueueClient->iWs.SetRemoveKeyCode(ETrue);
       
  1965 			iQueueClient->iWs.Flush();
       
  1966 			iTest->SimulateKey(TRawEvent::EKeyDown,'4'|TOP16B);
       
  1967 			iTest->SimulateKey(TRawEvent::EKeyUp,'4');
       
  1968 			AddExpectedKey(EEventKeyDown,'2');
       
  1969 			AddExpectedKey(EEventKey,'2',TOP16A>>16);
       
  1970 			AddExpectedKey(EEventKeyUp,'2');
       
  1971 			AddExpectedKey(EEventKeyDown,'3'|TOP16B);
       
  1972 			AddExpectedKey(EEventKey,'3',TOP16B>>16);
       
  1973 			AddExpectedKey(EEventKeyUp,'3');
       
  1974 			AddExpectedKey(EEventKeyDown,'4');
       
  1975 			AddExpectedKey(EEventKey,'4',TOP16B>>16);
       
  1976 			AddExpectedKey(EEventKeyUp,'4');
       
  1977 			break;
       
  1978 			}
       
  1979 		#endif
       
  1980 		default:
       
  1981 			CActiveScheduler::Stop();
       
  1982 			break;
       
  1983 		}
       
  1984 	TheClient->iWs.Flush();
       
  1985 	}
       
  1986 
       
  1987 void CTEventTest::WinCap_NextSetOfEvents()
       
  1988 	{
       
  1989 	switch(iEventSet++)
       
  1990 		{
       
  1991 		case 0:
       
  1992 			//iQueueClient->SetChildCapture(RWindowBase::TCaptureEnabled);
       
  1993 			SimulatePointer(TRawEvent::EButton1Down,35,27);
       
  1994 			SimulatePointer(TRawEvent::EButton1Up,25,12);
       
  1995 
       
  1996 
       
  1997 			AddExpectedEvent(EEventFocusGained);
       
  1998 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(35-EWinPositionX,27-EWinPositionY));
       
  1999 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(25-EWinPositionX,12-EWinPositionY));
       
  2000 			break;
       
  2001 
       
  2002 
       
  2003 		default:
       
  2004 			CActiveScheduler::Stop();
       
  2005 			break;
       
  2006 		}
       
  2007 	TheClient->iWs.Flush();
       
  2008 	}
       
  2009 
       
  2010 void CTEventTest::XyInputType_NextSetOfEvents()
       
  2011 	{
       
  2012 	switch(iEventSet++)
       
  2013 		{
       
  2014 		case 0:
       
  2015 			iQueueClient->iWin->BaseWin()->PointerFilter(EPointerMoveEvents|EPointerFilterDrag,EPointerGenerateSimulatedMove);
       
  2016 			iQueueClient->iWs.Flush();
       
  2017 #if !defined(TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA)
       
  2018 			SimulateButton1DownWithSimulatedMove(46,31);
       
  2019 #else			
       
  2020 			SimulatePointer(TRawEvent::EButton1Down,46,31);
       
  2021 #endif
       
  2022 			SimulatePointer(TRawEvent::EButton1Up,46,31);
       
  2023 			AddExpectedEvent(EEventFocusGained);
       
  2024 			AddExpectedPointer(TPointerEvent::EMove, TPoint(46-EWinPositionX,31-EWinPositionY));
       
  2025 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(46-EWinPositionX,31-EWinPositionY));
       
  2026 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(46-EWinPositionX,31-EWinPositionY));
       
  2027 			break;		//Must do something
       
  2028 		case 1:
       
  2029 			{
       
  2030 			// check if RWindowGroup::SimulatePointerEvent is working (DEF131563)
       
  2031 			RWindowGroup& group = *iQueueClient->iGroup->GroupWin();
       
  2032 			TRawEvent event;
       
  2033 			event.Set(TRawEvent::EButton1Down, 10, 10);
       
  2034 			group.SimulatePointerEvent(event);
       
  2035 			event.Set(TRawEvent::EButton1Up, 10, 10);
       
  2036 			group.SimulatePointerEvent(event);
       
  2037 			if(!iIs3DPointer)
       
  2038 				{
       
  2039 				// simulated move will be generated
       
  2040 				AddExpectedPointer(TPointerEvent::EMove, TPoint(10 - EWinPositionX, 10 - EWinPositionY));
       
  2041 				}
       
  2042 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(10 - EWinPositionX, 10 - EWinPositionY));
       
  2043 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(10 - EWinPositionX, 10 - EWinPositionY));
       
  2044 			}
       
  2045 			break;
       
  2046 		#if defined(__WINS__)
       
  2047 		case 2:
       
  2048 #if !defined(TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA)
       
  2049 			SimulateButton1DownWithSimulatedMove(45,32);
       
  2050 #else		
       
  2051 			SimulatePointer(TRawEvent::EButton1Down,45,32);
       
  2052 #endif
       
  2053 			SimulatePointer(TRawEvent::EButton1Up,45,32);
       
  2054 			TheClient->iWs.SimulateXyInputType(EXYInputNone);
       
  2055 			SimulatePointer(TRawEvent::EButton1Down,44,32);
       
  2056 			SimulatePointer(TRawEvent::EPointerMove,43,32);
       
  2057 			SimulatePointer(TRawEvent::EButton1Up,43,31);
       
  2058 			SimulatePointer(TRawEvent::EButton2Down,44,33);
       
  2059 			SimulatePointer(TRawEvent::EButton2Up,44,33);
       
  2060 			SimulatePointer(TRawEvent::EButton3Down,43,32);
       
  2061 			SimulatePointer(TRawEvent::EButton3Up,43,32);
       
  2062 			SimulatePointer(TRawEvent::EPointerSwitchOn,48,32);
       
  2063 			TheClient->iWs.SimulateXyInputType(EXYInputPointer);
       
  2064 #if !defined(TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA)
       
  2065 			SimulateButton1DownWithSimulatedMove(47,32);
       
  2066 #else				
       
  2067 			SimulatePointer(TRawEvent::EButton1Down,47,32);
       
  2068 #endif
       
  2069 			SimulatePointer(TRawEvent::EButton1Up,47,32);
       
  2070 			AddExpectedPointer(TPointerEvent::EMove, TPoint(45-EWinPositionX,32-EWinPositionY));
       
  2071 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(45-EWinPositionX,32-EWinPositionY));
       
  2072 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(45-EWinPositionX,32-EWinPositionY));
       
  2073 			AddExpectedPointer(TPointerEvent::EMove, TPoint(47-EWinPositionX,32-EWinPositionY));
       
  2074 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(47-EWinPositionX,32-EWinPositionY));
       
  2075 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(47-EWinPositionX,32-EWinPositionY));
       
  2076 			break;
       
  2077 		case 3:
       
  2078 			iQueueClient->iWin->BaseWin()->PointerFilter(EPointerGenerateSimulatedMove,0);
       
  2079 			iQueueClient->iWs.Flush();
       
  2080 			TheClient->iWs.SimulateXyInputType(EXYInputPointer);
       
  2081 			SimulatePointer(TRawEvent::EButton1Down,49,32);
       
  2082 			SimulatePointer(TRawEvent::EPointerMove,50,30);
       
  2083 			SimulatePointer(TRawEvent::EButton1Up,50,30);
       
  2084 			SimulatePointer(TRawEvent::EButton1Down,51,32);
       
  2085 			SimulatePointer(TRawEvent::EPointerMove,52,30);
       
  2086 			SimulatePointer(TRawEvent::EButton1Up,52,30);
       
  2087 			TheClient->iWs.SimulateXyInputType(EXYInputPointer);
       
  2088 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(49-EWinPositionX,32-EWinPositionY));
       
  2089 			AddExpectedPointer(TPointerEvent::EDrag, TPoint(50-EWinPositionX,30-EWinPositionY));
       
  2090 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(50-EWinPositionX,30-EWinPositionY));
       
  2091 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(51-EWinPositionX,32-EWinPositionY));
       
  2092 			AddExpectedPointer(TPointerEvent::EDrag, TPoint(52-EWinPositionX,30-EWinPositionY));
       
  2093 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(52-EWinPositionX,30-EWinPositionY));
       
  2094 			break;
       
  2095 		case 4:
       
  2096 			SimulatePointer(TRawEvent::EButton1Down,49,31);
       
  2097 			SimulatePointer(TRawEvent::EButton1Up,49,31);
       
  2098 			TheClient->iWs.SimulateXyInputType(EXYInputMouse);
       
  2099 			SimulatePointer(TRawEvent::EPointerMove,50,31);
       
  2100 			SimulatePointer(TRawEvent::EButton1Down,50,31);
       
  2101 			SimulatePointer(TRawEvent::EPointerMove,50,30);
       
  2102 			SimulatePointer(TRawEvent::EButton1Up,50,30);
       
  2103 			SimulatePointer(TRawEvent::EPointerMove,51,31);
       
  2104 			SimulatePointer(TRawEvent::EButton1Down,51,31);
       
  2105 			SimulatePointer(TRawEvent::EPointerMove,51,30);
       
  2106 			SimulatePointer(TRawEvent::EButton1Up,51,30);
       
  2107 			TheClient->iWs.SimulateXyInputType(EXYInputPointer);
       
  2108 			SimulatePointer(TRawEvent::EButton1Down,52,31);
       
  2109 			SimulatePointer(TRawEvent::EButton1Up,52,31);
       
  2110 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(49-EWinPositionX,31-EWinPositionY));
       
  2111 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(49-EWinPositionX,31-EWinPositionY));
       
  2112 			AddExpectedPointer(TPointerEvent::EMove, TPoint(50-EWinPositionX,31-EWinPositionY));
       
  2113 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(50-EWinPositionX,31-EWinPositionY));
       
  2114 			AddExpectedPointer(TPointerEvent::EDrag, TPoint(50-EWinPositionX,30-EWinPositionY));
       
  2115 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(50-EWinPositionX,30-EWinPositionY));
       
  2116 			AddExpectedPointer(TPointerEvent::EMove, TPoint(51-EWinPositionX,31-EWinPositionY));
       
  2117 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(51-EWinPositionX,31-EWinPositionY));
       
  2118 			AddExpectedPointer(TPointerEvent::EDrag, TPoint(51-EWinPositionX,30-EWinPositionY));
       
  2119 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(51-EWinPositionX,30-EWinPositionY));
       
  2120 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(52-EWinPositionX,31-EWinPositionY));
       
  2121 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(52-EWinPositionX,31-EWinPositionY));
       
  2122 			break;
       
  2123 		case 5:
       
  2124 			SimulatePointer(TRawEvent::EButton1Down,69,31);
       
  2125 			SimulatePointer(TRawEvent::EButton1Up,69,31);
       
  2126 			TheClient->iWs.SimulateXyInputType(EXYInputDeltaMouse);
       
  2127 			SimulatePointer(TRawEvent::EPointerMove,-5,-5);
       
  2128 			SimulatePointer(TRawEvent::EButton1Down,7,8);
       
  2129 			SimulatePointer(TRawEvent::EPointerMove,10,-3);
       
  2130 			SimulatePointer(TRawEvent::EButton1Up,-7,-8);
       
  2131 			SimulatePointer(TRawEvent::EPointerMove,-4,9);
       
  2132 			SimulatePointer(TRawEvent::EButton1Down,123,456);
       
  2133 			SimulatePointer(TRawEvent::EPointerMove,15,13);
       
  2134 			SimulatePointer(TRawEvent::EButton1Up,-2345,-6789);
       
  2135 			TheClient->iWs.SimulateXyInputType(EXYInputPointer);
       
  2136 			SimulatePointer(TRawEvent::EButton1Down,62,31);
       
  2137 			SimulatePointer(TRawEvent::EButton1Up,62,31);
       
  2138 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(69-EWinPositionX,31-EWinPositionY));
       
  2139 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(69-EWinPositionX,31-EWinPositionY));
       
  2140 			AddExpectedPointer(TPointerEvent::EMove, TPoint(64-EWinPositionX,26-EWinPositionY));
       
  2141 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(64-EWinPositionX,26-EWinPositionY));
       
  2142 			AddExpectedPointer(TPointerEvent::EDrag, TPoint(74-EWinPositionX,23-EWinPositionY));
       
  2143 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(74-EWinPositionX,23-EWinPositionY));
       
  2144 			AddExpectedPointer(TPointerEvent::EMove, TPoint(70-EWinPositionX,32-EWinPositionY));
       
  2145 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(70-EWinPositionX,32-EWinPositionY));
       
  2146 			AddExpectedPointer(TPointerEvent::EDrag, TPoint(85-EWinPositionX,45-EWinPositionY));
       
  2147 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(85-EWinPositionX,45-EWinPositionY));
       
  2148 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(62-EWinPositionX,31-EWinPositionY));
       
  2149 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(62-EWinPositionX,31-EWinPositionY));
       
  2150 			break;
       
  2151 		#endif
       
  2152 		default:
       
  2153 			CActiveScheduler::Stop();
       
  2154 			break;
       
  2155 		}
       
  2156 	TheClient->iWs.Flush();
       
  2157 	}
       
  2158 
       
  2159 void CTEventTest::MovingPointerCursor_NextSetOfEventsL()
       
  2160 	{
       
  2161 	switch(iEventSet++)
       
  2162 		{
       
  2163 		case 0:
       
  2164 			iQueueClient->iWin->BaseWin()->PointerFilter(EPointerFilterMove|EPointerFilterDrag,0);
       
  2165 			iQueueClient->iWin->BaseWin()->SetPointerGrab(EFalse);
       
  2166 			iQueueClient->iChildWin->BaseWin()->PointerFilter(EPointerFilterMove|EPointerFilterDrag,0);
       
  2167 			iQueueClient->iChildWin->BaseWin()->SetPointerGrab(EFalse);
       
  2168 			iQueueClient->iWs.Flush();
       
  2169 			//AddExpectedEvent(EEventFocusGained);
       
  2170 			break;
       
  2171 		#if defined(__WINS__)
       
  2172 		case 1:
       
  2173 			TheClient->iWs.SimulateXyInputType(EXYInputMouse);
       
  2174 			iQueueClient->iChildWin->BaseWin()->PointerFilter(EPointerFilterMove|EPointerFilterDrag,0);
       
  2175 			iQueueClient->iWin->BaseWin()->PointerFilter(EPointerFilterMove|EPointerFilterDrag,0);
       
  2176 			iQueueClient->iWin->BaseWin()->SetPointerGrab(EFalse);
       
  2177 			iQueueClient->iChildWin->BaseWin()->SetPointerGrab(EFalse);
       
  2178 			iQueueClient->iWs.Flush();
       
  2179 			SimulatePointer(TRawEvent::EPointerMove,46,31);
       
  2180 			SimulatePointer(TRawEvent::EButton1Down,46,31);
       
  2181 			SimulatePointer(TRawEvent::EPointerMove,47,32);
       
  2182 			SimulatePointer(TRawEvent::EButton1Up,47,32);
       
  2183 			AddExpectedPointer(TPointerEvent::EMove, TPoint(46-EWinPositionX,31-EWinPositionY));
       
  2184 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(46-EWinPositionX,31-EWinPositionY));
       
  2185 			AddExpectedPointer(TPointerEvent::EDrag, TPoint(47-EWinPositionX,32-EWinPositionY));
       
  2186 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(47-EWinPositionX,32-EWinPositionY));
       
  2187 			break;
       
  2188 		case 2:
       
  2189 			TheClient->iWs.SimulateXyInputType(EXYInputDeltaMouse);
       
  2190 			TheClient->iWs.SetPointerCursorPosition(TPoint(62,24));
       
  2191 			SimulatePointer(TRawEvent::EPointerMove,-5,-5);
       
  2192 			TheClient->iWs.SetPointerCursorPosition(TPoint(60,20));
       
  2193 			SimulatePointer(TRawEvent::EPointerMove,6,7);
       
  2194 			SimulatePointer(TRawEvent::EButton1Down,27,38);
       
  2195 			SimulatePointer(TRawEvent::EPointerMove,0,0);
       
  2196 			TheClient->iWs.SetPointerCursorPosition(TPoint(55,25));
       
  2197 			SimulatePointer(TRawEvent::EPointerMove,4,-13);
       
  2198 			TheClient->iWs.SetPointerCursorPosition(TPoint(58,20));
       
  2199 			SimulatePointer(TRawEvent::EButton1Up,45,-678);
       
  2200 			TheClient->iWs.Flush();
       
  2201 			iQueueClient->iWin->BaseWin()->PointerFilter(EPointerFilterEnterExit,0);
       
  2202 			iQueueClient->iChildWin->BaseWin()->PointerFilter(EPointerFilterEnterExit,0);
       
  2203 			iQueueClient->iWs.Flush();
       
  2204 			TheClient->iWs.SetPointerCursorPosition(TPoint(80,45));
       
  2205 			TheClient->iWs.SimulateXyInputType(EXYInputPointer);
       
  2206 			AddExpectedPointer(TPointerEvent::EMove, TPoint(57-EWinPositionX,19-EWinPositionY));
       
  2207 			AddExpectedPointer(TPointerEvent::EMove, TPoint(66-EWinPositionX,27-EWinPositionY));
       
  2208 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(66-EWinPositionX,27-EWinPositionY));
       
  2209 			AddExpectedPointer(TPointerEvent::EDrag, TPoint(66-EWinPositionX,27-EWinPositionY));
       
  2210 			AddExpectedPointer(TPointerEvent::EDrag, TPoint(59-EWinPositionX,12-EWinPositionY));
       
  2211 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(58-EWinPositionX,20-EWinPositionY));
       
  2212 			AddExpectedEnterExit(EEventPointerEnter, TPoint(58-EWinPositionX,20-EWinPositionY));
       
  2213 			AddExpectedEnterExit(EEventPointerExit, TPoint(58-EWinPositionX,20-EWinPositionY));
       
  2214 			AddExpectedEnterExit(EEventPointerEnter, TPoint(80-EWinPositionX,45-EWinPositionY));
       
  2215 			break;
       
  2216 		case 3:
       
  2217 			iQueueClient->iWin->BaseWin()->PointerFilter(EPointerFilterEnterExit,EPointerFilterEnterExit);
       
  2218 			iQueueClient->iChildWin->BaseWin()->PointerFilter(EPointerFilterEnterExit,EPointerFilterEnterExit);
       
  2219 			iQueueClient->iWs.Flush();
       
  2220 			TheClient->iWs.SetPointerCursorArea(TRect(0,0,70,240));
       
  2221 			TheClient->iWs.SimulateXyInputType(EXYInputDeltaMouse);
       
  2222 			TheClient->iWs.SetPointerCursorPosition(TPoint(65,30));
       
  2223 			SimulatePointer(TRawEvent::EPointerMove,20,0);
       
  2224 			TheClient->iWs.SetPointerCursorPosition(TPoint(75,32));
       
  2225 			SimulatePointer(TRawEvent::EPointerMove,-1,20);
       
  2226 			SimulatePointer(TRawEvent::EButton1Down,29,37);
       
  2227 			SimulatePointer(TRawEvent::EPointerMove,25,-13);
       
  2228 			SimulatePointer(TRawEvent::EButton1Up,47,-648);
       
  2229 			TheClient->iWs.SimulateXyInputType(EXYInputPointer);
       
  2230 			AddExpectedPointer(TPointerEvent::EMove, TPoint(69-EWinPositionX,30-EWinPositionY));
       
  2231 			AddExpectedPointer(TPointerEvent::EMove, TPoint(68-EWinPositionX,52-EWinPositionY));
       
  2232 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(68-EWinPositionX,52-EWinPositionY));
       
  2233 			AddExpectedPointer(TPointerEvent::EDrag, TPoint(69-EWinPositionX,39-EWinPositionY));
       
  2234 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(69-EWinPositionX,39-EWinPositionY));
       
  2235 			break;
       
  2236 		case 4:
       
  2237 			TheClient->iWs.SetPointerCursorArea(TRect(EWinPositionX+2,EWinPositionY+2,EWinPositionX+99,EWinPositionY+49));
       
  2238 			TheClient->iWs.SimulateXyInputType(EXYInputDeltaMouse);
       
  2239 			TheClient->iWs.SetPointerCursorPosition(TPoint(56,30));
       
  2240 			SimulatePointer(TRawEvent::EPointerMove,0,-34);
       
  2241 			TheClient->iWs.SetPointerCursorPosition(TPoint(56,30));
       
  2242 			SimulatePointer(TRawEvent::EPointerMove,0,0);
       
  2243 			SimulatePointer(TRawEvent::EPointerMove,-77,-35);
       
  2244 			TheClient->iWs.SetPointerCursorPosition(TPoint(56,30));
       
  2245 			SimulatePointer(TRawEvent::EPointerMove,0,0);
       
  2246 			SimulatePointer(TRawEvent::EPointerMove,-78,0);
       
  2247 			TheClient->iWs.SetPointerCursorPosition(TPoint(56,30));
       
  2248 			SimulatePointer(TRawEvent::EPointerMove,0,0);
       
  2249 			SimulatePointer(TRawEvent::EPointerMove,-79,36);
       
  2250 			TheClient->iWs.SetPointerCursorPosition(TPoint(56,30));
       
  2251 			SimulatePointer(TRawEvent::EPointerMove,0,0);
       
  2252 			SimulatePointer(TRawEvent::EPointerMove,0,37);
       
  2253 			TheClient->iWs.SetPointerCursorPosition(TPoint(56,30));
       
  2254 			SimulatePointer(TRawEvent::EPointerMove,0,0);
       
  2255 			SimulatePointer(TRawEvent::EPointerMove,80,38);
       
  2256 			TheClient->iWs.SetPointerCursorPosition(TPoint(56,30));
       
  2257 			SimulatePointer(TRawEvent::EPointerMove,0,0);
       
  2258 			SimulatePointer(TRawEvent::EPointerMove,81,0);
       
  2259 			TheClient->iWs.SetPointerCursorPosition(TPoint(56,30));
       
  2260 			SimulatePointer(TRawEvent::EPointerMove,0,0);
       
  2261 			SimulatePointer(TRawEvent::EPointerMove,82,-39);
       
  2262 			TheClient->iWs.SetPointerCursorPosition(TPoint(2,2));
       
  2263 			SimulatePointer(TRawEvent::EPointerMove,30,30);
       
  2264 			TheClient->iWs.SetPointerCursorPosition(TPoint(1,30));
       
  2265 			SimulatePointer(TRawEvent::EPointerMove,1,0);
       
  2266 			TheClient->iWs.SetPointerCursorPosition(TPoint(2,88));
       
  2267 			SimulatePointer(TRawEvent::EPointerMove,30,-30);
       
  2268 			TheClient->iWs.SetPointerCursorPosition(TPoint(56,88));
       
  2269 			SimulatePointer(TRawEvent::EPointerMove,0,-1);
       
  2270 			TheClient->iWs.SetPointerCursorPosition(TPoint(123,88));
       
  2271 			SimulatePointer(TRawEvent::EPointerMove,-30,-30);
       
  2272 			TheClient->iWs.SetPointerCursorPosition(TPoint(123,30));
       
  2273 			SimulatePointer(TRawEvent::EPointerMove,-1,0);
       
  2274 			TheClient->iWs.SetPointerCursorPosition(TPoint(123,2));
       
  2275 			SimulatePointer(TRawEvent::EPointerMove,-30,30);
       
  2276 			TheClient->iWs.SetPointerCursorPosition(TPoint(56,1));
       
  2277 			SimulatePointer(TRawEvent::EPointerMove,0,1);
       
  2278 			TheClient->iWs.SimulateXyInputType(EXYInputPointer);
       
  2279 			AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,2));
       
  2280 			AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,30-EWinPositionY));
       
  2281 			AddExpectedPointer(TPointerEvent::EMove, TPoint(2,2));
       
  2282 			AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,30-EWinPositionY));
       
  2283 			AddExpectedPointer(TPointerEvent::EMove, TPoint(2,30-EWinPositionY));
       
  2284 			AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,30-EWinPositionY));
       
  2285 			AddExpectedPointer(TPointerEvent::EMove, TPoint(2,48));
       
  2286 			AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,30-EWinPositionY));
       
  2287 			AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,48));
       
  2288 			AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,30-EWinPositionY));
       
  2289 			AddExpectedPointer(TPointerEvent::EMove, TPoint(98,48));
       
  2290 			AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,30-EWinPositionY));
       
  2291 			AddExpectedPointer(TPointerEvent::EMove, TPoint(98,30-EWinPositionY));
       
  2292 			AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,30-EWinPositionY));
       
  2293 			AddExpectedPointer(TPointerEvent::EMove, TPoint(98,2));
       
  2294 			AddExpectedPointer(TPointerEvent::EMove, TPoint(32,32));
       
  2295 			AddExpectedPointer(TPointerEvent::EMove, TPoint(3,30-EWinPositionY));
       
  2296 			AddExpectedPointer(TPointerEvent::EMove, TPoint(32,18));
       
  2297 			AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,47));
       
  2298 			AddExpectedPointer(TPointerEvent::EMove, TPoint(68,18));
       
  2299 			AddExpectedPointer(TPointerEvent::EMove, TPoint(97,30-EWinPositionY));
       
  2300 			AddExpectedPointer(TPointerEvent::EMove, TPoint(68,32));
       
  2301 			AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,3));
       
  2302 			break;
       
  2303 		case 5:
       
  2304 			TheClient->iWs.SetPointerCursorArea(TRect(0,0,EWinPositionX+100,EWinPositionY+50));
       
  2305 			TheClient->iWs.SimulateXyInputType(EXYInputDeltaMouse);
       
  2306 			TheClient->iWs.SetPointerCursorPosition(TPoint(57,31));
       
  2307 			TheClient->iWs.SetPointerCursorArea(TRect(0,35,EWinPositionX+100,EWinPositionY+50));
       
  2308 			SimulatePointer(TRawEvent::EPointerMove,1,0);
       
  2309 			TheClient->iWs.SetPointerCursorPosition(TPoint(10,55));
       
  2310 			TheClient->iWs.SetPointerCursorArea(TRect(15,0,EWinPositionX+100,50));
       
  2311 			SimulatePointer(TRawEvent::EPointerMove,1,1);
       
  2312 			TheClient->iWs.SetPointerCursorPosition(TPoint(57,31));
       
  2313 			TheClient->iWs.SetPointerCursorArea(TRect(0,0,50,EWinPositionY+50));
       
  2314 			SimulatePointer(TRawEvent::EPointerMove,0,1);
       
  2315 			TheClient->iWs.SetPointerCursorPosition(TPoint(10,10));
       
  2316 			TheClient->iWs.SetPointerCursorArea(TRect(15,15,EWinPositionX+100,EWinPositionY+50));
       
  2317 			SimulatePointer(TRawEvent::EPointerMove,1,-1);
       
  2318 			TheClient->iWs.SetPointerCursorPosition(TPoint(57,31));
       
  2319 			TheClient->iWs.SetPointerCursorArea(TRect(0,0,EWinPositionX+100,30));
       
  2320 			SimulatePointer(TRawEvent::EPointerMove,-1,0);
       
  2321 			TheClient->iWs.SetPointerCursorPosition(TPoint(100,10));
       
  2322 			TheClient->iWs.SetPointerCursorArea(TRect(0,15,95,EWinPositionY+50));
       
  2323 			SimulatePointer(TRawEvent::EPointerMove,-1,-1);
       
  2324 			TheClient->iWs.SetPointerCursorPosition(TPoint(57,31));
       
  2325 			TheClient->iWs.SetPointerCursorArea(TRect(60,0,EWinPositionX+100,EWinPositionY+50));
       
  2326 			SimulatePointer(TRawEvent::EPointerMove,0,-1);
       
  2327 			TheClient->iWs.SetPointerCursorPosition(TPoint(100,55));
       
  2328 			TheClient->iWs.SetPointerCursorArea(TRect(0,0,95,50));
       
  2329 			SimulatePointer(TRawEvent::EPointerMove,1,-1);
       
  2330 			TheClient->iWs.SimulateXyInputType(EXYInputPointer);
       
  2331 			AddExpectedPointer(TPointerEvent::EMove, TPoint(58-EWinPositionX,35-EWinPositionY));
       
  2332 			AddExpectedPointer(TPointerEvent::EMove, TPoint(16-EWinPositionX,49-EWinPositionY));
       
  2333 			AddExpectedPointer(TPointerEvent::EMove, TPoint(49-EWinPositionX,32-EWinPositionY));
       
  2334 			AddExpectedPointer(TPointerEvent::EMove, TPoint(16-EWinPositionX,15-EWinPositionY));
       
  2335 			AddExpectedPointer(TPointerEvent::EMove, TPoint(56-EWinPositionX,29-EWinPositionY));
       
  2336 			AddExpectedPointer(TPointerEvent::EMove, TPoint(93-EWinPositionX,15-EWinPositionY));
       
  2337 			AddExpectedPointer(TPointerEvent::EMove, TPoint(60-EWinPositionX,30-EWinPositionY));
       
  2338 			AddExpectedPointer(TPointerEvent::EMove, TPoint(94-EWinPositionX,48-EWinPositionY));
       
  2339 			break;
       
  2340 		#endif
       
  2341 		default:
       
  2342 			TheClient->iWs.SetPointerCursorArea(TRect(0,0,95,50));
       
  2343 			CActiveScheduler::Stop();
       
  2344 			break;
       
  2345 		}
       
  2346 	TheClient->iWs.Flush();
       
  2347 	}
       
  2348 
       
  2349 void CTEventTest::RotatedMode_NextSetOfEventsL()
       
  2350 	{
       
  2351 #if defined(LOGGING)
       
  2352 	TLogMessageText logMessageText;
       
  2353 	_LIT(KSet,"RotatedMode SetOfEvents: %d  Max=4");
       
  2354 	logMessageText.Format(KSet,iEventSet);
       
  2355 	INFO_PRINTF1(logMessageText);
       
  2356 #endif
       
  2357 	switch(iEventSet++)
       
  2358 		{
       
  2359 		case 0:
       
  2360 			{
       
  2361 			iQueueClient->iWin->BaseWin()->PointerFilter(EPointerFilterMove|EPointerFilterDrag,0);
       
  2362 			iQueueClient->iWin->BaseWin()->SetPointerGrab(EFalse);
       
  2363 			iQueueClient->iWs.Flush();
       
  2364 			TheClient->iWs.SetPointerCursorArea(TRect(10,10,51,51));
       
  2365 			SimulatePointer(TRawEvent::EButton1Down,5,5);
       
  2366 			SimulatePointer(TRawEvent::EButton1Up,25,5);
       
  2367 			SimulatePointer(TRawEvent::EButton1Down,55,5);
       
  2368 			SimulatePointer(TRawEvent::EButton1Up,55,35);
       
  2369 			SimulatePointer(TRawEvent::EButton1Down,55,55);
       
  2370 			SimulatePointer(TRawEvent::EButton1Up,25,55);
       
  2371 			SimulatePointer(TRawEvent::EButton1Down,5,55);
       
  2372 			SimulatePointer(TRawEvent::EButton1Up,5,35);
       
  2373 			AddExpectedEvent(EEventFocusGained);
       
  2374 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(10-EWinPositionX,10-EWinPositionY));
       
  2375 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(25-EWinPositionX,10-EWinPositionY));
       
  2376 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(50-EWinPositionX,10-EWinPositionY));
       
  2377 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(50-EWinPositionX,35-EWinPositionY));
       
  2378 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(50-EWinPositionX,50-EWinPositionY));
       
  2379 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(25-EWinPositionX,50-EWinPositionY));
       
  2380 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(10-EWinPositionX,50-EWinPositionY));
       
  2381 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(10-EWinPositionX,35-EWinPositionY));
       
  2382 			}
       
  2383 			break;
       
  2384 		case 1:
       
  2385 			{
       
  2386 			TInt enforc=TheClient->iScreen->ScreenModeEnforcement();
       
  2387 			iBlankWin->SetVisible(ETrue);
       
  2388 		#if defined(LOGGING)
       
  2389 			_LIT(KSet1,"AUTO  Rotating Events :1st ");
       
  2390 			INFO_PRINTF1(KSet1);
       
  2391 		#endif
       
  2392 			INFO_PRINTF1(_L(" Set of Events"));
       
  2393 			if (iScreenModeTests&EDoRot90)
       
  2394 				{
       
  2395 				TheClient->iScreen->SetScreenMode(1);
       
  2396 				TheClient->iWs.Flush();
       
  2397 				iTest->DelayIfFullRomL();
       
  2398 				INFO_PRINTF1(_L(" Screen mode 1."));
       
  2399 				TPoint screenModeOrigin=TheClient->iScreen->GetDefaultScreenModeOrigin();
       
  2400 			#if defined(__WINS__)
       
  2401 				iTest->SimulatePointer(TRawEvent::EButton1Down,20+screenModeOrigin.iX,20+screenModeOrigin.iY);
       
  2402 				iTest->SimulatePointer(TRawEvent::EButton1Up,20+screenModeOrigin.iX,20+screenModeOrigin.iY);
       
  2403 			#else
       
  2404 				// simulate pointer at (20,20) on rotated screen by providing physical coordinates
       
  2405 				iTest->SimulatePointer(TRawEvent::EButton1Down,iPhysicalScreenSize.iWidth-1-20+screenModeOrigin.iX,20+screenModeOrigin.iY);
       
  2406 				iTest->SimulatePointer(TRawEvent::EButton1Up,iPhysicalScreenSize.iWidth-1-20+screenModeOrigin.iX,20+screenModeOrigin.iY);
       
  2407 			#endif
       
  2408 				INFO_PRINTF1(_L(" Sent Up and Down 90"));
       
  2409 				}
       
  2410 			if (iScreenModeTests&EDoRot180)
       
  2411 				{
       
  2412 				TheClient->iScreen->SetCurrentRotations(0,CFbsBitGc::EGraphicsOrientationRotated180);
       
  2413 				TheClient->iScreen->SetScreenMode(0);
       
  2414 				INFO_PRINTF1(_L(" Screen mode 0"));
       
  2415 				TheClient->iWs.Flush();
       
  2416 				iTest->DelayIfFullRomL();
       
  2417 				INFO_PRINTF1(_L(" Upside Down"));
       
  2418 			#if defined(__WINS__)
       
  2419 				iTest->SimulatePointer(TRawEvent::EButton1Down,22,22);
       
  2420 				iTest->SimulatePointer(TRawEvent::EButton1Up,22,22);
       
  2421 			#else
       
  2422 				// simulate pointer at (22,22) on rotated screen by providing physical coordinates
       
  2423 				iTest->SimulatePointer(TRawEvent::EButton1Down,iPhysicalScreenSize.iWidth-1-22,iPhysicalScreenSize.iHeight-1-22);
       
  2424 				iTest->SimulatePointer(TRawEvent::EButton1Up,iPhysicalScreenSize.iWidth-1-22,iPhysicalScreenSize.iHeight-1-22);
       
  2425 			#endif
       
  2426 				INFO_PRINTF1(_L(" Sent Up and Down 180"));
       
  2427 				}
       
  2428 			TheClient->iScreen->SetCurrentRotations(0,CFbsBitGc::EGraphicsOrientationNormal);
       
  2429 			TheClient->iScreen->SetScreenMode(0);
       
  2430 			TheClient->iWs.Flush();
       
  2431 			iTest->DelayIfFullRomL();
       
  2432 			INFO_PRINTF1(_L(" Normal Screen mode"));
       
  2433 			if (iScreenModeTests&EDoRot0)
       
  2434 				{
       
  2435 				SimulatePointer(TRawEvent::EButton1Down,24,24);
       
  2436 				SimulatePointer(TRawEvent::EButton1Up,24,24);
       
  2437 				}
       
  2438 			if (iScreenModeTests&EDoRot90)
       
  2439 				{
       
  2440 				if (enforc>ESizeEnforcementNone)
       
  2441 					{
       
  2442 					AddExpectedEvent(EEventFocusLost);
       
  2443 					AddExpectedEvent(EEventFocusGained);
       
  2444 					}
       
  2445 				else
       
  2446 					{
       
  2447                     AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(20-EWinPositionX,20-EWinPositionY-iYOffset));
       
  2448                     AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(20-EWinPositionX,20-EWinPositionY-iYOffset));
       
  2449                     }
       
  2450 				}
       
  2451 			if (iScreenModeTests&EDoRot180)
       
  2452 				{
       
  2453                 AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(22-EWinPositionX,22-EWinPositionY-iYOffset));
       
  2454                 AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(22-EWinPositionX,22-EWinPositionY-iYOffset));
       
  2455 				}
       
  2456 			if (iScreenModeTests&EDoRot0)
       
  2457 				{
       
  2458 				AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(24-EWinPositionX,24-EWinPositionY));
       
  2459 				AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,24-EWinPositionY));
       
  2460 				}
       
  2461 			INFO_PRINTF1(_L(" Added Expected"));
       
  2462 			User::After(EPointerCursorUpdateGap);
       
  2463 			iBlankWin->SetVisible(EFalse);
       
  2464 			}
       
  2465 			break;
       
  2466 	#if defined(__WINS__)
       
  2467 		case 2:
       
  2468 			{
       
  2469 			TInt enforc=TheClient->iScreen->ScreenModeEnforcement();
       
  2470 			//INFO_PRINTF1("AUTO  Rotating Events ");
       
  2471 			//INFO_PRINTF1(" :2nd Set of Events");
       
  2472 			TheClient->iWs.SimulateXyInputType(EXYInputDeltaMouse);
       
  2473 			TheClient->iWs.SetPointerCursorPosition(TPoint(24+EWinPositionX,24+EWinPositionY));
       
  2474 			if (iScreenModeTests&EDoRot90)
       
  2475 				{
       
  2476 				TheClient->iScreen->SetScreenMode(1);
       
  2477 				TheClient->iWs.Flush();
       
  2478 				iTest->DelayIfFullRomL();
       
  2479 				SimulatePointer(TRawEvent::EPointerMove,1,2);
       
  2480 				SimulatePointer(TRawEvent::EButton1Down,56,89);
       
  2481 				SimulatePointer(TRawEvent::EPointerMove,2,-1);
       
  2482 				SimulatePointer(TRawEvent::EButton1Up,234,456);
       
  2483 				}
       
  2484 			else
       
  2485 				TheClient->iWs.SetPointerCursorPosition(TPoint(27+EWinPositionX,25+EWinPositionY));
       
  2486 			if (iScreenModeTests&EDoRot180)
       
  2487 				{
       
  2488 				TheClient->iScreen->SetCurrentRotations(0,CFbsBitGc::EGraphicsOrientationRotated180);
       
  2489 				TheClient->iScreen->SetScreenMode(0);
       
  2490 				TheClient->iWs.Flush();
       
  2491 				iTest->DelayIfFullRomL();
       
  2492 				SimulatePointer(TRawEvent::EPointerMove,-3,4);
       
  2493 				SimulatePointer(TRawEvent::EButton1Down,156,289);
       
  2494 				SimulatePointer(TRawEvent::EPointerMove,-4,-3);
       
  2495 				SimulatePointer(TRawEvent::EButton1Up,2234,3456);
       
  2496 				}
       
  2497 			else
       
  2498 				TheClient->iWs.SetPointerCursorPosition(TPoint(20+EWinPositionX,26+EWinPositionY));
       
  2499 			TheClient->iScreen->SetCurrentRotations(0,CFbsBitGc::EGraphicsOrientationNormal);
       
  2500 			TheClient->iScreen->SetScreenMode(0);
       
  2501 			TheClient->iWs.Flush();
       
  2502 			iTest->DelayIfFullRomL();
       
  2503 			if (iScreenModeTests&EDoRot0)
       
  2504 				{
       
  2505 				SimulatePointer(TRawEvent::EButton1Down,24,24);
       
  2506 				SimulatePointer(TRawEvent::EButton1Up,24,24);
       
  2507 				}
       
  2508 			TheClient->iWs.SimulateXyInputType(EXYInputPointer);
       
  2509 			TheClient->iWs.Flush();
       
  2510 			if (iScreenModeTests&EDoRot90)
       
  2511 				{
       
  2512 				if (enforc>ESizeEnforcementNone)
       
  2513 					{
       
  2514 					AddExpectedEvent(EEventFocusLost);
       
  2515 					AddExpectedEvent(EEventFocusGained);
       
  2516 					}
       
  2517 				else
       
  2518 					{
       
  2519 					AddExpectedPointer(TPointerEvent::EMove, TPoint(25,26));
       
  2520 					AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(25,26));
       
  2521 					AddExpectedPointer(TPointerEvent::EDrag, TPoint(27,25));
       
  2522 					AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(27,25));
       
  2523 					}
       
  2524 				}
       
  2525 			if (iScreenModeTests&EDoRot180)
       
  2526 				{
       
  2527 				AddExpectedPointer(TPointerEvent::EMove, TPoint(24,29));
       
  2528 				AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(24,29));
       
  2529 				AddExpectedPointer(TPointerEvent::EDrag, TPoint(20,26));
       
  2530 				AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(20,26));
       
  2531 				}
       
  2532 			if (iScreenModeTests&EDoRot0)
       
  2533 				{
       
  2534 				AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(20,26));
       
  2535 				AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(20,26));
       
  2536 				}
       
  2537 			}
       
  2538 			break;
       
  2539 		case 3:
       
  2540 			{
       
  2541 		#if defined(LOGGING)
       
  2542 			_LIT(KSet2,"AUTO  Rotating Events ");
       
  2543 			INFO_PRINTF1(KSet2);
       
  2544 		#endif
       
  2545 			INFO_PRINTF1(_L(" :3rd Set of Events"));
       
  2546 			if (iScreenModeTests&EDoScale)
       
  2547 				{
       
  2548 				INFO_PRINTF1(_L(" :Screen Scalling Supported"));
       
  2549 				iBlankWin->SetVisible(ETrue);
       
  2550 				iCurrentMode=iNumScrModes;
       
  2551 				--iCurrentMode;
       
  2552 				iTheClientFlush=TheClient->iWs.SetAutoFlush(ETrue);
       
  2553 				iQuequeClientFlush=iQueueClient->iWs.SetAutoFlush(ETrue);
       
  2554 				iQueueClient->iScreen->SetScreenMode(iCurrentMode);
       
  2555 				TheClient->iScreen->SetAppScreenMode(iCurrentMode);
       
  2556 				iQueueClient->iScreen->SetAppScreenMode(iCurrentMode);
       
  2557 				iSizeMode=iQueueClient->iScreen->GetCurrentScreenModeAttributes();
       
  2558 				TSizeMode testMode=iSizeMode;
       
  2559 				for (TInt xScale=2;xScale<4;xScale++)
       
  2560 					{
       
  2561 				INFO_PRINTF1(_L(" :New X-Scale Value"));
       
  2562 					for (TInt yScale=2;yScale<4;yScale++)
       
  2563 						{
       
  2564 						INFO_PRINTF1(_L(" :New Y-Scale Value"));
       
  2565 						testMode.iScreenScale.SetSize(xScale,yScale);
       
  2566 						CheckPointerCursorInDifferentScreenMode(testMode,TPoint(20,30));
       
  2567 						}
       
  2568 					}
       
  2569 				User::After(EPointerCursorUpdateGap);
       
  2570 				iBlankWin->SetVisible(EFalse);
       
  2571 				break;
       
  2572 				}
       
  2573 			}
       
  2574 		case 4:
       
  2575 			{
       
  2576 			if (iScreenModeTests&EDoScale)
       
  2577 				{
       
  2578 				TSizeMode testMode=iSizeMode;
       
  2579 				iBlankWin->SetVisible(ETrue);
       
  2580 				for (TInt xScale=2;xScale<4;xScale++)
       
  2581 					{
       
  2582 					for (TInt yScale=2;yScale<4;yScale++)
       
  2583 						{
       
  2584 						testMode.iScreenScale.SetSize(xScale,yScale);
       
  2585 						CheckPointerCursorInDifferentScreenMode(testMode,TPoint(30,20));
       
  2586 						}
       
  2587 					}
       
  2588 				User::After(EPointerCursorUpdateGap);
       
  2589 				iBlankWin->SetVisible(EFalse);
       
  2590 				break;
       
  2591 				}
       
  2592 			}
       
  2593 	#endif
       
  2594 		default:
       
  2595 		#if defined(__WINS__)
       
  2596 			if (iScreenModeTests&EDoScale)
       
  2597 				{
       
  2598 				iQueueClient->iScreen->SetScreenMode(iCurrentMode);
       
  2599 				iQueueClient->iScreen->SetCurrentScreenModeAttributes(iSizeMode);
       
  2600 				iQueueClient->iScreen->SetAppScreenMode(0);
       
  2601 				TheClient->iScreen->SetAppScreenMode(0);
       
  2602 				iQueueClient->iScreen->SetScreenMode(0);
       
  2603 				iBlankWin->SetVisible(EFalse);
       
  2604 				TheClient->iWs.SetAutoFlush(iTheClientFlush);
       
  2605 				iQueueClient->iWs.SetAutoFlush(iQuequeClientFlush);
       
  2606 				}
       
  2607 		#endif
       
  2608 			User::After(500000);		//0.5secs, to allow other screen devices to respond to the flip events
       
  2609 			CActiveScheduler::Stop();
       
  2610 			break;
       
  2611 		}
       
  2612 	TheClient->iWs.Flush();
       
  2613 	}
       
  2614 
       
  2615 
       
  2616 void CTEventTest::ScreenScaling_NextSetOfEventsL()
       
  2617 	{
       
  2618 #if defined(LOGGING)
       
  2619 	TLogMessageText logMessageText;
       
  2620 	_LIT(KSet,"ScreenScaling SetOfEvents: %d (Last=3)");
       
  2621 	logMessageText.Format(KSet,iEventSet);
       
  2622 	INFO_PRINTF1(logMessageText);
       
  2623 #endif
       
  2624 	if(! (iScreenModeTests & EDoScale))
       
  2625 		{
       
  2626 		User::After(500000);
       
  2627 		CActiveScheduler::Stop();
       
  2628 		return;
       
  2629 		}
       
  2630 	switch(iEventSet++)
       
  2631 		{
       
  2632 		case 0:
       
  2633 			{
       
  2634 			iTheClientFlush=TheClient->iWs.SetAutoFlush(ETrue);
       
  2635 			iQuequeClientFlush=iQueueClient->iWs.SetAutoFlush(ETrue);
       
  2636 			iBlankWin->SetVisible(ETrue);
       
  2637 
       
  2638 			TInt mode = TheClient->iScreen->CurrentScreenMode();
       
  2639 
       
  2640 			iSizeMode = iQueueClient->iScreen->GetCurrentScreenModeAttributes();
       
  2641 
       
  2642 			iQueueClient->iWin->BaseWin()->PointerFilter(EPointerFilterMove|EPointerFilterDrag,0);
       
  2643 			iQueueClient->iWin->BaseWin()->SetPointerGrab(EFalse);
       
  2644 
       
  2645 			TSizeMode szMode2 = iSizeMode;
       
  2646 
       
  2647 			szMode2.iScreenScale.SetSize(2,2);
       
  2648 
       
  2649 			iQueueClient->iScreen->SetCurrentScreenModeAttributes(szMode2);
       
  2650 			TheClient->iScreen->SetAppScreenMode(mode);
       
  2651 			iQueueClient->iScreen->SetAppScreenMode(mode);
       
  2652 			iQueueClient->iScreen->SetScreenMode(mode);
       
  2653 
       
  2654 			TPoint theScreenOrigin(iQueueClient->iScreen->GetScreenModeOrigin(mode));
       
  2655 
       
  2656 			SimulatePointer(TRawEvent::EButton1Down,
       
  2657 				20+theScreenOrigin.iX, 20+theScreenOrigin.iY);
       
  2658 			SimulatePointer(TRawEvent::EButton1Up,
       
  2659 				20+theScreenOrigin.iX, 20+theScreenOrigin.iY);
       
  2660 			iQueueClient->iScreen->SetCurrentScreenModeAttributes(iSizeMode);
       
  2661 			TheClient->iScreen->SetAppScreenMode(mode);
       
  2662 			iQueueClient->iScreen->SetAppScreenMode(mode);
       
  2663 			iQueueClient->iScreen->SetScreenMode(mode);
       
  2664 
       
  2665 			AddExpectedEvent(EEventFocusGained);
       
  2666 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(10-EWinPositionX,10-EWinPositionY));
       
  2667 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(10-EWinPositionX,10-EWinPositionY));
       
  2668 
       
  2669 			break;
       
  2670 			}
       
  2671 		case 1:
       
  2672 			{
       
  2673 			TSizeMode szMode2 = iSizeMode;
       
  2674 			TInt mode = TheClient->iScreen->CurrentScreenMode();
       
  2675 
       
  2676 			szMode2.iScreenScale.SetSize(2,2);
       
  2677 			szMode2.iOrigin.SetXY(20,20);
       
  2678 
       
  2679 			iQueueClient->iScreen->SetCurrentScreenModeAttributes(szMode2);
       
  2680 			TheClient->iScreen->SetAppScreenMode(mode);
       
  2681 			iQueueClient->iScreen->SetAppScreenMode(mode);
       
  2682 			iQueueClient->iScreen->SetScreenMode(mode);
       
  2683 
       
  2684 			TPoint theScreenOrigin(iQueueClient->iScreen->GetDefaultScreenModeOrigin());
       
  2685 
       
  2686 			SimulatePointer(TRawEvent::EButton1Down,
       
  2687 				30+theScreenOrigin.iX, 30+theScreenOrigin.iY);
       
  2688 			SimulatePointer(TRawEvent::EButton1Up,
       
  2689 				26+theScreenOrigin.iX, 20+theScreenOrigin.iY);
       
  2690 			SimulatePointer(TRawEvent::EButton1Down,
       
  2691 				40+theScreenOrigin.iX, 60+theScreenOrigin.iY);
       
  2692 			SimulatePointer(TRawEvent::EButton1Up,
       
  2693 				26+theScreenOrigin.iX, 20+theScreenOrigin.iY);
       
  2694 
       
  2695 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(15-EWinPositionX,15-EWinPositionY));
       
  2696 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(13-EWinPositionX,10-EWinPositionY));
       
  2697 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(20-EWinPositionX,30-EWinPositionY));
       
  2698 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(13-EWinPositionX,10-EWinPositionY));
       
  2699 
       
  2700 			iQueueClient->iScreen->SetCurrentScreenModeAttributes(iSizeMode);
       
  2701 			TheClient->iScreen->SetAppScreenMode(mode);
       
  2702 			iQueueClient->iScreen->SetAppScreenMode(mode);
       
  2703 			iQueueClient->iScreen->SetScreenMode(mode);
       
  2704 
       
  2705 			theScreenOrigin = TPoint(iQueueClient->iScreen->GetDefaultScreenModeOrigin());
       
  2706 
       
  2707 			SimulatePointer(TRawEvent::EButton1Down,
       
  2708 				30+theScreenOrigin.iX, 30+theScreenOrigin.iY);
       
  2709 			SimulatePointer(TRawEvent::EButton1Up,
       
  2710 				26+theScreenOrigin.iX, 20+theScreenOrigin.iY);
       
  2711 			SimulatePointer(TRawEvent::EButton1Down,
       
  2712 				40+theScreenOrigin.iX, 50+theScreenOrigin.iY);
       
  2713 			SimulatePointer(TRawEvent::EButton1Up,
       
  2714 				26+theScreenOrigin.iX, 20+theScreenOrigin.iY);
       
  2715 
       
  2716 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(30-EWinPositionX,30-EWinPositionY));
       
  2717 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(26-EWinPositionX,20-EWinPositionY));
       
  2718 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(40-EWinPositionX,50-EWinPositionY));
       
  2719 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(26-EWinPositionX,20-EWinPositionY));
       
  2720 			break;
       
  2721 			}
       
  2722 		case 2:
       
  2723 			{
       
  2724 			TInt mode = TheClient->iScreen->CurrentScreenMode();
       
  2725 			TRect	theRect = TheClient->iWs.PointerCursorArea();
       
  2726 
       
  2727 			TSizeMode szMode2 = iSizeMode;
       
  2728 
       
  2729 			//-----------  scaling 2X2
       
  2730 			szMode2.iScreenScale.SetSize(2,2);
       
  2731 
       
  2732 			iQueueClient->iScreen->SetCurrentScreenModeAttributes(szMode2);
       
  2733 			iQueueClient->iWs.SetPointerCursorArea(mode, TRect(24,10,52,52));
       
  2734 			TheClient->iScreen->SetAppScreenMode(mode);
       
  2735 			iQueueClient->iScreen->SetAppScreenMode(mode);
       
  2736 			iQueueClient->iScreen->SetScreenMode(mode);
       
  2737 
       
  2738 
       
  2739 			TPoint theScreenOrigin(iQueueClient->iScreen->GetDefaultScreenModeOrigin());
       
  2740 
       
  2741 			SimulatePointer(TRawEvent::EButton1Down,
       
  2742 				20+theScreenOrigin.iX, 20+theScreenOrigin.iY);
       
  2743 			SimulatePointer(TRawEvent::EButton1Up,
       
  2744 				26+theScreenOrigin.iX, 20+theScreenOrigin.iY);
       
  2745 			SimulatePointer(TRawEvent::EButton1Down,
       
  2746 				50+theScreenOrigin.iX, 30+theScreenOrigin.iY);
       
  2747 			SimulatePointer(TRawEvent::EButton1Up,
       
  2748 				26+theScreenOrigin.iX, 20+theScreenOrigin.iY);
       
  2749 
       
  2750 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(24-EWinPositionX,10-EWinPositionY));
       
  2751 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,10-EWinPositionY));
       
  2752 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(25-EWinPositionX,15-EWinPositionY));
       
  2753 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,10-EWinPositionY));
       
  2754 			//------------------------  scaling 1X2
       
  2755 			szMode2.iScreenScale.SetSize(1,2);
       
  2756 
       
  2757 			iQueueClient->iScreen->SetCurrentScreenModeAttributes(szMode2);
       
  2758 			iQueueClient->iWs.SetPointerCursorArea(mode, TRect(24,10,52,52));
       
  2759 			TheClient->iScreen->SetAppScreenMode(mode);
       
  2760 			iQueueClient->iScreen->SetAppScreenMode(mode);
       
  2761 			iQueueClient->iScreen->SetScreenMode(mode);
       
  2762 
       
  2763 			theScreenOrigin = TPoint(iQueueClient->iScreen->GetDefaultScreenModeOrigin());
       
  2764 
       
  2765 			SimulatePointer(TRawEvent::EButton1Down,
       
  2766 				20+theScreenOrigin.iX, 20+theScreenOrigin.iY);
       
  2767 			SimulatePointer(TRawEvent::EButton1Up,
       
  2768 				26+theScreenOrigin.iX, 20+theScreenOrigin.iY);
       
  2769 			SimulatePointer(TRawEvent::EButton1Down,
       
  2770 				50+theScreenOrigin.iX, 30+theScreenOrigin.iY);
       
  2771 			SimulatePointer(TRawEvent::EButton1Up,
       
  2772 				26+theScreenOrigin.iX, 20+theScreenOrigin.iY);
       
  2773 
       
  2774 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(24-EWinPositionX,10-EWinPositionY));
       
  2775 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(26-EWinPositionX,10-EWinPositionY));
       
  2776 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(50-EWinPositionX,15-EWinPositionY));
       
  2777 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(26-EWinPositionX,10-EWinPositionY));
       
  2778 			//------------------------  scaling 2X1
       
  2779 			szMode2.iScreenScale.SetSize(2,1);
       
  2780 
       
  2781 			iQueueClient->iScreen->SetCurrentScreenModeAttributes(szMode2);
       
  2782 			iQueueClient->iWs.SetPointerCursorArea(mode, TRect(24,10,52,52));
       
  2783 			TheClient->iScreen->SetAppScreenMode(mode);
       
  2784 			iQueueClient->iScreen->SetAppScreenMode(mode);
       
  2785 			iQueueClient->iScreen->SetScreenMode(mode);
       
  2786 
       
  2787 			theScreenOrigin = TPoint(iQueueClient->iScreen->GetDefaultScreenModeOrigin());
       
  2788 
       
  2789 			SimulatePointer(TRawEvent::EButton1Down,
       
  2790 				20+theScreenOrigin.iX, 20+theScreenOrigin.iY);
       
  2791 			SimulatePointer(TRawEvent::EButton1Up,
       
  2792 				26+theScreenOrigin.iX, 20+theScreenOrigin.iY);
       
  2793 			SimulatePointer(TRawEvent::EButton1Down,
       
  2794 				50+theScreenOrigin.iX, 30+theScreenOrigin.iY);
       
  2795 			SimulatePointer(TRawEvent::EButton1Up,
       
  2796 				26+theScreenOrigin.iX, 20+theScreenOrigin.iY);
       
  2797 
       
  2798 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(24-EWinPositionX,20-EWinPositionY));
       
  2799 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,20-EWinPositionY));
       
  2800 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(25-EWinPositionX,30-EWinPositionY));
       
  2801 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,20-EWinPositionY));
       
  2802 			//------------------------  scaling 3X1
       
  2803 
       
  2804 			szMode2.iScreenScale.SetSize(3,1);
       
  2805 
       
  2806 			iQueueClient->iScreen->SetCurrentScreenModeAttributes(szMode2);
       
  2807 			iQueueClient->iWs.SetPointerCursorArea(mode, TRect(24,10,52,52));
       
  2808 			TheClient->iScreen->SetAppScreenMode(mode);
       
  2809 			iQueueClient->iScreen->SetAppScreenMode(mode);
       
  2810 			iQueueClient->iScreen->SetScreenMode(mode);
       
  2811 
       
  2812 			theScreenOrigin = TPoint(iQueueClient->iScreen->GetDefaultScreenModeOrigin());
       
  2813 
       
  2814 			SimulatePointer(TRawEvent::EButton1Down,
       
  2815 				21+theScreenOrigin.iX, 20+theScreenOrigin.iY);
       
  2816 			SimulatePointer(TRawEvent::EButton1Up,
       
  2817 				30+theScreenOrigin.iX, 20+theScreenOrigin.iY);
       
  2818 			SimulatePointer(TRawEvent::EButton1Down,
       
  2819 				75+theScreenOrigin.iX, 30+theScreenOrigin.iY);
       
  2820 			SimulatePointer(TRawEvent::EButton1Up,
       
  2821 				30+theScreenOrigin.iX, 20+theScreenOrigin.iY);
       
  2822 
       
  2823 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(24-EWinPositionX,20-EWinPositionY));
       
  2824 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,20-EWinPositionY));
       
  2825 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(25-EWinPositionX,30-EWinPositionY));
       
  2826 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,20-EWinPositionY));
       
  2827 			//------------------------  scaling 3X2
       
  2828 
       
  2829 			szMode2.iScreenScale.SetSize(3,2);
       
  2830 
       
  2831 			iQueueClient->iScreen->SetCurrentScreenModeAttributes(szMode2);
       
  2832 			iQueueClient->iWs.SetPointerCursorArea(mode, TRect(24,10,52,52));
       
  2833 			TheClient->iScreen->SetAppScreenMode(mode);
       
  2834 			iQueueClient->iScreen->SetAppScreenMode(mode);
       
  2835 			iQueueClient->iScreen->SetScreenMode(mode);
       
  2836 
       
  2837 			theScreenOrigin = TPoint(iQueueClient->iScreen->GetDefaultScreenModeOrigin());
       
  2838 
       
  2839 			SimulatePointer(TRawEvent::EButton1Down,
       
  2840 				21+theScreenOrigin.iX, 20+theScreenOrigin.iY);
       
  2841 			SimulatePointer(TRawEvent::EButton1Up,
       
  2842 				30+theScreenOrigin.iX, 20+theScreenOrigin.iY);
       
  2843 			SimulatePointer(TRawEvent::EButton1Down,
       
  2844 				75+theScreenOrigin.iX, 30+theScreenOrigin.iY);
       
  2845 			SimulatePointer(TRawEvent::EButton1Up,
       
  2846 				30+theScreenOrigin.iX, 20+theScreenOrigin.iY);
       
  2847 
       
  2848 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(24-EWinPositionX,10-EWinPositionY));
       
  2849 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,10-EWinPositionY));
       
  2850 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(25-EWinPositionX,15-EWinPositionY));
       
  2851 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,10-EWinPositionY));
       
  2852 			//------------------------  scaling 3X3
       
  2853 			szMode2.iScreenScale.SetSize(3,3);
       
  2854 
       
  2855 			iQueueClient->iScreen->SetCurrentScreenModeAttributes(szMode2);
       
  2856 			iQueueClient->iWs.SetPointerCursorArea(mode, TRect(24,10,52,52));
       
  2857 			TheClient->iScreen->SetAppScreenMode(mode);
       
  2858 			iQueueClient->iScreen->SetAppScreenMode(mode);
       
  2859 			iQueueClient->iScreen->SetScreenMode(mode);
       
  2860 
       
  2861 			theScreenOrigin = TPoint(iQueueClient->iScreen->GetDefaultScreenModeOrigin());
       
  2862 
       
  2863 			SimulatePointer(TRawEvent::EButton1Down,
       
  2864 				21+theScreenOrigin.iX, 20+theScreenOrigin.iY);
       
  2865 			SimulatePointer(TRawEvent::EButton1Up,
       
  2866 				30+theScreenOrigin.iX, 20+theScreenOrigin.iY);
       
  2867 			SimulatePointer(TRawEvent::EButton1Down,
       
  2868 				75+theScreenOrigin.iX, 33+theScreenOrigin.iY);
       
  2869 			SimulatePointer(TRawEvent::EButton1Up,
       
  2870 				30+theScreenOrigin.iX, 20+theScreenOrigin.iY);
       
  2871 
       
  2872 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(24-EWinPositionX,10-EWinPositionY));
       
  2873 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,10-EWinPositionY));
       
  2874 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(25-EWinPositionX,11-EWinPositionY));
       
  2875 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(24-EWinPositionX,10-EWinPositionY));
       
  2876 			//------------------------
       
  2877 			iQueueClient->iWs.SetPointerCursorArea(mode, theRect);
       
  2878 			iQueueClient->iScreen->SetCurrentScreenModeAttributes(iSizeMode);
       
  2879 			TheClient->iScreen->SetAppScreenMode(mode);
       
  2880 			iQueueClient->iScreen->SetAppScreenMode(mode);
       
  2881 			iQueueClient->iScreen->SetScreenMode(mode);
       
  2882 			break;
       
  2883 			}
       
  2884 		case 3:
       
  2885 			{
       
  2886 			iQueueClient->iWs.SetAutoFlush(ETrue);
       
  2887 			TInt theCurMode = iQueueClient->iScreen->CurrentScreenMode();
       
  2888 			TPoint theScreenOrigin;
       
  2889 			if (iNumScrModes>2)
       
  2890 				{
       
  2891 				TheClient->iScreen->SetAppScreenMode(2);
       
  2892 				iQueueClient->iScreen->SetAppScreenMode(2);
       
  2893 				TheClient->iScreen->SetScreenMode(2);
       
  2894 
       
  2895 				theScreenOrigin=iQueueClient->iScreen->GetDefaultScreenModeOrigin();
       
  2896 				SimulatePointer(TRawEvent::EButton1Down,
       
  2897 					30+theScreenOrigin.iX,30+theScreenOrigin.iY);
       
  2898 				SimulatePointer(TRawEvent::EButton1Up,
       
  2899 					26+theScreenOrigin.iX,20+theScreenOrigin.iY);
       
  2900 				SimulatePointer(TRawEvent::EButton1Down,
       
  2901 					40+theScreenOrigin.iX,60+theScreenOrigin.iY);
       
  2902 				SimulatePointer(TRawEvent::EButton1Up,
       
  2903 					26+theScreenOrigin.iX,20+theScreenOrigin.iY);
       
  2904 
       
  2905 				AddExpectedPointer(TPointerEvent::EButton1Down,
       
  2906 					TPoint(15-EWinPositionX,15-EWinPositionY));
       
  2907 				AddExpectedPointer(TPointerEvent::EButton1Up,
       
  2908 					TPoint(13-EWinPositionX,10-EWinPositionY));
       
  2909 				AddExpectedPointer(TPointerEvent::EButton1Down,
       
  2910 					TPoint(20-EWinPositionX,30-EWinPositionY));
       
  2911 				AddExpectedPointer(TPointerEvent::EButton1Up,
       
  2912 					TPoint(13-EWinPositionX,10-EWinPositionY));
       
  2913 				}
       
  2914 
       
  2915 			TheClient->iScreen->SetAppScreenMode(0);
       
  2916 			iQueueClient->iScreen->SetAppScreenMode(0);
       
  2917 			iQueueClient->iScreen->SetScreenMode(0);
       
  2918 			iTest->DelayIfFullRomL();
       
  2919 
       
  2920 			theScreenOrigin = TPoint(iQueueClient->iScreen->GetDefaultScreenModeOrigin());
       
  2921 
       
  2922 			SimulatePointer(TRawEvent::EButton1Down,
       
  2923 				30+theScreenOrigin.iX, 30+theScreenOrigin.iY);
       
  2924 			SimulatePointer(TRawEvent::EButton1Up,
       
  2925 				26+theScreenOrigin.iX, 20+theScreenOrigin.iY);
       
  2926 			SimulatePointer(TRawEvent::EButton1Down,
       
  2927 				40+theScreenOrigin.iX, 50+theScreenOrigin.iY);
       
  2928 			SimulatePointer(TRawEvent::EButton1Up,
       
  2929 				26+theScreenOrigin.iX, 20+theScreenOrigin.iY);
       
  2930 
       
  2931 		#if defined(__WINS__)
       
  2932 			iQueueClient->iWs.SimulateXyInputType(EXYInputDeltaMouse);
       
  2933 			iQueueClient->iWs.SetPointerCursorPosition(TPoint(24+theScreenOrigin.iX,24+theScreenOrigin.iY));
       
  2934 			SimulatePointer(TRawEvent::EPointerMove,1,2);
       
  2935 			iQueueClient->iWs.SimulateXyInputType(EXYInputPointer);
       
  2936 		#endif
       
  2937 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(30-EWinPositionX,30-EWinPositionY));
       
  2938 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(26-EWinPositionX,20-EWinPositionY));
       
  2939 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(40-EWinPositionX,50-EWinPositionY));
       
  2940 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(26-EWinPositionX,20-EWinPositionY));
       
  2941 
       
  2942 		#if defined(__WINS__)
       
  2943 			AddExpectedPointer(TPointerEvent::EMove, TPoint(25-EWinPositionX,26-EWinPositionY));
       
  2944 		#endif
       
  2945 
       
  2946 			iQueueClient->iScreen->SetAppScreenMode(theCurMode);
       
  2947 			TheClient->iScreen->SetScreenMode(theCurMode);
       
  2948 			break;
       
  2949 			}
       
  2950 		default:
       
  2951 			User::After(EPointerCursorUpdateGap);
       
  2952 			iBlankWin->SetVisible(EFalse);
       
  2953 			TheClient->iWs.SetAutoFlush(iTheClientFlush);
       
  2954 			iQueueClient->iWs.SetAutoFlush(iQuequeClientFlush);
       
  2955 			iQueueClient->iScreen->SetCurrentScreenModeAttributes(iSizeMode);
       
  2956 			User::After(500000);		//0.5secs, to allow other screen devices to respond to the flip events
       
  2957 			CActiveScheduler::Stop();
       
  2958 			break;
       
  2959 		}
       
  2960 	}
       
  2961 
       
  2962 void CTEventTest::AnimEvent_NextSetOfEventsL()
       
  2963 	{
       
  2964 #if defined(LOGGING)
       
  2965 	TLogMessageText logMessageText;
       
  2966 	_LIT(KSet,"AnimEvent SetOfEvents: %d  (Max=4)");
       
  2967 	logMessageText.Format(KSet,iEventSet);
       
  2968 	INFO_PRINTF1(logMessageText);
       
  2969 #endif
       
  2970 	switch(iEventSet++)
       
  2971 		{
       
  2972 		case 0:
       
  2973 			iAnim=REventAnim::NewL(iQueueClient->iWin->BaseWin(), iAnimDll);
       
  2974 			AddExpectedEvent(EEventFocusGained);
       
  2975 			AddExpectedKeyAnim(TRawEvent::EKeyDown,32,ETrue);
       
  2976 			AddExpectedKeyAnim(TRawEvent::EKeyUp,32,ETrue);
       
  2977 			AddExpectedKeyAnim(TRawEvent::EKeyDown,33,EFalse);
       
  2978 			AddExpectedKeyAnim(TRawEvent::EKeyUp,33,EFalse);
       
  2979 			iTest->SimulateKey(TRawEvent::EKeyDown,32);
       
  2980 			iTest->SimulateKey(TRawEvent::EKeyUp,32);
       
  2981 			iTest->SimulateKey(TRawEvent::EKeyDown,33);
       
  2982 			iTest->SimulateKey(TRawEvent::EKeyUp,33);
       
  2983 			TheClient->iWs.Flush();
       
  2984 			if (iAnim->TestFail(4))
       
  2985 				Failed();
       
  2986 			break;
       
  2987 		case 1:
       
  2988 			iQueueClient->iWin->BaseWin()->PointerFilter(EPointerFilterMove|EPointerFilterDrag,0);
       
  2989 			iQueueClient->iWin->BaseWin()->SetPointerGrab(EFalse);
       
  2990 			iQueueClient->iWs.Flush();
       
  2991 			TheClient->iWs.SetPointerCursorArea(TRect(10,10,51,51));
       
  2992 			AddExpectedPointerAnim(TRawEvent::EButton1Down, TPoint(10,10));
       
  2993 			AddExpectedPointerAnim(TRawEvent::EButton1Up, TPoint(25,10));
       
  2994 			AddExpectedPointerAnim(TRawEvent::EButton1Down, TPoint(50,10));
       
  2995 			AddExpectedPointerAnim(TRawEvent::EButton1Up, TPoint(50,35));
       
  2996 			AddExpectedPointerAnim(TRawEvent::EButton1Down, TPoint(50,50));
       
  2997 			AddExpectedPointerAnim(TRawEvent::EButton1Up, TPoint(25,50));
       
  2998 			AddExpectedPointerAnim(TRawEvent::EButton1Down, TPoint(10,50));
       
  2999 			AddExpectedPointerAnim(TRawEvent::EButton1Up, TPoint(10,35));
       
  3000 			AddExpectedPointerAnim(TRawEvent::EButton1Down, TPoint(30,30),EFalse);
       
  3001 			AddExpectedPointerAnim(TRawEvent::EButton1Up, TPoint(30,30),EFalse);
       
  3002 			SimulatePointer(TRawEvent::EButton1Down,5,5);
       
  3003 			SimulatePointer(TRawEvent::EButton1Up,25,5);
       
  3004 			SimulatePointer(TRawEvent::EButton1Down,55,5);
       
  3005 			SimulatePointer(TRawEvent::EButton1Up,55,35);
       
  3006 			SimulatePointer(TRawEvent::EButton1Down,55,55);
       
  3007 			SimulatePointer(TRawEvent::EButton1Up,25,55);
       
  3008 			SimulatePointer(TRawEvent::EButton1Down,5,55);
       
  3009 			SimulatePointer(TRawEvent::EButton1Up,5,35);
       
  3010 			SimulatePointer(TRawEvent::EButton1Down,30,30);
       
  3011 			SimulatePointer(TRawEvent::EButton1Up,30,30);
       
  3012 			TheClient->iWs.Flush();
       
  3013 			if (iAnim->TestFail(10))
       
  3014 				Failed();
       
  3015 			break;
       
  3016 		case 2:
       
  3017 			{
       
  3018 		#if defined(LOGGING)
       
  3019 			_LIT(KLog," :2nd Set of Events  Modes=0x%x");
       
  3020 			logMessageText.Format(KLog,iScreenModeTests);
       
  3021 			INFO_PRINTF1(logMessageText);
       
  3022 		#endif
       
  3023 			TInt enforc=TheClient->iScreen->ScreenModeEnforcement();
       
  3024 			iBlankWin->SetVisible(ETrue);
       
  3025 			TInt expectedEvents=0;
       
  3026 			if (iScreenModeTests&EDoRot90 && enforc==ESizeEnforcementNone)
       
  3027 				{
       
  3028 				INFO_PRINTF1(_L(" :Rotation 90"));
       
  3029 				TheClient->iScreen->SetScreenMode(1);
       
  3030 				TheClient->iWs.Flush();
       
  3031 				iTest->DelayIfFullRomL();
       
  3032                 AddExpectedPointerAnim(TRawEvent::EButton1Down, TPoint(20,20-iYOffset));
       
  3033                 AddExpectedPointerAnim(TRawEvent::EButton1Up, TPoint(20,20-iYOffset));
       
  3034 				expectedEvents+=2;
       
  3035 				TPoint screenModeOrigin=TheClient->iScreen->GetDefaultScreenModeOrigin();
       
  3036 			#if defined(__WINS__)
       
  3037 				iTest->SimulatePointer(TRawEvent::EButton1Down,20+screenModeOrigin.iX,20+screenModeOrigin.iY);
       
  3038 				iTest->SimulatePointer(TRawEvent::EButton1Up,20+screenModeOrigin.iX,20+screenModeOrigin.iY);
       
  3039 			#else
       
  3040 				// simulate pointer at (20,20) on rotated screen by providing physical coordinates
       
  3041 				iTest->SimulatePointer(TRawEvent::EButton1Down,iPhysicalScreenSize.iWidth-1-20+screenModeOrigin.iX,20+screenModeOrigin.iY);
       
  3042 				iTest->SimulatePointer(TRawEvent::EButton1Up,iPhysicalScreenSize.iWidth-1-20+screenModeOrigin.iX,20+screenModeOrigin.iY);
       
  3043 			#endif
       
  3044 				}
       
  3045 			if (iScreenModeTests&EDoRot180)
       
  3046 				{
       
  3047 				INFO_PRINTF1(_L(" :Rotation 180"));
       
  3048 				TheClient->iScreen->SetCurrentRotations(0,CFbsBitGc::EGraphicsOrientationRotated180);
       
  3049 				TheClient->iScreen->SetScreenMode(0);
       
  3050 				TheClient->iWs.Flush();
       
  3051 				iTest->DelayIfFullRomL();
       
  3052                 AddExpectedPointerAnim(TRawEvent::EButton1Down, TPoint(22,22-iYOffset));
       
  3053                 AddExpectedPointerAnim(TRawEvent::EButton1Up, TPoint(22,22-iYOffset));
       
  3054                
       
  3055 				expectedEvents+=2;
       
  3056 			#if defined(__WINS__)
       
  3057 				iTest->SimulatePointer(TRawEvent::EButton1Down,22,22);
       
  3058 				iTest->SimulatePointer(TRawEvent::EButton1Up,22,22);
       
  3059 			#else
       
  3060 				// simulate pointer at (22,22) on rotated screen by providing physical coordinates
       
  3061 				iTest->SimulatePointer(TRawEvent::EButton1Down,iPhysicalScreenSize.iWidth-1-22,iPhysicalScreenSize.iHeight-1-22);
       
  3062 				iTest->SimulatePointer(TRawEvent::EButton1Up,iPhysicalScreenSize.iWidth-1-22,iPhysicalScreenSize.iHeight-1-22);
       
  3063 			#endif
       
  3064 				}
       
  3065 			TheClient->iScreen->SetCurrentRotations(0,CFbsBitGc::EGraphicsOrientationNormal);
       
  3066 			TheClient->iScreen->SetScreenMode(0);
       
  3067 			TheClient->iWs.Flush();
       
  3068 			iTest->DelayIfFullRomL();
       
  3069 			if (iScreenModeTests&EDoRot0)
       
  3070 				{
       
  3071 				INFO_PRINTF1(_L(" :Rotation 0"));
       
  3072 				AddExpectedPointerAnim(TRawEvent::EButton1Down, TPoint(24,24),EFalse);
       
  3073 				AddExpectedPointerAnim(TRawEvent::EButton1Up, TPoint(24,24),EFalse);
       
  3074 				expectedEvents+=2;
       
  3075 				SimulatePointer(TRawEvent::EButton1Down,24,24);
       
  3076 				SimulatePointer(TRawEvent::EButton1Up,24,24);
       
  3077 				}
       
  3078 		#if defined(LOGGING)
       
  3079 			_LIT(KNumEvents," :Expected Number of Events=%d  Actual=%d");
       
  3080 			logMessageText.Format(KNumEvents,expectedEvents,iAnim->GetNumEvents());
       
  3081 			INFO_PRINTF1(logMessageText);
       
  3082 			_LIT(KError," :Error Value %d ('0'=OK)");
       
  3083 			logMessageText.Format(KError,iAnim->GetError());
       
  3084 			INFO_PRINTF1(logMessageText);
       
  3085 		#endif
       
  3086 			if (iAnim->TestFail(expectedEvents))
       
  3087 				Failed();
       
  3088 			User::After(EPointerCursorUpdateGap);
       
  3089 			iBlankWin->SetVisible(EFalse);
       
  3090 			INFO_PRINTF1(_L(" :Finished 2nd Set"));
       
  3091 			}
       
  3092 			break;
       
  3093 		case 3:
       
  3094 			iAnim->Destroy(); iAnim=NULL;
       
  3095 			// Create an EventPostingAnim, key down & key up events are simulated.
       
  3096 			// The event posting anim sees the key events in turn, and creates duplicates.
       
  3097 			// Test checks that each simulated event is received twice. 
       
  3098 			TRAPD(err, iAnim=REventAnim::NewL(iQueueClient->iWin->BaseWin(), iAnimDll, REventAnimBase::EEventPostingAnim));
       
  3099 			if (err!=KErrNone)
       
  3100 				{
       
  3101 				Failed();
       
  3102 				return;
       
  3103 				}
       
  3104 			AddExpectedKeyAnim(TRawEvent::EKeyDown,32,ETrue);
       
  3105 			AddExpectedKeyAnim(TRawEvent::EKeyDown,32,EFalse);
       
  3106 			AddExpectedKeyAnim(TRawEvent::EKeyUp,32,ETrue);
       
  3107 			AddExpectedKeyAnim(TRawEvent::EKeyUp,32,EFalse);
       
  3108 			
       
  3109 			iTest->SimulateKey(TRawEvent::EKeyDown,32);
       
  3110 			iTest->SimulateKey(TRawEvent::EKeyUp,32);
       
  3111 			break;
       
  3112 		case 4:
       
  3113 			// Simulate a key down event, which calls anim's offer raw event
       
  3114 			// which inturn calls post key event with old and new API
       
  3115 			// Test checks the repeat count for old and new API are as expected.
       
  3116 			AddExpectedKeyAnim(TRawEvent::EKeyDown,45,ETrue);
       
  3117 			
       
  3118 			TKeyEvent event;
       
  3119 			event.iCode='J';
       
  3120 			event.iScanCode=0;
       
  3121 			event.iModifiers=0;
       
  3122 			event.iRepeats=0;
       
  3123 			AddExpectedKey(1, event.iScanCode, event.iCode, event.iRepeats, event.iModifiers);
       
  3124 			event.iRepeats=2;
       
  3125 			AddExpectedKey(1, event.iScanCode, event.iCode, event.iRepeats, event.iModifiers);
       
  3126 			
       
  3127 			iTest->SimulateKey(TRawEvent::EKeyDown,45);
       
  3128 			break;
       
  3129 		default:
       
  3130 			iAnim->Destroy();
       
  3131 			iAnim=NULL;
       
  3132 			CActiveScheduler::Stop();
       
  3133 			break;
       
  3134 		}
       
  3135 	TheClient->iWs.Flush();
       
  3136 	}
       
  3137 
       
  3138 void CTEventTest::FocusChanged_NextSetOfEventsL()
       
  3139 	{
       
  3140 #if defined(LOGGING)
       
  3141 	TLogMessageText logMessageText;
       
  3142 	_LIT(KSet,"FocusChanged SetOfEvents: %d ");
       
  3143 	logMessageText.Format(KSet,iEventSet);
       
  3144 	INFO_PRINTF1(logMessageText);
       
  3145 #endif
       
  3146 	switch(iEventSet++)
       
  3147 		{
       
  3148 		case 0:
       
  3149 			{
       
  3150 			_LIT(AutoFocusTest,"FocusEvents");
       
  3151 			iQueueClient->EnableFocusChangeEvents();
       
  3152 			iEventTestGroup2=new(ELeave) CTWindowGroup(TheClient);
       
  3153 			iEventTestGroup2->ConstructL();
       
  3154 			iEventTestGroup2->GroupWin()->SetName(AutoFocusTest);
       
  3155 			AddExpectedEvent(EEventFocusGained);
       
  3156 			AddExpectedEvent(EEventFocusLost);
       
  3157 			AddExpectedEvent(EEventFocusGroupChanged);
       
  3158 			AddExpectedEvent(EEventWindowGroupsChanged);
       
  3159 			}
       
  3160 			break;
       
  3161 		case 1:
       
  3162 			iEventTestGroup2->GroupWin()->EnableReceiptOfFocus(EFalse);
       
  3163 			AddExpectedEvent(EEventFocusGained);
       
  3164 			AddExpectedEvent(EEventFocusGroupChanged);
       
  3165 			break;
       
  3166 		case 2:
       
  3167 			iEventTestGroup2->GroupWin()->EnableReceiptOfFocus(ETrue);
       
  3168 			AddExpectedEvent(EEventFocusLost);
       
  3169 			AddExpectedEvent(EEventFocusGroupChanged);
       
  3170 			break;
       
  3171 		case 3:
       
  3172 			iEventTestGroup2->GroupWin()->SetOrdinalPosition(999);
       
  3173 			AddExpectedEvent(EEventFocusGained);
       
  3174 			AddExpectedEvent(EEventFocusGroupChanged);
       
  3175 			break;
       
  3176 		case 4:
       
  3177 			iEventTestGroup2->GroupWin()->SetOrdinalPosition(0);
       
  3178 			AddExpectedEvent(EEventFocusLost);
       
  3179 			AddExpectedEvent(EEventFocusGroupChanged);
       
  3180 			break;
       
  3181 		case 5:
       
  3182 			delete iEventTestGroup2;
       
  3183 			iEventTestGroup2=NULL;
       
  3184 			AddExpectedEvent(EEventWindowGroupsChanged);
       
  3185 			AddExpectedEvent(EEventFocusGroupChanged);
       
  3186 			break;
       
  3187 		default:
       
  3188 			CActiveScheduler::Stop();
       
  3189 			break;
       
  3190 		}
       
  3191 	TheClient->iWs.Flush();
       
  3192 	}
       
  3193 
       
  3194 	
       
  3195 void CTEventTest::StopEvents_NextSetOfEventsL()
       
  3196 	{
       
  3197 	// we are not running tests 0,1,2 as they currently fail
       
  3198 	if(iEventSet==0)
       
  3199 		{
       
  3200 		iEventSet=3;
       
  3201 		AddExpectedEvent(EEventFocusGained);
       
  3202 		}
       
  3203 	TInt retVal	= KErrNone;
       
  3204 				
       
  3205 	switch(iEventSet++)
       
  3206 		{
       
  3207 		case 0: // doesn't work if shell gets the off events - will fail on User::LeaveIfError(....
       
  3208 			iQueueClient->iWs.Flush();
       
  3209 			User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iGroup->WinTreeNode()));
       
  3210 			iTest->SimulateEvent(TRawEvent::ESwitchOff);
       
  3211 			TheClient->iWs.Flush();
       
  3212 			retVal = iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iWin->WinTreeNode());
       
  3213 			TEST(retVal==KErrAlreadyExists);
       
  3214 			if (retVal!=KErrAlreadyExists)
       
  3215 				INFO_PRINTF3(_L("iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iWin->WinTreeNode()) return value - Expected: %d, Actual: %d"), KErrAlreadyExists, retVal);
       
  3216 			User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(EFalse,iQueueClient->iGroup->WinTreeNode()));
       
  3217 			User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iGroup->WinTreeNode()));
       
  3218 			iTest->SimulateEvent(TRawEvent::ESwitchOff);
       
  3219 			TheClient->iWs.Flush();
       
  3220 			retVal = iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iGroup->WinTreeNode());
       
  3221 			TEST(retVal==KErrAlreadyExists);
       
  3222 			if (retVal!=KErrAlreadyExists)
       
  3223 				INFO_PRINTF3(_L("iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iGroup->WinTreeNode()) return value - Expected: %d, Actual: %d"), KErrAlreadyExists, retVal);
       
  3224 			User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(EFalse));
       
  3225 			AddExpectedEvent(EEventFocusGained);
       
  3226 			AddExpectedEvent(EEventSwitchOff);
       
  3227 			AddExpectedEvent(EEventSwitchOff);
       
  3228 			break;
       
  3229 			
       
  3230 		case 1: // doesn't work if shell gets the off events - will fail on User::LeaveIfError(....
       
  3231 			{
       
  3232 			TKeyEvent event; 
       
  3233 			iQueueClient->iWs.Flush();
       
  3234 			User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iGroup->WinTreeNode()));
       
  3235 			event.iCode=EKeyOff;
       
  3236 			event.iScanCode=EKeyOff;
       
  3237 			event.iModifiers=0;
       
  3238 			event.iRepeats=0;
       
  3239 			TheClient->iWs.SimulateKeyEvent(event);
       
  3240 			TheClient->iWs.Flush();
       
  3241 			User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(EFalse));
       
  3242 			AddExpectedEvent(EEventKeySwitchOff);
       
  3243 			}
       
  3244 			break;
       
  3245 		
       
  3246 		case 2: // doesn't work if shell gets the off events - will fail on User::LeaveIfError(....
       
  3247 			{
       
  3248 			TKeyEvent event;
       
  3249 			event.iCode=EKeyOff;
       
  3250 			event.iScanCode=EKeyOff;
       
  3251 			event.iModifiers=0;
       
  3252 			event.iRepeats=0;
       
  3253 			iQueueClient->iWs.Flush();
       
  3254 			User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iGroup->WinTreeNode()));
       
  3255 			iTest->SimulateEvent(TRawEvent::ESwitchOff);
       
  3256 			TheClient->iWs.SimulateKeyEvent(event);
       
  3257 			iTest->SimulateEvent(TRawEvent::ECaseClose);
       
  3258 			TheClient->iWs.Flush();
       
  3259 			retVal = iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iWin->WinTreeNode());
       
  3260 			TEST(retVal==KErrAlreadyExists);
       
  3261 			if (retVal!=KErrAlreadyExists)
       
  3262 				INFO_PRINTF3(_L("iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iWin->WinTreeNode()) return value - Expected: %d, Actual: %d"), KErrAlreadyExists, retVal);
       
  3263 			iTest->SimulateEvent(TRawEvent::ESwitchOff);
       
  3264 			iTest->SimulateEvent(TRawEvent::ECaseClose);
       
  3265 			TheClient->iWs.SimulateKeyEvent(event);
       
  3266 			TheClient->iWs.Flush();
       
  3267 			User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(EFalse,iQueueClient->iGroup->WinTreeNode()));
       
  3268 			User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iWin->WinTreeNode()));
       
  3269 			iTest->SimulateEvent(TRawEvent::ECaseClose);
       
  3270 			iTest->SimulateEvent(TRawEvent::ESwitchOff);
       
  3271 			TheClient->iWs.SimulateKeyEvent(event);
       
  3272 			TheClient->iWs.Flush();
       
  3273 			User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(EFalse));
       
  3274 			User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(ETrue,iQueueClient->iChildWin->WinTreeNode()));
       
  3275 			iTest->SimulateEvent(TRawEvent::ESwitchOff);
       
  3276 			TheClient->iWs.SimulateKeyEvent(event);
       
  3277 			iTest->SimulateEvent(TRawEvent::ECaseClose);
       
  3278 			TheClient->iWs.Flush();
       
  3279 			User::LeaveIfError(iQueueClient->iWs.RequestOffEvents(EFalse));
       
  3280 			AddExpectedEvent(EEventSwitchOff);
       
  3281 			AddExpectedEvent(EEventKeySwitchOff);
       
  3282 			AddExpectedEvent(EEventCaseClosed);
       
  3283 			AddExpectedEvent(EEventSwitchOff);
       
  3284 			AddExpectedEvent(EEventCaseClosed);
       
  3285 			AddExpectedEvent(EEventKeySwitchOff);
       
  3286 			AddExpectedEvent(EEventCaseClosed,iQueueClient->iWin);
       
  3287 			AddExpectedEvent(EEventSwitchOff,iQueueClient->iWin);
       
  3288 			AddExpectedEvent(EEventKeySwitchOff,iQueueClient->iWin);
       
  3289 			AddExpectedEvent(EEventSwitchOff,iQueueClient->iChildWin);
       
  3290 			AddExpectedEvent(EEventKeySwitchOff,iQueueClient->iChildWin);
       
  3291 			AddExpectedEvent(EEventCaseClosed,iQueueClient->iChildWin);
       
  3292 			}
       
  3293 			break;
       
  3294 			
       
  3295 		case 3: 
       
  3296 			iQueueClient->iWs.Flush();
       
  3297 			//User::LeaveIfError(iQueueClient->iGroup->WinTreeNode()->EnableOnEvents(EEventControlAlways));
       
  3298 			iTest->SimulateEvent(TRawEvent::ESwitchOn);
       
  3299 			iTest->SimulateEvent(TRawEvent::ECaseOpen);
       
  3300 			TheClient->iWs.Flush();
       
  3301 			User::LeaveIfError(iQueueClient->iWin->WinTreeNode()->EnableOnEvents(EEventControlAlways));
       
  3302 			iTest->SimulateEvent(TRawEvent::ECaseOpen);
       
  3303 			iTest->SimulateEvent(TRawEvent::ESwitchOn);
       
  3304 			TheClient->iWs.Flush();
       
  3305 			iQueueClient->iWin->WinTreeNode()->DisableOnEvents();
       
  3306 			AddExpectedEvent(EEventSwitchOn);
       
  3307 			//AddExpectedEvent(EEventSwitchOn);
       
  3308 			AddExpectedEvent(EEventCaseOpened);
       
  3309 			AddExpectedEvent(EEventCaseOpened,iQueueClient->iWin);
       
  3310 			AddExpectedEvent(EEventCaseOpened);
       
  3311 			AddExpectedEvent(EEventSwitchOn,iQueueClient->iWin);
       
  3312 			AddExpectedEvent(EEventSwitchOn);
       
  3313 			break;
       
  3314 			
       
  3315 		case 4:
       
  3316 			iQueueClient->iWs.Flush();
       
  3317 			// switch off the device
       
  3318 			iTest->SimulateEvent(TRawEvent::ESwitchOff);
       
  3319 			// switch it back on. 
       
  3320 			iTest->SimulateEvent(TRawEvent::ESwitchOn);
       
  3321 			TheClient->iWs.Flush();	
       
  3322 			// TRawEvent::ESwitchOff never actually comes back. The tests will hang if we look for one
       
  3323 			AddExpectedEvent(EEventSwitchOn);
       
  3324 			break;
       
  3325 			
       
  3326 		case 5:
       
  3327 			{
       
  3328 			TKeyEvent event; 
       
  3329 			iQueueClient->iWs.Flush();
       
  3330 			event.iCode=EKeyOff;
       
  3331 			event.iScanCode=EKeyOff;
       
  3332 			event.iModifiers=0;
       
  3333 			event.iRepeats=0;
       
  3334 			// switch off the device - this one seems to send it to standby rather than off
       
  3335 			TheClient->iWs.SimulateKeyEvent(event);
       
  3336 			// switch it back on or no further tests will complete
       
  3337 			iTest->SimulateEvent(TRawEvent::ESwitchOn);
       
  3338 			TheClient->iWs.Flush();	
       
  3339 			// again we would expect EEventKeySwitchOff but it doesn't come back. The tests will hang if we look for one
       
  3340 			AddExpectedEvent(EEventSwitchOn);
       
  3341 			}
       
  3342 			break;
       
  3343 		
       
  3344 		case 6:
       
  3345 			iQueueClient->iWs.Flush();
       
  3346 			iTest->SimulateEvent(TRawEvent::ESwitchOn);
       
  3347 			iTest->SimulateEvent(TRawEvent::ECaseOpen);
       
  3348 			TheClient->iWs.Flush();
       
  3349 			User::LeaveIfError(iQueueClient->iWin->WinTreeNode()->EnableOnEvents(EEventControlAlways));
       
  3350 			iTest->SimulateEvent(TRawEvent::ECaseOpen);
       
  3351 			iTest->SimulateEvent(TRawEvent::ESwitchOn);
       
  3352 			TheClient->iWs.Flush();
       
  3353 			iQueueClient->iWin->WinTreeNode()->DisableOnEvents();
       
  3354 			AddExpectedEvent(EEventSwitchOn);
       
  3355 			AddExpectedEvent(EEventCaseOpened);
       
  3356 			AddExpectedEvent(EEventCaseOpened,iQueueClient->iWin);
       
  3357 			AddExpectedEvent(EEventCaseOpened);
       
  3358 			AddExpectedEvent(EEventSwitchOn,iQueueClient->iWin);
       
  3359 			AddExpectedEvent(EEventSwitchOn);
       
  3360 			break;
       
  3361 					
       
  3362 		default:
       
  3363 			CActiveScheduler::Stop();
       
  3364 			break;
       
  3365 		}
       
  3366 	TheClient->iWs.Flush();
       
  3367 	}
       
  3368 	
       
  3369 void CTEventTest::VirtualKeyboard_NextSetOfEventsL()
       
  3370 	{
       
  3371 	const TInt noVirtualKeys=10;
       
  3372 	const TInt keyWidth=2*EWinWidth/noVirtualKeys/3;
       
  3373 	const TInt keyHeight=EWinHeight/2;
       
  3374 	const TInt keySpacing=EWinWidth/noVirtualKeys;
       
  3375 	const TInt baseChar='1';
       
  3376 	TInt startX=1;
       
  3377 	TInt ii;
       
  3378 	switch(iEventSet++)
       
  3379 		{
       
  3380 		case 0:
       
  3381 			iQueueClient->iWin->BaseWin()->SetPointerGrab(EFalse);
       
  3382 			for (ii=0;ii<noVirtualKeys;++ii)
       
  3383 				{
       
  3384 				iQueueClient->iWin->BaseWin()->AddKeyRect(TRect(startX,1,startX+keyWidth,keyHeight),baseChar+ii,EFalse);
       
  3385 				startX+=keySpacing;
       
  3386 				}
       
  3387 			iQueueClient->iWs.Flush();
       
  3388 			iTest->SimulatePointerDownUp(EWinPositionX+1,EWinPositionY+1+iYOffset);
       
  3389 			//TheClient->iWs.Flush();
       
  3390 			AddExpectedEvent(EEventFocusGained);
       
  3391 			AddExpectedKeyDownUp(baseChar);
       
  3392 			break;
       
  3393 		case 1:
       
  3394 			startX=3;
       
  3395 			for (ii=0;ii<noVirtualKeys-2;++ii)		//Can't do all 10 as this will overflow the event buffer
       
  3396 				{
       
  3397 				iTest->SimulatePointerDownUp(startX+EWinPositionX+1,EWinPositionY+keyHeight-1+iYOffset);
       
  3398 				AddExpectedKeyDownUp(baseChar+ii);
       
  3399 				startX+=keySpacing;
       
  3400 				}
       
  3401 			break;
       
  3402 		case 2:
       
  3403 			SimulatePointerDownUpWin(keySpacing+1,1);
       
  3404 			//SimulatePointerDownUp(EWinPositionX+keySpacing+1,EWinPositionY+1);
       
  3405 			iTest->SimulatePointerDownUp(EWinPositionX+keyWidth,EWinPositionY+1+iYOffset);
       
  3406 			iTest->SimulatePointerDownUp(EWinPositionX+1,EWinPositionY+keyHeight-1+iYOffset);
       
  3407 			iTest->SimulatePointerDownUp(EWinPositionX+keyWidth,EWinPositionY+keyHeight-1+iYOffset);
       
  3408 			AddExpectedKeyDownUp(baseChar+1);
       
  3409 			AddExpectedKeyDownUp(baseChar);
       
  3410 			AddExpectedKeyDownUp(baseChar);
       
  3411 			AddExpectedKeyDownUp(baseChar);
       
  3412 			break;
       
  3413 		case 3:
       
  3414 			SimulatePointerDownUpWin(keySpacing+3,4);
       
  3415 			SimulatePointerDownUpWin(0,0);		//No Pointer event get through even if there are gaps
       
  3416 			SimulatePointerDownUpWin(1,0);
       
  3417 			SimulatePointerDownUpWin(0,1);
       
  3418 			SimulatePointerDownUpWin(keyWidth+1,0);
       
  3419 			SimulatePointerDownUpWin(keyWidth,0);
       
  3420 			SimulatePointerDownUpWin(keyWidth+1,1);
       
  3421 			SimulatePointerDownUpWin(0,keyHeight);
       
  3422 			SimulatePointerDownUpWin(1,keyHeight);
       
  3423 			SimulatePointerDownUpWin(0,keyHeight-1);
       
  3424 			SimulatePointerDownUpWin(keyWidth+1,keyHeight);
       
  3425 			SimulatePointerDownUpWin(keyWidth,keyHeight);
       
  3426 			SimulatePointerDownUpWin(keyWidth+1,keyHeight-1);
       
  3427 			SimulatePointerDownUpWin(2*keySpacing+3,4);
       
  3428 			AddExpectedKeyDownUp(baseChar+1);
       
  3429 			AddExpectedPointerDownUpScr(TPoint(EWinPositionX+0,EWinPositionY+0));		//No Pointer event get through even if there are gaps
       
  3430 			AddExpectedPointerDownUpScr(TPoint(EWinPositionX+1,EWinPositionY+0));
       
  3431 			AddExpectedPointerDownUpScr(TPoint(EWinPositionX+0,EWinPositionY+1));
       
  3432 			AddExpectedPointerDownUpScr(TPoint(EWinPositionX+keyWidth+1,EWinPositionY+0));
       
  3433 			AddExpectedPointerDownUpScr(TPoint(EWinPositionX+keyWidth,EWinPositionY+0));
       
  3434 			AddExpectedPointerDownUpScr(TPoint(EWinPositionX+keyWidth+1,EWinPositionY+1));
       
  3435 			AddExpectedPointerDownUpScr(TPoint(EWinPositionX+0,EWinPositionY+keyHeight));
       
  3436 			AddExpectedPointerDownUpScr(TPoint(EWinPositionX+1,EWinPositionY+keyHeight));
       
  3437 			AddExpectedPointerDownUpScr(TPoint(EWinPositionX+0,EWinPositionY+keyHeight-1));
       
  3438 			AddExpectedPointerDownUpScr(TPoint(EWinPositionX+keyWidth+1,EWinPositionY+keyHeight));
       
  3439 			AddExpectedPointerDownUpScr(TPoint(EWinPositionX+keyWidth,EWinPositionY+keyHeight));
       
  3440 			AddExpectedPointerDownUpScr(TPoint(EWinPositionX+keyWidth+1,EWinPositionY+keyHeight-1));
       
  3441 			AddExpectedKeyDownUp(baseChar+2);
       
  3442 			break;
       
  3443 		case 4:
       
  3444 			SimulatePointerWin(TRawEvent::EButton1Down,keySpacing+2,6);
       
  3445 			SimulatePointerWin(TRawEvent::EButton1Up,2*keySpacing+1,5);
       
  3446 			SimulatePointerWin(TRawEvent::EButton1Down,2*keySpacing+2,7);
       
  3447 			SimulatePointer(TRawEvent::EButton1Up,0,0);
       
  3448 			AddExpectedKeyDownUp(baseChar+1);
       
  3449 			AddExpectedKeyDownUp(baseChar+2);
       
  3450 			break;
       
  3451 		default:
       
  3452 			CActiveScheduler::Stop();
       
  3453 			break;
       
  3454 		}
       
  3455 	TheClient->iWs.Flush();
       
  3456 	}
       
  3457 
       
  3458 TInt CTEventTest::ClickCommandReply(TInt aCommand,TInt aData)
       
  3459 	{
       
  3460 	TPckgBuf<TInt> intPkg;
       
  3461 	intPkg()=aData;
       
  3462 	return iClick.CommandReply(aCommand,intPkg);
       
  3463 	}
       
  3464 
       
  3465 TInt CTEventTest::CreateGroupWindow(RWindowGroup& aWinGp,TClients aClient,TInt& aWinGpId)
       
  3466 	{
       
  3467 	ClickCommandReply(EClickCreateGroupWin,aClient);
       
  3468 	TInt err=aWinGp.Construct(ENullWsHandle,EFalse);
       
  3469 	if (!err)
       
  3470 		{
       
  3471 		aWinGpId=aWinGp.Identifier();
       
  3472 		ClickCommandReply(EClickCheckGpWinId,aWinGpId);
       
  3473 		}
       
  3474 	return err;
       
  3475 	}
       
  3476 
       
  3477 void CTEventTest::CloseGroupWindow(RWindowGroup& aWinGp,TInt aWinGpId)
       
  3478 	{
       
  3479 	ClickCommandReply(EClickCloseGroupWin,aWinGpId);
       
  3480 	aWinGp.Close();
       
  3481 	}
       
  3482 
       
  3483 void CTEventTest::CloseWindow(RWindowBase& aWin,TInt aHandle,TInt aWinGpId)
       
  3484 	{
       
  3485 	TPckgBuf<TWindowCloseData> winClose;
       
  3486 	winClose().iClientHandle=aHandle;
       
  3487 	winClose().iWindowGroupId=aWinGpId;
       
  3488 	iClick.CommandReply(EClickCloseWin,winClose);
       
  3489 	aWin.Close();
       
  3490 	}
       
  3491 
       
  3492 /**
       
  3493 @SYMTestCaseID		GRAPHICS-WSERV-0447
       
  3494 
       
  3495 @SYMCR				CR1164
       
  3496 
       
  3497 @SYMTestCaseDesc	Tests that Key Click Plug-in gets new event Information
       
  3498 
       
  3499 @SYMTestPriority	High
       
  3500 
       
  3501 @SYMTestStatus		Implemented
       
  3502 
       
  3503 @SYMTestActions		Do things that cause the new events to be sent into plug-in.
       
  3504 Creating destroying windows, pointer events.  Provide test plug-in with information it needs to check events.
       
  3505 
       
  3506 @SYMTestExpectedResults When Test Plug-in is querried to see if events match what was expected it says that they were.
       
  3507 */
       
  3508 void CTEventTest::KeyClicks_NextSetOfEvents()
       
  3509 	{
       
  3510 #if defined(LOGGING)
       
  3511 	TLogMessageText logMessageText;
       
  3512 	_LIT(KSet,"KeyClicks SetOfEvents: %d (last=13)");
       
  3513 	logMessageText.Format(KSet,iEventSet);
       
  3514 	INFO_PRINTF1(logMessageText);
       
  3515 #endif
       
  3516 	TInt events=-1;
       
  3517 	switch(iEventSet++)
       
  3518 		{
       
  3519 		case 0:
       
  3520 			if (SetClickType(EClickCheck))
       
  3521 				return;
       
  3522 			iAddToClick=ETrue;
       
  3523 			iQueueClient->iWin->BaseWin()->SetPointerGrab(EFalse);
       
  3524 			iQueueClient->iChildWin->BaseWin()->SetPointerGrab(EFalse);
       
  3525 			AddExpectedEvent(EEventFocusGained);
       
  3526 			AddExpectedKeyDownUp(EStdKeySpace,EKeySpace);
       
  3527 			iQueueClient->iWs.Flush();
       
  3528 			iTest->SimulateKeyDownUp(EStdKeySpace);		//3 events
       
  3529 			events=3;
       
  3530 			break;
       
  3531 		case 1:
       
  3532 			AddExpectedKeyDownUp(EStdKeyEnter,EKeyEnter);
       
  3533 			AddExpectedKeyDownUp('0');
       
  3534 			AddExpectedKeyDownUp('A','a');
       
  3535 			AddExpectedKeyDownUp('X','x');
       
  3536 			AddExpectedKey(EEventKeyDown,EStdKeyLeftShift,0,0,EModifierLeftShift|EModifierShift);
       
  3537 			AddExpectedKey(EEventKeyUp,EStdKeyLeftShift);
       
  3538 			iQueueClient->iWs.Flush();
       
  3539 			iTest->SimulateKeyDownUp(EStdKeyEnter);		//3 events
       
  3540 			iTest->SimulateKeyDownUp('0');		//3 events
       
  3541 			iTest->SimulateKeyDownUp('A');		//3 events
       
  3542 			iTest->SimulateKeyDownUp('X');		//3 events
       
  3543 			iTest->SimulateKeyDownUp(EStdKeyLeftShift);		//2 events
       
  3544 			events=14;
       
  3545 			break;
       
  3546 		case 2:
       
  3547 			AddExpectedKey(EEventKeyDown,EStdKeyRightShift,0,0,EModifierRightShift|EModifierShift);
       
  3548 			AddExpectedKeyDownUp('B','B',0,EModifierRightShift|EModifierShift);
       
  3549 			AddExpectedKeyDownUp('W','W',0,EModifierRightShift|EModifierShift);
       
  3550 			AddExpectedKey(EEventKeyUp,EStdKeyRightShift);
       
  3551 			iQueueClient->iWs.Flush();
       
  3552 			iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeyRightShift);		//1 event
       
  3553 			iTest->SimulateKeyDownUp('B');		//3 events
       
  3554 			iTest->SimulateKeyDownUp('W');		//3 events
       
  3555 			iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeyRightShift);		//1 event
       
  3556 			events=8;
       
  3557 			break;
       
  3558 		case 3:
       
  3559 			AddExpectedKey(EEventKeyDown,'C');
       
  3560 			AddExpectedKey(EEventKey,'C','c');
       
  3561 			AddExpectedKey(EEventKeyDown,'V');
       
  3562 			AddExpectedKey(EEventKey,'V','v');
       
  3563 			AddExpectedKey(EEventKeyUp,'C');
       
  3564 			AddExpectedKey(EEventKeyUp,'V');
       
  3565 			iQueueClient->iWs.Flush();
       
  3566 			iTest->SimulateKey(TRawEvent::EKeyDown,'C');		//2 events
       
  3567 			iTest->SimulateKey(TRawEvent::EKeyDown,'V');		//2 events
       
  3568 			iTest->SimulateKey(TRawEvent::EKeyUp,'C');		//1 event
       
  3569 			iTest->SimulateKey(TRawEvent::EKeyUp,'V');		//1 event
       
  3570 			events=6;
       
  3571 			break;
       
  3572 		case 4:
       
  3573 			{
       
  3574 			AddExpectedKey(EEventKeyDown,'D');
       
  3575 			AddExpectedKey(EEventKey,'D','d');
       
  3576 			AddExpectedKey(EEventKey,'D','d',1);
       
  3577 			AddExpectedKey(EEventKeyUp,'D');
       
  3578 			iQueueClient->iWs.Flush();
       
  3579 			iTest->SimulateKey(TRawEvent::EKeyDown,'D');		//2 events
       
  3580 			TTimeIntervalMicroSeconds32 initialTime,time;
       
  3581 			TheClient->iWs.GetKeyboardRepeatRate(initialTime,time);
       
  3582 			User::After(initialTime.Int()+time.Int()/4);		//1 event
       
  3583 			iTest->SimulateKey(TRawEvent::EKeyUp,'D');		//1 event
       
  3584 			events=4;
       
  3585 			}
       
  3586 			break;
       
  3587 		case 5:
       
  3588 			AddExpectedPointerDownUpScr(TPoint(40,25));
       
  3589 			AddExpectedPointerDownUpScr(TPoint(95,30));
       
  3590 			AddExpectedPointer(TPointerEvent::EButton1Down,TPoint(20-EWinPositionX,50-EWinPositionY));
       
  3591 			AddExpectedPointer(TPointerEvent::EDrag,TPoint(45-EWinPositionX,42-EWinPositionY));
       
  3592 			AddExpectedPointer(TPointerEvent::EButton1Up,TPoint(45-EWinPositionX,42-EWinPositionY));
       
  3593 			AddExpectedPointer(TPointerEvent::EButton1Down,TPoint(98-EWinPositionX,15-EWinPositionY));
       
  3594 			AddExpectedPointerClick(TPointerEvent::EDrag,TPoint(68-EWinPositionX,39-EWinPositionY));
       
  3595 			AddExpectedPointer(TPointerEvent::EDrag,TPoint(41-EWinPositionX,42-EWinPositionY));
       
  3596 			AddExpectedPointer(TPointerEvent::EButton1Up,TPoint(50-EWinPositionX,58-EWinPositionY));
       
  3597 			iQueueClient->iWs.Flush();
       
  3598 			iTest->SimulatePointerDownUp(40,25+iYOffset);		//2 events
       
  3599 			iTest->SimulatePointerDownUp(95,30+iYOffset);		//2 events
       
  3600 			SimulatePointer(TRawEvent::EButton1Down,20,50);		//1 event
       
  3601 			SimulatePointer(TRawEvent::EPointerMove,45,42);		//1 event
       
  3602 			SimulatePointer(TRawEvent::EButton1Up,45,42);		//1 event
       
  3603 			SimulatePointer(TRawEvent::EButton1Down,98,15);		//1 event
       
  3604 			SimulatePointer(TRawEvent::EPointerMove,68,39);		//1 event
       
  3605 			SimulatePointer(TRawEvent::EPointerMove,41,42);		//1 event
       
  3606 			SimulatePointer(TRawEvent::EButton1Up,50,58);		//1 event
       
  3607 			events=11;
       
  3608 			break;
       
  3609 		case 6:
       
  3610 			AddExpectedKey(EEventKeyDown,'E');
       
  3611 			AddExpectedKey(EEventKey,'E','e');
       
  3612 			AddExpectedPointerDownUpScr(TPoint(41,24));
       
  3613 			AddExpectedKey(EEventKeyUp,'E');
       
  3614 			AddExpectedPointer(TPointerEvent::EButton1Down,TPoint(23-EWinPositionX,52-EWinPositionY));
       
  3615 			AddExpectedKeyDownUp('1');
       
  3616 			AddExpectedPointer(TPointerEvent::EButton1Up,TPoint(44-EWinPositionX,45-EWinPositionY));
       
  3617 			AddExpectedPointer(TPointerEvent::EButton1Down,TPoint(33-EWinPositionX,53-EWinPositionY));
       
  3618 			AddExpectedKey(EEventKeyDown,'F');
       
  3619 			AddExpectedKey(EEventKey,'F','f');
       
  3620 			AddExpectedPointer(TPointerEvent::EButton1Up,TPoint(34-EWinPositionX,47-EWinPositionY));
       
  3621 			AddExpectedKey(EEventKeyUp,'F');
       
  3622 			iQueueClient->iWs.Flush();
       
  3623 			iTest->SimulateKey(TRawEvent::EKeyDown,'E');		//2 events
       
  3624 			iTest->SimulatePointerDownUp(41,24+iYOffset);		//2 events
       
  3625 			iTest->SimulateKey(TRawEvent::EKeyUp,'E');		//1 event
       
  3626 			SimulatePointer(TRawEvent::EButton1Down,23,52);		//1 event
       
  3627 			iTest->SimulateKeyDownUp('1');		//3 events
       
  3628 			SimulatePointer(TRawEvent::EButton1Up,44,45);		//1 event
       
  3629 			SimulatePointer(TRawEvent::EButton1Down,33,53);		//1 event
       
  3630 			iTest->SimulateKey(TRawEvent::EKeyDown,'F');		//2 events
       
  3631 			SimulatePointer(TRawEvent::EButton1Up,34,47);		//1 event
       
  3632 			iTest->SimulateKey(TRawEvent::EKeyUp,'F');		//1 event
       
  3633 			events=15;
       
  3634 			break;
       
  3635 		case 7:
       
  3636 			AddExpectedKeyDownUp('2');
       
  3637 			iAddToClick=EFalse;
       
  3638 			AddExpectedKeyDownUp('G','g');
       
  3639 			iAddToClick=ETrue;
       
  3640 			AddExpectedPointerDownUpScr(TPoint(42,26));
       
  3641 			AddExpectedKeyDownUp('U','u');
       
  3642 			iQueueClient->iWs.Flush();
       
  3643 			iTest->SimulateKeyDownUp('2');		//3 events
       
  3644 			TheClient->iWs.Flush();
       
  3645 			iQueueClient->iGroup->GroupWin()->DisableKeyClick(ETrue);
       
  3646 			iQueueClient->iWs.Flush();
       
  3647 			iTest->SimulateKeyDownUp('G');
       
  3648 			iTest->SimulatePointerDownUp(42,26+iYOffset);		//2 events
       
  3649 			TheClient->iWs.Flush();
       
  3650 			iQueueClient->iGroup->GroupWin()->DisableKeyClick(EFalse);
       
  3651 			iQueueClient->iWs.Flush();
       
  3652 			iTest->SimulateKeyDownUp('U');		//3 events
       
  3653 			events=8;
       
  3654 			break;
       
  3655 		case 8:
       
  3656 			{
       
  3657 			TPckgBuf<TPointerEventInfo> pointerEventInfo;
       
  3658 			pointerEventInfo().iClientHandle=reinterpret_cast<TInt>(iQueueClient->iChildWin);
       
  3659 			pointerEventInfo().iWinGpId=iQueueClient->iGroup->GroupWin()->Identifier();
       
  3660 			pointerEventInfo().iWinOrigin=iQueueClient->ChildTopLeft();
       
  3661 			pointerEventInfo().iParentOrigin.SetXY(EWinPositionX,EWinPositionY);
       
  3662 			iClick.CommandReply(EClickPointerEvent,pointerEventInfo);
       
  3663 			AddExpectedKeyDownUp('3');
       
  3664 			AddExpectedPointerDownUpScr(TPoint(43,26));
       
  3665 			AddExpectedKeyDownUp('H','h');
       
  3666 			iAddToClick=EFalse;
       
  3667 			AddExpectedPointerDownUpScr(TPoint(43,27));
       
  3668 			AddExpectedKeyDownUp('4');
       
  3669 			AddExpectedPointerDownUpScr(TPoint(42,27));
       
  3670 			AddExpectedKeyDownUp('I','i');
       
  3671 			iAddToClick=ETrue;
       
  3672 			AddExpectedPointerDownUpScr(TPoint(44,27));
       
  3673 			AddExpectedKeyDownUp('5');
       
  3674 			AddExpectedPointerDownUpScr(TPoint(44,26));
       
  3675 			iQueueClient->iWs.Flush();
       
  3676 			iTest->SimulateKeyDownUp('3');		//3 events
       
  3677 			iTest->SimulatePointerDownUp(43,26+iYOffset);		//2 events
       
  3678 			iClick.SetPenClick(EFalse);
       
  3679 			iTest->SimulateKeyDownUp('H');		//3 events
       
  3680 			iTest->SimulatePointerDownUp(43,27+iYOffset);
       
  3681 			iClick.SetKeyClick(EFalse);
       
  3682 			iTest->SimulateKeyDownUp('4');
       
  3683 			iTest->SimulatePointerDownUp(42,27+iYOffset);
       
  3684 			iClick.SetPenClick(ETrue);
       
  3685 			iTest->SimulateKeyDownUp('I');
       
  3686 			iTest->SimulatePointerDownUp(44,27+iYOffset);		//2 events
       
  3687 			iClick.SetKeyClick(ETrue);
       
  3688 			iTest->SimulateKeyDownUp('5');		//3 events
       
  3689 			iTest->SimulatePointerDownUp(44,26+iYOffset);		//2 events
       
  3690 			pointerEventInfo().iClientHandle=0;
       
  3691 			pointerEventInfo().iWinGpId=0;
       
  3692 			iClick.CommandReply(EClickPointerEvent,pointerEventInfo);
       
  3693 			events=15;
       
  3694 			}
       
  3695 			break;
       
  3696 		case 9:
       
  3697 			{
       
  3698 			RWindowGroup winGp(iQueueClient->iWs);
       
  3699 			TInt winGpId;
       
  3700 			TInt ii;
       
  3701 			AddExpectedEvent(EEventWindowGroupsChanged);
       
  3702 			for (ii=0;ii<2;++ii)	//events x2
       
  3703 				{
       
  3704 				if (CreateGroupWindow(winGp,EQueueClient,winGpId))		//1 event
       
  3705 					Failed();
       
  3706 				CloseGroupWindow(winGp,winGpId);		//1 event
       
  3707 				iQueueClient->iWs.Flush();
       
  3708 				}
       
  3709 			events=4;
       
  3710 			}
       
  3711 			break;
       
  3712 		case 10:
       
  3713 			{
       
  3714 			RWindowGroup winGp(TheClient->iWs);
       
  3715 			RWindowGroup winGp1(iQueueClient->iWs);
       
  3716 			RWindowGroup winGp2(iQueueClient->iWs);
       
  3717 			TInt winGpId;
       
  3718 			TInt winGpId1;
       
  3719 			TInt winGpId2;
       
  3720 			AddExpectedEvent(EEventWindowGroupsChanged);
       
  3721 			if (CreateGroupWindow(winGp,ETheClient,winGpId))		//1 event
       
  3722 				Failed();
       
  3723 			CloseGroupWindow(winGp,winGpId);		//1 event
       
  3724 			TheClient->iWs.Flush();
       
  3725 			if (CreateGroupWindow(winGp1,EQueueClient,winGpId1))		//1 event
       
  3726 				Failed();
       
  3727 			if (CreateGroupWindow(winGp2,EQueueClient,winGpId2))		//1 event
       
  3728 				Failed();
       
  3729 			if (CreateGroupWindow(winGp,ETheClient,winGpId))		//1 event
       
  3730 				Failed();
       
  3731 			CloseGroupWindow(winGp2,winGpId2);		//1 event
       
  3732 			iQueueClient->iWs.Flush();
       
  3733 			CloseGroupWindow(winGp,winGpId);		//1 event
       
  3734 			TheClient->iWs.Flush();
       
  3735 			CloseGroupWindow(winGp1,winGpId1);		//1 event
       
  3736 			iQueueClient->iWs.Flush();
       
  3737 			events=8;
       
  3738 			}
       
  3739 			break;
       
  3740 		case 11:
       
  3741 			{
       
  3742 			RWindowGroup winGp(iQueueClient->iWs);
       
  3743 			TInt winGpId;
       
  3744 			AddExpectedEvent(EEventWindowGroupsChanged);
       
  3745 			if (CreateGroupWindow(winGp,EQueueClient,winGpId))		//1 event
       
  3746 				Failed();
       
  3747 			RWindow win(iQueueClient->iWs);
       
  3748 			const TInt handle=79;
       
  3749 			if (win.Construct(winGp,handle))
       
  3750 				Failed();
       
  3751 			win.Activate();
       
  3752 			CloseWindow(win,handle,winGpId);		//1 event
       
  3753 			iQueueClient->iWs.Flush();
       
  3754 			CloseGroupWindow(winGp,winGpId);		//1 event
       
  3755 			iQueueClient->iWs.Flush();
       
  3756 			events=3;
       
  3757 			}
       
  3758 			break;
       
  3759 		case 12:
       
  3760 			{
       
  3761 			RWindowGroup winGp1(iQueueClient->iWs);
       
  3762 			RWindowGroup winGp2(TheClient->iWs);
       
  3763 			TInt winGpId1;
       
  3764 			TInt winGpId2;
       
  3765 			AddExpectedEvent(EEventWindowGroupsChanged);
       
  3766 			if (CreateGroupWindow(winGp2,ETheClient,winGpId2))		//1 event
       
  3767 				Failed();
       
  3768 			if (CreateGroupWindow(winGp1,EQueueClient,winGpId1))		//1 event
       
  3769 				Failed();
       
  3770 			RWindow win1(iQueueClient->iWs);
       
  3771 			RWindow win2(iQueueClient->iWs);
       
  3772 			RWindow win(TheClient->iWs);
       
  3773 			const TInt handle1a=80;
       
  3774 			const TInt handle1b=81;
       
  3775 			const TInt handle2a=82;
       
  3776 			const TInt handle2b=83;
       
  3777 			const TInt handle=84;
       
  3778 			if (win1.Construct(winGp1,handle1a))
       
  3779 				Failed();
       
  3780 			win1.Activate();
       
  3781 			if (win2.Construct(win1,handle2a))
       
  3782 				Failed();
       
  3783 			win2.Activate();
       
  3784 			if (win.Construct(winGp2,handle))
       
  3785 				Failed();
       
  3786 			win.Activate();
       
  3787 			CloseWindow(win2,handle2a,winGpId1);		//1 event
       
  3788 			iQueueClient->iWs.Flush();
       
  3789 			if (win2.Construct(winGp1,handle2b))
       
  3790 				Failed();
       
  3791 			win2.Activate();
       
  3792 			CloseWindow(win1,handle1a,winGpId1);		//1 event
       
  3793 			iQueueClient->iWs.Flush();
       
  3794 			CloseWindow(win,handle,winGpId2);		//1 event
       
  3795 			TheClient->iWs.Flush();
       
  3796 			if (win1.Construct(win2,handle1b))
       
  3797 				Failed();
       
  3798 			win1.Activate();
       
  3799 			CloseWindow(win1,handle1b,winGpId1);		//1 event
       
  3800 			iQueueClient->iWs.Flush();
       
  3801 			CloseGroupWindow(winGp2,winGpId2);		//1 event
       
  3802 			TheClient->iWs.Flush();
       
  3803 			CloseWindow(win2,handle2b,winGpId1);		//1 event
       
  3804 			iQueueClient->iWs.Flush();
       
  3805 			CloseGroupWindow(winGp1,winGpId1);		//1 event
       
  3806 			iQueueClient->iWs.Flush();
       
  3807 			events=9;
       
  3808 			}
       
  3809 			break;
       
  3810 		case 13:
       
  3811 			{
       
  3812 			TPckgBuf<TPointerEventInfo> pointerEventInfo;
       
  3813 			pointerEventInfo().iClientHandle=reinterpret_cast<TInt>(iQueueClient->iWin);
       
  3814 			pointerEventInfo().iWinGpId=iQueueClient->iGroup->GroupWin()->Identifier();
       
  3815 			pointerEventInfo().iWinOrigin.SetXY(EWinPositionX,EWinPositionY);
       
  3816 			pointerEventInfo().iParentOrigin.SetXY(0,0);
       
  3817 			iClick.CommandReply(EClickPointerEvent,pointerEventInfo);
       
  3818 			AddExpectedPointerDownUpScr(TPoint(43,18));
       
  3819 			AddExpectedPointerDownUpScr(TPoint(43,17));
       
  3820 			AddExpectedPointerDownUpScr(TPoint(42,52));
       
  3821 			AddExpectedPointerDownUpScr(TPoint(24,27));
       
  3822 			AddExpectedPointerDownUpScr(TPoint(94,26));
       
  3823 			iQueueClient->iWs.Flush();
       
  3824 			iTest->SimulatePointerDownUp(43,18+iYOffset);		//2 events
       
  3825 			iTest->SimulatePointerDownUp(43,17+iYOffset);		//2 events
       
  3826 			iTest->SimulatePointerDownUp(42,52+iYOffset);		//2 events
       
  3827 			iTest->SimulatePointerDownUp(24,27+iYOffset);		//2 events
       
  3828 			iTest->SimulatePointerDownUp(94,26+iYOffset);		//2 events
       
  3829 			pointerEventInfo().iClientHandle=0;
       
  3830 			pointerEventInfo().iWinGpId=0;
       
  3831 			iClick.CommandReply(EClickPointerEvent,pointerEventInfo);
       
  3832 			events=10;
       
  3833 			}
       
  3834 			break;
       
  3835 		default:
       
  3836 			iAddToClick=EFalse;
       
  3837 			if (!SetClickType(EClickNone))
       
  3838 				CActiveScheduler::Stop();
       
  3839 			return;
       
  3840 		}
       
  3841 	TInt failedAt=iClick.CommandReply(EClickFailed,TPtrC8(NULL,0));
       
  3842 	TInt eventsDone=iClick.CommandReply(EClickEvents,TPtrC8(NULL,0));
       
  3843 	if (failedAt!=0 || eventsDone!=events)		//iEventSet (already incremented)
       
  3844 		{
       
  3845 	#if defined(LOGGING)
       
  3846 		_LIT(KeyClickFailed,"KeyClick Failed EventSet=%d FailedAt=%d TotalEvents=%d EventsDone=%d");
       
  3847 		logMessageText.Format(KeyClickFailed,iEventSet-1,failedAt,events,eventsDone);
       
  3848 		INFO_PRINTF1(logMessageText);
       
  3849 	#endif
       
  3850 		Failed();
       
  3851 		}
       
  3852 	iClick.CommandReply(EClickReset,TPtrC8(NULL,0));
       
  3853 	}
       
  3854 
       
  3855 void CTEventTest::CaptureLong_NextSetOfEventsL()
       
  3856 	{
       
  3857 	TTimeIntervalMicroSeconds32 initialTime,time;
       
  3858 	TheClient->iWs.GetKeyboardRepeatRate(initialTime,time);
       
  3859 	#if defined(LOGGING)
       
  3860 		TLogMessageText logMessageText;
       
  3861 		_LIT(KSet,"CaptureLong SetOfEvents: %d of 14");
       
  3862 		logMessageText.Format(KSet,iEventSet);
       
  3863 		INFO_PRINTF1(logMessageText);
       
  3864 	#endif
       
  3865 
       
  3866 	switch(iEventSet++)
       
  3867 		{
       
  3868 		case 0:
       
  3869 			iQueueClient->iWs.Flush();
       
  3870 			iTest->SimulateKeyDownUp('A');
       
  3871 			AddExpectedEvent(EEventFocusGained);
       
  3872 			AddExpectedKeyDownUp('A','a');
       
  3873 			break;
       
  3874 		case 1:
       
  3875 			iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureLongKey(' ','a',0,0,2,ELongCaptureNormal);
       
  3876 			iQueueClient->iWs.Flush();
       
  3877 			iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace);
       
  3878 			TheClient->iWs.Flush();
       
  3879 			User::After(initialTime.Int()+time.Int()/3);
       
  3880 			iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace);
       
  3881 			AddExpectedKey(EEventKeyDown,EStdKeySpace);
       
  3882 			AddExpectedKey(EEventKey,EStdKeySpace,' ');
       
  3883 			AddExpectedKey(EEventKey,EStdKeySpace,'a',1);
       
  3884 			AddExpectedKey(EEventKeyUp,EStdKeySpace);
       
  3885 			iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(iCaptureKey);
       
  3886 			break;
       
  3887 		case 2:
       
  3888 			iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureLongKey(' ','a',0,0,2,ELongCaptureWaitShort);
       
  3889 			iQueueClient->iWs.Flush();
       
  3890 			iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace);
       
  3891 			TheClient->iWs.Flush();
       
  3892 			User::After(initialTime.Int()+time.Int()/3);
       
  3893 			iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace);
       
  3894 			iTest->SimulateKeyDownUp(EStdKeySpace);
       
  3895 			AddExpectedKey(EEventKeyDown,EStdKeySpace);
       
  3896 			AddExpectedKey(EEventKey,EStdKeySpace,'a',1);
       
  3897 			AddExpectedKey(EEventKeyUp,EStdKeySpace);
       
  3898 			AddExpectedKeyDownUp(EStdKeySpace,' ');
       
  3899 			iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(iCaptureKey);
       
  3900 			break;
       
  3901 		case 3:
       
  3902 			iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureLongKey(' ','a',0,0,2,ELongCaptureNormal|ELongCaptureRepeatEvents);
       
  3903 			iQueueClient->iWs.Flush();
       
  3904 			iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace);
       
  3905 			TheClient->iWs.Flush();
       
  3906 			User::After(initialTime.Int()+5*time.Int());
       
  3907 			iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace);
       
  3908 			AddExpectedKey(EEventKeyDown,EStdKeySpace);
       
  3909 			AddExpectedKey(EEventKey,EStdKeySpace,' ');
       
  3910 			AddExpectedKey(EEventKey,EStdKeySpace,'a',2);
       
  3911 			AddExpectedKey(EEventKeyUp,EStdKeySpace);
       
  3912 			iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(iCaptureKey);
       
  3913 			break;
       
  3914 		case 4:
       
  3915 			iQueueClient->iWs.Flush();
       
  3916 			iTest->SimulateKey(TRawEvent::EKeyDown,'Z');
       
  3917 			TheClient->iWs.Flush();
       
  3918 			User::After(initialTime.Int()+3*time.Int());
       
  3919 			iTest->SimulateKey(TRawEvent::EKeyDown,'Y');
       
  3920 			TheClient->iWs.Flush();
       
  3921 			User::After(initialTime.Int()+2*time.Int());
       
  3922 			iTest->SimulateKey(TRawEvent::EKeyUp,'Z');
       
  3923 			iTest->SimulateKey(TRawEvent::EKeyUp,'Y');
       
  3924 			AddExpectedKey(EEventKeyDown,'Z');
       
  3925 			AddExpectedKey(EEventKey,'Z','z');
       
  3926 			AddExpectedKey(EEventKey,'Z','z',1);
       
  3927 			AddExpectedKey(EEventKeyDown,'Y');
       
  3928 			AddExpectedKey(EEventKey,'Y','y');
       
  3929 			AddExpectedKey(EEventKey,'Y','y',1);
       
  3930 			AddExpectedKey(EEventKeyUp,'Z');
       
  3931 			AddExpectedKey(EEventKeyUp,'Y');
       
  3932 			break;
       
  3933 		case 5:
       
  3934 			iQueueClient->iWs.Flush();
       
  3935 			iTest->SimulateKey(TRawEvent::EKeyDown,'Z');
       
  3936 			TheClient->iWs.Flush();
       
  3937 			User::After(initialTime.Int()+3*time.Int());
       
  3938 			iTest->SimulateKey(TRawEvent::EKeyDown,'Y');
       
  3939 			TheClient->iWs.Flush();
       
  3940 			User::After(initialTime.Int()+5*time.Int()/2);
       
  3941 			iTest->SimulateKey(TRawEvent::EKeyUp,'Y');
       
  3942 			TheClient->iWs.Flush();
       
  3943 			User::After(initialTime.Int()+2*time.Int());
       
  3944 			iTest->SimulateKey(TRawEvent::EKeyUp,'Z');
       
  3945 			AddExpectedKey(EEventKeyDown,'Z');
       
  3946 			AddExpectedKey(EEventKey,'Z','z');
       
  3947 			AddExpectedKey(EEventKey,'Z','z',1);
       
  3948 			AddExpectedKey(EEventKeyDown,'Y');
       
  3949 			AddExpectedKey(EEventKey,'Y','y');
       
  3950 			AddExpectedKey(EEventKey,'Y','y',1);
       
  3951 			AddExpectedKey(EEventKeyUp,'Y');
       
  3952 			AddExpectedKey(EEventKey,'Z','z',1);
       
  3953 			AddExpectedKey(EEventKeyUp,'Z');
       
  3954 			break;
       
  3955 		case 6:
       
  3956 			iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureLongKey(' ','b',0,0,2,ELongCaptureNormal);
       
  3957 			iQueueClient->iWs.Flush();
       
  3958 			iTest->SimulateKey(TRawEvent::EKeyDown,'X');
       
  3959 			TheClient->iWs.Flush();
       
  3960 			User::After(initialTime.Int()+3*time.Int());
       
  3961 			iTest->SimulateKeyDownUp(EStdKeySpace);
       
  3962 			TheClient->iWs.Flush();
       
  3963 			if(!iTest->IsFullRomL())
       
  3964 				{
       
  3965 				User::After(initialTime.Int()+2*time.Int());
       
  3966 				}
       
  3967 			iTest->SimulateKey(TRawEvent::EKeyUp,'X');
       
  3968 			AddExpectedKey(EEventKeyDown,'X');
       
  3969 			AddExpectedKey(EEventKey,'X','x');
       
  3970 			AddExpectedKey(EEventKey,'X','x',1);
       
  3971 			AddExpectedKey(EEventKeyDown,EStdKeySpace);
       
  3972 			AddExpectedKey(EEventKey,EStdKeySpace,' ');
       
  3973 			AddExpectedKey(EEventKeyUp,EStdKeySpace);
       
  3974 			if(!iTest->IsFullRomL())
       
  3975 				{
       
  3976 				AddExpectedKey(EEventKey,'X','x',1);
       
  3977 				}
       
  3978 			AddExpectedKey(EEventKeyUp,'X');
       
  3979 			iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(iCaptureKey);
       
  3980 			break;
       
  3981 		case 7:
       
  3982 			iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureLongKey(' ','b',0,0,2,ELongCaptureNormal|ELongCaptureRepeatEvents);
       
  3983 			iQueueClient->iWs.Flush();
       
  3984 			iTest->SimulateKey(TRawEvent::EKeyDown,'X');
       
  3985 			TheClient->iWs.Flush();
       
  3986 			User::After(initialTime.Int()+5*time.Int());
       
  3987 			iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace);
       
  3988 			TheClient->iWs.Flush();
       
  3989 			User::After(initialTime.Int()+time.Int()/3);
       
  3990 			iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace);
       
  3991 			TheClient->iWs.Flush();
       
  3992 			User::ResetInactivityTime();
       
  3993 			User::After(initialTime.Int()+4*time.Int());
       
  3994 			iTest->SimulateKey(TRawEvent::EKeyUp,'X');
       
  3995 			AddExpectedKey(EEventKeyDown,'X');
       
  3996 			AddExpectedKey(EEventKey,'X','x');
       
  3997 			AddExpectedKey(EEventKey,'X','x',1);
       
  3998 			AddExpectedKey(EEventKeyDown,EStdKeySpace);
       
  3999 			AddExpectedKey(EEventKey,EStdKeySpace,' ');
       
  4000 			AddExpectedKey(EEventKey,EStdKeySpace,'b',1);
       
  4001 			AddExpectedKey(EEventKeyUp,EStdKeySpace);
       
  4002 			AddExpectedKey(EEventKey,'X','x',1);
       
  4003 			AddExpectedKey(EEventKeyUp,'X');
       
  4004 			iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(iCaptureKey);
       
  4005 			break;
       
  4006 		case 8:
       
  4007 			iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureLongKey(' ','c',0,0,2,ELongCaptureRepeatEvents);
       
  4008 			iQueueClient->iWs.Flush();
       
  4009 			iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace);
       
  4010 			TheClient->iWs.Flush();
       
  4011 			User::After(initialTime.Int()+5*time.Int());
       
  4012 			iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace);
       
  4013 			AddExpectedKey(EEventKeyDown,EStdKeySpace);
       
  4014 			AddExpectedKey(EEventKey,EStdKeySpace,'c',1);
       
  4015 			AddExpectedKey(EEventKeyUp,EStdKeySpace);
       
  4016 			iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(iCaptureKey);
       
  4017 			break;
       
  4018 		case 9:
       
  4019 			{
       
  4020 			TInt captureKey=iQueueClient->iGroup->GroupWin()->CaptureLongKey(EKeyEscape,'e',0,0,2,ELongCaptureNormal|ELongCaptureRepeatEvents);
       
  4021 			iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureLongKey(' ','d',0,0,2,ELongCaptureNormal|ELongCaptureRepeatEvents);
       
  4022 			iQueueClient->iWs.Flush();
       
  4023 			iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace);
       
  4024 			TheClient->iWs.Flush();
       
  4025 			User::After(initialTime.Int()+5*time.Int()/2);
       
  4026 			iTest->SimulateKeyDownUp(EStdKeyEscape);
       
  4027 			TheClient->iWs.Flush();
       
  4028 			User::After(initialTime.Int()+3*time.Int());
       
  4029 			iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace);
       
  4030 			AddExpectedKey(EEventKeyDown,EStdKeySpace);
       
  4031 			AddExpectedKey(EEventKey,EStdKeySpace,' ');
       
  4032 			AddExpectedKey(EEventKey,EStdKeySpace,'d',1);
       
  4033 			AddExpectedKey(EEventKeyDown,EStdKeyEscape);
       
  4034 			AddExpectedKey(EEventKey,EStdKeyEscape,EKeyEscape);
       
  4035 			AddExpectedKey(EEventKeyUp,EStdKeyEscape);
       
  4036 			AddExpectedKey(EEventKeyUp,EStdKeySpace);
       
  4037 			iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(iCaptureKey);
       
  4038 			iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(captureKey);
       
  4039 			}
       
  4040 			break;
       
  4041 		case 10:
       
  4042 			//Cancel a long capture key event whilst a repeat is underway
       
  4043 			iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureLongKey(' ','a',0,0,2,ELongCaptureNormal|ELongCaptureRepeatEvents);
       
  4044 			iQueueClient->iWs.Flush();
       
  4045 			iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace);
       
  4046 			TheClient->iWs.Flush();
       
  4047 			iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(iCaptureKey);
       
  4048 			User::After(initialTime.Int()+5*time.Int());
       
  4049 			iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace);
       
  4050 			AddExpectedKey(EEventKeyDown,EStdKeySpace);
       
  4051 			AddExpectedKey(EEventKey,EStdKeySpace,' ');
       
  4052 			AddExpectedKey(EEventKeyUp,EStdKeySpace);
       
  4053 			break;
       
  4054 		case 11:
       
  4055 			//Cancel a capture key up and down event whilst a repeat is underway
       
  4056 			iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureKeyUpAndDowns(EStdKeySpace,0,0);
       
  4057 			iQueueClient->iWs.Flush();
       
  4058 			iTest->SimulateKey(TRawEvent::EKeyDown,'X');
       
  4059 			TheClient->iWs.Flush();
       
  4060 			iQueueClient->iGroup->GroupWin()->CancelCaptureKeyUpAndDowns(iCaptureKey);
       
  4061 			User::After(initialTime.Int()+5*time.Int());
       
  4062 			iTest->SimulateKey(TRawEvent::EKeyUp,'X');
       
  4063 			AddExpectedKey(EEventKeyDown,'X');
       
  4064 			AddExpectedKey(EEventKey,'X','x');
       
  4065 			AddExpectedKey(EEventKeyUp,'X');
       
  4066 			break;
       
  4067 		case 12:
       
  4068 			//Cancel a capture key event whilst a repeat is underway
       
  4069 			iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureKey(EStdKeySpace,0,0);
       
  4070 			iQueueClient->iWs.Flush();
       
  4071 			iTest->SimulateKey(TRawEvent::EKeyDown,'Y');
       
  4072 			TheClient->iWs.Flush();
       
  4073 			iQueueClient->iGroup->GroupWin()->CancelCaptureKey(iCaptureKey);
       
  4074 			User::After(initialTime.Int()+5*time.Int());
       
  4075 			iTest->SimulateKey(TRawEvent::EKeyUp,'Y');
       
  4076 			AddExpectedKey(EEventKeyDown,'Y');
       
  4077 			AddExpectedKey(EEventKey,'Y','y');
       
  4078 			AddExpectedKey(EEventKeyUp,'Y');
       
  4079 			break;
       
  4080 		case 13:
       
  4081 			//Variation on case 12 i.e. change in the timing of the CancelCaptureKey call
       
  4082 			iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureKey(EStdKeySpace,0,0);
       
  4083 			iQueueClient->iWs.Flush();
       
  4084 			iTest->SimulateKey(TRawEvent::EKeyDown,'Z');
       
  4085 			TheClient->iWs.Flush();
       
  4086 			User::After(initialTime.Int()+5*time.Int()/2);
       
  4087 			iQueueClient->iGroup->GroupWin()->CancelCaptureKey(iCaptureKey);
       
  4088 			User::After(initialTime.Int()+5*time.Int()/2);
       
  4089 			iTest->SimulateKey(TRawEvent::EKeyUp,'Z');
       
  4090 			AddExpectedKey(EEventKeyDown,'Z');
       
  4091 			AddExpectedKey(EEventKey,'Z','z');
       
  4092 			AddExpectedKey(EEventKey,'Z','z',2);
       
  4093 			AddExpectedKey(EEventKeyUp,'Z');
       
  4094 			break;
       
  4095 		case 14:
       
  4096 			{
       
  4097 	    	// Cancel long capture key event when normal capture key is scheduled for different
       
  4098 	    	// window group.
       
  4099 			iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureLongKey(' ','a',0,0,2,ELongCaptureNormal);
       
  4100 			TInt shortCaptKey = TheClient->iGroup->GroupWin()->CaptureKey(' ',0,0);
       
  4101 
       
  4102 			iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace);
       
  4103 			TheClient->iWs.Flush();
       
  4104 			iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(iCaptureKey);
       
  4105 			User::After(initialTime.Int()+time.Int()/3);
       
  4106 
       
  4107 			TheClient->iGroup->GroupWin()->CancelCaptureKey(shortCaptKey);
       
  4108 			iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace);
       
  4109 			AddExpectedKey(EEventKeyDown,EStdKeySpace);
       
  4110 			AddExpectedKey(EEventKeyUp,EStdKeySpace);
       
  4111 			}
       
  4112 			break;
       
  4113 		default:
       
  4114 			CActiveScheduler::Stop();
       
  4115 			break;
       
  4116 		}
       
  4117 	TheClient->iWs.Flush();
       
  4118 	}
       
  4119 
       
  4120 #define PASSWORD_START_OF_DAY 4
       
  4121 void CTEventTest::Password_NextSetOfEvents()
       
  4122 	{
       
  4123 	switch(iEventSet++)
       
  4124 		{
       
  4125 		case 0:
       
  4126 			iQueueClient->iWin->BaseWin()->PasswordWindow(EPasswordAlwaysTriggerNow);
       
  4127 			iQueueClient->iWs.PasswordEntered();
       
  4128 			iTest->SimulateKeyDownUp('2');
       
  4129 			iQueueClient->iWs.Flush();
       
  4130 			AddExpectedEvent(EEventFocusGained);
       
  4131 			AddExpectedEvent(EEventPassword);
       
  4132 			AddExpectedKeyDownUp('2');
       
  4133 			break;
       
  4134 		case 1:
       
  4135 			iQueueClient->iWin->BaseWin()->PasswordWindow(EPasswordOnceADayTriggerNow);
       
  4136 			iQueueClient->iWs.PasswordEntered();
       
  4137 			iTest->SimulateKeyDownUp('3');
       
  4138 			iQueueClient->iWs.Flush();
       
  4139 			AddExpectedEvent(EEventPassword);
       
  4140 			AddExpectedKeyDownUp('3');
       
  4141 			break;
       
  4142 		case 2:
       
  4143 			{
       
  4144 			TTime time;
       
  4145 			time.HomeTime();
       
  4146 			TInt day=time.DayNoInMonth();
       
  4147 			if (day==0)
       
  4148 				day=5;
       
  4149 			time-=TTimeIntervalDays(day);
       
  4150 			time+=TTimeIntervalHours(PASSWORD_START_OF_DAY);
       
  4151 			User::SetHomeTime(time);
       
  4152 			iQueueClient->iWin->BaseWin()->PasswordWindow(EPasswordOnceADayTriggerNow);
       
  4153 			iQueueClient->iWs.PasswordEntered();
       
  4154 			iTest->SimulateKeyDownUp('3');
       
  4155 			iQueueClient->iWs.Flush();
       
  4156 			AddExpectedEvent(EEventPassword);
       
  4157 			AddExpectedKeyDownUp('3');
       
  4158 			time+=TTimeIntervalDays(day);
       
  4159 			time-=TTimeIntervalHours(PASSWORD_START_OF_DAY);
       
  4160 			User::SetHomeTime(time);
       
  4161 			}
       
  4162 			break;
       
  4163 		case 3:
       
  4164 			{
       
  4165 			TTime time;
       
  4166 			time.HomeTime();
       
  4167 			TInt day=time.DayNoInMonth();
       
  4168 			time-=TTimeIntervalDays(day);
       
  4169 			time+=TTimeIntervalHours(PASSWORD_START_OF_DAY);
       
  4170 			User::SetHomeTime(time);
       
  4171 			iQueueClient->iWin->BaseWin()->PasswordWindow(EPasswordOnceADay);
       
  4172 			iQueueClient->iWs.PasswordEntered();
       
  4173 			iTest->SimulateEvent(TRawEvent::ESwitchOn);
       
  4174 			iTest->SimulateKeyDownUp('3');
       
  4175 			iQueueClient->iWs.Flush();
       
  4176 			AddExpectedEvent(EEventPassword);
       
  4177 			AddExpectedEvent(EEventSwitchOn);
       
  4178 			AddExpectedKeyDownUp('3');
       
  4179 			time+=TTimeIntervalDays(day);
       
  4180 			time-=TTimeIntervalHours(PASSWORD_START_OF_DAY);
       
  4181 			User::SetHomeTime(time);
       
  4182 			}
       
  4183 			break;
       
  4184 		default:
       
  4185 			CActiveScheduler::Stop();
       
  4186 			break;
       
  4187 		}
       
  4188 	TheClient->iWs.Flush();
       
  4189 	}
       
  4190 
       
  4191 void CTEventTest::GroupListChanged_NextSetOfEventsL()
       
  4192 	{
       
  4193 	_LIT(WindowGroup1,"WindowGroupName1");
       
  4194 	_LIT(WindowGroup2,"WindowGroupName2");
       
  4195 	switch(iEventSet++)
       
  4196 		{
       
  4197 		case 0:
       
  4198 			{
       
  4199 			_LIT(TestGroup3,"GroupListEvents3");
       
  4200 			iQueueClient->EnableGroupListChangeEvents();
       
  4201 			iEventTestGroup3=new(ELeave) CTWindowGroup(TheClient);
       
  4202 			iEventTestGroup3->ConstructL();
       
  4203 			iEventTestGroup3->GroupWin()->SetName(TestGroup3);
       
  4204 			AddExpectedEvent(EEventFocusGained);
       
  4205 			AddExpectedEvent(EEventFocusLost);
       
  4206 			AddExpectedEvent(EEventWindowGroupListChanged);
       
  4207 			AddExpectedEvent(EEventWindowGroupsChanged);
       
  4208 			}
       
  4209 			break;
       
  4210 		case 1:
       
  4211 			{
       
  4212 			_LIT(TestGroup4,"GroupListEvents4");
       
  4213 			iEventTestGroup4=new(ELeave) CTWindowGroup(TheClient);
       
  4214 			iEventTestGroup4->ConstructL();
       
  4215 			iEventTestGroup4->GroupWin()->SetName(TestGroup4);
       
  4216 			AddExpectedEvent(EEventWindowGroupListChanged);
       
  4217 			AddExpectedEvent(EEventWindowGroupsChanged);
       
  4218 			}
       
  4219 			break;
       
  4220 		case 2:
       
  4221 			iEventTestGroup3->GroupWin()->SetOrdinalPosition(0);
       
  4222 			AddExpectedEvent(EEventWindowGroupListChanged);
       
  4223 			break;
       
  4224 		case 3:
       
  4225 			iEventTestGroup3->GroupWin()->SetOrdinalPosition(999);
       
  4226 			AddExpectedEvent(EEventWindowGroupListChanged);
       
  4227 			break;
       
  4228 		case 4:
       
  4229 			iEventTestGroup4->GroupWin()->SetOrdinalPosition(999);
       
  4230 			AddExpectedEvent(EEventFocusGained);
       
  4231 			AddExpectedEvent(EEventWindowGroupListChanged);
       
  4232             // Testcase for defect INC135635
       
  4233 			// Since iWin has OrdinalPosition Zero (the front) clicking on it won't generate an 
       
  4234 			// EEventWindowGroupListChanged event as there is no change in the order of the windows
       
  4235 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(20-EWinPositionX,11-EWinPositionY));
       
  4236 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(20-EWinPositionX,11-EWinPositionY));
       
  4237 			SimulatePointer(TRawEvent::EButton1Down,20,11);
       
  4238 			SimulatePointer(TRawEvent::EButton1Up,20,11);
       
  4239 			break;
       
  4240 		case 5:
       
  4241 			iEventTestGroup3->GroupWin()->SetOrdinalPosition(999);
       
  4242 			AddExpectedEvent(EEventWindowGroupListChanged);
       
  4243 			break;
       
  4244 		case 6:
       
  4245 			iEventTestGroup3->GroupWin()->SetOrdinalPosition(99);
       
  4246 			SimulatePointer(TRawEvent::EButton1Down,20,11);
       
  4247 			iEventTestGroup3->GroupWin()->SetName(WindowGroup1);
       
  4248 			AddExpectedPointer(TPointerEvent::EButton1Down, TPoint(20-EWinPositionX,11-EWinPositionY));
       
  4249 			AddExpectedEvent(EEventWindowGroupsChanged);
       
  4250 			break;
       
  4251 		case 7:
       
  4252 			iEventTestGroup3->GroupWin()->SetName(WindowGroup2);
       
  4253 			SimulatePointer(TRawEvent::EButton1Up,10,20);
       
  4254 			AddExpectedEvent(EEventWindowGroupsChanged);
       
  4255 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(10-EWinPositionX,20-EWinPositionY));
       
  4256 			break;
       
  4257 		case 8:
       
  4258 			iEventTestGroup3->GroupWin()->SetName(WindowGroup1);
       
  4259 			SimulatePointer(TRawEvent::EButton2Down,20,30);
       
  4260 			AddExpectedEvent(EEventWindowGroupsChanged);
       
  4261 			AddExpectedPointer(TPointerEvent::EButton2Down, TPoint(20-EWinPositionX,30-EWinPositionY));
       
  4262 			break;
       
  4263 		case 9:
       
  4264 			SimulatePointer(TRawEvent::EButton1Up,15,15);
       
  4265 			iEventTestGroup3->GroupWin()->SetName(WindowGroup2);
       
  4266 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(15-EWinPositionX,15-EWinPositionY));
       
  4267 			AddExpectedEvent(EEventWindowGroupsChanged);
       
  4268 			break;
       
  4269 		case 10:
       
  4270 			SimulatePointer(TRawEvent::EButton2Down,25,20);
       
  4271 			iEventTestGroup3->GroupWin()->SetName(WindowGroup2);
       
  4272 			SimulatePointer(TRawEvent::EButton1Up,15,20);
       
  4273 			iEventTestGroup3->GroupWin()->SetName(WindowGroup1);
       
  4274 			AddExpectedPointer(TPointerEvent::EButton2Down, TPoint(25-EWinPositionX,20-EWinPositionY));
       
  4275 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(15-EWinPositionX,20-EWinPositionY));
       
  4276 			AddExpectedEvent(EEventWindowGroupsChanged);
       
  4277 			break;
       
  4278 		case 11:
       
  4279 			iEventTestGroup3->GroupWin()->SetName(WindowGroup1);
       
  4280 			SimulatePointer(TRawEvent::EButton2Down,12,12);
       
  4281 			iEventTestGroup3->GroupWin()->SetName(WindowGroup2);
       
  4282 			SimulatePointer(TRawEvent::EButton1Up,12,12);
       
  4283 			AddExpectedPointer(TPointerEvent::EButton2Down, TPoint(12-EWinPositionX,12-EWinPositionY));
       
  4284 			AddExpectedEvent(EEventWindowGroupsChanged);
       
  4285 			AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(12-EWinPositionX,12-EWinPositionY));
       
  4286 			break;
       
  4287 		case 12:
       
  4288 			delete iEventTestGroup3;
       
  4289 			iEventTestGroup3=NULL;
       
  4290 			AddExpectedEvent(EEventWindowGroupsChanged);
       
  4291 			AddExpectedEvent(EEventWindowGroupListChanged);
       
  4292 			break;
       
  4293 		case 13:
       
  4294 			delete iEventTestGroup4;
       
  4295 			iEventTestGroup4=NULL;
       
  4296 			AddExpectedEvent(EEventWindowGroupsChanged);
       
  4297 			AddExpectedEvent(EEventWindowGroupListChanged);
       
  4298 			break;
       
  4299 		default:
       
  4300 			CActiveScheduler::Stop();
       
  4301 			break;
       
  4302 		}
       
  4303 	TheClient->iWs.Flush();
       
  4304 	}
       
  4305 
       
  4306 TInt CTEventTest::KeyRepeatTime() const
       
  4307 	{
       
  4308 	TTimeIntervalMicroSeconds32 initialTime;
       
  4309 	TTimeIntervalMicroSeconds32 time;
       
  4310 	TheClient->iWs.GetKeyboardRepeatRate(initialTime,time);
       
  4311 	return(initialTime.Int());
       
  4312 	}
       
  4313 
       
  4314 void CTEventTest::RepeatableKeysL()
       
  4315 	{
       
  4316 	// repeatable key event
       
  4317 	TKeyEvent repKeyEvent; 
       
  4318 	repKeyEvent.iCode='J';
       
  4319 	repKeyEvent.iScanCode=0;
       
  4320 	repKeyEvent.iModifiers=EModifierAutorepeatable;
       
  4321 	repKeyEvent.iRepeats=0;
       
  4322 	
       
  4323 	// non-repeatable key event
       
  4324 	TKeyEvent keyEvent; 
       
  4325 	keyEvent.iCode='J';
       
  4326 	keyEvent.iScanCode=0;
       
  4327 	keyEvent.iModifiers=0;
       
  4328 	keyEvent.iRepeats=0;
       
  4329 	
       
  4330 	switch(iEventSet++)
       
  4331 		{
       
  4332 		case 0:
       
  4333 			{
       
  4334 			TheClient->iWs.SimulateKeyEvent(repKeyEvent);	// Create a repeatable key event
       
  4335 			TheClient->iWs.SimulateKeyEvent(repKeyEvent);	// Create a repeatable key event
       
  4336 			TheClient->iWs.SimulateKeyEvent(keyEvent);		// Create a non-repeatable key event
       
  4337 			TheClient->iWs.Flush();							// Send events
       
  4338 			AddExpectedEvent(EEventFocusGained);			// Always get a focus gain at start
       
  4339 			AddExpectedKey(1, repKeyEvent.iScanCode, repKeyEvent.iCode, repKeyEvent.iRepeats, repKeyEvent.iModifiers);// Expect the event that was created above
       
  4340 			AddExpectedKey(1, repKeyEvent.iScanCode, repKeyEvent.iCode, repKeyEvent.iRepeats, repKeyEvent.iModifiers);// Expect the event that was created above
       
  4341 			AddExpectedKey(1, keyEvent.iScanCode, keyEvent.iCode, keyEvent.iRepeats, keyEvent.iModifiers);// Expect the event that was created above
       
  4342 			break;
       
  4343 			}
       
  4344 		case 1:
       
  4345 			{
       
  4346 			TheClient->iWs.SimulateKeyEvent(repKeyEvent);	// Create a repeatable key event
       
  4347 			TheClient->iWs.SimulateKeyEvent(keyEvent);		// Create a non-repeatable key event
       
  4348 			TheClient->iWs.Flush();
       
  4349 			iTest->SimulateKey(TRawEvent::EKeyDown, 'A');	// Create a raw event
       
  4350 			TheClient->iWs.Flush();
       
  4351 			User::After(KeyRepeatTime()*3/2);
       
  4352 			iTest->SimulateKey(TRawEvent::EKeyUp, 'A');		// Create a raw event
       
  4353 			TheClient->iWs.Flush();
       
  4354 			AddExpectedKey(1, repKeyEvent.iScanCode, repKeyEvent.iCode, repKeyEvent.iRepeats, repKeyEvent.iModifiers);// Expect the event that was created above
       
  4355 			AddExpectedKey(1, keyEvent.iScanCode, keyEvent.iCode, keyEvent.iRepeats, keyEvent.iModifiers);// Expect the event that was created above
       
  4356 			AddExpectedKey(EEventKeyDown, 'A');
       
  4357 			AddExpectedKey(EEventKey,'A','a');
       
  4358 			AddExpectedKey(EEventKey,'A','a',1);
       
  4359 			AddExpectedKey(EEventKeyUp, 'A');
       
  4360 			break;
       
  4361 			}
       
  4362 		case 2:
       
  4363 			{
       
  4364 			iTest->SimulateKey(TRawEvent::EKeyDown, 'A');	// Create a raw event
       
  4365 			TheClient->iWs.Flush();
       
  4366 			User::After(KeyRepeatTime()*3/2);
       
  4367 			TheClient->iWs.SimulateKeyEvent(repKeyEvent);	// Create a repeatable key event
       
  4368 			TheClient->iWs.SimulateKeyEvent(keyEvent);		// Create a non-repeatable key event
       
  4369 			TheClient->iWs.Flush();							// Send event
       
  4370 			iTest->SimulateKey(TRawEvent::EKeyUp, 'A');		// Create a raw event
       
  4371 			TheClient->iWs.Flush();
       
  4372 			AddExpectedKey(EEventKeyDown, 'A');
       
  4373 			AddExpectedKey(EEventKey,'A','a');
       
  4374 			AddExpectedKey(EEventKey,'A','a',1);
       
  4375 			AddExpectedKey(1, repKeyEvent.iScanCode, repKeyEvent.iCode, repKeyEvent.iRepeats, repKeyEvent.iModifiers);// Expect the event that was created above
       
  4376 			AddExpectedKey(1, keyEvent.iScanCode, keyEvent.iCode, keyEvent.iRepeats, keyEvent.iModifiers);// Expect the event that was created above
       
  4377 			AddExpectedKey(EEventKeyUp, 'A');
       
  4378 			break;
       
  4379 			}
       
  4380 		default:
       
  4381 			CActiveScheduler::Stop();
       
  4382 			break;
       
  4383 		}
       
  4384 	TheClient->iWs.Flush();
       
  4385 	}
       
  4386 
       
  4387 CTBlankWindow* CTEventTest::NewBlueForgroundWindowL()
       
  4388 	{
       
  4389 	CTBlankWindow* window;
       
  4390 	window=new (ELeave) CTBlankWindow;
       
  4391 	CleanupStack::PushL(window);
       
  4392 	window->ConstructL(*iQueueClient->iGroup);
       
  4393 	User::LeaveIfError(window->BaseWin()->SetRequiredDisplayMode(EColor256));
       
  4394 	CleanupStack::Pop(window);
       
  4395 
       
  4396 	window->SetColor(KRgbBlue);
       
  4397 	window->SetExt(TPoint(40, 40), TSize(40,40));
       
  4398 	window->BaseWin()->SetOrdinalPosition(0);
       
  4399 	return window;
       
  4400 	}
       
  4401 
       
  4402 CTBlankWindow* CTEventTest::NewBlueForgroundWindow()
       
  4403 	{
       
  4404 	CTBlankWindow* window = NULL;
       
  4405 	TRAPD(err, window=NewBlueForgroundWindowL());
       
  4406 	if (err != KErrNone)
       
  4407 		Failed();
       
  4408 	return window;
       
  4409 	}
       
  4410 
       
  4411 #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
       
  4412 #ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
       
  4413 static void CreateSurfaceAttributes(RSurfaceManager::TSurfaceCreationAttributesBuf& aBuffer , const TSize& aSize)
       
  4414     {
       
  4415     RSurfaceManager::TSurfaceCreationAttributes& b = aBuffer();
       
  4416                 
       
  4417     b.iSize.iWidth = aSize.iWidth;
       
  4418     b.iSize.iHeight = aSize.iHeight;
       
  4419     b.iBuffers = 1;              // number of buffers in the surface
       
  4420     b.iPixelFormat = EUidPixelFormatARGB_8888;
       
  4421     b.iStride = aSize.iWidth * 4;        // Number of bytes between start of one line and start of next
       
  4422     b.iOffsetToFirstBuffer = 0; // way of reserving space before the surface pixel data
       
  4423     b.iAlignment = 4;           // alignment, 1,2,4,8 byte aligned
       
  4424     b.iContiguous = EFalse;
       
  4425     b.iMappable = ETrue;
       
  4426     }
       
  4427 
       
  4428 static const TInt KFullyVisible = TWsVisibilityChangedEvent::EPartiallyVisible | TWsVisibilityChangedEvent::EFullyVisible;
       
  4429 
       
  4430 void CTEventTest::SurfaceVisibilityChanged1_NextSetOfEventsL()
       
  4431     {    
       
  4432     switch(iEventSet++)
       
  4433         {
       
  4434         case 0:
       
  4435             {
       
  4436             //Setup
       
  4437             LOG_MESSAGE(_L("case 0"));
       
  4438             TInt err = iSurfaceManager.Open();
       
  4439             if (err != KErrNone)
       
  4440                 {
       
  4441                 RDebug::Printf("RSurfaceManager::Open() failed", err);
       
  4442                 User::Leave(err);
       
  4443                 }
       
  4444             
       
  4445             iVisWins1=NewBlueForgroundWindowL();
       
  4446             iVisWins1->Activate();
       
  4447             iVisWins1->BaseWin()->EnableVisibilityChangeEvents();
       
  4448 
       
  4449             AddExpectedEvent(EEventFocusGained);
       
  4450             AddExpectedVisibilityChange(KFullyVisible, iVisWins1);
       
  4451             break;
       
  4452             }
       
  4453         case 1:
       
  4454             {
       
  4455             LOG_MESSAGE(_L("case 1"));
       
  4456             iVisWins2=NewBlueForgroundWindowL(); // will cover iVisWins1
       
  4457             iVisWins2->BlankWin()->SetColor();  //remove colour to ensure window does not draw to UI layer
       
  4458             iVisWins2->Activate();
       
  4459             
       
  4460             AddExpectedVisibilityChange(TWsVisibilityChangedEvent::ENotVisible, iVisWins1);
       
  4461             break;
       
  4462             }
       
  4463         case 2:
       
  4464             {
       
  4465             // This case contains the actual test GRAPHICS-WSERV-2669-0015
       
  4466             LOG_MESSAGE(_L("case 2"));
       
  4467             RSurfaceManager::TSurfaceCreationAttributesBuf surfaceBuf;
       
  4468             CreateSurfaceAttributes(surfaceBuf, iVisWins2->BaseWin()->Size());
       
  4469             
       
  4470             iSurfaceId = TSurfaceId::CreateNullId();
       
  4471             TInt err = iSurfaceManager.CreateSurface(surfaceBuf, iSurfaceId);
       
  4472             if (err != KErrNone)
       
  4473                 {
       
  4474                 RDebug::Printf("RSurfaceManager::CreateSurface() error: %d", err);
       
  4475                 TEST(EFalse);
       
  4476                 }
       
  4477          
       
  4478             err = iVisWins2->BaseWin()->SetBackgroundSurface(iSurfaceId);
       
  4479             if (err != KErrNone)
       
  4480                 {
       
  4481                 RDebug::Printf("RWindow::SetBackgroundSurface() error: %d", err);
       
  4482                 TEST(EFalse);
       
  4483                 }
       
  4484             
       
  4485             iVisWins2->BaseWin()->SetSurfaceTransparency(ETrue); //iVisWins1 will become visible
       
  4486             
       
  4487             AddExpectedVisibilityChange(KFullyVisible, iVisWins1);
       
  4488             break;
       
  4489             }
       
  4490         default:
       
  4491             LOG_MESSAGE(_L("default"));
       
  4492             if (!iSurfaceId.IsNull())
       
  4493                 {
       
  4494                 iSurfaceManager.CloseSurface(iSurfaceId);
       
  4495                 iSurfaceId = TSurfaceId::CreateNullId();
       
  4496                 }
       
  4497             iSurfaceManager.Close();
       
  4498             delete iVisWins1;
       
  4499             iVisWins1 = NULL;
       
  4500             delete iVisWins2;
       
  4501             iVisWins2 = NULL;
       
  4502             CActiveScheduler::Stop();
       
  4503             break;
       
  4504         }
       
  4505     TheClient->iWs.Flush();
       
  4506     }
       
  4507 
       
  4508 void CTEventTest::SurfaceVisibilityChanged2_NextSetOfEventsL()
       
  4509     {
       
  4510     switch (iEventSet++)
       
  4511         {
       
  4512         case 0:
       
  4513             {
       
  4514             //Win1 - bottom window
       
  4515             //Win2 - middle window with semi-transparent background surface, which totally obscures win1
       
  4516             LOG_MESSAGE(_L("case 0"));
       
  4517             TInt err = iSurfaceManager.Open();
       
  4518             if (err != KErrNone)
       
  4519                 {
       
  4520                 RDebug::Printf("RSurfaceManager::Open() failed", err);
       
  4521                 User::Leave(err);
       
  4522                 }
       
  4523             
       
  4524             iVisWins1 = NewBlueForgroundWindowL();
       
  4525             iVisWins1->BaseWin()->EnableVisibilityChangeEvents();
       
  4526 
       
  4527             iVisWins2 = NewBlueForgroundWindowL();
       
  4528             iVisWins2->BlankWin()->SetColor(); //remove colour to ensure window does not draw to UI layer
       
  4529             iVisWins2->BaseWin()->EnableVisibilityChangeEvents();
       
  4530             
       
  4531             iVisWins1->Activate(); //obscured
       
  4532             iVisWins2->Activate(); //visible
       
  4533             
       
  4534             // Create surface for background window    
       
  4535             RSurfaceManager::TSurfaceCreationAttributesBuf surfaceBuf;
       
  4536             CreateSurfaceAttributes(surfaceBuf, iVisWins2->BaseWin()->Size());
       
  4537 
       
  4538             iSurfaceId = TSurfaceId::CreateNullId();
       
  4539             err = iSurfaceManager.CreateSurface(surfaceBuf, iSurfaceId);
       
  4540             if (err != KErrNone)
       
  4541                 {
       
  4542                 RDebug::Printf("RSurfaceManager::CreateSurface() error: %d", err);
       
  4543                 TEST(EFalse);
       
  4544                 }
       
  4545 
       
  4546             err = iVisWins2->BaseWin()->SetBackgroundSurface(iSurfaceId);
       
  4547             if (err != KErrNone)
       
  4548                 {
       
  4549                 RDebug::Printf("RWindow::SetBackgroundSurface() error: %d", err);
       
  4550                 TEST(EFalse);
       
  4551                 }
       
  4552 
       
  4553             iVisWins2->BaseWin()->SetSurfaceTransparency(ETrue); //win1 and win2 both visible
       
  4554 
       
  4555             AddExpectedEvent(EEventFocusGained);
       
  4556             AddExpectedVisibilityChange(KFullyVisible, iVisWins2);
       
  4557             AddExpectedVisibilityChange(KFullyVisible, iVisWins1);
       
  4558             break;
       
  4559             }
       
  4560         case 1:
       
  4561             {
       
  4562             //Win3 - opaque top window which obscures win2 and win1
       
  4563             LOG_MESSAGE(_L("case 1"));
       
  4564             iVisWins3 = NewBlueForgroundWindowL();
       
  4565             iVisWins3->SetColor(KRgbRed);
       
  4566             iVisWins3->Activate();
       
  4567 
       
  4568             AddExpectedVisibilityChange(TWsVisibilityChangedEvent::ENotVisible, iVisWins2);
       
  4569             AddExpectedVisibilityChange(TWsVisibilityChangedEvent::ENotVisible, iVisWins1);
       
  4570             break;
       
  4571             }
       
  4572         case 2:
       
  4573             {
       
  4574             //This case contains the actual test GRAPHICS-WSERV-2669-0016
       
  4575             LOG_MESSAGE(_L("case 2"));
       
  4576             delete iVisWins3;
       
  4577             iVisWins3 = NULL;
       
  4578 
       
  4579             AddExpectedVisibilityChange(KFullyVisible, iVisWins2);
       
  4580             AddExpectedVisibilityChange(KFullyVisible, iVisWins1);
       
  4581             break;
       
  4582             }
       
  4583         default:
       
  4584             LOG_MESSAGE(_L("default"));
       
  4585             if (!iSurfaceId.IsNull())
       
  4586                 {
       
  4587                 iSurfaceManager.CloseSurface(iSurfaceId);
       
  4588                 iSurfaceId = TSurfaceId::CreateNullId();
       
  4589                 }
       
  4590             iSurfaceManager.Close();
       
  4591             delete iVisWins1;
       
  4592             iVisWins1 = NULL;
       
  4593             delete iVisWins2;
       
  4594             iVisWins2 = NULL;
       
  4595             delete iVisWins3;
       
  4596             iVisWins3 = NULL;
       
  4597             CActiveScheduler::Stop();
       
  4598             return;
       
  4599         }
       
  4600     TheClient->iWs.Flush();
       
  4601     }
       
  4602 
       
  4603 TInt CTEventTest::GenerateAnEvent(TAny* aEventTest)
       
  4604     {
       
  4605     CTEventTest* self = static_cast<CTEventTest*>(aEventTest);
       
  4606     self->LogMessage(((TText8*)__FILE__), __LINE__,_L("Negative test passed OK - no event was generated."));
       
  4607     //Now we must generate an event to get CTQueueTestEvent out of its wait loop 
       
  4608     self->SimulateRepeatEvent(32);
       
  4609     self->AddExpectedKey(EEventKey, 32);
       
  4610     return KErrNone;
       
  4611     }
       
  4612 
       
  4613 void CTEventTest::SurfaceVisibilityChanged3_NextSetOfEventsL()
       
  4614     {
       
  4615     switch (iEventSet++)
       
  4616         {
       
  4617         case 0:
       
  4618             {
       
  4619             //Win1 - Bottom window
       
  4620             //Win2 - Top window with semi-transparent background surface. Does not overlap win1.
       
  4621             LOG_MESSAGE(_L("case 0"));
       
  4622             TInt err = iSurfaceManager.Open();
       
  4623             if (err != KErrNone)
       
  4624                 {
       
  4625                 RDebug::Printf("RSurfaceManager::Open() failed", err);
       
  4626                 User::Leave(err);
       
  4627                 }
       
  4628             iTimeOutCallback = CPeriodic::NewL(CActive::EPriorityIdle);
       
  4629             
       
  4630             iVisWins1 = NewBlueForgroundWindowL();
       
  4631             iVisWins1->BaseWin()->EnableVisibilityChangeEvents();
       
  4632 
       
  4633             iVisWins2 = NewBlueForgroundWindowL();
       
  4634             iVisWins2->BlankWin()->SetColor(); //remove colour to ensure window does not draw to UI layer
       
  4635             TPoint newPos(iVisWins1->Position() + iVisWins1->Size());
       
  4636             iVisWins2->SetPos(newPos); //to not overlap win1 
       
  4637             
       
  4638             iVisWins1->Activate(); //upper left
       
  4639             iVisWins2->Activate(); //lower right
       
  4640             
       
  4641             // Create surface for background window    
       
  4642             RSurfaceManager::TSurfaceCreationAttributesBuf surfaceBuf;
       
  4643             CreateSurfaceAttributes(surfaceBuf, iVisWins2->BaseWin()->Size());
       
  4644 
       
  4645             iSurfaceId = TSurfaceId::CreateNullId();
       
  4646             err = iSurfaceManager.CreateSurface(surfaceBuf, iSurfaceId);
       
  4647             if (err != KErrNone)
       
  4648                 {
       
  4649                 RDebug::Printf("RSurfaceManager::CreateSurface() error: %d", err);
       
  4650                 TEST(EFalse);
       
  4651                 }
       
  4652 
       
  4653             err = iVisWins2->BaseWin()->SetBackgroundSurface(iSurfaceId);
       
  4654             if (err != KErrNone)
       
  4655                 {
       
  4656                 RDebug::Printf("RWindow::SetBackgroundSurface() error: %d", err);
       
  4657                 TEST(EFalse);
       
  4658                 }
       
  4659 
       
  4660             iVisWins2->BaseWin()->SetSurfaceTransparency(ETrue);
       
  4661 
       
  4662             AddExpectedEvent(EEventFocusGained);
       
  4663             AddExpectedVisibilityChange(KFullyVisible, iVisWins1);            
       
  4664             break;
       
  4665             }
       
  4666         case 1:
       
  4667             {
       
  4668             //This case contains the actual test GRAPHICS-WSERV-2669-0017
       
  4669             LOG_MESSAGE(_L("case 1"));
       
  4670             iVisWins2->SetPos(iVisWins1->Position()); //Win2 now overlaps Win1, but because Win2 has 
       
  4671                                                       //a transparent surface Win1 is still fully visible
       
  4672 
       
  4673             //Because we don't expect any events we need to generate one to avoid waiting forever.
       
  4674             TCallBack timeout(GenerateAnEvent, this);
       
  4675             iTimeOutCallback->Start(1000000, 10000000, timeout);
       
  4676             break;
       
  4677             }
       
  4678         default:            
       
  4679             LOG_MESSAGE(_L("default"));
       
  4680             iTimeOutCallback->Cancel();
       
  4681             delete iTimeOutCallback;
       
  4682             iTimeOutCallback = NULL;
       
  4683             if (!iSurfaceId.IsNull())
       
  4684                 {
       
  4685                 iSurfaceManager.CloseSurface(iSurfaceId);
       
  4686                 iSurfaceId = TSurfaceId::CreateNullId();
       
  4687                 }
       
  4688             iSurfaceManager.Close();
       
  4689             delete iVisWins1;
       
  4690             iVisWins1 = NULL;
       
  4691             delete iVisWins2;
       
  4692             iVisWins2 = NULL;
       
  4693             CActiveScheduler::Stop();
       
  4694             return;
       
  4695         }
       
  4696     TheClient->iWs.Flush();
       
  4697     }
       
  4698 #endif //TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
       
  4699 #endif //SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
       
  4700 
       
  4701 void CTEventTest::VisibilityChanged_NextSetOfEventsL()
       
  4702 	{
       
  4703 	const TInt fullyVisible = TWsVisibilityChangedEvent::EPartiallyVisible | TWsVisibilityChangedEvent::EFullyVisible;
       
  4704 
       
  4705 	switch(iEventSet++)
       
  4706 		{
       
  4707 		case 0: //only this case can leave
       
  4708 			{
       
  4709 			iQueueClient->iWin->BackedUpWin()->MaintainBackup();
       
  4710 			iVisWins1=NewBlueForgroundWindowL();
       
  4711 			iVisWins2=NewBlueForgroundWindowL();
       
  4712 
       
  4713 			iVisWins1->BaseWin()->EnableVisibilityChangeEvents();
       
  4714 			iVisWins1->Activate();
       
  4715 			iVisWins2->SetColor(KRgbGreen);
       
  4716 			iVisWins2->SetExt(TPoint(80, 80), TSize(120,120));
       
  4717 			iVisWins2->Activate();
       
  4718 
       
  4719 			AddExpectedEvent(EEventFocusGained);
       
  4720 			AddExpectedVisibilityChange(fullyVisible);
       
  4721 			}
       
  4722 			break;
       
  4723 		case 1:
       
  4724 			iVisWins1->BaseWin()->SetVisible(EFalse);
       
  4725 			AddExpectedVisibilityChange(TWsVisibilityChangedEvent::ENotVisible);
       
  4726 			break;
       
  4727 		case 2:
       
  4728 			iVisWins1->BaseWin()->SetVisible(ETrue);
       
  4729 			AddExpectedVisibilityChange(fullyVisible);
       
  4730 			break;
       
  4731 		case 3:
       
  4732 			iVisWins2->SetExt(TPoint(0,0), TSize(120,120));
       
  4733 			AddExpectedVisibilityChange(TWsVisibilityChangedEvent::ENotVisible);
       
  4734 			break;
       
  4735 		case 4:
       
  4736 			iVisWins2->BaseWin()->SetVisible(EFalse);
       
  4737 			AddExpectedVisibilityChange(fullyVisible);
       
  4738 			break;
       
  4739 		case 5:
       
  4740 			iVisWins2->BaseWin()->SetVisible(ETrue);
       
  4741 			AddExpectedVisibilityChange(TWsVisibilityChangedEvent::ENotVisible);
       
  4742 			break;
       
  4743 		case 6:
       
  4744 			iVisWins2->SetExt(TPoint(60,60), TSize(120,120));
       
  4745 			AddExpectedVisibilityChange(TWsVisibilityChangedEvent::EPartiallyVisible);
       
  4746 			break;
       
  4747 		case 7:
       
  4748 			iVisWins1->SetExt(TPoint(80,80), TSize(40,40));
       
  4749 			AddExpectedVisibilityChange(TWsVisibilityChangedEvent::ENotVisible);
       
  4750 			break;
       
  4751 		case 8:
       
  4752 			iVisWins1->BaseWin()->SetOrdinalPosition(0);
       
  4753 			AddExpectedVisibilityChange(fullyVisible);
       
  4754 
       
  4755 			if(TransparencySupportedL() != KErrNone)
       
  4756 				{
       
  4757 				iEventSet += 2; //we shall skip set 9,10 as they work with transparency
       
  4758 				}
       
  4759 			break;
       
  4760 		case 9:
       
  4761 			{
       
  4762 			TDisplayMode mode = EColor256;
       
  4763 			iTransWin=CTransWindow::NewL(iQueueClient->iGroup, TRgb(255, 0, 0, 128), TRect(0,0,200,200), &mode);
       
  4764 			iTransWin->CTWin::DrawNow();
       
  4765 			// it gets put at ordinal position 0
       
  4766 			iVisWins2->BaseWin()->SetOrdinalPosition(1);
       
  4767 			AddExpectedVisibilityChange(TWsVisibilityChangedEvent::ENotVisible);
       
  4768 			}
       
  4769 			break;
       
  4770 		case 10:
       
  4771 			iVisWins1->BaseWin()->SetOrdinalPosition(1);
       
  4772 			AddExpectedVisibilityChange(fullyVisible);
       
  4773 			break;
       
  4774 		case 11:
       
  4775 			{
       
  4776 			delete iVisWins1;
       
  4777 			iVisWins1=NULL;
       
  4778 			iVisWins1=NewBlueForgroundWindow();
       
  4779 
       
  4780 			iVisWins1->Activate();
       
  4781 			iVisWins1->BaseWin()->EnableVisibilityChangeEvents();
       
  4782 
       
  4783 			AddExpectedVisibilityChange(fullyVisible);
       
  4784 			}
       
  4785 			break;
       
  4786 		case 12:
       
  4787 			{
       
  4788 			delete iVisWins1;
       
  4789 			iVisWins1=NULL;
       
  4790 			iVisWins1=NewBlueForgroundWindow();
       
  4791 
       
  4792 			iVisWins1->Activate();
       
  4793 			iVisWins1->BaseWin()->EnableVisibilityChangeEvents();
       
  4794 			iVisWins1->BaseWin()->SetVisible(EFalse);
       
  4795 
       
  4796 			AddExpectedVisibilityChange(TWsVisibilityChangedEvent::ENotVisible);
       
  4797 			}
       
  4798 			break;
       
  4799 		case 13:
       
  4800 			{
       
  4801 			delete iVisWins1;
       
  4802 			iVisWins1=NULL;
       
  4803 			iVisWins1=NewBlueForgroundWindow();
       
  4804 
       
  4805 			iVisWins1->BaseWin()->EnableVisibilityChangeEvents();
       
  4806 			iVisWins1->Activate();
       
  4807 
       
  4808 			AddExpectedVisibilityChange(fullyVisible);
       
  4809 			}
       
  4810 			break;
       
  4811 		case 14:
       
  4812 			{
       
  4813 			delete iVisWins1;
       
  4814 			iVisWins1=NULL;
       
  4815 			iVisWins1=NewBlueForgroundWindow();
       
  4816 
       
  4817 			iVisWins1->Activate();
       
  4818 			iVisWins1->BaseWin()->SetVisible(EFalse);
       
  4819 			iVisWins1->BaseWin()->EnableVisibilityChangeEvents();
       
  4820 
       
  4821 			AddExpectedVisibilityChange(TWsVisibilityChangedEvent::ENotVisible);
       
  4822 			}
       
  4823 			break;
       
  4824 		default:
       
  4825 			delete iVisWins1;
       
  4826 			delete iVisWins2;
       
  4827 			iVisWins1 = NULL;
       
  4828 			iVisWins2 = NULL;
       
  4829 			delete iTransWin;
       
  4830 			iTransWin = NULL;
       
  4831 			CActiveScheduler::Stop();
       
  4832 			break;
       
  4833 		}
       
  4834 	TheClient->iWs.Flush();
       
  4835 	}
       
  4836 
       
  4837 void CTEventTest::CheckTimeStamp_NextSetOfEventsL()
       
  4838 	{
       
  4839 	iQueueClient->EventQueue()->SetCheckTimeStamp(ETrue);
       
  4840 	switch(iEventSet++)
       
  4841 		{
       
  4842 	case 0:
       
  4843 		iTest->SimulateKey(TRawEvent::EKeyDown, 'A');	// Create a raw event
       
  4844 		iTest->SimulateKey(TRawEvent::EKeyUp, 'A');	// Create a raw event
       
  4845 		AddExpectedEvent(EEventFocusGained);
       
  4846 		AddExpectedKey(EEventKeyDown,'A');
       
  4847 		AddExpectedKey(EEventKey,'A','a');
       
  4848 		AddExpectedKey(EEventKeyUp,'A','a');
       
  4849 		break;
       
  4850 	case 1:
       
  4851 		{
       
  4852 		_LIT8(KMsgParam,"CheckTimeStamp");
       
  4853 		TBuf8<0x20> params(KMsgParam);
       
  4854 		TInt err = TheClient->iWs.SendMessageToWindowGroup(iQueueClient->WindowGroupIdentifier(),TUid::Uid(123),params);
       
  4855 		AddExpectedEvent(EEventMessageReady);
       
  4856 		}
       
  4857 		break;
       
  4858 	default:
       
  4859 		CActiveScheduler::Stop();
       
  4860 		break;
       
  4861 		}
       
  4862 	TheClient->iWs.Flush();
       
  4863 	}
       
  4864 
       
  4865 /**
       
  4866  * @SYMTestCaseID GRAPHICS-WSERV-0001
       
  4867  *
       
  4868  * @SYMPREQ PREQ525
       
  4869  *
       
  4870  * @SYMTestCaseDesc Test Capture priority of different top most windows in a Group.
       
  4871  *
       
  4872  * @SYMTestPriority Critical
       
  4873  *
       
  4874  * @SYMTestStatus Implemented
       
  4875  *
       
  4876  * @SYMTestActions Create two different top client windows under one parent window
       
  4877  *	in a same window group. Add pointer event by clicking various position on the
       
  4878  *	window and Simulate the pointer event. Change the pointer capture flag, capture
       
  4879  *	priority and simulate the pointer event.
       
  4880  *
       
  4881  * @SYMTestExpectedResults In general the expected event and the window server event should
       
  4882  *	match same event handle, type and pointer position for following cases.
       
  4883  *	When pointer capture is disabled and capture priorities are 0, the pointer position on window1
       
  4884  *	window2 or parent window are same as expected.
       
  4885  *	When pointer capture is enabled and capture priorities are 0, the pointer position on window2(which is top most now)
       
  4886  *	is same as expected.
       
  4887  *	When pointer capture is enabled and capture priorities of win1 is greater than win2
       
  4888  *	the pointer position on win1 and win2 are same as expected.
       
  4889  *	The combination of above cases should match the general expexted result.
       
  4890  *
       
  4891  */
       
  4892 void CTEventTest::PointerCapture_NextSetOfEventsL()
       
  4893 	{
       
  4894 #if defined(LOGGING)
       
  4895 	TLogMessageText logMessageText;
       
  4896 	_LIT(KSet,"Pointer Capture SetOfEvents: %d (last=9)");
       
  4897 	logMessageText.Format(KSet,iEventSet);
       
  4898 	INFO_PRINTF1(logMessageText);
       
  4899 #endif
       
  4900 	switch(iEventSet++)
       
  4901 		{
       
  4902 		case 0:			//Create two top client windows of same group
       
  4903 			iVisWins1=new (ELeave) CTBlankWindow;
       
  4904 			iVisWins2=new (ELeave) CTBlankWindow;
       
  4905 			iVisWins1->ConstructL(*iQueueClient->iGroup);
       
  4906 			iVisWins2->ConstructL(*iQueueClient->iGroup);
       
  4907 			iVisWins1->SetColor(KRgbBlue);
       
  4908 			iVisWins1->SetExt(iQueueClient->ChildTopLeft(),iQueueClient->ChildSize());
       
  4909 			iVisWins1->Activate();
       
  4910 			iVisWins2->SetColor(KRgbGreen);
       
  4911 			iVisWins2->SetExt(iQueueClient->ChildTopLeft()+TPoint(15,15),iQueueClient->ChildSize());
       
  4912 			iVisWins2->Activate();
       
  4913 			iQueueClient->iWs.Flush();
       
  4914 			AddExpectedEvent(EEventFocusGained);
       
  4915 			break;
       
  4916 		case 1:			//Pointer capture are disabled and priorities are 0
       
  4917 			iVisWins1->BaseWin()->SetPointerCapture(RWindowBase::TCaptureDisabled);
       
  4918 			iVisWins1->BaseWin()->SetPointerCapturePriority(0);
       
  4919 			iVisWins2->BaseWin()->SetPointerCapture(RWindowBase::TCaptureDisabled);
       
  4920 			iVisWins2->BaseWin()->SetPointerCapturePriority(0);
       
  4921 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(35,25));	//Pointer on the first window
       
  4922 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(35,25));
       
  4923 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(50,30));	//Pointer on the second window(overlaping on first window)
       
  4924 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(50,30));
       
  4925 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(60,50));	//Pointer on the second window
       
  4926 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(60,50));
       
  4927 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(75,25));	//Pointer on the parent window
       
  4928 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(75,25));
       
  4929 			iQueueClient->iWs.Flush();
       
  4930 			SimulatePointer(TRawEvent::EButton1Down,35,25);
       
  4931 			SimulatePointer(TRawEvent::EButton1Up,35,25);
       
  4932 			SimulatePointer(TRawEvent::EButton1Down,50,30);
       
  4933 			SimulatePointer(TRawEvent::EButton1Up,50,30);
       
  4934 			SimulatePointer(TRawEvent::EButton1Down,60,50);
       
  4935 			SimulatePointer(TRawEvent::EButton1Up,60,50);
       
  4936 			SimulatePointer(TRawEvent::EButton1Down,75,25);
       
  4937 			SimulatePointer(TRawEvent::EButton1Up,75,25);
       
  4938 			break;
       
  4939 		case 2:			//Pointer capture are enabled and priorities are 0
       
  4940 			iVisWins1->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled);
       
  4941 			iVisWins2->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled);
       
  4942 			iVisWins1->BaseWin()->SetPointerCapturePriority(0);
       
  4943 			iVisWins2->BaseWin()->SetPointerCapturePriority(0);
       
  4944 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(35,25),(TInt)iVisWins2);	//Pointer on the first window
       
  4945 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(35,25),(TInt)iVisWins2);
       
  4946 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(50,30));	//Pointer on the second window(overlaping on first window)
       
  4947 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(50,30));
       
  4948 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(60,50));	//Pointer on the second window
       
  4949 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(60,50));
       
  4950 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(75,25),(TInt)iVisWins2);	//Pointer on the parent window
       
  4951 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(75,25),(TInt)iVisWins2);
       
  4952 			iQueueClient->iWs.Flush();
       
  4953 			SimulatePointer(TRawEvent::EButton1Down,35,25);
       
  4954 			SimulatePointer(TRawEvent::EButton1Up,35,25);
       
  4955 			SimulatePointer(TRawEvent::EButton1Down,50,30);
       
  4956 			SimulatePointer(TRawEvent::EButton1Up,50,30);
       
  4957 			SimulatePointer(TRawEvent::EButton1Down,60,50);
       
  4958 			SimulatePointer(TRawEvent::EButton1Up,60,50);
       
  4959 			SimulatePointer(TRawEvent::EButton1Down,75,25);
       
  4960 			SimulatePointer(TRawEvent::EButton1Up,75,25);
       
  4961 			break;
       
  4962 		case 3:			//Pointer capture are enabled and priorities of win1 is higher than win2
       
  4963 			iVisWins1->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled);
       
  4964 			iVisWins2->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled);
       
  4965 			iVisWins1->BaseWin()->SetPointerCapturePriority(1);
       
  4966 			iVisWins2->BaseWin()->SetPointerCapturePriority(0);
       
  4967 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(35,25));
       
  4968 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(35,25));
       
  4969 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(50,30));
       
  4970 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(50,30));
       
  4971 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(60,50));
       
  4972 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(60,50));
       
  4973 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(75,25),(TInt)iVisWins2);
       
  4974 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(75,25),(TInt)iVisWins2);
       
  4975 			iQueueClient->iWs.Flush();
       
  4976 			SimulatePointer(TRawEvent::EButton1Down,35,25);
       
  4977 			SimulatePointer(TRawEvent::EButton1Up,35,25);
       
  4978 			SimulatePointer(TRawEvent::EButton1Down,50,30);
       
  4979 			SimulatePointer(TRawEvent::EButton1Up,50,30);
       
  4980 			SimulatePointer(TRawEvent::EButton1Down,60,50);
       
  4981 			SimulatePointer(TRawEvent::EButton1Up,60,50);
       
  4982 			SimulatePointer(TRawEvent::EButton1Down,75,25);
       
  4983 			SimulatePointer(TRawEvent::EButton1Up,75,25);
       
  4984 			break;
       
  4985 		case 4:			//Pointer capture are enabled and priorities of win1 is equal to win2
       
  4986 			iVisWins1->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled);
       
  4987 			iVisWins2->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled);
       
  4988 			iVisWins1->BaseWin()->SetPointerCapturePriority(1);
       
  4989 			iVisWins2->BaseWin()->SetPointerCapturePriority(1);
       
  4990 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(35,25),(TInt)iVisWins2);
       
  4991 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(35,25),(TInt)iVisWins2);
       
  4992 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(50,30));
       
  4993 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(50,30));
       
  4994 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(60,50));
       
  4995 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(60,50));
       
  4996 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(75,25),(TInt)iVisWins2);
       
  4997 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(75,25),(TInt)iVisWins2);
       
  4998 			iQueueClient->iWs.Flush();
       
  4999 			SimulatePointer(TRawEvent::EButton1Down,35,25);
       
  5000 			SimulatePointer(TRawEvent::EButton1Up,35,25);
       
  5001 			SimulatePointer(TRawEvent::EButton1Down,50,30);
       
  5002 			SimulatePointer(TRawEvent::EButton1Up,50,30);
       
  5003 			SimulatePointer(TRawEvent::EButton1Down,60,50);
       
  5004 			SimulatePointer(TRawEvent::EButton1Up,60,50);
       
  5005 			SimulatePointer(TRawEvent::EButton1Down,75,25);
       
  5006 			SimulatePointer(TRawEvent::EButton1Up,75,25);
       
  5007 			break;
       
  5008 		case 5:			//Pointer capture are enabled and priorities of win2 is higher than win1
       
  5009 			iVisWins1->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled);
       
  5010 			iVisWins2->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled);
       
  5011 			iVisWins1->BaseWin()->SetPointerCapturePriority(0);
       
  5012 			iVisWins2->BaseWin()->SetPointerCapturePriority(1);
       
  5013 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(35,25),(TInt)iVisWins2);
       
  5014 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(35,25),(TInt)iVisWins2);
       
  5015 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(50,30));
       
  5016 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(50,30));
       
  5017 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(60,50));
       
  5018 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(60,50));
       
  5019 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(75,25),(TInt)iVisWins2);
       
  5020 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(75,25),(TInt)iVisWins2);
       
  5021 			iQueueClient->iWs.Flush();
       
  5022 			SimulatePointer(TRawEvent::EButton1Down,35,25);
       
  5023 			SimulatePointer(TRawEvent::EButton1Up,35,25);
       
  5024 			SimulatePointer(TRawEvent::EButton1Down,50,30);
       
  5025 			SimulatePointer(TRawEvent::EButton1Up,50,30);
       
  5026 			SimulatePointer(TRawEvent::EButton1Down,60,50);
       
  5027 			SimulatePointer(TRawEvent::EButton1Up,60,50);
       
  5028 			SimulatePointer(TRawEvent::EButton1Down,75,25);
       
  5029 			SimulatePointer(TRawEvent::EButton1Up,75,25);
       
  5030 			break;
       
  5031 		case 6:			//Pointer capture are enabled for all groups and priorities of win1 is higher than win2
       
  5032 			iVisWins1->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled|RWindowBase::TCaptureFlagAllGroups);
       
  5033 			iVisWins2->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled|RWindowBase::TCaptureFlagAllGroups);
       
  5034 			iVisWins1->BaseWin()->SetPointerCapturePriority(1);
       
  5035 			iVisWins2->BaseWin()->SetPointerCapturePriority(0);
       
  5036 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(35,25));
       
  5037 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(35,25));
       
  5038 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(50,30));
       
  5039 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(50,30));
       
  5040 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(60,50));
       
  5041 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(60,50));
       
  5042 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(75,25),(TInt)iVisWins2);
       
  5043 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(75,25),(TInt)iVisWins2);
       
  5044 			iQueueClient->iWs.Flush();
       
  5045 			SimulatePointer(TRawEvent::EButton1Down,35,25);
       
  5046 			SimulatePointer(TRawEvent::EButton1Up,35,25);
       
  5047 			SimulatePointer(TRawEvent::EButton1Down,50,30);
       
  5048 			SimulatePointer(TRawEvent::EButton1Up,50,30);
       
  5049 			SimulatePointer(TRawEvent::EButton1Down,60,50);
       
  5050 			SimulatePointer(TRawEvent::EButton1Up,60,50);
       
  5051 			SimulatePointer(TRawEvent::EButton1Down,75,25);
       
  5052 			SimulatePointer(TRawEvent::EButton1Up,75,25);
       
  5053 			break;
       
  5054 		case 7:			//Pointer capture are enabled and priorities of iWin is higher than the other windows
       
  5055 			iVisWins1->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled);
       
  5056 			iVisWins2->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled);
       
  5057 			iVisWins1->BaseWin()->SetPointerCapturePriority(0);
       
  5058 			iVisWins2->BaseWin()->SetPointerCapturePriority(0);
       
  5059 			iQueueClient->iWin->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled);
       
  5060 			iQueueClient->iWin->BaseWin()->SetPointerCapturePriority(1);
       
  5061 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(80,20));	//Pointer on the parent window
       
  5062 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(80,20));
       
  5063 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(35,25),(TInt)iVisWins2);
       
  5064 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(35,25),(TInt)iVisWins2);
       
  5065 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(60,50));
       
  5066 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(60,50));
       
  5067 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(50,30));
       
  5068 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(50,30));
       
  5069 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(75,25));
       
  5070 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(75,25));
       
  5071 			iQueueClient->iWs.Flush();
       
  5072 			SimulatePointer(TRawEvent::EButton1Down,80,20);
       
  5073 			SimulatePointer(TRawEvent::EButton1Up,80,20);
       
  5074 			SimulatePointer(TRawEvent::EButton1Down,35,25);
       
  5075 			SimulatePointer(TRawEvent::EButton1Up,35,25);
       
  5076 			SimulatePointer(TRawEvent::EButton1Down,60,50);
       
  5077 			SimulatePointer(TRawEvent::EButton1Up,60,50);
       
  5078 			SimulatePointer(TRawEvent::EButton1Down,50,30);
       
  5079 			SimulatePointer(TRawEvent::EButton1Up,50,30);
       
  5080 			SimulatePointer(TRawEvent::EButton1Down,75,25);
       
  5081 			SimulatePointer(TRawEvent::EButton1Up,75,25);
       
  5082 			break;
       
  5083 		case 8:			//Pointer capture are enabled and priorities of iWin is 0
       
  5084 			iVisWins1->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled);
       
  5085 			iVisWins2->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled);
       
  5086 			iVisWins1->BaseWin()->SetPointerCapturePriority(1);
       
  5087 			iVisWins2->BaseWin()->SetPointerCapturePriority(0);
       
  5088 			iQueueClient->iWin->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled);
       
  5089 			iQueueClient->iWin->BaseWin()->SetPointerCapturePriority(0);
       
  5090 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(80,20),(TInt)iVisWins2);	//Pointer on the parent window
       
  5091 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(80,20),(TInt)iVisWins2);
       
  5092 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(35,25));
       
  5093 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(35,25));
       
  5094 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(60,50));
       
  5095 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(60,50));
       
  5096 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(50,30));
       
  5097 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(50,30));
       
  5098 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(75,25),(TInt)iVisWins2);
       
  5099 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(75,25),(TInt)iVisWins2);
       
  5100 			iQueueClient->iWs.Flush();
       
  5101 			SimulatePointer(TRawEvent::EButton1Down,80,20);
       
  5102 			SimulatePointer(TRawEvent::EButton1Up,80,20);
       
  5103 			SimulatePointer(TRawEvent::EButton1Down,35,25);
       
  5104 			SimulatePointer(TRawEvent::EButton1Up,35,25);
       
  5105 			SimulatePointer(TRawEvent::EButton1Down,60,50);
       
  5106 			SimulatePointer(TRawEvent::EButton1Up,60,50);
       
  5107 			SimulatePointer(TRawEvent::EButton1Down,50,30);
       
  5108 			SimulatePointer(TRawEvent::EButton1Up,50,30);
       
  5109 			SimulatePointer(TRawEvent::EButton1Down,75,25);
       
  5110 			SimulatePointer(TRawEvent::EButton1Up,75,25);
       
  5111 			break;
       
  5112 		case 9:			//Pointer capture are enabled and with different groups
       
  5113 			iVisWins1->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled|RWindowBase::TCaptureFlagAllGroups);
       
  5114 			iVisWins2->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled|RWindowBase::TCaptureFlagAllGroups);
       
  5115 			iVisWins1->BaseWin()->SetPointerCapturePriority(0);
       
  5116 			iVisWins2->BaseWin()->SetPointerCapturePriority(0);
       
  5117 			iQueueClient->iWin->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled|RWindowBase::TCaptureFlagAllGroups);
       
  5118 			iQueueClient->iWin->BaseWin()->SetPointerCapturePriority(1);
       
  5119 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(25,150),(TInt)iVisWins2);
       
  5120 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(25,150),(TInt)iVisWins2);
       
  5121 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(150,25),(TInt)iVisWins2);
       
  5122 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(150,25),(TInt)iVisWins2);
       
  5123 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(80,20));	//Pointer on the parent window
       
  5124 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(80,20));
       
  5125 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(35,25),(TInt)iVisWins2);
       
  5126 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(35,25),(TInt)iVisWins2);
       
  5127 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(60,50));
       
  5128 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(60,50));
       
  5129 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(50,30));
       
  5130 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(50,30));
       
  5131 			AddExpectedPointerCapture(TPointerEvent::EButton1Down,TPoint(75,25));
       
  5132 			AddExpectedPointerCapture(TPointerEvent::EButton1Up,TPoint(75,25));
       
  5133 			iQueueClient->iWs.Flush();
       
  5134 			SimulatePointer(TRawEvent::EButton1Down,25,150);
       
  5135 			SimulatePointer(TRawEvent::EButton1Up,25,150);
       
  5136 			SimulatePointer(TRawEvent::EButton1Down,150,25);
       
  5137 			SimulatePointer(TRawEvent::EButton1Up,150,25);
       
  5138 			SimulatePointer(TRawEvent::EButton1Down,80,20);
       
  5139 			SimulatePointer(TRawEvent::EButton1Up,80,20);
       
  5140 			SimulatePointer(TRawEvent::EButton1Down,35,25);
       
  5141 			SimulatePointer(TRawEvent::EButton1Up,35,25);
       
  5142 			SimulatePointer(TRawEvent::EButton1Down,60,50);
       
  5143 			SimulatePointer(TRawEvent::EButton1Up,60,50);
       
  5144 			SimulatePointer(TRawEvent::EButton1Down,50,30);
       
  5145 			SimulatePointer(TRawEvent::EButton1Up,50,30);
       
  5146 			SimulatePointer(TRawEvent::EButton1Down,75,25);
       
  5147 			SimulatePointer(TRawEvent::EButton1Up,75,25);
       
  5148 			break;
       
  5149 		default:
       
  5150 			delete iVisWins1;
       
  5151 			delete iVisWins2;
       
  5152 			iVisWins1=NULL;
       
  5153 			iVisWins2=NULL;
       
  5154 			CActiveScheduler::Stop();
       
  5155 			break;
       
  5156 		}
       
  5157 	TheClient->iWs.Flush();
       
  5158 	}
       
  5159 
       
  5160 /**
       
  5161 PDEF110849
       
  5162 Allocate a pointer buffer, send it some events and then disconnect.
       
  5163 Now fill the event queue, causing a purge.
       
  5164 The purge will call void CWsPointerBuffer::DiscardPointerMoveBuffer(TUint aHandle)
       
  5165 in which an access violation occurred because iCurrentBuffer had not been set to NULL.
       
  5166 */
       
  5167 void CTEventTest::PointerBufferPurge_NextSetOfEventsL()
       
  5168 	{
       
  5169 #if defined(LOGGING)
       
  5170 	TLogMessageText logMessageText;
       
  5171 	_LIT(KSet,"PointerBufferPurge SetOfEvents: %d of 1");
       
  5172 	logMessageText.Format(KSet,iEventSet);
       
  5173 	TheClient->LogMessage(logMessageText);
       
  5174 #endif
       
  5175 	iTheClientFlush=TheClient->iWs.SetAutoFlush(ETrue);
       
  5176 	iQuequeClientFlush=iQueueClient->iWs.SetAutoFlush(ETrue);
       
  5177 	switch(iEventSet++)
       
  5178 		{
       
  5179 		case 0:
       
  5180 			{
       
  5181 			RWindowBase& win = *iQueueClient->iWin->BaseWin();
       
  5182 			
       
  5183 			// Cause a connect to happen
       
  5184 			RDebug::Print(_L("PointerBufferPurge - AllocPointerMoveBuffer()"));
       
  5185 			win.AllocPointerMoveBuffer(10, 0);
       
  5186 			
       
  5187 			// Allow pen events to be received
       
  5188 			RDebug::Print(_L("PointerBufferPurge - EnablePointerMoveBuffer()"));
       
  5189 			win.EnablePointerMoveBuffer();
       
  5190 			
       
  5191 			// Simulate some pen events
       
  5192 			RDebug::Print(_L("PointerBufferPurge - Events"));
       
  5193 			SimulatePointer(TRawEvent::EPointerMove,10,20);
       
  5194 			SimulatePointer(TRawEvent::EButton1Down,10,20);
       
  5195 			SimulatePointer(TRawEvent::EPointerMove,11,21);
       
  5196 			SimulatePointer(TRawEvent::EButton1Up,11,21);
       
  5197 	
       
  5198 			// Disconnect
       
  5199 			RDebug::Print(_L("PointerBufferPurge - FreePointerMoveBuffer()"));
       
  5200 			win.FreePointerMoveBuffer();
       
  5201 			
       
  5202 			// Send sufficient events to cause a purge to happen
       
  5203 			for (TInt i=0; i<EMaxEventQueueSize; i++)
       
  5204 				{
       
  5205 				RDebug::Print(_L("PointerBufferPurge - Purge Loop %d"), i);
       
  5206 				SimulatePointer(TRawEvent::EButton1Up,15,25);
       
  5207 				}
       
  5208 	
       
  5209 			// Expected events
       
  5210 			// - We only expect the focus and button up events because the other events have been purged
       
  5211 			// - button up events which are not paired with button down take precedence 
       
  5212 			// - but even some of our button up events will have been purged - hence the lower count
       
  5213 			
       
  5214 			AddExpectedEvent(EEventFocusGained);
       
  5215 			
       
  5216 			for (TInt i=0; i<EMaxEventQueueSize-1; i++)
       
  5217 				{
       
  5218 				AddExpectedPointer(TPointerEvent::EButton1Up, TPoint(15-EWinPositionX,25-EWinPositionY));
       
  5219 				}
       
  5220 				
       
  5221 			break;
       
  5222 			}
       
  5223 		default:
       
  5224 			CActiveScheduler::Stop();
       
  5225 		break;
       
  5226 		}
       
  5227 	TheClient->iWs.SetAutoFlush(iTheClientFlush);
       
  5228 	iQueueClient->iWs.SetAutoFlush(iQuequeClientFlush);
       
  5229 	}
       
  5230 
       
  5231 /**
       
  5232  * @SYMTestCaseID GRAPHICS-WSERV-0025
       
  5233  *
       
  5234  * @SYMDEF DEF085009
       
  5235  *
       
  5236  * @SYMTestCaseDesc Test removal of event handlers mid-way through processing an event.
       
  5237  *
       
  5238  * @SYMTestPriority Critical
       
  5239  *
       
  5240  * @SYMTestStatus Implemented
       
  5241  *
       
  5242  * @SYMTestActions The following tests use RRemovable anim to replicate the removal of
       
  5243  * event handlers mid-way through processing an event (where an event is offered to each of the
       
  5244  * listed event handlers).
       
  5245  *
       
  5246  * RRemovableAnim is an anim which removes itself from the event handler list
       
  5247  * after receiving n events, where n is the 'lifetime' of the anim measured in events received.
       
  5248  * By setting the lifetimes of a number of these anims, we replicate the removal of event handlers
       
  5249  * mid-way through processing an event.
       
  5250  *
       
  5251  * Event set 0:
       
  5252  *  Sends 2 events e1,e2 and expects them be received by wserv event processing.
       
  5253  *
       
  5254  * Event set 1: (Simple scenario)
       
  5255  *  Adds 3 removable anims to event handler list
       
  5256  *  Sets lifetimes as {1000,2,5}
       
  5257  *  Sends 6 events
       
  5258  *  Expected events to be received by anims: {6,2,5}
       
  5259  *
       
  5260  * Event set 2: (Manual removal and reset state)
       
  5261  *  Manually remove all anims from event handler list
       
  5262  *  Sends 2 events
       
  5263  *  No events expected to be received by anims
       
  5264  *  Resets all anims ready for next test
       
  5265  *
       
  5266  * Event set 3: (Removal of multiple anims on receipt of same event)
       
  5267  *  Adds 10 removable anims in event handler list
       
  5268  *  Set lifetimes: {1,5,9,3,8,8,8,10,5,2}
       
  5269  *  Sends 12 events:
       
  5270  *  Expected number of received events for anims: {1,5,9,3,8,8,8,10,5,2}
       
  5271  *
       
  5272  * Event set 4: (Manual removal and reset state)
       
  5273  *  Manually remove all anims from event handler list
       
  5274  *  Sends 2 events
       
  5275  *  No events expected to be received by anims
       
  5276  *  Resets all anims ready for next test
       
  5277  *
       
  5278  * Event set 5: (Addition of anims to non-empty event handler list, part 1)
       
  5279  *  Adds 6 removable anims in the event handler list
       
  5280  *  Set lifetimes: {1,1,1,5,5,5}
       
  5281  *  Sends 2 events:
       
  5282  *  Expected number of received events for anims: {1,1,1,2,2,2}
       
  5283  *
       
  5284  * Event set 6: (Addition of anims to non-empty event handler list, part 2)
       
  5285  *  Readds first 3 anims to event handler list
       
  5286  *  Sets lifetimes of these three anims {13,24,6}
       
  5287  *  Sends 5 events:
       
  5288  *  Expected number of received events for anims: {5,5,5,3,3,3}
       
  5289  *
       
  5290  * Event set 7: (Addition of anims to non-empty event handler list, part 3)
       
  5291  *  Sends 16 events:
       
  5292  *  Expected number of received events for anims: {8,16,1,0,0,0}
       
  5293  *
       
  5294  * Event set 8: (Manual Removal and reset state)
       
  5295  *  Manually remove all anims from event handler list
       
  5296  *  Sends 2 events
       
  5297  *  No events expected to be received by anims
       
  5298  *  Resets all anims ready for next test
       
  5299  *
       
  5300  * Event set 9: (Creating anims which again generate events.)
       
  5301  *  Create 3 anims. One anims generates events in its OfferrawEvent function.
       
  5302  *	Check the funtionality of ProcessRawEvent in Wserv when it is called
       
  5303  *	recursively. Also check the fix for defect INC095892.
       
  5304  *
       
  5305  * @SYMTestExpectedResults
       
  5306  *  All events should be received by wserv event processing
       
  5307  *  Each anim should only receive events when (number of events received by anim) <= (lifetime of anim)
       
  5308  */
       
  5309 void CTEventTest::EventHandlerRemoval_NextSetOfEventsL()
       
  5310 	{
       
  5311 #if defined(LOGGING)
       
  5312 	INFO_PRINTF1(_L("EventHandlerRemoval SetOfEvents: (Max=8)"));
       
  5313 #endif
       
  5314 	switch(iEventSet++)
       
  5315 		{
       
  5316 		case 0:
       
  5317 		#if defined(LOGGING)
       
  5318 			INFO_PRINTF1(_L("AUTO  Event Handler Removal Anim Events"));
       
  5319 		#endif
       
  5320 		#if defined(DETAILED)
       
  5321 			INFO_PRINTF1(_L("No anims in event handler list"));
       
  5322 			INFO_PRINTF1(_L(" Send 2 events"));
       
  5323 			INFO_PRINTF1(_L(" - Expected to be received by wserv event processing"));
       
  5324 		#endif
       
  5325 			// Always get a focus gain at start
       
  5326 			AddExpectedEvent(EEventFocusGained);
       
  5327 			// All expected to be received by wserv event processing
       
  5328 			AddExpectedKey(EEventKeyDown,32,ETrue);
       
  5329 			AddExpectedKey(EEventKeyUp,32,ETrue);
       
  5330 			// Send 2 events - none expected to be received by anims,
       
  5331 			iTest->SimulateKey(TRawEvent::EKeyDown,32);
       
  5332 			iTest->SimulateKey(TRawEvent::EKeyUp,32);
       
  5333 			// Flush events to wserv
       
  5334 			TheClient->iWs.Flush();
       
  5335 			// Create all anims for all tests in first event set because
       
  5336 			// first event set is only place where leaving functions can be called
       
  5337 			EventHandlerRemoval_CreateAnimsL(10);
       
  5338 			break;
       
  5339 		case 1:
       
  5340 			{
       
  5341 		#if defined(DETAILED)
       
  5342 			INFO_PRINTF1(_L(" Add 3 removable anims to event handler list"));
       
  5343 			INFO_PRINTF1(_L(" Set lifetimes for anims: {1000,2,5}"));
       
  5344 			INFO_PRINTF1(_L(" Send 6 events"));
       
  5345 			INFO_PRINTF1(_L(" - Expected number of received events for anims: {6,2,5}"));
       
  5346 			INFO_PRINTF1(_L(" All events expected to be received by wserv event processing"));
       
  5347 		#endif
       
  5348 			const TInt KLifetimes [] = {1000,2,5};
       
  5349 			EventHandlerRemoval_PrepareAnims(KLifetimes, 3);
       
  5350 			EventHandlerRemoval_CreateExpectedEvents(6,3);
       
  5351 			// Flush events to wserv
       
  5352 			TheClient->iWs.Flush();
       
  5353 			// Check each anim has received the expected events
       
  5354 			EventHandlerRemoval_CheckExpectedEventsReceivedByAnims();
       
  5355 			}
       
  5356 			break;
       
  5357 		case 2:
       
  5358 			{
       
  5359 			// Remove all anims, check removal was successful
       
  5360 			// and reset all anims ready for next test
       
  5361 			EventHandlerRemoval_RemoveAndResetAllAnims();
       
  5362 			}
       
  5363 			break;
       
  5364 		case 3:
       
  5365 			{
       
  5366 		#if defined(DETAILED)
       
  5367 			INFO_PRINTF1(_L(" Add 10 removable anims in event handler list"));
       
  5368 			INFO_PRINTF1(_L(" Set lifetimes: {1,5,9,3,8,8,8,10,5,2}"));
       
  5369 			INFO_PRINTF1(_L(" Send 12 events"));
       
  5370 			INFO_PRINTF1(_L(" - Expected number of received events for anims:{1,5,9,3,8,8,8,10,5,2}"));
       
  5371 			INFO_PRINTF1(_L(" All expected to be received by wserv event processing"));
       
  5372 		#endif
       
  5373 			const TInt KLifetimes [] = {1,5,9,3,8,8,8,10,5,2};
       
  5374 
       
  5375 			// Create anims, set lifetimes, add to event handlers and add to iRemovableAnims array
       
  5376 			EventHandlerRemoval_PrepareAnims(KLifetimes, 10);
       
  5377 			EventHandlerRemoval_CreateExpectedEvents(12,10);
       
  5378 			// Flush events to wserv
       
  5379 			TheClient->iWs.Flush();
       
  5380 			// Check each anim has received the expected events
       
  5381 			EventHandlerRemoval_CheckExpectedEventsReceivedByAnims();
       
  5382 			}
       
  5383 			break;
       
  5384 		case 4:
       
  5385 			{
       
  5386 			// Remove all anims, check removal was successful
       
  5387 			// and reset all anims ready for next test
       
  5388 			EventHandlerRemoval_RemoveAndResetAllAnims();
       
  5389 			}
       
  5390 			break;
       
  5391 		case 5:
       
  5392 			{
       
  5393 		#if defined(DETAILED)
       
  5394 			INFO_PRINTF1(_L(" Add 6 removable anims in event handler list"));
       
  5395 			INFO_PRINTF1(_L(" Set lifetimes: {1,1,1,5,5,5}"));
       
  5396 			INFO_PRINTF1(_L(" Send 2 events"));
       
  5397 			INFO_PRINTF1(_L(" - Expected number of received events for anims:{1,1,1,2,2,2}"));
       
  5398 			INFO_PRINTF1(_L(" All expected to be received by wserv event processing"));
       
  5399 		#endif
       
  5400 			const TInt KLifetimes [] = {1,1,1,5,5,5};
       
  5401 
       
  5402 			// Create anims, set lifetimes, add to event handlers and add to iRemovableAnims array
       
  5403 			EventHandlerRemoval_PrepareAnims(KLifetimes, 6);
       
  5404 			EventHandlerRemoval_CreateExpectedEvents(2, 6);
       
  5405 			// Flush events to wserv
       
  5406 			TheClient->iWs.Flush();
       
  5407 			// Check each anim has received the expected events
       
  5408 			EventHandlerRemoval_CheckExpectedEventsReceivedByAnims();
       
  5409 			}
       
  5410 			break;
       
  5411 		case 6:
       
  5412 			{
       
  5413 		#if defined(DETAILED)
       
  5414 			INFO_PRINTF1(_L(" Readds first 3 removable anims to event handler list"));
       
  5415 			INFO_PRINTF1(_L(" Set lifetimes of these three anims {13,24,6}"));
       
  5416 			INFO_PRINTF1(_L(" Send 5 events"));
       
  5417 			INFO_PRINTF1(_L(" - Expected number of received events for anims: {5,5,5,3,3,3}"));
       
  5418 			INFO_PRINTF1(_L(" All expected to be received by wserv event processing"));
       
  5419 		#endif
       
  5420 			const TInt KLifetimes [] = {13,24,6};
       
  5421 
       
  5422 			// Create anims, set lifetimes, add to event handlers and add to iRemovableAnims array
       
  5423 			EventHandlerRemoval_PrepareAnims(KLifetimes, 3);
       
  5424 			EventHandlerRemoval_CreateExpectedEvents(5, 6);
       
  5425 			// Flush events to wserv
       
  5426 			TheClient->iWs.Flush();
       
  5427 			// Check each anim has received the expected events
       
  5428 			EventHandlerRemoval_CheckExpectedEventsReceivedByAnims();
       
  5429 			}
       
  5430 			break;
       
  5431 		case 7:
       
  5432 			{
       
  5433 		#if defined(DETAILED)
       
  5434 			INFO_PRINTF1(_L(" Send 16 events"));
       
  5435 			INFO_PRINTF1(_L(" - Expected number of received events for anims:{8,16,1,0,0,0}"));
       
  5436 			INFO_PRINTF1(_L(" All expected to be received by wserv event processing"));
       
  5437 		#endif
       
  5438 			EventHandlerRemoval_CreateExpectedEvents(16, 3);
       
  5439 			// Flush events to wserv
       
  5440 			TheClient->iWs.Flush();
       
  5441 			// Check each anim has received the expected events
       
  5442 			EventHandlerRemoval_CheckExpectedEventsReceivedByAnims();
       
  5443 			}
       
  5444 			break;
       
  5445 		case 8:
       
  5446 			{
       
  5447 			// Remove all anims, check removal was successful
       
  5448 			// and reset all anims ready for next test
       
  5449 			EventHandlerRemoval_RemoveAndResetAllAnims();
       
  5450 			}
       
  5451 			break;
       
  5452 		case 9:
       
  5453 			EventHandlerRemoval_CheckRecursionOfProcessRawEvent();
       
  5454 			break;
       
  5455 		case 10:
       
  5456 			EventHandlerRemoval_AddEventHandlerMultipleTimes();
       
  5457 			break;
       
  5458 		default:
       
  5459 		#if defined(DETAILED)
       
  5460 			INFO_PRINTF1(_L(" Test postamble"));
       
  5461 			INFO_PRINTF1(_L(" Destroy anims"));
       
  5462 		#endif
       
  5463 			// Destroy anims
       
  5464 			EventHandlerRemoval_DestroyAllAnims();
       
  5465 			iRemovableAnims->Close();
       
  5466 			delete iRemovableAnims;
       
  5467 			iRemovableAnims = NULL;
       
  5468 			CActiveScheduler::Stop();
       
  5469 			break;
       
  5470 		}
       
  5471 	TheClient->iWs.Flush();
       
  5472 	}
       
  5473 
       
  5474 /**
       
  5475  * Creates an array of aAnimCount anims on heap
       
  5476  * Assigns array to iRemovableAnims for use in rest of tests
       
  5477  */
       
  5478 void CTEventTest::EventHandlerRemoval_CreateAnimsL(TInt aAnimCount)
       
  5479 	{
       
  5480 	RPointerArray<RRemovableAnim>* removableAnims = new (ELeave) RPointerArray<RRemovableAnim>();
       
  5481 	CleanupStack::PushL(removableAnims);
       
  5482 	for (TInt animIndex = 0; animIndex < aAnimCount; animIndex++)
       
  5483 		{
       
  5484 		RRemovableAnim* anim = RRemovableAnim::NewLC(iQueueClient->iWin->BaseWin(), iAnimDll);
       
  5485 		removableAnims->AppendL(anim);
       
  5486 		}
       
  5487 	CleanupStack::Pop(aAnimCount, (*removableAnims)[0]);
       
  5488 	CleanupStack::Pop(removableAnims);
       
  5489 	iRemovableAnims = removableAnims;
       
  5490 	}
       
  5491 
       
  5492 /**
       
  5493  * Sets lifetimes of anims as specified in aLifeTimes
       
  5494  * Adds anims to event handler list
       
  5495  */
       
  5496 void CTEventTest::EventHandlerRemoval_PrepareAnims(const TInt* aLifetimes, TInt aAnimCount)
       
  5497 	{
       
  5498 	for (TInt animIndex = 0; animIndex < aAnimCount; animIndex++)
       
  5499 		{
       
  5500 		RRemovableAnim* anim = (*iRemovableAnims)[animIndex];
       
  5501 		anim->SetEventHandlerLifetime(aLifetimes[animIndex]);
       
  5502 		anim->AddToEventHandlers();
       
  5503 		}
       
  5504 	}
       
  5505 
       
  5506 /**
       
  5507  * Creates aEventCount key events to be used in test
       
  5508  * Adds the expected event aEvent to the first aLiveAnimCount anims
       
  5509  * Adds expected events observed by the rest of wserv
       
  5510  * Simulates events on wserv
       
  5511  */
       
  5512 void CTEventTest::EventHandlerRemoval_CreateExpectedEvents(TInt aEventCount, TInt aLiveAnimCount)
       
  5513 	{
       
  5514 	RArray<TRawEvent> events;
       
  5515 
       
  5516 	// Add expected events to anims
       
  5517 	for (TInt eventCount = 0; eventCount < aEventCount; eventCount++)
       
  5518 		{
       
  5519 		TRawEvent rawEvent;
       
  5520 		TInt scanCode = 33 + eventCount;
       
  5521 		// Alternate key down, key up events.
       
  5522 		if (eventCount%2 == 0)
       
  5523 			{
       
  5524 			rawEvent.Set(TRawEvent::EKeyDown, scanCode);
       
  5525 			}
       
  5526 		else
       
  5527 			{
       
  5528 			rawEvent.Set(TRawEvent::EKeyUp, scanCode);
       
  5529 			}
       
  5530  		EventHandlerRemoval_AddExpectedEvent(rawEvent, aLiveAnimCount);
       
  5531 		events.Append(rawEvent);
       
  5532 		}
       
  5533 
       
  5534 	// Simulates expected events
       
  5535 	for (TInt eventCount = 0; eventCount < aEventCount; eventCount++)
       
  5536 		{
       
  5537 		TRawEvent event = events[eventCount];
       
  5538 		iTest->SimulateKey(event.Type(), event.ScanCode());
       
  5539 		}
       
  5540 
       
  5541 	events.Close();
       
  5542 	}
       
  5543 
       
  5544 /**
       
  5545  * Adds the expected event aEvent to the first aLiveAnimCount anims
       
  5546  * Adds expected event observed by the rest of wserv
       
  5547  */
       
  5548 void CTEventTest::EventHandlerRemoval_AddExpectedEvent(TRawEvent aEvent, TInt aLiveAnimCount)
       
  5549 	{
       
  5550 	// Add event to each of the anims
       
  5551 	for (TInt animIndex = 0; animIndex < aLiveAnimCount; animIndex++)
       
  5552 		{
       
  5553 		TInt err = (*iRemovableAnims)[animIndex]->AddExpectedEvent(aEvent);
       
  5554 		}
       
  5555 	TInt eventType = (aEvent.Type() == TRawEvent::EKeyDown ? EEventKeyDown : EEventKeyUp);
       
  5556 	AddExpectedKey(eventType, aEvent.ScanCode(), ETrue);
       
  5557 	}
       
  5558 
       
  5559 /**
       
  5560  * Checks each anim has received the expected events
       
  5561  */
       
  5562 void CTEventTest::EventHandlerRemoval_CheckExpectedEventsReceivedByAnims()
       
  5563 	{
       
  5564 	for (TInt animIndex = iRemovableAnims->Count() - 1; animIndex >= 0; animIndex--)
       
  5565 		{
       
  5566 		if (!(*iRemovableAnims)[animIndex]->TestPassed())
       
  5567 			{
       
  5568 			Failed();
       
  5569 			break;
       
  5570 			}
       
  5571 		}
       
  5572 	}
       
  5573 
       
  5574 
       
  5575 /**
       
  5576  * Create three anims. In the first anim's Offer raw event generate two more events
       
  5577  * which will call recursively the process raw event at the server side.
       
  5578  * The second and third anims are just removable anims. To simulate the scenario 
       
  5579  * for the defect INC095892. If teh fix for this is defect is not supplied then
       
  5580  * wserv would panic for this test case.
       
  5581  */
       
  5582 void CTEventTest::EventHandlerRemoval_CheckRecursionOfProcessRawEvent()
       
  5583 	{
       
  5584 	iTheClientFlush=TheClient->iWs.SetAutoFlush(ETrue);
       
  5585 	iQuequeClientFlush=iQueueClient->iWs.SetAutoFlush(ETrue);
       
  5586 	
       
  5587 	// Create 3 anims	
       
  5588 	RRemovableAnim* eventRecurAnim = RRemovableAnim::NewLC(iQueueClient->iWin->BaseWin(), iAnimDll);
       
  5589 	RRemovableAnim* removableAnim = RRemovableAnim::NewLC(iQueueClient->iWin->BaseWin(), iAnimDll);
       
  5590 	RRemovableAnim* eventAnim = RRemovableAnim::NewLC(iQueueClient->iWin->BaseWin(), iAnimDll);
       
  5591 
       
  5592 	// Add these anim as event handlers and set thier respective life time
       
  5593 	eventRecurAnim->AddToEventHandlers();
       
  5594 	eventRecurAnim->SetEventHandlerLifetime(4);
       
  5595 	
       
  5596 	removableAnim->AddToEventHandlers();
       
  5597 	removableAnim->SetEventHandlerLifetime(1);
       
  5598 	
       
  5599 	eventAnim->AddToEventHandlers();
       
  5600 	eventAnim->SetEventHandlerLifetime(2);
       
  5601 
       
  5602 	TRawEvent rawEvent1;
       
  5603 	TRawEvent rawEvent2;
       
  5604 	TRawEvent rawEvent3;
       
  5605 	rawEvent1.Set(TRawEvent::EKeyDown, 60);
       
  5606 	rawEvent2.Set(TRawEvent::EKeyUp, 34);
       
  5607 	rawEvent3.Set(TRawEvent::EKeyUp, 35);
       
  5608 	
       
  5609 	eventRecurAnim->AddExpectedEvent(rawEvent2);
       
  5610 	eventRecurAnim->AddExpectedEvent(rawEvent3);
       
  5611 	
       
  5612 	removableAnim->AddExpectedEvent(rawEvent2);
       
  5613 	
       
  5614 	eventAnim->AddExpectedEvent(rawEvent2);
       
  5615 	eventAnim->AddExpectedEvent(rawEvent3);
       
  5616 
       
  5617 	// Add these events to iQueueClient for testing	
       
  5618 	AddExpectedKey(EEventKeyUp, 34, ETrue);
       
  5619 	AddExpectedKey(EEventKeyUp, 35, ETrue);
       
  5620 
       
  5621 	iTest->SimulateKey(rawEvent1.Type(), rawEvent1.ScanCode());
       
  5622 	
       
  5623 	CleanupStack::PopAndDestroy(3, eventRecurAnim);
       
  5624 	
       
  5625 	TheClient->iWs.SetAutoFlush(iTheClientFlush);
       
  5626 	iQueueClient->iWs.SetAutoFlush(iQuequeClientFlush);
       
  5627 	}
       
  5628 
       
  5629 /**
       
  5630  * Manually removes all anims from event handlers array
       
  5631  */
       
  5632 void CTEventTest::EventHandlerRemoval_ManuallyRemoveAllAnims()
       
  5633 	{
       
  5634 	// Manually remove all anims from event handler list
       
  5635 	for (TInt animIndex = iRemovableAnims->Count() - 1; animIndex >= 0; animIndex--)
       
  5636 		{
       
  5637 		(*iRemovableAnims)[animIndex]->RemoveFromEventHandlers();
       
  5638 		}
       
  5639 	}
       
  5640 
       
  5641 /**
       
  5642  * Manually removes all anims from event handlers array
       
  5643  */
       
  5644 void CTEventTest::EventHandlerRemoval_ResetAllAnims()
       
  5645 	{
       
  5646 	// Manually remove all anims from event handler list
       
  5647 	for (TInt animIndex = iRemovableAnims->Count() - 1; animIndex >= 0; animIndex--)
       
  5648 		{
       
  5649 		(*iRemovableAnims)[animIndex]->Reset();
       
  5650 		(*iRemovableAnims)[animIndex]->SetEventHandlerLifetime(0);
       
  5651 		}
       
  5652 	}
       
  5653 
       
  5654 /**
       
  5655  *  Manually removes all anims from event handler list
       
  5656  *  Sends 2 events
       
  5657  *  Checks that no events have been received by anims
       
  5658  *  Resets all anims ready for next test
       
  5659  */
       
  5660 void CTEventTest::EventHandlerRemoval_RemoveAndResetAllAnims()
       
  5661 	{
       
  5662 #if defined(DETAILED)
       
  5663 	INFO_PRINTF1(_L(" Manually remove all anims from event handler list"));
       
  5664 	INFO_PRINTF1(_L(" Send 2 events: none expected to be received by anims"));
       
  5665 	INFO_PRINTF1(_L(" All expected to be received by wserv event processing"));
       
  5666 #endif
       
  5667 	// Manually remove all anims from event handler list
       
  5668 	EventHandlerRemoval_ManuallyRemoveAllAnims();
       
  5669 	// All expected to be received by wserv event processing
       
  5670 	AddExpectedKey(EEventKeyDown,32,ETrue);
       
  5671 	AddExpectedKey(EEventKeyUp,32,ETrue);
       
  5672 	// Send 2 events - none expected to be received by anims,
       
  5673 	iTest->SimulateKey(TRawEvent::EKeyDown,32);
       
  5674 	iTest->SimulateKey(TRawEvent::EKeyUp,32);
       
  5675 	// Flush events to wserv
       
  5676 	TheClient->iWs.Flush();
       
  5677 	// Check the anims have not received any events
       
  5678 	EventHandlerRemoval_CheckExpectedEventsReceivedByAnims();
       
  5679 #if defined(DETAILED)
       
  5680 	INFO_PRINTF1(_L(" Cleanup before next step"));
       
  5681 #endif
       
  5682 	// Reset anims
       
  5683 	EventHandlerRemoval_ResetAllAnims();
       
  5684 	}
       
  5685 
       
  5686 /**
       
  5687  * Destroys all anims in iRemovableAnims
       
  5688  * Resets iRemovableAnims
       
  5689  */
       
  5690 void CTEventTest::EventHandlerRemoval_DestroyAllAnims()
       
  5691 	{
       
  5692 	if (iRemovableAnims)
       
  5693 		{
       
  5694 		// Destroy anims
       
  5695 		for (TInt animIndex = iRemovableAnims->Count() - 1; animIndex >= 0; animIndex--)
       
  5696 			{
       
  5697 			RRemovableAnim* anim = (*iRemovableAnims)[animIndex];
       
  5698 			if (anim)
       
  5699 				{
       
  5700 				anim->Destroy();
       
  5701 				}
       
  5702 			}
       
  5703 		iRemovableAnims->Reset();
       
  5704 		}
       
  5705 	}
       
  5706 
       
  5707 /**
       
  5708 SYMTestCaseID			GRAPHICS-WSERV-0496
       
  5709 
       
  5710 @SYMDEF					DEF133776
       
  5711 
       
  5712 @SYMTestCaseDesc		Cancels key captures using all combinations of 
       
  5713  RWindowGroup::Capture...() and RWindowGroup::Cancel...() APIs.
       
  5714 
       
  5715 @SYMTestPriority 		High
       
  5716 
       
  5717 @SYMTestStatus 			Implemented
       
  5718 
       
  5719 @SYMTestActions 		Call each of the RWindowGroup::Capture***() APIs followed by
       
  5720  each of the RWindowGroup::CancelCapture***() APIs.
       
  5721  RWindowGroup::Capture***() APIs:
       
  5722  	CaptureKey(TUint, TUint, TUint)
       
  5723  	CaptureKey(TUint, TUint, TUint, TInt)
       
  5724  	CaptureKeyUpAndDowns(TUint, TUint, TUint)
       
  5725  	CaptureKeyUpAndDowns(TUint, TUint, TUint, TInt)
       
  5726  	CaptureLongKey(TUint, TUint, TUint, TUint, TInt, TUint)
       
  5727   	CaptureLongKey(TTimeIntervalMicroSeconds32, TUint, TUint, TUint, TUint, TInt, TUint)
       
  5728  RWindowGroup::CancelCapture***() APIs:
       
  5729 	CancelCaptureKey()
       
  5730 	CancelCaptureKeyUpAndDowns()
       
  5731 	CancelCaptureLongKey()
       
  5732 
       
  5733 @SYMTestExpectedResults WServ should handle matched and mismatched Cancel 
       
  5734  and Capture calls without panicking.
       
  5735  */
       
  5736 void CTEventTest::MismatchedCapture_NextSetOfEventsL()
       
  5737 	{
       
  5738 	if (iEventSet == 0)
       
  5739 		AddExpectedEvent(EEventFocusGained);
       
  5740 	
       
  5741 	if (iEventSet < (EMaxCaptureKeyApis*EMaxCancelCaptureKeyApis))
       
  5742 		{
       
  5743 		TestCaptureAndCancelCapturePair(static_cast<TCaptureKeyApis>(iEventSet%EMaxCaptureKeyApis), static_cast<TCancelCaptureKeyApis>(iEventSet/EMaxCaptureKeyApis));
       
  5744 		iEventSet++;
       
  5745 		}	
       
  5746 	else
       
  5747 		{
       
  5748 		CActiveScheduler::Stop();				
       
  5749 		}
       
  5750 	}
       
  5751 
       
  5752 /** Helper function that applies a key capture and then cancels it using the
       
  5753 passed capture and cancel RWindowGroup APIs.
       
  5754 
       
  5755 @param aCaptureApi Enum value specifying the capture API to use
       
  5756 @param aCancelCaptureApi Enum value specifying the cancel capture API to use
       
  5757  */
       
  5758 void CTEventTest::TestCaptureAndCancelCapturePair(TCaptureKeyApis aCaptureApi, TCancelCaptureKeyApis aCancelCaptureApi)
       
  5759 	{		
       
  5760 #if defined(LOGGING)
       
  5761 	_LIT(KCaptureKey, "CaptureKey");
       
  5762 	_LIT(KCaptureKeyKeyUpAndDowns, "CaptureKeyKeyUpAndDowns");
       
  5763 	_LIT(KCaptureLongKey, "CaptureLongKey");	
       
  5764 	_LIT(KCancelCaptureKey, "CancelCaptureKey");
       
  5765 	_LIT(KCancelCaptureKeyKeyUpAndDowns, "CancelCaptureKeyKeyUpAndDowns");
       
  5766 	_LIT(KCancelCaptureLongKey, "CancelCaptureLongKey");
       
  5767 	_LIT(KLog,"TestCaptureAndCancelCapturePair: %S, %S");
       
  5768 	TPtrC captures[EMaxCaptureKeyApis] = {KCaptureKey(), KCaptureKey(), KCaptureKeyKeyUpAndDowns(), KCaptureKeyKeyUpAndDowns(), KCaptureLongKey(), KCaptureLongKey()};
       
  5769 	TPtrC cancelCaptures[EMaxCancelCaptureKeyApis] = {KCancelCaptureKey(), KCancelCaptureKeyKeyUpAndDowns(), KCancelCaptureLongKey()};
       
  5770 	TLogMessageText logMessageText;	
       
  5771 	logMessageText.Format(KLog, &captures[aCaptureApi], &cancelCaptures[aCancelCaptureApi]);
       
  5772 	INFO_PRINTF1(logMessageText);
       
  5773 #endif // LOGGING	
       
  5774 	
       
  5775 	// Start a key capture using one of the six RWindowGroup Capture***() APIs
       
  5776 	switch (aCaptureApi)
       
  5777 		{
       
  5778 		case ECaptureKey1:
       
  5779 		case ECaptureKey2:
       
  5780 			// Test RWindowGroup::CaptureKey()
       
  5781 			if (aCaptureApi == ECaptureKey1) 				
       
  5782 				iCaptureKey = iQueueClient->iGroup->GroupWin()->CaptureKey('A',0,0);
       
  5783 			else
       
  5784 				iCaptureKey = iQueueClient->iGroup->GroupWin()->CaptureKey('A',0,0,1); // priority 1 (default priority is 0)
       
  5785 			iTest->SimulateKey(TRawEvent::EKeyDown, 'A');
       
  5786 			TheClient->iWs.Flush();
       
  5787 			User::After(KeyRepeatTime()*3/2);
       
  5788 			iTest->SimulateKey(TRawEvent::EKeyUp, 'A');
       
  5789 			TheClient->iWs.Flush();
       
  5790 			AddExpectedKey(EEventKeyDown, 'A');
       
  5791 			AddExpectedKey(EEventKey,'A','a');
       
  5792 			AddExpectedKey(EEventKey,'A','a',1);			
       
  5793 			AddExpectedKey(EEventKeyUp, 'A');
       
  5794 			break;				
       
  5795 			
       
  5796 		case ECaptureKeyUpAndDowns1:
       
  5797 		case ECaptureKeyUpAndDowns2:
       
  5798 			// Test RWindowGroup::CaptureKeyUpAndDowns()
       
  5799 			if (aCaptureApi == ECaptureKeyUpAndDowns1)			
       
  5800 				iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureKeyUpAndDowns(EStdKeySpace,0,0);
       
  5801 			else
       
  5802 				iCaptureKey=iQueueClient->iGroup->GroupWin()->CaptureKeyUpAndDowns(EStdKeySpace,0,0,1); // priority 1 (default priority is 0)
       
  5803 			iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace);
       
  5804 			TheClient->iWs.Flush();			
       
  5805 			User::After(KeyRepeatTime()*3/2);
       
  5806 			iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace);
       
  5807 			TheClient->iWs.Flush();
       
  5808 			AddExpectedKey(EEventKeyDown,EStdKeySpace);
       
  5809 			AddExpectedKey(EEventKey,EStdKeySpace,' ');
       
  5810 			AddExpectedKey(EEventKey,EStdKeySpace,' ',1);
       
  5811 			AddExpectedKey(EEventKeyUp,EStdKeySpace);
       
  5812 			break;	
       
  5813 			
       
  5814 		case ECaptureLongKey1:
       
  5815 		case ECaptureLongKey2:
       
  5816 			{
       
  5817 			// Test RWindowGroup::CaptureLongKey()
       
  5818 			TTimeIntervalMicroSeconds32 repeat = KeyRepeatTime();
       
  5819 			if (aCaptureApi == ECaptureLongKey1)
       
  5820 				{
       
  5821 				iCaptureKey = iQueueClient->iGroup->GroupWin()->CaptureLongKey(' ', 'a', 0, 0, 2, ELongCaptureNormal);	
       
  5822 				}
       
  5823 			else
       
  5824 				{
       
  5825 				repeat = KeyRepeatTime()/2;
       
  5826 				iCaptureKey = iQueueClient->iGroup->GroupWin()->CaptureLongKey(repeat, ' ', 'a', 0, 0, 2, ELongCaptureNormal);
       
  5827 				}					
       
  5828 			iQueueClient->iWs.Flush();
       
  5829 			iTest->SimulateKey(TRawEvent::EKeyDown,EStdKeySpace);
       
  5830 			TheClient->iWs.Flush();
       
  5831 			User::After(KeyRepeatTime()*3/2);
       
  5832 			iTest->SimulateKey(TRawEvent::EKeyUp,EStdKeySpace);
       
  5833 			TheClient->iWs.Flush();
       
  5834 			AddExpectedKey(EEventKeyDown,EStdKeySpace);
       
  5835 			AddExpectedKey(EEventKey,EStdKeySpace,' ');
       
  5836 			AddExpectedKey(EEventKey,EStdKeySpace,'a',1);
       
  5837 			AddExpectedKey(EEventKeyUp,EStdKeySpace);
       
  5838 			}
       
  5839 			break;
       
  5840 				
       
  5841 		default:
       
  5842 			INFO_PRINTF1(_L("Unexpected TCaptureKeyApis value passed to CTEventTest::TestCaptureAndCancelCapturePair()"));
       
  5843 			TEST(EFalse);
       
  5844 			break;
       
  5845 		}	
       
  5846 	
       
  5847 	if (iCaptureKey)
       
  5848 		{
       
  5849 		// End a capture using one of the three RWindowGroup CancelCapture***() APIs,
       
  5850 		// for each Capture***() API each one of these will be called, therefore there will
       
  5851 		// be one correct CancelCapture***() APIs called and two incorrect CancelCapture***() 
       
  5852 		// APIs called for each Capture***() API.
       
  5853 		switch (aCancelCaptureApi)
       
  5854 			{
       
  5855 			case ECancelCaptureKey:
       
  5856 				iQueueClient->iGroup->GroupWin()->CancelCaptureKey(iCaptureKey);
       
  5857 				break;
       
  5858 			case ECancelCaptureKeyUpAndDowns:
       
  5859 				iQueueClient->iGroup->GroupWin()->CancelCaptureKeyUpAndDowns(iCaptureKey);
       
  5860 				break;
       
  5861 			case ECancelCaptureLongKey:
       
  5862 				iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(iCaptureKey);
       
  5863 				break;
       
  5864 			default:
       
  5865 				INFO_PRINTF1(_L("Unexpected TCancelCaptureKeyApis value passed to CTEventTest::TestCaptureAndCancelCapturePair()"));
       
  5866 				TEST(EFalse);
       
  5867 				break;
       
  5868 			}
       
  5869 		
       
  5870 		// If an mistmatched CancelCapture***() API was called, call the correct one now
       
  5871 		// to make sure the Capture/CancelCapture state is clean before the next test starts
       
  5872 		if ((aCaptureApi/2) != aCancelCaptureApi)
       
  5873 			{
       
  5874 			switch (aCaptureApi)				
       
  5875 				{
       
  5876 				case ECaptureKey1:
       
  5877 				case ECaptureKey2:
       
  5878 					iQueueClient->iGroup->GroupWin()->CancelCaptureKey(iCaptureKey);
       
  5879 					break;
       
  5880 				case ECaptureKeyUpAndDowns1:
       
  5881 				case ECaptureKeyUpAndDowns2:
       
  5882 					iQueueClient->iGroup->GroupWin()->CancelCaptureKeyUpAndDowns(iCaptureKey);
       
  5883 					break;
       
  5884 				case ECaptureLongKey1:
       
  5885 				case ECaptureLongKey2:
       
  5886 					iQueueClient->iGroup->GroupWin()->CancelCaptureLongKey(iCaptureKey);
       
  5887 					break;
       
  5888 				}
       
  5889 			}
       
  5890 		}
       
  5891 		
       
  5892 	TheClient->iWs.Flush();
       
  5893 	}	
       
  5894 
       
  5895 /*void CTEventTest::_NextSetOfEvents()		//Template for these functions
       
  5896 	{
       
  5897 	switch(iEventSet++)
       
  5898 		{
       
  5899 		case 0:
       
  5900 			iQueueClient->iWin->WinTreeNode()->;		//Set up window
       
  5901 			iQueueClient->iWin->BaseWin()->;
       
  5902 			iQueueClient->iGroup->GroupWin()->;
       
  5903 			iQueueClient->iWs.Flush();					//Make take effect
       
  5904 			SimulateEvent(TRawEvent::);					//Create an event
       
  5905 			TheClient->iWs.Flush();						//Send event
       
  5906 			AddExpectedEvent(EEventFocusGained);		//Always get a focus gain at start
       
  5907 			AddExpectedEvent();							//Expect the event that was created above
       
  5908 			break;
       
  5909 		case 1:
       
  5910 			iQueueClient->iWs.Flush();
       
  5911 			SimulateEvent(TRawEvent::);
       
  5912 			TheClient->iWs.Flush();
       
  5913 			AddExpectedEvent();
       
  5914 			break;
       
  5915 		default:
       
  5916 			CActiveScheduler::Stop();
       
  5917 			break;
       
  5918 		}
       
  5919 	TheClient->iWs.Flush();
       
  5920 	}*/
       
  5921 
       
  5922 /**
       
  5923 	@SYMTestCaseID GRAPHICS-WSERV-CODEBASE-WSERV-0051
       
  5924   
       
  5925 	@SYMPREQ PGM027
       
  5926   
       
  5927 	@SYMTestCaseDesc Tests SetKeyboardRepeatRate API. 
       
  5928    
       
  5929 	@SYMTestPriority 1 
       
  5930   
       
  5931 	@SYMTestStatus Implemented
       
  5932    
       
  5933 	@SYMTestActions This test tryes to call SetKeyboardRepeatRate with invalid time values\n
       
  5934 			
       
  5935 	@SYMTestExpectedResults KeyRepeatRateNegTest should tests the API SetKeyboardRepeatRate return value\n
       
  5936 	The test should pass and API should return KErrArgument.
       
  5937 
       
  5938  */
       
  5939 void CTEventTest::KeyRepeatRateNegTest(TInt aInitialRepeat, TInt aRepeat)
       
  5940 	{
       
  5941 	((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-CODEBASE-WSERV-0051"));
       
  5942 	TInt ret=TheClient->iWs.SetKeyboardRepeatRate(TTimeIntervalMicroSeconds32(aInitialRepeat), TTimeIntervalMicroSeconds32(aRepeat));
       
  5943 	TEST(ret==KErrArgument);
       
  5944 	TRAPD(err,((CTEventTestStep*)iStep)->RecordTestResultL());
       
  5945    	if (err!=KErrNone)
       
  5946     		INFO_PRINTF1(_L("Failed to record test result"));
       
  5947 	}
       
  5948 
       
  5949 void CTEventTest::RunTestsL(TBool aNeedChildWindows/*=EFalse*/)
       
  5950 	{
       
  5951 	iQueueClient=new(ELeave) CTQueueClient(this);
       
  5952 	iQueueClient->SetScreenNumber(iTest->iScreenNumber);
       
  5953 	iQueueClient->ConstructL(aNeedChildWindows);
       
  5954 	iEventSet=0;
       
  5955 	TRAPD(err,NextSetOfEventsL());
       
  5956 	if (err!=KErrNone)
       
  5957 		{
       
  5958 		iFailed=ETrue;
       
  5959 		return;
       
  5960 		}
       
  5961 //
       
  5962 	CActiveScheduler::Start();
       
  5963 //
       
  5964 	TInt eventsLeft=iQueueClient->EventQueue()->EventsLeft();
       
  5965 	if (eventsLeft>0)
       
  5966 		iFailed=ETrue;
       
  5967 	delete iVisWins1;
       
  5968 	iVisWins1 = NULL;
       
  5969 	delete iVisWins2;
       
  5970 	iVisWins2 = NULL;
       
  5971 	delete iQueueClient;
       
  5972 	iQueueClient=NULL;
       
  5973 	}
       
  5974 
       
  5975 void CTEventTest::RunTestsRestoreAreaL(TBool aNeedChildWindows)
       
  5976 	{
       
  5977 	TRect area(TheClient->iWs.PointerCursorArea());
       
  5978 	RunTestsL(aNeedChildWindows);
       
  5979 	TheClient->iWs.SetPointerCursorArea(area);
       
  5980 	}
       
  5981 
       
  5982 /*void CTEventTest::QueuePurgingL()
       
  5983 	{
       
  5984 	RunTestsL(EFalse);
       
  5985 	}
       
  5986 
       
  5987 void CTEventTest::SendEventL()
       
  5988 	{
       
  5989 	RunTestsL(EFalse);
       
  5990 	}
       
  5991 
       
  5992 void CTEventTest::InvisibleWindowL()
       
  5993 	{
       
  5994 	RunTestsL(ETrue);
       
  5995 	}
       
  5996 
       
  5997 void CTEventTest::JavaAdditionsL()
       
  5998 	{
       
  5999 	RunTestsL(EFalse);
       
  6000 	}*/
       
  6001 
       
  6002 void CTEventTest::WindowCapBugL()
       
  6003 	{
       
  6004 	RunTestsL(ETrue);
       
  6005 	}
       
  6006 
       
  6007 /*void CTEventTest::XyInputTypeL()
       
  6008 	{
       
  6009 	RunTestsL(EFalse);
       
  6010 	}
       
  6011 
       
  6012 void CTEventTest::MovingPointerCursorL()
       
  6013 	{
       
  6014 	RunTestsRestoreAreaL(ETrue);
       
  6015 	}
       
  6016 
       
  6017 void CTEventTest::RotatedModeL()
       
  6018 	{
       
  6019 	RunTestsRestoreAreaL(EFalse);
       
  6020 	}*/
       
  6021 
       
  6022 /**
       
  6023 * This test creates one anim and calls AddToEventHandlers() twenty times.
       
  6024 * it shouldn't add the same anim to event handler if anim is already in handler.
       
  6025 */
       
  6026 void CTEventTest::EventHandlerRemoval_AddEventHandlerMultipleTimes()
       
  6027 	{
       
  6028 	iTheClientFlush=TheClient->iWs.SetAutoFlush(ETrue);
       
  6029 	iQuequeClientFlush=iQueueClient->iWs.SetAutoFlush(ETrue);
       
  6030 
       
  6031 	RRemovableAnim* eventTestAnim = RRemovableAnim::NewLC(iQueueClient->iWin->BaseWin(), iAnimDll);
       
  6032 
       
  6033 	// Call AddToEventHandlers() on same anim 20 times, it should add this anim in event handler only once
       
  6034 	for (TInt count = 0; count < 20; count++)
       
  6035 		eventTestAnim->AddToEventHandlers();
       
  6036 	eventTestAnim->SetEventHandlerLifetime(1);
       
  6037 
       
  6038 	TRawEvent rawEvent1;
       
  6039 	rawEvent1.Set(TRawEvent::EKeyUp, 34);
       
  6040 
       
  6041 	eventTestAnim->AddExpectedEvent(rawEvent1);
       
  6042 
       
  6043 	// Add these events to iQueueClient for testing
       
  6044 	AddExpectedKey(EEventKeyUp, 34, ETrue);
       
  6045 
       
  6046 	iTest->SimulateKey(TRawEvent::EKeyUp, 34);
       
  6047 
       
  6048 	CleanupStack::PopAndDestroy(eventTestAnim);
       
  6049 	TheClient->iWs.SetAutoFlush(iTheClientFlush);
       
  6050 	iQueueClient->iWs.SetAutoFlush(iQuequeClientFlush);
       
  6051 	}
       
  6052 
       
  6053 void CTEventTest::EventQueuePtrCrashTest()
       
  6054 // Code designed to hit the defect reported in INC109199 & INC105430, needs a very specific sequence of
       
  6055 // events and client disconnections to hit the exact problem state.
       
  6056 	{
       
  6057 	const TInt KNumTestEvents=6;
       
  6058 	const TInt KMaxNumTestEvents=16;
       
  6059 	// Number of iterations needs to be as high as the queue granularity to make sure at least
       
  6060 	// once around we actually hit the code to change the queue size
       
  6061 	const TInt KNumEvTestIterations=4;
       
  6062 	const TInt KNumBaseTestSessions=KNumEvTestIterations+1;
       
  6063 	const TInt KNumMainTestSessions=13;
       
  6064 	const TInt KMaxNumSessions=KNumBaseTestSessions+KNumMainTestSessions+KNumEvTestIterations;
       
  6065 	RWsSession wsSessions[KMaxNumSessions];
       
  6066 	RWindowGroup wGroups[KMaxNumSessions];
       
  6067 	for(TInt iterationLoop=0;iterationLoop<KNumEvTestIterations;iterationLoop++)
       
  6068 		{
       
  6069 		const TInt numTestSessions=KNumBaseTestSessions+KNumMainTestSessions+iterationLoop;
       
  6070 	#if defined(LOGGING)
       
  6071 		_LIT(KLog1,"EventQueuePtrCrashTest: Test Creating %d Clients");
       
  6072 		LOG_MESSAGE2(KLog1,numTestSessions);
       
  6073 	#endif
       
  6074 		for(TInt testSessionIndex=0;testSessionIndex<numTestSessions;testSessionIndex++)
       
  6075 			{
       
  6076 			RWsSession& ws=wsSessions[testSessionIndex];
       
  6077 			User::LeaveIfError(ws.Connect());
       
  6078 			wGroups[testSessionIndex]=RWindowGroup(ws);
       
  6079 			RWindowGroup& group=wGroups[testSessionIndex];
       
  6080 			User::LeaveIfError(group.Construct(testSessionIndex+1,EFalse)); 
       
  6081 			if (testSessionIndex>=KNumBaseTestSessions)
       
  6082 				{
       
  6083 				TWsEvent event;
       
  6084 				for(TInt evLoop=0;evLoop<KNumTestEvents;evLoop++)
       
  6085 					{
       
  6086 					event.SetType(1001+evLoop);
       
  6087 					ws.SendEventToWindowGroup(group.Identifier(),event);
       
  6088 					}
       
  6089 				if (testSessionIndex==(numTestSessions-1))
       
  6090 					{
       
  6091 					for(TInt eventIndex=0;eventIndex<KMaxNumTestEvents;eventIndex++)
       
  6092 						{
       
  6093 						event.SetType(1001+eventIndex);
       
  6094 						ws.SendEventToAllWindowGroups(event);
       
  6095 						}
       
  6096 					}
       
  6097 				}
       
  6098 			}
       
  6099 	#if defined(LOGGING)
       
  6100 		_LIT(KLog2,"EventQueuePtrCrashTest: Closing Clients");
       
  6101 		LOG_MESSAGE(KLog2);
       
  6102 	#endif
       
  6103 		TInt closeLoop=0;
       
  6104 		while(closeLoop<KNumBaseTestSessions)
       
  6105 			{
       
  6106 			wsSessions[closeLoop++].Close();
       
  6107 			}
       
  6108 		RWsSession extraSession1;
       
  6109 		User::LeaveIfError(extraSession1.Connect());
       
  6110 		extraSession1.Close();
       
  6111 		while(closeLoop<numTestSessions)
       
  6112 			{
       
  6113 			wsSessions[closeLoop++].Close();
       
  6114 			}
       
  6115 		}
       
  6116 	}
       
  6117 
       
  6118 /**
       
  6119 Test queue size of the new queue can be initialized to be at least EMinQueueSize.
       
  6120 @param aEventReadyCancel whether there is inactive client. This parameter can be specified
       
  6121 		to test different code path for expanding spaces for new queue. If the value is false, 
       
  6122 		the space for the new queue is gained from current global queue or by growing global queue size. 
       
  6123 		Otherwise, there are inactive clients which	cancel their listening to event, in addition, 
       
  6124 		memory allocation is simulated to be failed when growing global queue size, 
       
  6125 		so that space is gained by purging events from inactive clients. 
       
  6126 */
       
  6127 void CTEventTest::InitializeQueueSizeTestL(TBool aEventReadyCancel)
       
  6128 	{
       
  6129 	const TInt numEvents = 50;
       
  6130 	const TInt maxClients = 3; 
       
  6131 	const TInt oneSecond = 1000000;
       
  6132 	RWsSession wsSession[maxClients];
       
  6133 	RWindowGroup groupWin[maxClients];
       
  6134 	TRequestStatus status;
       
  6135 	TInt cliHanGrpWin = 10000;
       
  6136 	RTimer timer;
       
  6137 	timer.CreateLocal();
       
  6138 	CleanupClosePushL(timer);
       
  6139 	// To have the test creating different number of clients is to make sure
       
  6140 	// there is at least one of the tests meets the below requirement:
       
  6141 	// the number of the connections when the new queue created for test is not multiple
       
  6142 	// of queue granularity, so that the queue size initialization is not done by growing
       
  6143 	// global queue size due to the increase of the connections.
       
  6144 	for (TInt numClients = maxClients - 1; numClients <= maxClients; numClients++)
       
  6145 		{
       
  6146 		TInt clientIndex;
       
  6147 		//Create test clients
       
  6148 		for (clientIndex = 0; clientIndex < numClients; clientIndex++)
       
  6149 			{
       
  6150 			User::LeaveIfError(wsSession[clientIndex].Connect());
       
  6151 			CleanupClosePushL(wsSession[clientIndex]);
       
  6152 			groupWin[clientIndex] = RWindowGroup(wsSession[clientIndex]);
       
  6153 			User::LeaveIfError(groupWin[clientIndex].Construct(cliHanGrpWin++));
       
  6154 			CleanupClosePushL(groupWin[clientIndex]);
       
  6155 			}
       
  6156 		
       
  6157 		// Cancel listening to event for the first client. 
       
  6158 		// This is for testing PurgeInactiveEvents. 
       
  6159 		if (aEventReadyCancel)
       
  6160 			{
       
  6161 			wsSession[0].EventReady(&status);
       
  6162 			wsSession[0].EventReadyCancel();
       
  6163 			User::WaitForRequest(status);
       
  6164 			}
       
  6165 
       
  6166 		//send events to window group to make the queue full.
       
  6167 		TWsEvent event;
       
  6168 		TInt evLoop;
       
  6169 		for(evLoop = 0; evLoop < numEvents; evLoop++)
       
  6170 			{
       
  6171 			event.SetType(2001 + evLoop);
       
  6172 			TheClient->iWs.SendEventToWindowGroup(groupWin[0].Identifier(),event);
       
  6173 			TheClient->iWs.SendEventToWindowGroup(groupWin[1].Identifier(),event);
       
  6174 			}
       
  6175 		
       
  6176 		//To create a new client, although the queue is full, wserv will guarantee to initialize 
       
  6177 		//the queue size of the new queue to at least EMinQueueSize. So that it can response to 
       
  6178 		//the event.
       
  6179 		RWsSession testWsSession;
       
  6180 		RWindowGroup testGroupWin;
       
  6181 		TRequestStatus testStatus;
       
  6182 		if (aEventReadyCancel)
       
  6183 			{
       
  6184 			//Simulate the heap allocation failure to test expanding spaces by purge 
       
  6185 			//events from inactive clients when initialize queue size.
       
  6186 			TInt failAt = 1;
       
  6187 			TInt err;
       
  6188 			do	{
       
  6189 				TheClient->iWs.HeapSetFail(RHeap::EFailNext, failAt++);
       
  6190 				TheClient->iWs.Flush();
       
  6191 				err = testWsSession.Connect();
       
  6192 				TheClient->iWs.HeapSetFail(RHeap::ENone, 1);
       
  6193 				} while (err == KErrNoMemory);
       
  6194 			User::LeaveIfError(err);
       
  6195 			}
       
  6196 		else
       
  6197 			{
       
  6198 			User::LeaveIfError(testWsSession.Connect());
       
  6199 			}
       
  6200 		CleanupClosePushL(testWsSession);
       
  6201 		testGroupWin = RWindowGroup(testWsSession);
       
  6202 		User::LeaveIfError(testGroupWin.Construct(cliHanGrpWin++));
       
  6203 		CleanupClosePushL(testGroupWin);
       
  6204 	
       
  6205 		//Send events to the newly created client.
       
  6206 		// The Debug version of WServ puts a EEventFocusGained into the event 
       
  6207 		// before this test's custom event, so leave one slot in the queue 
       
  6208 		// for it.
       
  6209 #if (defined _DEBUG)
       
  6210 		TInt testEventCount = EMinQueueSize - 1; 
       
  6211 #else
       
  6212 		TInt testEventCount = EMinQueueSize; 
       
  6213 #endif
       
  6214 		for(TInt evLoop = 0; evLoop < testEventCount; evLoop++)
       
  6215 			{
       
  6216 			event.SetType(3001 + evLoop);
       
  6217 			TheClient->iWs.SendEventToWindowGroup(testGroupWin.Identifier(),event);
       
  6218 			}
       
  6219 		
       
  6220 		//Check the event queue.
       
  6221 		//Having a timer here to avoid infinitely wait for event.
       
  6222 		TInt expectedEvent = 3001;
       
  6223 		for(TInt evLoop = 0; evLoop < EMinQueueSize; evLoop++)
       
  6224             {
       
  6225 			testWsSession.EventReady(&testStatus);
       
  6226 			TRequestStatus timerStatus;
       
  6227 			timer.After(timerStatus, oneSecond);
       
  6228 			User::WaitForRequest(testStatus, timerStatus);
       
  6229 			TEST(testStatus == 0);
       
  6230 			if (testStatus == 0) 
       
  6231 				{
       
  6232 				// Tests the event
       
  6233 				testWsSession.GetEvent(event);
       
  6234 				// WServ sometimes puts a EEventFocusGained event into the queue 
       
  6235 				// before the test's custom event, so ignore it.
       
  6236 				if (event.Type() != EEventFocusGained)
       
  6237 					{
       
  6238 					TEST(event.Type() == expectedEvent);
       
  6239 					expectedEvent++;
       
  6240 					}
       
  6241 				// testStatus has been completed. Cancel the timer.
       
  6242 				timer.Cancel();
       
  6243 				User::WaitForRequest(timerStatus);
       
  6244 				}
       
  6245 			else
       
  6246 				{
       
  6247 				// Times out, cancel the event notification
       
  6248 				testWsSession.EventReadyCancel();
       
  6249 				User::WaitForRequest(testStatus);
       
  6250 				}
       
  6251 			}
       
  6252 		CleanupStack::PopAndDestroy(2*numClients + 2, &wsSession[0]);
       
  6253 		}
       
  6254 	CleanupStack::PopAndDestroy(&timer);
       
  6255 	}
       
  6256 
       
  6257 void CTEventTest::SimulateRepeatEvent(TInt aScanCode, TInt aRepeats/*=0*/)
       
  6258     {
       
  6259     TRawEvent rawEvent;
       
  6260     if (aRepeats)
       
  6261         rawEvent.Set(TRawEvent::EKeyRepeat, aScanCode, aRepeats);
       
  6262     else
       
  6263         rawEvent.Set(TRawEvent::EKeyRepeat, aScanCode);
       
  6264     UserSvr::AddEvent(rawEvent);
       
  6265     }
       
  6266 
       
  6267 void CTEventTest::RawEventRepeatTest_NextSetOfEventsL()
       
  6268     {
       
  6269     switch(iEventSet++)
       
  6270         {
       
  6271         case 0:
       
  6272             // Tests EKeyRepeat without repeat value set.
       
  6273             SimulateRepeatEvent(32);
       
  6274             
       
  6275             // Tests EKeyRepeat with repeat value set to 2.
       
  6276             SimulateRepeatEvent(33,2);
       
  6277           
       
  6278             AddExpectedEvent(EEventFocusGained);
       
  6279             AddExpectedKey(EEventKey, 32);
       
  6280             AddExpectedKey(EEventKey, 33, 0, 2);
       
  6281             break;
       
  6282         default:
       
  6283              CActiveScheduler::Stop();
       
  6284              break;
       
  6285         }
       
  6286     TheClient->iWs.Flush();
       
  6287     }
       
  6288 
       
  6289 void CTEventTest::RunTestCaseL(TInt /*aCurTestCase*/)
       
  6290 	{
       
  6291 	_LIT(KTest0,"General 1");
       
  6292 	_LIT(KTest1,"Event queue purging");
       
  6293 	_LIT(KTest2,"SendEvent");
       
  6294 	_LIT(KTest3,"SendEventToAll");
       
  6295 	_LIT(KTest4,"InvisibleWindow");
       
  6296 	_LIT(KTest5,"JavaAdditions");
       
  6297 	_LIT(KTest6,"WindowCaptureBug");
       
  6298 	_LIT(KTest7,"XYInput Types");
       
  6299 	_LIT(KTest8,"MovingPointerCursor");
       
  6300 	_LIT(KTest9,"Rotated Modes");
       
  6301 	_LIT(KTest10,"Anim Event");
       
  6302 	_LIT(KTest11,"Focus Changed");
       
  6303 	_LIT(KTest12,"On/Off Events");
       
  6304 	_LIT(KTest13,"Virtual Keyboard");
       
  6305 	_LIT(KTest14,"Key Clicks");
       
  6306 	_LIT(KTest15,"Capture Long");
       
  6307 	_LIT(KTest16,"Password Window");
       
  6308 	_LIT(KTest17,"Group List Changed");
       
  6309 	_LIT(KTest18,"Repeatable Key Events");
       
  6310 	_LIT(KTest19,"Screen Scaling");
       
  6311 	_LIT(KTest20,"Visibility Changed Events");
       
  6312 	_LIT(KTest21,"Check Time Stamp Of Events");
       
  6313 	_LIT(KTest22,"Pointer Capture Priority Events");
       
  6314 	_LIT(KTest23,"Event Handler Removal");
       
  6315 	_LIT(KTest24,"Event Queue ptr crash test");
       
  6316 	_LIT(KTest25,"Mismatched Pointer Events");
       
  6317 	_LIT(KTest26,"Pointer Buffer Purge");
       
  6318 	_LIT(KTest27,"TRawEvent test for Repeats");
       
  6319 #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS            
       
  6320 #ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA 
       
  6321 	_LIT(KTest28,"Transparent Surface Visibility Changed Events 1");
       
  6322 	_LIT(KTest29,"Transparent Surface Visibility Changed Events 2");
       
  6323 	_LIT(KTest30,"Transparent Surface Visibility Changed Events 3");
       
  6324 #endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
       
  6325 #endif // SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
       
  6326 	_LIT(KTest31A,"Initialize Queue Size without inactive queue");
       
  6327 	_LIT(KTest31B,"Initialize Queue Size with inactive queue");	
       
  6328 	
       
  6329 	if (!TestBase()->ConfigurationSupportsPointerEventTesting())
       
  6330 	    {
       
  6331 	    INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing"));
       
  6332 	    TestComplete();
       
  6333 	    return;
       
  6334 	    }
       
  6335 	
       
  6336 	//if (iTest->iState==1) iTest->iState=14;	//Use this line to skip to a particular test
       
  6337 	((CTEventTestStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
       
  6338 	switch(iTest->iState)
       
  6339 		{
       
  6340 /**
       
  6341 @SYMTestCaseID		GRAPHICS-WSERV-0053
       
  6342 
       
  6343 @SYMDEF             DEF081259
       
  6344 
       
  6345 @SYMTestCaseDesc    Carry out general event tests on WServ
       
  6346 
       
  6347 @SYMTestPriority    High
       
  6348 
       
  6349 @SYMTestStatus      Implemented
       
  6350 
       
  6351 @SYMTestActions     General events are sent via WServ
       
  6352 
       
  6353 @SYMTestExpectedResults The events are sent without error
       
  6354 */
       
  6355 		case 0:
       
  6356 			iTest->LogSubTest(KTest0);
       
  6357 			General();
       
  6358 			((CTEventTestStep*)iStep)->SetOverallTestStepID(_L("GRAPHICS-WSERV-0053"));
       
  6359 			//iState=8;
       
  6360 			break;
       
  6361 /**
       
  6362 @SYMTestCaseID		GRAPHICS-WSERV-0054
       
  6363 
       
  6364 @SYMDEF             DEF081259
       
  6365 
       
  6366 @SYMTestCaseDesc    Carry out event queue purging
       
  6367 
       
  6368 @SYMTestPriority    High
       
  6369 
       
  6370 @SYMTestStatus      Implemented
       
  6371 
       
  6372 @SYMTestActions     Purge the event queue
       
  6373 
       
  6374 @SYMTestExpectedResults The events queue is purged without error
       
  6375 */
       
  6376 		case 1:
       
  6377 			((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0054"));
       
  6378 			iTest->LogSubTest(KTest1);
       
  6379 			RunTestsL();		//QueuePurgingL();
       
  6380 			break;
       
  6381 /**
       
  6382 @SYMTestCaseID		GRAPHICS-WSERV-0055
       
  6383 
       
  6384 @SYMDEF             DEF081259
       
  6385 
       
  6386 @SYMTestCaseDesc    Test that events can be sent
       
  6387 
       
  6388 @SYMTestPriority    High
       
  6389 
       
  6390 @SYMTestStatus      Implemented
       
  6391 
       
  6392 @SYMTestActions     Send events in WServ
       
  6393 
       
  6394 @SYMTestExpectedResults The events are sent without error
       
  6395 */
       
  6396 		case 2:
       
  6397 			((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0055"));
       
  6398 			iTest->LogSubTest(KTest2);
       
  6399 			RunTestsL();		//SendEventL();
       
  6400 			break;
       
  6401 /**
       
  6402 @SYMTestCaseID		GRAPHICS-WSERV-0056
       
  6403 
       
  6404 @SYMDEF             DEF081259
       
  6405 
       
  6406 @SYMTestCaseDesc    Send an event to all window groups
       
  6407 
       
  6408 @SYMTestPriority    High
       
  6409 
       
  6410 @SYMTestStatus      Implemented
       
  6411 
       
  6412 @SYMTestActions     Send an event to all window groups
       
  6413 
       
  6414 @SYMTestExpectedResults The events are sent to all window groups
       
  6415 						without error
       
  6416 */
       
  6417 		case 3:
       
  6418 			((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0056"));
       
  6419 			iTest->LogSubTest(KTest3);
       
  6420 			General2();
       
  6421 			break;
       
  6422 /**
       
  6423 @SYMTestCaseID		GRAPHICS-WSERV-0057
       
  6424 
       
  6425 @SYMDEF             DEF081259
       
  6426 
       
  6427 @SYMTestCaseDesc    Send events to an invisible window
       
  6428 
       
  6429 @SYMTestPriority    High
       
  6430 
       
  6431 @SYMTestStatus      Implemented
       
  6432 
       
  6433 @SYMTestActions     Send events to an invisible window
       
  6434 
       
  6435 @SYMTestExpectedResults The events are sent to the window without
       
  6436 						error
       
  6437 */
       
  6438 		case 4:
       
  6439 			((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0057"));
       
  6440 			iTest->LogSubTest(KTest4);
       
  6441 			RunTestsL(ETrue);		//InvisibleWindowL();
       
  6442 			break;
       
  6443 /**
       
  6444 @SYMTestCaseID		GRAPHICS-WSERV-0058
       
  6445 
       
  6446 @SYMDEF             DEF081259
       
  6447 
       
  6448 @SYMTestCaseDesc    Send events for java additions
       
  6449 
       
  6450 @SYMTestPriority    High
       
  6451 
       
  6452 @SYMTestStatus      Implemented
       
  6453 
       
  6454 @SYMTestActions     Send events for java additions
       
  6455 
       
  6456 @SYMTestExpectedResults The events are sent to the window without
       
  6457 						error
       
  6458 */
       
  6459 		case 5:
       
  6460 			((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0058"));
       
  6461 			iTest->LogSubTest(KTest5);
       
  6462 			RunTestsL();		//JavaAdditionsL();
       
  6463 			break;
       
  6464 
       
  6465 		case 6:
       
  6466 			((CTEventTestStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
       
  6467 			iTest->LogSubTest(KTest6);
       
  6468 			//WindowCapBugL();		//Not finished
       
  6469 			break;
       
  6470 /**
       
  6471 @SYMTestCaseID		GRAPHICS-WSERV-0059
       
  6472 
       
  6473 @SYMDEF             DEF081259
       
  6474 
       
  6475 @SYMTestCaseDesc    Send events for x and y inputs
       
  6476 
       
  6477 @SYMTestPriority    High
       
  6478 
       
  6479 @SYMTestStatus      Implemented
       
  6480 
       
  6481 @SYMTestActions     Send events for x and y inputs
       
  6482 
       
  6483 @SYMTestExpectedResults The events are sent to the window without
       
  6484 						error
       
  6485 */
       
  6486 		case 7:
       
  6487 			((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0059"));
       
  6488 			iTest->LogSubTest(KTest7);
       
  6489 			RunTestsL();		//XyInputTypeL();
       
  6490 			break;
       
  6491 /**
       
  6492 @SYMTestCaseID		GRAPHICS-WSERV-0060
       
  6493 
       
  6494 @SYMDEF             DEF081259
       
  6495 
       
  6496 @SYMTestCaseDesc    Send events for moving pointer cursor
       
  6497 
       
  6498 @SYMTestPriority    High
       
  6499 
       
  6500 @SYMTestStatus      Implemented
       
  6501 
       
  6502 @SYMTestActions     Send events for moving pointer cursor
       
  6503 
       
  6504 @SYMTestExpectedResults The events are sent to the window without
       
  6505 						error
       
  6506 */
       
  6507 		case 8:
       
  6508 			((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0060"));
       
  6509 			iTest->LogSubTest(KTest8);
       
  6510 			RunTestsRestoreAreaL(ETrue);		//MovingPointerCursorL();
       
  6511 		    break;
       
  6512 /**
       
  6513 @SYMTestCaseID		GRAPHICS-WSERV-0061
       
  6514 
       
  6515 @SYMDEF             DEF081259
       
  6516 
       
  6517 @SYMTestCaseDesc    Send events for rotate mode
       
  6518 
       
  6519 @SYMTestPriority    High
       
  6520 
       
  6521 @SYMTestStatus      Implemented
       
  6522 
       
  6523 @SYMTestActions     Send events for rotate mode
       
  6524 
       
  6525 @SYMTestExpectedResults The events are sent to the window without
       
  6526 						error
       
  6527 */
       
  6528 		case 9:
       
  6529 			((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0061"));
       
  6530 			iTest->LogSubTest(KTest9);
       
  6531 			RunTestsRestoreAreaL(EFalse);		//RotatedModeL();
       
  6532 			break;
       
  6533 /**
       
  6534 @SYMTestCaseID		GRAPHICS-WSERV-0062
       
  6535 
       
  6536 @SYMDEF             DEF081259
       
  6537 
       
  6538 @SYMTestCaseDesc    Send events for an anim event
       
  6539 
       
  6540 @SYMTestPriority    High
       
  6541 
       
  6542 @SYMTestStatus      Implemented
       
  6543 
       
  6544 @SYMTestActions     Send events for an anim event
       
  6545 
       
  6546 @SYMTestExpectedResults The events are sent to the window without
       
  6547 						error
       
  6548 */
       
  6549 		case 10:
       
  6550 			((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0062"));
       
  6551 			iTest->LogSubTest(KTest10);
       
  6552 			RunTestsRestoreAreaL(EFalse);		//AnimEvent();
       
  6553 			break;
       
  6554 /**
       
  6555 @SYMTestCaseID		GRAPHICS-WSERV-0063
       
  6556 
       
  6557 @SYMDEF             DEF081259
       
  6558 
       
  6559 @SYMTestCaseDesc    Send events for focus changed
       
  6560 
       
  6561 @SYMTestPriority    High
       
  6562 
       
  6563 @SYMTestStatus      Implemented
       
  6564 
       
  6565 @SYMTestActions     Send events for focus changed
       
  6566 
       
  6567 @SYMTestExpectedResults The events are sent to the window without
       
  6568 						error
       
  6569 */
       
  6570 		case 11:
       
  6571 			((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0063"));
       
  6572 			iTest->LogSubTest(KTest11);
       
  6573 			RunTestsL();		//FocusChanged();
       
  6574 			break;
       
  6575 /**
       
  6576 @SYMTestCaseID		GRAPHICS-WSERV-0064
       
  6577 
       
  6578 @SYMDEF             DEF081259
       
  6579 
       
  6580 @SYMTestCaseDesc    Send stop events
       
  6581 
       
  6582 @SYMTestPriority    High
       
  6583 
       
  6584 @SYMTestStatus      Implemented
       
  6585 
       
  6586 @SYMTestActions     Send stop events
       
  6587 
       
  6588 @SYMTestExpectedResults The events are sent to the window without
       
  6589 						error
       
  6590 */
       
  6591 		case 12:
       
  6592 			((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0064"));
       
  6593 			iTest->LogSubTest(KTest12);
       
  6594 			RunTestsL(ETrue);		//StopEvents();
       
  6595 			break;
       
  6596 /**
       
  6597 @SYMTestCaseID		GRAPHICS-WSERV-0065
       
  6598 
       
  6599 @SYMDEF             DEF081259
       
  6600 
       
  6601 @SYMTestCaseDesc    Send events for the virtual keyboard
       
  6602 
       
  6603 @SYMTestPriority    High
       
  6604 
       
  6605 @SYMTestStatus      Implemented
       
  6606 
       
  6607 @SYMTestActions     Send events for the virtual keyboard
       
  6608 
       
  6609 @SYMTestExpectedResults The events are sent to the window without
       
  6610 						error
       
  6611 */
       
  6612 		case 13:
       
  6613 			((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0065"));
       
  6614 			iTest->LogSubTest(KTest13);
       
  6615 			RunTestsL();		//VirtualKeyboard();
       
  6616 			break;
       
  6617 /**
       
  6618 @SYMTestCaseID		GRAPHICS-WSERV-0066
       
  6619 
       
  6620 @SYMDEF             DEF081259
       
  6621 
       
  6622 @SYMTestCaseDesc    Send events for key clicks
       
  6623 
       
  6624 @SYMTestPriority    High
       
  6625 
       
  6626 @SYMTestStatus      Implemented
       
  6627 
       
  6628 @SYMTestActions     Send stop events
       
  6629 
       
  6630 @SYMTestExpectedResults The events are sent to the window without
       
  6631 						error
       
  6632 */
       
  6633 		case 14:
       
  6634 			((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0066"));
       
  6635 			iTest->LogSubTest(KTest14);
       
  6636 			{
       
  6637 			TBool changeable;
       
  6638 			if (iClick.IsLoaded(changeable) && !iTest->IsFullRomL())
       
  6639 				RunTestsL(ETrue);		//KeyClicks();
       
  6640 			}
       
  6641 			break;
       
  6642 /**
       
  6643 @SYMTestCaseID		GRAPHICS-WSERV-0067
       
  6644 
       
  6645 @SYMDEF             DEF081259
       
  6646 
       
  6647 @SYMTestCaseDesc    Send events for capturing large areas of text
       
  6648 
       
  6649 @SYMTestPriority    High
       
  6650 
       
  6651 @SYMTestStatus      Implemented
       
  6652 
       
  6653 @SYMTestActions     Send events for capturing large areas of text
       
  6654 
       
  6655 @SYMTestExpectedResults The events are sent to the window without
       
  6656 						error
       
  6657 */
       
  6658 		case 15:
       
  6659 			((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0067"));
       
  6660 			iTest->LogSubTest(KTest15);
       
  6661 			RunTestsL(ETrue);		//CaptureLong();
       
  6662 			break;
       
  6663 /**
       
  6664 @SYMTestCaseID		GRAPHICS-WSERV-0068
       
  6665 
       
  6666 @SYMDEF             DEF081259
       
  6667 
       
  6668 @SYMTestCaseDesc    Send events for activating password
       
  6669 
       
  6670 @SYMTestPriority    High
       
  6671 
       
  6672 @SYMTestStatus      Implemented
       
  6673 
       
  6674 @SYMTestActions     Send events for activating password
       
  6675 
       
  6676 @SYMTestExpectedResults The events are sent to the window without
       
  6677 						error
       
  6678 */
       
  6679 		case 16:
       
  6680 			((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0068"));
       
  6681 			iTest->LogSubTest(KTest16);
       
  6682 			if (!iTest->IsFullRomL())
       
  6683 				RunTestsL();		//Password();
       
  6684 			break;
       
  6685 /**
       
  6686 @SYMTestCaseID		GRAPHICS-WSERV-0069
       
  6687 
       
  6688 @SYMDEF             DEF081259
       
  6689 
       
  6690 @SYMTestCaseDesc    Send events for activating password
       
  6691 
       
  6692 @SYMTestPriority    High
       
  6693 
       
  6694 @SYMTestStatus      Implemented
       
  6695 
       
  6696 @SYMTestActions     Send events for activating password
       
  6697 
       
  6698 @SYMTestExpectedResults The events are sent to the window without
       
  6699 						error
       
  6700 */
       
  6701 		case 17:
       
  6702 			((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0069"));
       
  6703 			iTest->LogSubTest(KTest17);
       
  6704 			RunTestsL();
       
  6705 			break;
       
  6706 /**
       
  6707 @SYMTestCaseID		GRAPHICS-WSERV-0070
       
  6708 
       
  6709 @SYMDEF             DEF081259
       
  6710 
       
  6711 @SYMTestCaseDesc    Send repeatable key events
       
  6712 
       
  6713 @SYMTestPriority    High
       
  6714 
       
  6715 @SYMTestStatus      Implemented
       
  6716 
       
  6717 @SYMTestActions     Send repeatable key events
       
  6718 
       
  6719 @SYMTestExpectedResults The events are sent to the window without
       
  6720 						error
       
  6721 */
       
  6722 		case 18:
       
  6723 			((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0070"));
       
  6724 			iTest->LogSubTest(KTest18);
       
  6725 			RunTestsL();
       
  6726 			break;
       
  6727 /**
       
  6728 @SYMTestCaseID		GRAPHICS-WSERV-0071
       
  6729 
       
  6730 @SYMDEF             DEF081259
       
  6731 
       
  6732 @SYMTestCaseDesc    Send Screen Scaling events
       
  6733 
       
  6734 @SYMTestPriority    High
       
  6735 
       
  6736 @SYMTestStatus      Implemented
       
  6737 
       
  6738 @SYMTestActions     Send Screen Scaling events
       
  6739 
       
  6740 @SYMTestExpectedResults The events are sent to the window without
       
  6741 						error
       
  6742 */
       
  6743 		case 19:
       
  6744 			((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0071"));
       
  6745 			iTest->LogSubTest(KTest19);
       
  6746 			if (iScreenModeTests&EDoScale)
       
  6747 				{
       
  6748 				RunTestsL();
       
  6749 				}
       
  6750 			break;
       
  6751 /**
       
  6752 @SYMTestCaseID		GRAPHICS-WSERV-0072
       
  6753 
       
  6754 @SYMDEF             DEF081259
       
  6755 
       
  6756 @SYMTestCaseDesc    Send Visibility Changed events
       
  6757 
       
  6758 @SYMTestPriority    High
       
  6759 
       
  6760 @SYMTestStatus      Implemented
       
  6761 
       
  6762 @SYMTestActions     Send Visibility Changed events
       
  6763 
       
  6764 @SYMTestExpectedResults The events are sent to the window without
       
  6765 						error
       
  6766 */
       
  6767 		case 20:
       
  6768 			((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0072"));
       
  6769 			iTest->LogSubTest(KTest20);
       
  6770 			RunTestsL();
       
  6771 			break;
       
  6772 /**
       
  6773 @SYMTestCaseID		GRAPHICS-WSERV-0073
       
  6774 
       
  6775 @SYMDEF             DEF081259
       
  6776 
       
  6777 @SYMTestCaseDesc    Check Time Stamp Of Sent Events
       
  6778 
       
  6779 @SYMTestPriority    High
       
  6780 
       
  6781 @SYMTestStatus      Implemented
       
  6782 
       
  6783 @SYMTestActions     Check Time Stamp Of Sent Events
       
  6784 
       
  6785 @SYMTestExpectedResults The time stamps for the events are correct
       
  6786 */
       
  6787 		case 21:
       
  6788 			((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0073"));
       
  6789 			iTest->LogSubTest(KTest21);
       
  6790 			RunTestsL();
       
  6791 			break;
       
  6792 /**
       
  6793 @SYMTestCaseID		GRAPHICS-WSERV-0074
       
  6794 
       
  6795 @SYMDEF             DEF081259
       
  6796 
       
  6797 @SYMTestCaseDesc    Send Pointer Capture Priority Events
       
  6798 
       
  6799 @SYMTestPriority    High
       
  6800 
       
  6801 @SYMTestStatus      Implemented
       
  6802 
       
  6803 @SYMTestActions     Send Pointer Capture Priority Events
       
  6804 
       
  6805 @SYMTestExpectedResults The events are sent to the window without
       
  6806 						error
       
  6807 */
       
  6808 		case 22:
       
  6809 			((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0074"));
       
  6810 			iTest->LogSubTest(KTest22);
       
  6811 			RunTestsL();
       
  6812 			break;
       
  6813 /**
       
  6814 @SYMTestCaseID		GRAPHICS-WSERV-0343
       
  6815 
       
  6816 @SYMDEF             DEF081259
       
  6817 
       
  6818 @SYMTestCaseDesc    Send Event Handler Removal Events
       
  6819 
       
  6820 @SYMTestPriority    High
       
  6821 
       
  6822 @SYMTestStatus      Implemented
       
  6823 
       
  6824 @SYMTestActions     Send Event Handler Removal Events
       
  6825 
       
  6826 @SYMTestExpectedResults The events are sent to the window without
       
  6827 						error
       
  6828 */
       
  6829 		case 23:
       
  6830 			((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0343"));
       
  6831 			iTest->LogSubTest(KTest23);
       
  6832 			RunTestsL();                   //EventHandlerRemoval();
       
  6833 			break;
       
  6834 		case 24:
       
  6835 /**
       
  6836 @SYMTestCaseID		GRAPHICS-WSERV-0565
       
  6837 */
       
  6838 			((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0565"));
       
  6839 			iTest->LogSubTest(KTest24);
       
  6840 			EventQueuePtrCrashTest();
       
  6841 			break;
       
  6842 /**
       
  6843 @SYMTestCaseID 		GRAPHICS-WSERV-0496
       
  6844 
       
  6845 @SYMDEF 			DEF133776
       
  6846 
       
  6847 @SYMTestCaseDesc 	Cancels key captures using all combinations of 
       
  6848   RWindowGroup::Capture...() and RWindowGroup::Cancel...() APIs.
       
  6849 
       
  6850 @SYMTestPriority 	High
       
  6851 
       
  6852 @SYMTestStatus 		Implemented
       
  6853 
       
  6854 @SYMTestActions 	Call each of the RWindowGroup::Capture***() APIs followed by
       
  6855  each of the RWindowGroup::CancelCapture***() APIs.
       
  6856  RWindowGroup::Capture***() APIs:
       
  6857  	CaptureKey(TUint, TUint, TUint)
       
  6858  	CaptureKey(TUint, TUint, TUint, TInt)
       
  6859  	CaptureKeyUpAndDowns(TUint, TUint, TUint)
       
  6860  	CaptureKeyUpAndDowns(TUint, TUint, TUint, TInt)
       
  6861  	CaptureLongKey(TUint, TUint, TUint, TUint, TInt, TUint)
       
  6862  	CaptureLongKey(TTimeIntervalMicroSeconds32, TUint, TUint, TUint, TUint, TInt, TUint)
       
  6863  RWindowGroup::CancelCapture***() APIs:
       
  6864 	CancelCaptureKey()
       
  6865 	CancelCaptureKeyUpAndDowns()
       
  6866 	CancelCaptureLongKey()
       
  6867  
       
  6868 @SYMTestExpectedResults WServ should handle matched and mismatched Cancel 
       
  6869  and Capture calls without panicking.
       
  6870 */			
       
  6871 		case 25:
       
  6872 // Skip this test in debug on the emulator, run it always on hardware as debug ROMs include
       
  6873 // a release version of the production code that doesn't panic
       
  6874 			((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0496"));
       
  6875 #if defined(_DEBUG) && !defined (__MARM__)
       
  6876 			INFO_PRINTF1(_L("Skipping this test in _DEBUG on emulator to avoid debug only panics, see GRAPHICS-WSERV-0497 for the matching panic test"));				
       
  6877 #else						
       
  6878 			iTest->LogSubTest(KTest25);
       
  6879 			RunTestsL();
       
  6880 #endif
       
  6881 			break;	
       
  6882 /**
       
  6883 @SYMTestCaseID		GRAPHICS-WSERV-0444
       
  6884 
       
  6885 @SYMDEF             PDEF110849
       
  6886 
       
  6887 @SYMTestCaseDesc    Pointer Buffer Exception After Event Queue Purge
       
  6888 
       
  6889 @SYMTestPriority    High
       
  6890 
       
  6891 @SYMTestStatus      Implemented
       
  6892 
       
  6893 @SYMTestActions     Connect to pointer buffer, send it some pointer events and disconnect.
       
  6894 					Now send enough events to cause an event queue purge.  The purge will
       
  6895 					attempt to empty the pointer buffer, but will fail because we have disconnected.
       
  6896 
       
  6897 @SYMTestExpectedResults The purge will realise it does not need to empty the pointer buffer and 
       
  6898 						so there will not be an access violation - exception.
       
  6899 						
       
  6900 */			
       
  6901 		case 26:
       
  6902 			((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0444"));
       
  6903 			iTest->LogSubTest(KTest26);
       
  6904 			RunTestsL();
       
  6905 			break;
       
  6906 /**
       
  6907 @SYMTestCaseID		GRAPHICS-WSERV-0484
       
  6908 @SYMDEF             PDEF120721
       
  6909 @SYMTestCaseDesc    Window server guarantees to initialize the queue size of the new queue to 
       
  6910 					at least EMinQueueSize.
       
  6911 @SYMTestPriority    High
       
  6912 @SYMTestStatus      Implemented
       
  6913 @SYMTestActions     Create multiple clients to connect to window server.
       
  6914 					Send enough events to make the event queue full.
       
  6915 					Create a new client to connect to window server.
       
  6916 					Send events to the new client and test that the new client 
       
  6917 					can get the events.
       
  6918 @SYMTestExpectedResults Window server guarantees to initialize the size of the new event 
       
  6919 						queue to EMinQueueSize, so that window server will not lock up
       
  6920 						due to the full of global event queue.
       
  6921 						
       
  6922 */			
       
  6923 		case 27:
       
  6924 		    iTest->LogSubTest(KTest27);
       
  6925 		    RunTestsL();
       
  6926 		    break;
       
  6927 		    
       
  6928 #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS            
       
  6929 #ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA            
       
  6930 /**
       
  6931 @SYMTestCaseID      GRAPHICS-WSERV-2669-0015
       
  6932 @SYMREQ             REQ13202: Possibility for external layers to appear above UI layer
       
  6933 @SYMTestCaseDesc    Window obscured by transparent surface window receives 
       
  6934                     (EPartiallyVisible | EFullyVisible) when surface is made semi-transparent.
       
  6935 @SYMTestPriority    2
       
  6936 @SYMPrerequisites   Win1 – bottom window
       
  6937                     Win2 – middle window with background surface, which totally obscures win1
       
  6938 @SYMTestActions     Call SetSurfaceTransparency(ETrue) on win2
       
  6939 @SYMTestExpectedResults Win1 receives visibility event
       
  6940 */            
       
  6941         case 28:
       
  6942             ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-2669-0015"));
       
  6943             iTest->LogSubTest(KTest28);
       
  6944             RunTestsL();
       
  6945             break;
       
  6946 /**
       
  6947 @SYMTestCaseID      GRAPHICS-WSERV-2669-0016
       
  6948 @SYMREQ             REQ13202: Possibility for external layers to appear above UI layer 
       
  6949 @SYMTestCaseDesc    Window obscured by semi-transparent surface window receives   
       
  6950                     (EPartiallyVisible | EFullyVisible) when obscuring window is deleted
       
  6951 @SYMTestPriority    2
       
  6952 @SYMPrerequisites   Win1 – bottom window
       
  6953                     Win2 – middle window with semi-transparent background surface, which totally obscures win1
       
  6954                     Win3 – top window which totally obscures win2, and is opaque
       
  6955 @SYMTestActions     Delete win3
       
  6956 @SYMTestExpectedResults Both win1 and win2 receive visibility events
       
  6957 */            
       
  6958         case 29:
       
  6959             ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-2669-0016"));
       
  6960             iTest->LogSubTest(KTest29);
       
  6961             RunTestsL();
       
  6962             break;
       
  6963 /**
       
  6964 @SYMTestCaseID      GRAPHICS-WSERV-2669-0017
       
  6965 @SYMREQ             REQ13202: Possibility for external layers to appear above UI layer 
       
  6966 @SYMTestCaseDesc    Window does not receive any visibiliy event when a semi-transparent
       
  6967                     surface is moved onto/above it.
       
  6968 @SYMTestPriority    2
       
  6969 @SYMPrerequisites   Win1 – bottom window
       
  6970                     Win2 – top window which does not overlap win1
       
  6971 @SYMTestActions     Move win2 to overlap win1
       
  6972 @SYMTestExpectedResults No visibility event is received (win1 is still fully visible)
       
  6973 */            
       
  6974         case 30:
       
  6975             ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-2669-0017"));
       
  6976             iTest->LogSubTest(KTest30);
       
  6977             RunTestsL();
       
  6978             break;
       
  6979 #endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
       
  6980 #endif // SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS  
       
  6981 
       
  6982 /**
       
  6983 @SYMTestCaseID      GRAPHICS-WSERV-0559
       
  6984 @SYMDEF             INC140850
       
  6985 @SYMTestCaseDesc    To check Wserv passes correct repeat value for TRawEvent of type EKeyRepeat.
       
  6986 @SYMTestPriority    High
       
  6987 @SYMTestStatus      Implemented
       
  6988 @SYMTestActions     Simulate TRawEvent of type EKeyRepeat without Repeat value set.
       
  6989                     Simulate the above with repeat value set to 2.
       
  6990 @SYMTestExpectedResults Simulated events should match expected events added to the array. 
       
  6991 */
       
  6992 
       
  6993 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
       
  6994 		case 28:
       
  6995 #else
       
  6996 #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
       
  6997 		case 31:
       
  6998 #else
       
  6999 		case 28:
       
  7000 #endif
       
  7001 #endif
       
  7002 		    // This test was moved to be the last test in the test suite, because it sometimes leaves events in the event queue, 
       
  7003 		    //it can affect the results of other tests. This test case should be the last test in the test suite. 
       
  7004 		    ((CTEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0484"));
       
  7005 		    iTest->LogSubTest(KTest31A);
       
  7006 		    InitializeQueueSizeTestL(EFalse);
       
  7007 		    iTest->LogSubTest(KTest31B);
       
  7008 		    InitializeQueueSizeTestL(ETrue);
       
  7009 		    break;    
       
  7010 			
       
  7011 		default:
       
  7012             ((CTEventTestStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
       
  7013 			((CTEventTestStep*)iStep)->CloseTMSGraphicsStep();
       
  7014 			TestComplete();
       
  7015 			break;
       
  7016 		}
       
  7017 	((CTEventTestStep*)iStep)->RecordTestResultL();
       
  7018 	if (iFailed)
       
  7019 		{
       
  7020 		TEST(EFalse);
       
  7021 		iFailed=EFalse;
       
  7022 		}
       
  7023 	++iTest->iState;
       
  7024 	}
       
  7025 
       
  7026 __WS_CONSTRUCT_STEP__(EventTest)
       
  7027