os/graphics/windowing/windowserver/test/tauto/tmultiptrevent.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2008-2010 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 // Multi pointer and Z-coordinate test code
    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 "tmultiptrevent.h"
    30 #include <e32cmn.h>
    31 #include <hal.h>
    32 
    33 //#define FAILLOG 1			// Uncomment this code to get detailed log
    34 #define TESTMULTIPOINTER 1	// Comment this line to get detailed log without testing
    35 
    36 _LIT(KMultiPtrPluginDll, "multiptrclick.dll");
    37 
    38 const TInt KErrDescSize = 128;
    39 const TInt KMaxQueueSize = 32;	// Queue size of wserv. In any test we cannot test more than MaxQueueSize events. 
    40 
    41 LOCAL_C void DestroyAnim(TAny* aAnim)
    42 	{
    43 	(static_cast<RMultiPointerAnim*>(aAnim))->Destroy();
    44 	}
    45 
    46 
    47 //CTMultiPtrEventBuffer
    48 CTMultiPtrEventBuffer::CTMultiPtrEventBuffer(RWsSession *aWs, CTMultiPtrEventTest *aTest, CTMultiPtrEventClient* aClient) 
    49 	: CTEvent(aWs), iTest(aTest), iClient(aClient)
    50 	{
    51 	}
    52 
    53 void CTMultiPtrEventBuffer::ConstructL()
    54 	{
    55 	CTEventBase::Construct();
    56 	iEventBuffer.SetLengthL(EEventBufferSize);
    57 	iMovePtsBuffer.SetLengthL(EMovePtsBuffer);
    58 	}
    59 
    60 void CTMultiPtrEventBuffer::AddExpectedEvent(TWsEvent &aEvent)
    61 	{
    62 	iEventBuffer.Add(&aEvent);
    63 	}
    64 
    65 void CTMultiPtrEventBuffer::AddExpectedMovePtEvent(TPoint &aMovePt)
    66 	{
    67 	iMovePtsBuffer.Add(&aMovePt);
    68 	}
    69 
    70 TInt CTMultiPtrEventBuffer::EventsRemaining()
    71 	{
    72 	return iEventBuffer.Count();
    73 	}
    74 
    75 void CTMultiPtrEventBuffer::GetMoveBufferAndCompareL()
    76 	{
    77 	TBuf8<EMovePtsBuffer*sizeof(TPoint)> buf;
    78 	iClient->ParentWin()->BaseWin()->RetrievePointerMoveBuffer(buf);
    79 	
    80 	TUint bufferSize = buf.Length();
    81 	TUint numLoop = bufferSize/sizeof(TPoint);
    82 	
    83 	if (iMovePtsBuffer.Count() != numLoop)
    84 		{
    85 #if defined(FAILLOG)
    86 		TLogMessageText logText;
    87 		_LIT(KPointerNumber, "Actual number of move/drag buffer points from Wserv = %d Expected number of move/drag buffer points = %d ");
    88 		logText.Format(KPointerNumber, numLoop, iMovePtsBuffer.Count());
    89 		iTest->LOG_MESSAGE(logText);
    90 #endif
    91 		TestL(EFalse);
    92 		}
    93 	
    94 	TPoint wsPoint;
    95 	TPoint expPoint;
    96 	TUint8* BasePtr = const_cast<TUint8*>(buf.Ptr());
    97 	for (TUint count = 0; count < numLoop; count++)
    98 		{
    99 		wsPoint = *(reinterpret_cast<TPoint*>(BasePtr));
   100 		iMovePtsBuffer.Remove(&expPoint);
   101 		if (wsPoint != expPoint)
   102 			{
   103 #if defined(FAILLOG)
   104 			TLogMessageText logText;
   105 			_LIT(KMoveBufferPoint, "Actual move/drag buffer point from Wserv = ([%d], [%d]) Expected move/drag buffer point = ([%d], [%d])");
   106 			logText.Format(KMoveBufferPoint, wsPoint.iX, wsPoint.iY, expPoint.iX, expPoint.iY);
   107 			iTest->LOG_MESSAGE(logText);
   108 #endif
   109 			TestL(EFalse);
   110 			}
   111 		BasePtr = BasePtr + sizeof(TPoint);
   112 		}
   113 	}
   114 
   115 
   116 #define TESTXL(expr1, oper, expr2, event, expected) \
   117     TestL(expr1 oper expr2, expr1, expr2, #oper, #expr1 ## #oper ## #expr2, \
   118             event, expected, __FILE__, __LINE__);
   119 
   120 // Main function which gets the event, checks with the event in buffer
   121 // Then calls function NextSetOfEventsL for running other tests of a particualar test case
   122 void CTMultiPtrEventBuffer::doRunL()
   123 	{
   124 	// Get the event from wserv
   125 	TWsEvent wsEvent;
   126 	iWs->GetEvent(wsEvent);
   127 
   128 	TWsEvent expectedEvent;
   129 	TInt wsType=wsEvent.Type();
   130 	if (wsEvent.Type()==EEventNull)
   131 		{
   132 		TESTXL(wsEvent.Handle(), ==, 0, &wsEvent, NULL);
   133 		goto End;
   134 		}
   135 	// This code is for running successive anim test code 
   136 	if (wsEvent.Type()==EEventPointer && wsEvent.Pointer()->iType==TPointerEvent::ESwitchOn)
   137 		goto End;
   138 	// if this is called accidentally
   139 	if (iEventBuffer.Count()==0 && wsType==EEventFocusGained)
   140 		goto End;
   141 
   142 	iEventBuffer.Remove(&expectedEvent);
   143 	iEventCount++;
   144 
   145 	if (wsEvent.Type() == EEventPointerBufferReady)
   146 		{
   147 		GetMoveBufferAndCompareL();
   148 #if defined(FAILLOG)
   149 		TLogMessageText logText;
   150 		_LIT(KEventHandle, "Actual Window Handle from Wserv = %d Expected Window Handle = %d ");
   151 		logText.Format(KEventHandle, wsEvent.Handle(), expectedEvent.Handle());
   152 		iTest->LOG_MESSAGE(logText);
   153 #endif
   154 #if defined(TESTMULTIPOINTER)
   155 		TESTXL(wsEvent.Handle(), ==, expectedEvent.Handle(), &wsEvent, &expectedEvent);
   156 #endif
   157 		goto End;
   158 		}
   159 
   160 	// Test wsEvent and expected event have same handle, position and type.
   161 #if defined(FAILLOG)
   162 	{
   163 	TLogMessageText logText;
   164 	_LIT(KEventCountCheck, "Checking event number = %d");
   165 	logText.Format(KEventCountCheck, iEventCount);
   166 	iTest->LOG_MESSAGE(logText);
   167 	_LIT(KEventType, "Actual Event type from Wserv = %d Expected Event Type = %d ");
   168 	logText.Format(KEventType, wsEvent.Type(), expectedEvent.Type());
   169 	iTest->LOG_MESSAGE(logText);
   170 	}
   171 #endif
   172 
   173 #if defined(TESTMULTIPOINTER)
   174 	TESTXL(wsEvent.Type(), ==, expectedEvent.Type(), &wsEvent, &expectedEvent);
   175 #endif
   176 	// Test pointer number for Enter/Exit events
   177 	if (wsType == EEventPointerEnter || wsType == EEventPointerExit)
   178 		{
   179 #if defined(FAILLOG)
   180 		TLogMessageText logText;
   181 		_LIT(KPointerNumber, "Actual PointerNumber for Enter/Exit event from Wserv = %d Expected PointerNumber for Enter/Exit event = %d ");
   182 		logText.Format(KPointerNumber, *wsEvent.Int(), *expectedEvent.Int());
   183 		iTest->LOG_MESSAGE(logText);
   184 #endif
   185 #if defined(TESTMULTIPOINTER)
   186 		TESTXL(*wsEvent.Int(), ==, *expectedEvent.Int(), &wsEvent, &expectedEvent);
   187 #endif
   188 		}
   189 
   190 	// Test only if it is a Pointer event
   191 	if (wsType==EEventPointer)
   192 		{
   193 		TAdvancedPointerEvent* expectedPointerEvent=expectedEvent.Pointer();
   194 		TAdvancedPointerEvent* actualPointerEvent=wsEvent.Pointer();
   195 #if defined(FAILLOG)
   196 		TLogMessageText logText;
   197 		_LIT(KEventHandle, "Actual Window Handle from Wserv = %d Expected Window Handle = %d ");
   198 		logText.Format(KEventHandle, wsEvent.Handle(), expectedEvent.Handle());
   199 		iTest->LOG_MESSAGE(logText);
   200 #endif
   201 #if defined(TESTMULTIPOINTER)
   202 		TESTXL(wsEvent.Handle(), ==, expectedEvent.Handle(), &wsEvent, &expectedEvent);
   203 #endif
   204 #if defined(FAILLOG)
   205 		_LIT(KPointerType, "Actual PointerType from Wserv = %d Expected PointerType = %d ");
   206 		logText.Format(KPointerType, actualPointerEvent->iType, expectedPointerEvent->iType);
   207 		iTest->LOG_MESSAGE(logText);
   208 #endif
   209 #if defined(TESTMULTIPOINTER)
   210 		TESTXL(actualPointerEvent->iType, ==, expectedPointerEvent->iType, &wsEvent, &expectedEvent);
   211 #endif
   212 #if defined(FAILLOG)
   213 		_LIT(KPointerPosition, "Actual PointerPosition from Wserv = (%d, %d) Expected PointerPosition = (%d, %d) ");
   214 		logText.Format(KPointerPosition, actualPointerEvent->iPosition.iX, actualPointerEvent->iPosition.iY, expectedPointerEvent->iPosition.iX, expectedPointerEvent->iPosition.iY);
   215 		iTest->LOG_MESSAGE(logText);
   216 #endif
   217 #if defined(TESTMULTIPOINTER)		
   218 		TESTXL(actualPointerEvent->iPosition, ==, expectedPointerEvent->iPosition, &wsEvent, &expectedEvent);
   219 #endif		
   220 #if defined(FAILLOG)
   221 		_LIT(KPointerNumber, "Actual PointerNumber from Wserv = %d Expected PointerNumber = %d ");
   222 		logText.Format(KPointerNumber, actualPointerEvent->PointerNumber(), expectedPointerEvent->PointerNumber());
   223 		iTest->LOG_MESSAGE(logText);
   224 #endif
   225 #if defined(TESTMULTIPOINTER)		
   226 		TESTXL(actualPointerEvent->PointerNumber(), ==, expectedPointerEvent->PointerNumber(), &wsEvent, &expectedEvent);
   227 #endif
   228 #if defined(FAILLOG)
   229 		_LIT(KPointerProximity, "Actual PointerProximity from Wserv = %d Expected PointerProximity = %d ");
   230 		logText.Format(KPointerProximity, actualPointerEvent->Proximity(), expectedPointerEvent->Proximity());
   231 		iTest->LOG_MESSAGE(logText);
   232 #endif
   233 #if defined(TESTMULTIPOINTER)		
   234 		TESTXL(actualPointerEvent->Proximity(), ==, expectedPointerEvent->Proximity(), &wsEvent, &expectedEvent);
   235 #endif		
   236 #if defined(FAILLOG)
   237 		_LIT(KPointerPressure, "Actual PointerPressure from Wserv = %d Expected PointerPressure = %d ");
   238 		logText.Format(KPointerPressure, actualPointerEvent->Pressure(), expectedPointerEvent->Pressure());
   239 		iTest->LOG_MESSAGE(logText);
   240 #endif
   241 #if defined(TESTMULTIPOINTER)		
   242 		TESTXL(actualPointerEvent->Pressure(), ==, expectedPointerEvent->Pressure(), &wsEvent, &expectedEvent);
   243 #endif
   244 #if defined(FAILLOG)
   245 		_LIT(KPointerModifier, "Actual Modifier value from Wserv = 0x%08x Expected Modfier value = 0x%08x ");
   246 		logText.Format(KPointerModifier, actualPointerEvent->iModifiers, expectedPointerEvent->iModifiers);
   247 		iTest->LOG_MESSAGE(logText);
   248 #endif
   249 #if defined(TESTMULTIPOINTER)		
   250 		TESTXL((actualPointerEvent->iModifiers&expectedPointerEvent->iModifiers), ==, expectedPointerEvent->iModifiers, &wsEvent, &expectedEvent);
   251 #endif		
   252 		}
   253 End:
   254 	// Call NextSetOfEvents() only for primary client
   255 	if (iEventBuffer.Count()==0 && !iClient->IsSecondaryClient())	
   256 		{
   257 		iTest->NextSetOfEventsL();		// Cannot Leave
   258 		}
   259 	
   260 	// If this is for secondary client and active scheduler(nested loop) has started, this code stops that scheduler
   261 	if (iEventBuffer.Count()==0 && iClient->IsSecondaryClient() && iNestedLoopStarted)
   262 		{
   263 		iNestedLoopStarted = EFalse;
   264 		CActiveScheduler::Stop();
   265 		}
   266 	}
   267 
   268 void CTMultiPtrEventBuffer::TestL(TInt aTest)
   269 	{
   270 	if (!aTest)
   271 		{
   272 		iTest->Failed();
   273 		User::Leave(ETestFailed);
   274 		}
   275 	}
   276 
   277 static void DumpEvent(const char *aName, const TWsEvent *aEvent)
   278     {
   279     // aEvent may be NULL - if it isn't NULL, we print it's data.
   280     if (aEvent)
   281         {
   282         RDebug::Printf("%s:", aName);
   283         RDebug::Printf("handle = %u", aEvent->Handle());
   284         RDebug::Printf("type() = %d", aEvent->Type());
   285         if (aEvent->Type() == EEventPointer)
   286             {
   287             TAdvancedPointerEvent *pointer = aEvent->Pointer();
   288             RDebug::Printf("pointer type = %d, position = (%d, %d)", 
   289                     pointer->iType, pointer->iPosition.iX, pointer->iPosition.iY);
   290             RDebug::Printf("PointerNumber() = %d, proximity=%d, pressure=%d", 
   291                     pointer->PointerNumber(), pointer->Proximity(), pointer->Pressure());
   292             RDebug::Printf("modifiers = 0x%08x", pointer->iModifiers);
   293             }
   294         else
   295             {
   296             RDebug::Printf("Not a pointer event, event type");
   297             }
   298         }
   299     else
   300         {
   301         // aEvent is NULL, just let us know it is. 
   302         RDebug::Printf("%s: is NULL which means not applicapable");
   303         }
   304     }
   305 
   306 void CTMultiPtrEventBuffer::TestL(TInt aTest, TInt aVal1, TInt aVal2, const char *aOper, const char *aTestStr, 
   307         const TWsEvent *aEvent, const TWsEvent *aExpected, const char *aFile, TUint aLine)
   308     {
   309     if (!aTest)
   310         {
   311         RDebug::Printf("Expression %d %s %d [%s] (=%d) failed [call from %s:%d]", aVal1, aOper, aVal2, aTestStr, aTest, aFile, aLine);
   312         DumpEvent("actual", aEvent);
   313         DumpEvent("expected", aExpected);
   314         iTest->Failed();
   315         User::Leave(ETestFailed);
   316         }
   317     }
   318 
   319 
   320 void CTMultiPtrEventBuffer::TestL(TInt aTest, TPoint aVal1, TPoint aVal2, const char *oper, const char *aTestStr, 
   321         const TWsEvent *aEvent, const TWsEvent *aExpected, const char *aFile, TUint aLine)
   322     {
   323     if (!aTest)
   324         {
   325         RDebug::Printf("Expression (%d, %d) %s (%d, %d) [%s] (=%d) failed [call from %s:%d]", 
   326                 aVal1.iX, aVal1.iY, oper, aVal2.iX, aVal2.iY, aTestStr, aTest, aFile, aLine);
   327         DumpEvent("actual", aEvent);
   328         DumpEvent("expected", aExpected);
   329         iTest->Failed();
   330         User::Leave(ETestFailed);
   331         }
   332     }
   333 
   334 //CTMultiPtrEventClient
   335 CTMultiPtrEventClient::CTMultiPtrEventClient(CTMultiPtrEventTest *aTest, TBool aSecondaryClient) 
   336 	: iTest(aTest), iSecondaryClient(aSecondaryClient)
   337 	{
   338 	}
   339 
   340 CTMultiPtrEventClient::~CTMultiPtrEventClient()
   341 	{
   342 	if (iWinAutoFocus1 || iWinAutoFocus2 || iGroupWinAutoFocus2 || iGroupWinAutoFocus1)
   343 		{
   344 		DeleteGroupBlankWin();
   345 		}
   346 	delete iChildWin;
   347 	delete iParentWin;
   348 	}
   349 
   350 void CTMultiPtrEventClient::ConstructL()
   351 	{
   352 	CTClient::ConstructL();
   353 	
   354 	// Create a group window and assign it iGroup
   355 	iGroup = new(ELeave) CTWindowGroup(this);
   356 	iGroup->ConstructL();
   357 	
   358 	iParentWinSize = iScreen->SizeInPixels();
   359 	iParentWinPos = TPoint();
   360 	
   361 	// Change the parent window size and position for secondary client
   362 	if (iSecondaryClient)
   363 		{
   364 		iParentWinSize.iWidth /= 2; 
   365 		iParentWinPos.iX = iParentWinSize.iWidth;
   366 		}
   367 	
   368 	// Create window/s for this client so that events can come to this client
   369 	iParentWin=new(ELeave) CTBlankWindow();
   370 	iParentWin->ConstructL(*iGroup);
   371 	iParentWin->SetExt(iParentWinPos, iParentWinSize);
   372 	iParentWin->SetColor(KRgbRed);
   373 	if (iTest->TestBase()->iState != 12)
   374 		{
   375 		iParentWin->BaseWin()->EnableAdvancedPointers();
   376 		}
   377 	iParentWin->Activate();
   378 	
   379 	// Don't create child window for secodary client
   380 	if (!iSecondaryClient)
   381 		{
   382 		iChildWinSize = TSize(iParentWinSize.iWidth/2, iParentWinSize.iHeight);
   383 		iChildWinPos = TPoint(iParentWinSize.iWidth/2,0);
   384 		
   385 		iChildWin=new(ELeave) CTBlankWindow();
   386 		iChildWin->ConstructL(*iGroup);
   387 		iChildWin->SetExt(iChildWinPos, iChildWinSize);
   388 		iChildWin->SetColor(KRgbRed);
   389 		iChildWin->BaseWin()->EnableAdvancedPointers();
   390 		iChildWin->Activate();
   391 		}
   392 	}
   393 
   394 void CTMultiPtrEventClient::CalculatePtrPosAndSet3Ddata(TWsEvent& aEvent, TPointerEvent::TType aType, TPoint aPos, TUint aModifiers, TInt aZ, TUint8 aPointerNumber, TUint aHandle)
   395 	{
   396 	// If in future you need to change parent position then put this in corresponding if statements
   397 	aEvent.Pointer()->iParentPosition = aPos;
   398 	
   399 	// This is for Auto foreground test
   400 	if (iTest->TestBase()->iState == 11)
   401 		{
   402 		if (TRect(iWinPosAutoFocus1, iWinSizeAutoFocus1).Contains(aPos))
   403 			{
   404 			aPos -= iWinPosAutoFocus1;
   405 			aEvent.SetHandle((TUint)iWinAutoFocus1);
   406 			}
   407 		else if (TRect(iWinPosAutoFocus2, iWinSizeAutoFocus2).Contains(aPos))
   408 			{
   409 			aPos -= iWinPosAutoFocus2;
   410 			aEvent.SetHandle((TUint)iWinAutoFocus2);
   411 			}
   412 		goto SETOTHERDATA;
   413 		}
   414 
   415 	// Here simulated pointer position is w.r.t to 0,0
   416 	// Actual pointer position is w.r.t windowPosition
   417 	if (iSecondaryClient)
   418 		{
   419 		if (TRect(iParentWinPos, TSize(iParentWinSize.iWidth, iParentWinSize.iHeight)).Contains(aPos))
   420 			{
   421 			// Since for secondary client parent window is at half of screensize
   422 			aPos -= iParentWinPos;
   423 			aEvent.SetHandle((aHandle == 0) ? (TUint)iParentWin : aHandle);
   424 			}
   425 		}
   426 	else
   427 		{
   428 		// If sent position is on blankWindow then
   429 		if (TRect(iParentWinPos, TSize(iParentWinSize.iWidth/2, iParentWinSize.iHeight)).Contains(aPos))
   430 			{
   431 			aEvent.SetHandle((aHandle == 0) ? (TUint)iParentWin : aHandle);
   432 			}
   433 		else // else the pointer event occured on child window
   434 			{
   435 			// if aPos < 0 then position has been generated in test code and should not be adjusted
   436 			if (aPos.iX >= 0)
   437 				{
   438 				aPos -= iChildWinPos;	
   439 				}
   440 			aEvent.SetHandle((aHandle == 0) ? (TUint)iChildWin : aHandle);
   441 			}
   442 		}
   443 	
   444 SETOTHERDATA:	
   445 	aEvent.Pointer()->iType = aType;
   446 	aEvent.Pointer()->iPosition = aPos;
   447 	if(iExpectNonAdvancedPointerEvents)
   448 		{
   449 		aEvent.Pointer()->iModifiers = aModifiers;		
   450 		}
   451 	else
   452 		{
   453 		aEvent.Pointer()->iModifiers = aModifiers|EModifierAdvancedPointerEvent;
   454 		aEvent.SetPointerNumber(aPointerNumber);
   455 		aEvent.SetPointerZ(aZ);
   456 		}
   457 	}
   458 
   459 void CTMultiPtrEventClient::AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TUint8 aPointerNumber, TUint aHandle)
   460 	{
   461 	AddExpectedPointerEvent(aType, aPos, 0, 0, aPointerNumber, aHandle);
   462 	}
   463 
   464 void CTMultiPtrEventClient::AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle)
   465 	{
   466 	TWsEvent ptrEvent;
   467 	ptrEvent.SetType(EEventPointer);
   468 	if (aType != TPointerEvent::ESwitchOn)
   469 		{
   470 		CalculatePtrPosAndSet3Ddata(ptrEvent, aType, aPos, aModifier, aZ, aPointerNumber, aHandle);
   471 		}
   472 	static_cast<CTMultiPtrEventBuffer*>(iEventHandler)->AddExpectedEvent(ptrEvent);
   473 	}
   474 
   475 void CTMultiPtrEventClient::AddExpectedWsEvent(TEventCode aType, TInt aPointerNumber, TUint aHandle)
   476 	{
   477 	TWsEvent ptrEvent;
   478 	ptrEvent.SetType(aType);
   479 	if (aType == EEventPointerEnter || aType == EEventPointerExit)
   480 		{
   481 		*ptrEvent.Int() = aPointerNumber;
   482 		}
   483 	if (aType == EEventPointerBufferReady)
   484 		{
   485 		ptrEvent.SetHandle(aHandle);
   486 		}
   487 	static_cast<CTMultiPtrEventBuffer*>(iEventHandler)->AddExpectedEvent(ptrEvent);
   488 	}
   489 
   490 void CTMultiPtrEventClient::AddExpectedMovePoint(TPoint aPos)
   491 	{
   492 	static_cast<CTMultiPtrEventBuffer*>(iEventHandler)->AddExpectedMovePtEvent(aPos);
   493 	}
   494 
   495 // Create and store CTMultiPtrEventBuffer in iEventHandler
   496 void CTMultiPtrEventClient::ConstructEventHandlerL()
   497 	{
   498 	CTMultiPtrEventBuffer* eventBufferAndHandler = new(ELeave) CTMultiPtrEventBuffer(&iWs, iTest, this);
   499 	eventBufferAndHandler->ConstructL();
   500 	iEventHandler = eventBufferAndHandler;
   501 	}
   502 
   503 // Create groupwindow and blank window for AutoFocus tests
   504 void CTMultiPtrEventClient::ConstructGroupBlankWinL()
   505 	{
   506 	iWinPosAutoFocus1 = TPoint(10,10);
   507 	iWinSizeAutoFocus1 = TSize(40,40);
   508 	
   509 	iWinPosAutoFocus2 = TPoint(50,50);
   510 	iWinSizeAutoFocus2 = TSize(80,80);
   511 	
   512 	iGroupWinAutoFocus1 = new(ELeave) CTWindowGroup(this);
   513 	iGroupWinAutoFocus1->ConstructL();
   514 	iGroupWinAutoFocus1->GroupWin()->AutoForeground(ETrue);
   515 	iGroupWinAutoFocus1->GroupWin()->EnableFocusChangeEvents();
   516 	
   517 	iGroupWinAutoFocus2 = new(ELeave) CTWindowGroup(this);
   518 	iGroupWinAutoFocus2->ConstructL();
   519 	iGroupWinAutoFocus2->GroupWin()->AutoForeground(ETrue);
   520 	iGroupWinAutoFocus2->GroupWin()->EnableFocusChangeEvents();
   521 	
   522 	iWinAutoFocus1=new(ELeave) CTBlankWindow();
   523 	iWinAutoFocus1->ConstructL(*iGroupWinAutoFocus1);
   524 	iWinAutoFocus1->SetExt(iWinPosAutoFocus1, iWinSizeAutoFocus1);
   525 	iWinAutoFocus1->SetColor(KRgbDarkYellow);
   526 	iWinAutoFocus1->BaseWin()->EnableAdvancedPointers();
   527 	iWinAutoFocus1->Activate();
   528 	
   529 	iWinAutoFocus2=new(ELeave) CTBlankWindow();
   530 	iWinAutoFocus2->ConstructL(*iGroupWinAutoFocus2);
   531 	iWinAutoFocus2->SetExt(iWinPosAutoFocus2, iWinSizeAutoFocus2);
   532 	iWinAutoFocus2->SetColor(KRgbDarkCyan);
   533 	iWinAutoFocus2->BaseWin()->EnableAdvancedPointers();
   534 	iWinAutoFocus2->Activate();
   535 	}
   536 
   537 void CTMultiPtrEventClient::DeleteGroupBlankWin()
   538 	{
   539 	delete iWinAutoFocus2;
   540 	iWinAutoFocus2 = NULL;
   541 	delete iGroupWinAutoFocus2;
   542 	iGroupWinAutoFocus2 = NULL;
   543 	delete iWinAutoFocus1;
   544 	iWinAutoFocus1 = NULL;
   545 	delete iGroupWinAutoFocus1;
   546 	iGroupWinAutoFocus1 = NULL;
   547 	}
   548 
   549 TBool CTMultiPtrEventClient::CheckOrdinalPosition(TInt aAutoFocusWin)
   550 	{
   551 	if (aAutoFocusWin == 1)
   552 		{
   553 		return iWinAutoFocus1->BaseWin()->OrdinalPosition() == 0;
   554 		}
   555 	else
   556 		{
   557 		return iWinAutoFocus2->BaseWin()->OrdinalPosition() == 0;
   558 		}
   559 	}
   560 
   561 //CTMultiPtrEventTest
   562 CTMultiPtrEventTest::CTMultiPtrEventTest(CTestStep* aStep)
   563 	: CTWsGraphicsBase(aStep)
   564 	{
   565 	}
   566 
   567 CTMultiPtrEventTest::~CTMultiPtrEventTest()
   568 	{
   569 	((CTMultiPtrEventTestStep*)iStep)->CloseTMSGraphicsStep();
   570 	delete iMultiPtrEventClient;
   571 	DestroyAnimDllAndAnim();	
   572 	if (iPtrPluginLoaded)
   573 		{
   574 		iClick.Unload();
   575 		}
   576 	iClick.Close();
   577 	if (iHeap)
   578 		{
   579 		iHeap->Close();
   580 		iChunk.Close();
   581 		}
   582 	DeleteGroupWin();
   583 	}
   584 
   585 void CTMultiPtrEventTest::ConstructL()
   586 	{
   587 	// Here check if the HAL configuration are correct if not then finish the test case
   588 	TInt ret = HAL::Get(HALData::EPointerMaxPointers, iMaxDevPointers);
   589 	if (ret != KErrNone || iMaxDevPointers < 2 || iMaxDevPointers > 8)
   590 		{
   591 		TLogMessageText logText1;
   592 		_LIT(KWrongHALConfig, "HAL configuration are incorrect. \n");
   593 		logText1.Append(KWrongHALConfig);
   594 		LOG_MESSAGE(logText1);
   595 		TEST(EFalse);
   596 		User::Leave(ret);
   597 		}
   598 	
   599 	// Get the data by using HAL api
   600   	User::LeaveIfError(HAL::Get(HALData::EPointerMaxPointers,iMaxDevPointers));
   601   	User::LeaveIfError(HAL::Get(HALData::EPointerNumberOfPointers,iMaxUiPointers));
   602   	User::LeaveIfError(HAL::Get(HALData::EPointer3DMaxPressure, iMaxPressure));
   603   	User::LeaveIfError(HAL::Get(HALData::EPointer3DPressureStep, iPressureStep));
   604   	User::LeaveIfError(HAL::Get(HALData::EPointer3DMaxProximity, iMaxProximity));
   605   	User::LeaveIfError(HAL::Get(HALData::EPointer3DProximityStep, iProximityStep));
   606 	
   607     _LIT(KWsIniFile, "z:\\system\\data\\wsini.ini");
   608     CIniData* iniData = CIniData::NewL(KWsIniFile, ' ');
   609     _LIT( KWsiniYShifting, "YSHIFTING");
   610     iniData->FindVar(KWsiniYShifting, iYOffset);
   611     delete iniData;
   612 	TheClient->iScreen->SetAppScreenMode(0);
   613 	TheClient->iScreen->SetScreenMode(0);
   614 	iPhysicalScreenSize = TheClient->iScreen->SizeInPixels();
   615 	
   616 	TheGc->Activate(*BaseWin->Win());
   617 	TheGc->SetBrushColor(TRgb::Gray16(12));
   618 	TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   619 	TheGc->SetPenStyle(CGraphicsContext::ENullPen);
   620 	TheGc->DrawRect(TRect(BaseWin->Win()->Size()));
   621 	TheGc->Deactivate();
   622 	
   623 	TheGc->Activate(*TestWin->Win());
   624 	TheGc->SetBrushColor(TRgb::Gray16(4));
   625 	TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   626 	TheGc->SetPenStyle(CGraphicsContext::ENullPen);
   627 	TheGc->DrawRect(TRect(TestWin->Win()->Size()));
   628 	TheGc->Deactivate();
   629 	
   630 	TheClient->iWs.Flush();
   631 	}
   632 
   633 // Create raw event setting type, X, Y, Z and pointernumber for rawevent
   634 // use UserSvr for simulating the event
   635 void CTMultiPtrEventTest::SimulatePointerEvent(TRawEvent::TType aType, TInt aX, TInt aY, TUint8 aPointerNumber)
   636 	{
   637 	TRawEvent rawEvent;
   638 	rawEvent.Set(aType, aX, aY+iYOffset, aPointerNumber);
   639 	UserSvr::AddEvent(rawEvent);
   640 	}
   641 
   642 void CTMultiPtrEventTest::SimulatePointerEvent(TRawEvent::TType aType, TInt aX, TInt aY, TInt aZ, TUint8 aPointerNumber)
   643 	{
   644 	TRawEvent rawEvent;
   645 	rawEvent.Set(aType, aX, aY+iYOffset, aZ, aPointerNumber);
   646 	UserSvr::AddEvent(rawEvent);
   647 	}
   648 
   649 // Simulate multipointer down and up event
   650 void CTMultiPtrEventTest::SimulatePointerDownUp(TInt aX, TInt aY, TInt aZ, TUint8 aPointerNumber)
   651 	{
   652 	SimulatePointerEvent(TRawEvent::EButton1Down, aX, aY, aZ, aPointerNumber);
   653 	SimulatePointerEvent(TRawEvent::EButton1Up, aX, aY, aZ, aPointerNumber);
   654 	}
   655 
   656 void CTMultiPtrEventTest::AddExpectedKey(TInt aEventCode, TInt aScanCode, TInt aCode/*=0*/, TInt aRepeats/*=0*/, TUint aModifiers/*=0*/)
   657 	{
   658 	TPckgBuf<TWsEvent> evtPkg;
   659 	TWsEvent& event=evtPkg();
   660 	if (aEventCode==EEventKey && aCode==0)
   661 		aCode=aScanCode;
   662 	event.SetType(aEventCode);
   663 	event.SetHandle((TUint)iMultiPtrEventClient->iGroup);
   664 	event.Key()->iCode=aCode;
   665 	event.Key()->iScanCode=aScanCode;
   666 	event.Key()->iModifiers=aModifiers;
   667 	event.Key()->iRepeats=aRepeats;
   668 	iMultiPtrEventClient->EventBuffer()->AddExpectedEvent(event);
   669 	}
   670 
   671 void CTMultiPtrEventTest::AddExpectedKeyDownUp(TInt aScanCode, TInt aCode/*=0*/, TInt aRepeats/*=0*/, TUint aModifiers/*=0*/)
   672 	{
   673 	__ASSERT_DEBUG(aScanCode<'a' || aScanCode>'z',AutoPanic(EAutoPanicScanCapital));
   674 	AddExpectedKey(EEventKeyDown,aScanCode,0,aRepeats,aModifiers);
   675 	AddExpectedKey(EEventKey,aScanCode,aCode,aRepeats,aModifiers);
   676 	AddExpectedKey(EEventKeyUp,aScanCode,0,aRepeats,aModifiers);
   677 	}
   678 
   679 void CTMultiPtrEventTest::AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TUint8 aPointerNumber, TUint aHandle)
   680 	{
   681 	AddExpectedPointerEvent(aType, aPos, 0, 0, aPointerNumber, aHandle);
   682 	}
   683 
   684 void CTMultiPtrEventTest::AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle, TBool aSecondaryClient)
   685 	{
   686 	if (aSecondaryClient)
   687 		{
   688 		iSecMultiPtrEventClient->AddExpectedPointerEvent(aType, aPos, aZ, aModifier, aPointerNumber, aHandle);
   689 		}
   690 	else
   691 		{
   692 		iMultiPtrEventClient->AddExpectedPointerEvent(aType, aPos, aZ, aModifier, aPointerNumber, aHandle);
   693 		}
   694 	}
   695 
   696 void CTMultiPtrEventTest::SetExpectNonAdvancedPointerEvents(TBool aSecondaryClient)
   697 	{
   698 	if (aSecondaryClient)
   699 		{
   700 		iSecMultiPtrEventClient->SetExpectNonAdvancedPointerEvents();
   701 		}
   702 	else
   703 		{
   704 		iMultiPtrEventClient->SetExpectNonAdvancedPointerEvents();
   705 		}
   706 	}
   707 
   708 void CTMultiPtrEventTest::ClearExpectNonAdvancedPointerEvents(TBool aSecondaryClient)
   709 	{
   710 	if (aSecondaryClient)
   711 		{
   712 		iSecMultiPtrEventClient->ClearExpectNonAdvancedPointerEvents();
   713 		}
   714 	else
   715 		{
   716 		iMultiPtrEventClient->ClearExpectNonAdvancedPointerEvents();
   717 		}
   718 	}
   719 
   720 void CTMultiPtrEventTest::AddExpectedPointerDownUp(TPoint aPos, TInt aZ, TUint8 aPointerNumber)
   721 	{
   722 	AddExpectedPointerEvent(TPointerEvent::EButton1Down, aPos, aZ, 0, aPointerNumber);
   723 	AddExpectedPointerEvent(TPointerEvent::EButton1Up, aPos, aZ, 0, aPointerNumber);
   724 	}
   725 
   726 void CTMultiPtrEventTest::AddExpectedWsEvent(TEventCode aType, TBool aSecondaryClient, TInt aPointerNumber, TUint aHandle)
   727 	{
   728 	if (aSecondaryClient)
   729 		{
   730 		iSecMultiPtrEventClient->AddExpectedWsEvent(aType);
   731 		}
   732 	else
   733 		{
   734 		iMultiPtrEventClient->AddExpectedWsEvent(aType, aPointerNumber, aHandle);
   735 		}
   736 	}
   737 
   738 void CTMultiPtrEventTest::TestDragForMultiPointer(TPoint aPtrPos, TInt aPrValue, TUint8 aPointerNumber)
   739 	{
   740 	SimulatePointerEvent(TRawEvent::EButton1Down, aPtrPos.iX, aPtrPos.iY, aPrValue, aPointerNumber);
   741 	SimulatePointerEvent(TRawEvent::EPointerMove, aPtrPos.iX+2, aPtrPos.iY+1, aPrValue, aPointerNumber);
   742 	SimulatePointerEvent(TRawEvent::EButton1Up, aPtrPos.iX+2, aPtrPos.iY+1, 0, aPointerNumber);
   743 	AddExpectedPointerEvent(TPointerEvent::EButton1Down, aPtrPos, aPrValue, 0, aPointerNumber);
   744 	aPtrPos.iX += 2; aPtrPos.iY += 1;
   745 	AddExpectedPointerEvent(TPointerEvent::EDrag, aPtrPos, aPrValue, 0, aPointerNumber);
   746 	AddExpectedPointerEvent(TPointerEvent::EButton1Up, aPtrPos, 0, 0, aPointerNumber);
   747 	}
   748 
   749 void CTMultiPtrEventTest::SimulateAndAddLoneUpEvents(TInt aNumSimulation, TInt aNumAddition, TPoint aPos)
   750 	{
   751 	for (TInt count = 0; count < aNumSimulation; count++)
   752 		{
   753 		SimulatePointerEvent(TRawEvent::EButton1Up, aPos.iX, aPos.iY, 0, 0);
   754 		}
   755 	for (TInt count = 0; count < aNumAddition; count++)
   756 		{
   757 		AddExpectedPointerEvent(TPointerEvent::EButton1Up, aPos, 0, 0, 0);
   758 		}
   759 	}
   760 
   761 void CTMultiPtrEventTest::TestFilteringForMultiPointer(TBool aFiltering)
   762 	{
   763 	TPoint ptrPos;
   764 	TInt ptrNum;
   765 	TInt xInc = iPhysicalScreenSize.iWidth/iMaxDevPointers;
   766 	TInt yInc = iPhysicalScreenSize.iHeight/iMaxDevPointers;
   767 	
   768 	for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
   769 		{
   770 		SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, ptrNum);
   771 		SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum);
   772 		if(!aFiltering)
   773 			{
   774 			AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, ptrNum);
   775 			}
   776 		AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, ptrNum);
   777 		ptrPos.iX += xInc/2;
   778 		ptrPos.iY += yInc/2;
   779 		}
   780 	
   781 	ptrPos.SetXY(0,0);
   782 	TPoint interPt = ptrPos;
   783 	for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
   784 		{
   785 		SimulatePointerEvent(TRawEvent::EPointerMove, interPt.iX+2, interPt.iY+1, 0, ptrNum);
   786 		SimulatePointerEvent(TRawEvent::EPointerMove, interPt.iX+4, interPt.iY+2, 0, ptrNum);
   787 		SimulatePointerEvent(TRawEvent::EPointerMove, interPt.iX+6, interPt.iY+3, 0, ptrNum);
   788 		if(!aFiltering)
   789 			{
   790 			interPt.iX += 6; interPt.iY += 3;
   791 			AddExpectedPointerEvent(TPointerEvent::EDrag, interPt, ptrNum);
   792 			}
   793 		ptrPos.iX += xInc/2;
   794 		ptrPos.iY += yInc/2;
   795 		interPt = ptrPos; 
   796 		}
   797 
   798 	ptrPos.SetXY(0,0);
   799 	interPt = ptrPos;
   800 	for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
   801 		{
   802 		interPt.iX += 6;
   803 		interPt.iY += 3;
   804 		SimulatePointerEvent(TRawEvent::EButton1Up, interPt.iX, interPt.iY, 0, ptrNum);
   805 		AddExpectedPointerEvent(TPointerEvent::EButton1Up, interPt, ptrNum);
   806 		ptrPos.iX += xInc/2;
   807 		ptrPos.iY += yInc/2;
   808 		interPt = ptrPos; 
   809 		}
   810 	}
   811 
   812 void CTMultiPtrEventTest::TestGrabbingForMultiPointer(TBool aGrabbing)
   813 	{
   814 	TPoint ptrPos;
   815 	TInt ptrNum;
   816 	TInt xInc = iPhysicalScreenSize.iWidth/iMaxDevPointers;
   817 	TInt yInc = iPhysicalScreenSize.iHeight/iMaxDevPointers;
   818 	
   819 	for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
   820 		{
   821 		SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum);
   822 		AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, ptrNum);
   823 		ptrPos.iX += xInc/3;	// Ensure all Button1Down events are on iParentWin
   824 		ptrPos.iY += yInc/3;
   825 		}
   826 	
   827 	ptrPos.SetXY(0,0);
   828 	ptrPos.iX += iPhysicalScreenSize.iWidth/2;		// Ensure all Drag and Button1Up events are on iChildWin
   829 	ptrPos.iY += iPhysicalScreenSize.iHeight/2;
   830 	for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
   831 		{
   832 		SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, ptrNum);
   833 		if(aGrabbing)
   834 			{
   835 			// CalculatePtrPosAndSet3Ddata will subtract iChildWinPos from ptrPos if pointer event occured on child window. Thus we add iChildWinPos here.
   836 			AddExpectedPointerEvent(TPointerEvent::EDrag, ptrPos+iMultiPtrEventClient->ChildWin()->Position(), ptrNum, (TUint)iMultiPtrEventClient->ParentWin());	
   837 			}
   838 		else
   839 			{
   840 			AddExpectedPointerEvent(TPointerEvent::EDrag, ptrPos, ptrNum);
   841 			}
   842 		ptrPos.iX += xInc/3;
   843 		ptrPos.iY += yInc/3; 
   844 		}
   845 
   846 	ptrPos.SetXY(0,0);
   847 	ptrPos.iX += iPhysicalScreenSize.iWidth/2;
   848 	ptrPos.iY += iPhysicalScreenSize.iHeight/2;
   849 	for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
   850 		{
   851 		SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum);
   852 		if(aGrabbing)
   853 			{
   854 			AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos+iMultiPtrEventClient->ChildWin()->Position(), ptrNum, (TUint)iMultiPtrEventClient->ParentWin());
   855 			}
   856 		else
   857 			{
   858 			AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, ptrNum);
   859 			}
   860 		ptrPos.iX += xInc/3;
   861 		ptrPos.iY += yInc/3;
   862 		}
   863 	}
   864 
   865 void CTMultiPtrEventTest::TestCapturingForMultiPointer(TBool aAllWinGroups)
   866 	{
   867 	TPoint ptrPos;
   868 	TInt ptrNum = 0;
   869 	TInt xInc = iPhysicalScreenSize.iWidth/iMaxDevPointers;
   870 	TInt yInc = iPhysicalScreenSize.iHeight/iMaxDevPointers;
   871 	
   872 	// These are some typical values which are used only for testing purposes.
   873 	// 20mm to screen
   874 	// 50mm to screen
   875 	// 4N of pressure
   876 	// 2N of pressure
   877 	SetThresholdValues(-20,-50,4000,2000);
   878 	
   879 	iMultiPtrEventClient->ChildWin()->BaseWin()->PointerFilter(EPointerMoveEvents, 0);
   880 	
   881 	if(!aAllWinGroups)
   882 		{
   883 		for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
   884 			{
   885 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, -30, ptrNum);
   886 			AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos-iMultiPtrEventClient->ChildWin()->Position(), -30, 0, ptrNum, (TInt)iMultiPtrEventClient->ChildWin());
   887 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, -10, ptrNum);
   888 			AddExpectedPointerEvent(TPointerEvent::EEnterCloseProximity, ptrPos-iMultiPtrEventClient->ChildWin()->Position(), -10, 0, ptrNum, (TInt)iMultiPtrEventClient->ChildWin());
   889 			SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum);
   890 			AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos-iMultiPtrEventClient->ChildWin()->Position(), 0, 0, ptrNum, (TInt)iMultiPtrEventClient->ChildWin());
   891 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX+=2, ptrPos.iY+=2, 5000, ptrNum);
   892 			AddExpectedPointerEvent(TPointerEvent::EEnterHighPressure, ptrPos-iMultiPtrEventClient->ChildWin()->Position(), 5000, 0, ptrNum, (TInt)iMultiPtrEventClient->ChildWin());
   893 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX-=2, ptrPos.iY-=2, 1000, ptrNum);
   894 			AddExpectedPointerEvent(TPointerEvent::EExitHighPressure, ptrPos-iMultiPtrEventClient->ChildWin()->Position(), 1000, 0, ptrNum, (TInt)iMultiPtrEventClient->ChildWin());
   895 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX+=2, ptrPos.iY+=2, 1000, ptrNum);
   896 			AddExpectedPointerEvent(TPointerEvent::EDrag, ptrPos-iMultiPtrEventClient->ChildWin()->Position(), 1000, 0, ptrNum, (TInt)iMultiPtrEventClient->ChildWin());
   897 			SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum);
   898 			AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos-iMultiPtrEventClient->ChildWin()->Position(), 0, 0, ptrNum, (TInt)iMultiPtrEventClient->ChildWin());
   899 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX-=2, ptrPos.iY-=2, -60, ptrNum);
   900 			AddExpectedPointerEvent(TPointerEvent::EExitCloseProximity, ptrPos-iMultiPtrEventClient->ChildWin()->Position(), -60, 0, ptrNum, (TInt)iMultiPtrEventClient->ChildWin());
   901 			ptrPos.iX += xInc/3;	// Ensure all Pointer events are on iParentWin
   902 			ptrPos.iY += yInc/3;
   903 			}		
   904 		}
   905 	else
   906 		{
   907 		ptrPos.iX = iPhysicalScreenSize.iWidth/2 + xInc/3;
   908 		ptrPos.iY = 0;
   909 		 		
   910 		for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
   911 			{
   912 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, -10, ptrNum);
   913 			AddExpectedPointerEvent(TPointerEvent::EEnterCloseProximity, TPoint(ptrPos.iX+iPhysicalScreenSize.iWidth/2, ptrPos.iY), -10, 0, ptrNum, (TInt)iWinForCapturing);
   914 			SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum);
   915 			AddExpectedPointerEvent(TPointerEvent::EButton1Down, TPoint(ptrPos.iX+iPhysicalScreenSize.iWidth/2, ptrPos.iY), 0, 0, ptrNum, (TInt)iWinForCapturing);		
   916 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX+=2, ptrPos.iY+=2, 5000, ptrNum);
   917 			AddExpectedPointerEvent(TPointerEvent::EEnterHighPressure, TPoint(ptrPos.iX+iPhysicalScreenSize.iWidth/2, ptrPos.iY), 5000, 0, ptrNum, (TInt)iWinForCapturing);			
   918 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX-=2, ptrPos.iY-=2, 1000, ptrNum);
   919 			AddExpectedPointerEvent(TPointerEvent::EExitHighPressure, TPoint(ptrPos.iX+iPhysicalScreenSize.iWidth/2, ptrPos.iY), 1000, 0, ptrNum, (TInt)iWinForCapturing);
   920 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX+=2, ptrPos.iY+=2, 1000, ptrNum);
   921 			AddExpectedPointerEvent(TPointerEvent::EDrag, TPoint(ptrPos.iX+iPhysicalScreenSize.iWidth/2, ptrPos.iY), 1000, 0, ptrNum, (TInt)iWinForCapturing);
   922 			SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum);
   923 			AddExpectedPointerEvent(TPointerEvent::EButton1Up, TPoint(ptrPos.iX+iPhysicalScreenSize.iWidth/2, ptrPos.iY), 0, 0, ptrNum, (TInt)iWinForCapturing);
   924 			SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum);
   925 			AddExpectedPointerEvent(TPointerEvent::EOutOfRange, TPoint(ptrPos.iX+iPhysicalScreenSize.iWidth/2, ptrPos.iY), 0, 0, ptrNum, (TInt)iWinForCapturing);
   926 			ptrPos.iX += xInc/3;	
   927 			ptrPos.iY += yInc/3;
   928 			}
   929 		}
   930 	}
   931 
   932 void CTMultiPtrEventTest::SetAutoFlush()
   933 	{
   934 	iTheClientFlush = TheClient->iWs.SetAutoFlush(ETrue);
   935 	iClientFlush = iMultiPtrEventClient->iWs.SetAutoFlush(ETrue);
   936 	}
   937 
   938 void CTMultiPtrEventTest::ResetFlushStopAS()
   939 	{
   940 	if (iActiveSchedulerStarted)
   941 		{
   942 		iActiveSchedulerStarted = EFalse;
   943 		CActiveScheduler::Stop();
   944 		}
   945 	TheClient->iWs.SetAutoFlush(iTheClientFlush);
   946 	iMultiPtrEventClient->iWs.SetAutoFlush(iClientFlush);
   947 	}
   948 
   949 // Common function for all test cases
   950 void CTMultiPtrEventTest::RunTestsL()
   951 	{
   952 	// Create CTMultiPtrEventClient for each test case and call NextSetOfEventsL()
   953 	iMultiPtrEventClient = new(ELeave) CTMultiPtrEventClient(this);
   954 	iMultiPtrEventClient->SetScreenNumber(iTest->iScreenNumber);
   955 	iMultiPtrEventClient->ConstructL();
   956 	
   957 	iEventSet=0;
   958 
   959 	// Create secondary client for test case number 3
   960 	if (iTest->iState == 3)
   961 		{
   962 		iSecMultiPtrEventClient = new(ELeave) CTMultiPtrEventClient(this, 1);
   963 		iSecMultiPtrEventClient->SetScreenNumber(iTest->iScreenNumber);
   964 		iSecMultiPtrEventClient->ConstructL(); 
   965 		}
   966 	
   967 	TRAPD(err, NextSetOfEventsL());
   968 	if (err != KErrNone)
   969 		{
   970 		iFailed = ETrue;
   971 		}
   972 
   973 	// Start nested activescheduler if it is not failed for the first attempt
   974 	if (!iFailed)
   975 		{
   976 		iActiveSchedulerStarted = ETrue;
   977 		CActiveScheduler::Start();
   978 		}
   979 
   980 	//
   981 	TInt eventsRem = iMultiPtrEventClient->EventBuffer()->EventsRemaining();
   982 	if (eventsRem > 0)
   983 		{
   984 		iFailed=ETrue;
   985 		}
   986 
   987 	// Delete secondary client for test case number 3
   988 	if (iTest->iState == 3)
   989 		{
   990 		delete iSecMultiPtrEventClient;
   991 		iSecMultiPtrEventClient = NULL;
   992 		}
   993 	
   994 	delete iMultiPtrEventClient;
   995 	iMultiPtrEventClient = NULL;
   996 	}
   997 
   998 // Common function for all tests
   999 // Important point to remember is that this function should not leave when running tests
  1000 void CTMultiPtrEventTest::NextSetOfEventsL()
  1001 	{
  1002 	// For each test case calls its respective tests
  1003 		
  1004 	((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
  1005 	switch (iTest->iState)
  1006 		{
  1007 	case 0:
  1008 /**
  1009 @SYMTestCaseID			GRAPHICS-WSERV-ADVANCEDPOINTER-0036
  1010 */
  1011 		((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0036"));
  1012 		MultiPointerEvents();
  1013 		break;
  1014 	case 1:
  1015 		((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0014"));
  1016 		PurgingMultiPointerEvents();
  1017 		break;
  1018 	case 2:
  1019 		((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0013"));
  1020 		MultiPointerEventsForAnimsL();
  1021 		break;
  1022 	case 3:
  1023 		((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0011"));
  1024 		GetRemainingEventsFromSecondaryClient();	// Does nothing for first time
  1025 		MultiClientMultiPointerEvents();
  1026 		break;
  1027 	case 4:
  1028 		((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0027"));
  1029 		MultiPointerEventsForPointerClickL();
  1030 		break;
  1031 	case 5:
  1032 		((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0028"));
  1033 		MultiPointerEventsInDiffScreenModes();
  1034 		break;
  1035 	case 6:
  1036 		((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0025"));
  1037 		FilteringMultiPointerEvents();
  1038 		break;
  1039 	case 7:
  1040 		((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0021"));
  1041 		GrabbingMultiPointerEvents();
  1042 		break;
  1043 	case 8:
  1044 		((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0031"));
  1045 		VirtualKeyBoardForMultiplePointers();
  1046 		break;
  1047 	case 9:
  1048 		((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0032"));
  1049 		DoubleClickForMultiplePointers();
  1050 		break;
  1051 	case 10:
  1052 		((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0015"));
  1053 		MultiPointerOutOfRangeEvents();
  1054 		break;
  1055 	case 11:
  1056 		((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0026"));
  1057 		AutoForeGroundForMultiplePointersL();
  1058 		break;
  1059 	case 12:
  1060 		((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0029"));
  1061 		EmulationRulesForMultiplePointers();
  1062 		break;
  1063 	case 13:
  1064 		((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0034"));
  1065 		CloseProximityAndHighPressureEventsL();
  1066 		break;
  1067 	case 14:
  1068 		((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0017"));
  1069 		OutOfBoundValueTesting();
  1070 		break;	
  1071 	case 15:
  1072 		((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0019"));
  1073 		CapturingMultiPointerEvents();
  1074 		break;
  1075 	case 16:
  1076 		((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0035"));
  1077 		NegativeTestsForProximityPressureEventsL();
  1078 		break;
  1079 	case 17:
  1080 		((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-ADVANCEDPOINTER-0034"));
  1081 		PointerRepeatEventForMultiplePointers();
  1082 		break;
  1083 	// Any new test case should be added here.
  1084 	// because some of the above tests use testcase number for certain checks
  1085 	default:
  1086 		((CTMultiPtrEventTestStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
  1087 		AutoPanic(EAutoPanicWrongTest);
  1088 		}
  1089 	((CTMultiPtrEventTestStep*)iStep)->RecordTestResultL();
  1090 	}
  1091 
  1092 /**
  1093 @SYMTestCaseID			GRAPHICS-WSERV-ADVANCEDPOINTER-0033
  1094 @SYMPREQ				PREQ1226
  1095 @SYMREQ					REQ9677
  1096 @SYMTestPriority		High
  1097 @SYMTestCaseDesc		To check Wserv sends Pointer Repeat Events for all pointers. 
  1098 @SYMTestStatus			Implemented
  1099 
  1100 @SYMTestActions			Simulate events being passed to the client by implementing each discrete test 
  1101 						over 4 seperate test cases. 
  1102 						In the first test case simulate EButton1Down and add event to a TWsEvent buffer. 
  1103 						In the second test case call RequestPointerRepeatEvent on the base window passing 
  1104 						in a time interval,	a rectangle (the 'hitbox') and pointer number. 
  1105 						Add EButtonRepeat to TWsEvent buffer.  
  1106 						In the third test case simulate EPointerMove event within the hitbox, then simulate 
  1107 						an elapsed period of time longer that specified interval. Add only a EButtonRepeat
  1108 						to TWsEvent buffer.
  1109 						In the final test case simulate EButton1Up and add event to TWsEvent buffer.
  1110 						
  1111 						Repeat steps for the second discrete test, however, in the third test case simulate 
  1112 						EPointerMove event outside the hitbox. In addition add EDrag to TWsEvent buffer 
  1113 						instead of EButtonRepeat. 
  1114 						
  1115 						A third discrete test will be executed over two test cases and will test
  1116 						CancelPointerRepeatEventRequest API.
  1117 						
  1118 @SYMTestExpectedResults The received events must match the events added to the buffer except where EPointerMove
  1119  						events should be filtered out. In addition, EButtonRepeat will be generated by wserv
  1120  						after calling RequestPointerRepeatEvent and time interval specified has elapsed.
  1121 						
  1122 */
  1123 void CTMultiPtrEventTest::PointerRepeatEventForMultiplePointers()
  1124 	{
  1125 	// Test PointerRepeatEvent for Multiple Pointers 
  1126 	TLogMessageText logText;
  1127 	_LIT(KSet, "PointerRepeatEventForMultiplePointers SetOfEvents: %d of 10");
  1128 	logText.AppendFormat(KSet, iEventSet);
  1129 	LOG_MESSAGE(logText);
  1130 	
  1131 	if (!iEventSet)
  1132 		{
  1133 		SetAutoFlush();
  1134 		AddExpectedWsEvent(EEventFocusGained);
  1135 		}
  1136 	iMultiPtrEventClient->EventBuffer()->SetEventCount(0);
  1137 	
  1138 	TPoint ptrPos;
  1139 	TInt ptrNum;
  1140 	// Ensure all pointers are on iParentWin
  1141 	TInt xInc = iPhysicalScreenSize.iWidth/iMaxDevPointers/3;
  1142 	TInt yInc = iPhysicalScreenSize.iHeight/iMaxDevPointers/3;
  1143 		
  1144 	switch(iEventSet++)
  1145 		{
  1146 		// Test cases 0 - 3 represent first discrete test for PointerRepeatEvents
  1147 		case 0:
  1148 			// Simulate EButton1Down events only. This is in order to simulate the event being passed to the client. 
  1149 			// If the event remained in the window queue the PointerRepeatEvent request would be cancelled when PointerRepeatPurgeCheck is performed.
  1150 			INFO_PRINTF1(_L("Simulate EButton1Down event for all pointers."));
  1151 			for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
  1152 				{
  1153 				SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum);			
  1154 				AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, ptrNum);
  1155 				ptrPos.iX+=xInc;
  1156 				ptrPos.iY+=yInc;
  1157 				}	
  1158 			break;
  1159 		case 1:
  1160 			// Simulate client calling RequestPointerRepeatEvent in response to EButton1Down event being within a 'hitbox'.
  1161 			INFO_PRINTF1(_L("Simulate PointerRepeatEvent request for all pointers."));
  1162 			ptrPos.SetXY(0,0);
  1163 			for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
  1164 				{
  1165 				iMultiPtrEventClient->ParentWin()->BaseWin()->RequestPointerRepeatEvent(TTimeIntervalMicroSeconds32(100000),TRect(TPoint(0,0), TSize(iPhysicalScreenSize.iWidth/2,iPhysicalScreenSize.iHeight)),ptrNum);				
  1166 				User::After(200000);	
  1167 				AddExpectedPointerEvent(TPointerEvent::EButtonRepeat, ptrPos, ptrNum);			
  1168 				ptrPos.iX+=xInc;
  1169 				ptrPos.iY+=yInc;
  1170 				}
  1171 			break;
  1172 		case 2:
  1173 			// Simulate client calling RequestPointerRepeatEvent in response to EButtonRepeat and pointer remaining within the 'hitbox'.
  1174 			INFO_PRINTF1(_L("Simulate additional PointerRepeatEvent request for all pointers."));
  1175 			// New coordinates will be used for a simulated EPointerMove. This event will be filtered out, however, EButtonRepeat will occur at new coordinates
  1176 			ptrPos.iX = xInc;
  1177 			ptrPos.iY = yInc;
  1178 			for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
  1179 				{
  1180 				iMultiPtrEventClient->ParentWin()->BaseWin()->RequestPointerRepeatEvent(TTimeIntervalMicroSeconds32(100000),TRect(TPoint(0,0), TSize(iPhysicalScreenSize.iWidth/2,iPhysicalScreenSize.iHeight)),ptrNum);				
  1181 				// EPointerMove event is filtered out by TWsPointer::PointerRepeatPurgeCheck
  1182 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, ptrNum);
  1183 				User::After(200000);
  1184 				AddExpectedPointerEvent(TPointerEvent::EButtonRepeat, ptrPos, ptrNum);
  1185 				ptrPos.iX+=xInc;
  1186 				ptrPos.iY+=yInc;
  1187 				}
  1188 			break;		
  1189 		case 3:
  1190 			INFO_PRINTF1(_L("Simulate EButton1Up for all pointers."));
  1191 			ptrPos.iX = xInc;
  1192 			ptrPos.iY = yInc;
  1193 			for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
  1194 				{
  1195 				SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum);
  1196 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, ptrNum);
  1197 				ptrPos.iX+=xInc;
  1198 				ptrPos.iY+=yInc;
  1199 				}
  1200 			break; 			
  1201 		// Test cases 4 - 7 represent second second discrete test for PointerRepeatEvents	
  1202 		case 4:
  1203 			// Simulate EButton1Down events only. This is in order to simulate the event being passed to the client. 
  1204 			// If the event remained in the window queue the PointerRepeatEvent request would be cancelled when PointerRepeatPurgeCheck is performed.
  1205 			INFO_PRINTF1(_L("Simulate EButton1Down event for all pointers.")); 
  1206 			ptrPos.SetXY(0,0);
  1207 			for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
  1208 				{
  1209 				SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum);			
  1210 				AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, ptrNum);
  1211 				ptrPos.iX+=xInc;
  1212 				ptrPos.iY+=yInc;
  1213 				}	
  1214 			break;
  1215 		case 5:
  1216 			// Simulate client calling RequestPointerRepeatEvent in response to EButton1Down event being within a 'hitbox'.
  1217 			INFO_PRINTF1(_L("Call RequestPointerRepeatEvent for all pointers."));
  1218 			ptrPos.SetXY(0,0);
  1219 			for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
  1220 				{
  1221 				iMultiPtrEventClient->ParentWin()->BaseWin()->RequestPointerRepeatEvent(TTimeIntervalMicroSeconds32(100000),TRect(TPoint(0,0), TSize(iPhysicalScreenSize.iWidth/3,iPhysicalScreenSize.iHeight)),ptrNum); // hitbox size reduced 				
  1222 				User::After(200000);	
  1223 				AddExpectedPointerEvent(TPointerEvent::EButtonRepeat, ptrPos, ptrNum);			
  1224 				ptrPos.iX+=xInc;
  1225 				ptrPos.iY+=yInc;
  1226 				}
  1227 			break;
  1228 		case 6:
  1229 			// Simulate client calling RequestPointerRepeatEvent in response to EButtonRepeat and event remaining within the 'hitbox' rect.
  1230 			// EPointerMove will take pointer out of the hitbox so should not be filtered. PointerRepeatEvent should be cancelled.
  1231 			INFO_PRINTF1(_L("Simulate a PointerMove event for all pointers to a coordinate outside the hitbox."));
  1232 			// New coordinates will be used for a simulated EPointerMove outisde the hitbox. 
  1233 			ptrPos.iX = iPhysicalScreenSize.iWidth/3 + xInc;
  1234 			ptrPos.iY = 0;
  1235 			for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
  1236 				{
  1237 				iMultiPtrEventClient->ParentWin()->BaseWin()->RequestPointerRepeatEvent(TTimeIntervalMicroSeconds32(100000),TRect(TPoint(0,0), TSize(iPhysicalScreenSize.iWidth/3,iPhysicalScreenSize.iHeight)),ptrNum);				
  1238 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, ptrNum);
  1239 				User::After(200000);
  1240 				AddExpectedPointerEvent(TPointerEvent::EDrag, ptrPos, ptrNum);
  1241 				}
  1242 			break;		
  1243 		case 7:
  1244 			INFO_PRINTF1(_L("Simulate EButton1Up for all pointers."));
  1245 			ptrNum = 0;
  1246 			ptrPos.iX = iPhysicalScreenSize.iWidth/3 + xInc;
  1247 			ptrPos.iY = 0;
  1248 			for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
  1249 				{
  1250 				SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum);
  1251 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, ptrNum);
  1252 				}
  1253 			break;
  1254 		// Test cases 8 and 9 represent third discrete test for PointerRepeatEvents
  1255 		case 8:
  1256 			// Simulate EButton1Down events only. This is in order to simulate the event being passed to the client. 
  1257 			// If the event remained in the window queue the PointerRepeatEvent request would be cancelled when PointerRepeatPurgeCheck is performed.
  1258 			INFO_PRINTF1(_L("Simulate EButton1Down event for all pointers.")); 
  1259 			ptrPos.SetXY(0,0);
  1260 			for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
  1261 				{
  1262 				SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum);			
  1263 				AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, ptrNum);
  1264 				ptrPos.iX+=xInc;
  1265 				ptrPos.iY+=yInc;
  1266 				}	
  1267 			break;	
  1268 		case 9:
  1269 			// No simulated events. This test case is to explicity call RWindowBase::CancelPointerRepeatEventRequest(const TUint8 aPointerNumber)
  1270 			INFO_PRINTF1(_L("Call RequestPointerRepeatEvent and CancelPointerRepeatEventRequest for all pointers."));
  1271 			ptrPos.SetXY(0,0);
  1272 			for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
  1273 				{
  1274 				iMultiPtrEventClient->ParentWin()->BaseWin()->RequestPointerRepeatEvent(TTimeIntervalMicroSeconds32(100000),TRect(TPoint(0,0), TSize(iPhysicalScreenSize.iWidth/3,iPhysicalScreenSize.iHeight)),ptrNum); 				
  1275 				iMultiPtrEventClient->ParentWin()->BaseWin()->CancelPointerRepeatEventRequest(ptrNum); 
  1276 				ptrPos.iX+=xInc;
  1277 				ptrPos.iY+=yInc;
  1278 				}
  1279 			INFO_PRINTF1(_L("Simulate EButton1Up for all pointers."));
  1280 			ptrPos.iX = xInc;
  1281 			ptrPos.iY = yInc;
  1282 			for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
  1283 				{
  1284 				SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum);
  1285 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, ptrNum);
  1286 				ptrPos.iX+=xInc;
  1287 				ptrPos.iY+=yInc;
  1288 				}
  1289 			break;	
  1290 		default:
  1291 			ResetFlushStopAS();
  1292 			break;
  1293 		}
  1294 	LogEventsAdded();
  1295 	}
  1296 
  1297 void CTMultiPtrEventTest::TestErrorCodeL(TInt aExpErrCode, TInt aActualErrCode)
  1298 	{
  1299 	if (aExpErrCode != aActualErrCode)
  1300 		{
  1301 		TLogMessageText logText;
  1302 		_LIT(KError, "Expected Error code = %d Actual Actual Error code %d");
  1303 		logText.AppendFormat(KError, aExpErrCode, aActualErrCode);
  1304 		LOG_MESSAGE(logText);
  1305 		User::Leave(ETestFailed);
  1306 		}
  1307 	}
  1308 
  1309 void CTMultiPtrEventTest::NegativeTestingOfProximityPressureAPIsL()
  1310 	{
  1311 	// First send -10 for EnterCloseProximity and -5 for ExitCLoseProximity, it should return KErrArgument
  1312 	// Then send 20 and 10 which should return KErrNone
  1313 	// Then sent 10 and 20 which should return KErrArgument
  1314 	TInt retVal;
  1315 	retVal = iMultiPtrEventClient->iWs.SetCloseProximityThresholds(-10, -5);
  1316 	TestErrorCodeL(KErrArgument, retVal);
  1317 	
  1318 	retVal = iMultiPtrEventClient->iWs.SetCloseProximityThresholds(20, 10);
  1319 	TestErrorCodeL(KErrNone, retVal);
  1320 	
  1321 	retVal = iMultiPtrEventClient->iWs.SetCloseProximityThresholds(10, 20);
  1322 	TestErrorCodeL(KErrArgument, retVal);
  1323 	
  1324 	// Repeat the above for EnterHighPressure and ExitHighPressure with these values
  1325 	// -10 and -5 it should return KErrArgument
  1326 	// -5 and -10 it should return KErrNone
  1327 	retVal = iMultiPtrEventClient->iWs.SetHighPressureThresholds(-10, -5);
  1328 	TestErrorCodeL(KErrArgument, retVal);
  1329 	
  1330 	retVal = iMultiPtrEventClient->iWs.SetHighPressureThresholds(-5, -10);
  1331 	TestErrorCodeL(KErrNone, retVal);
  1332 	}
  1333 
  1334 void CTMultiPtrEventTest::SimulateProximityAndPressureEvents(TInt aCloseProxEnterValue, TInt aCloseProxExitValue, TInt aHighPresEnterValue, TInt aHighPresExitValue)
  1335 	{
  1336 	TPoint ptrPos(10,10);
  1337 	// Simulate EPointerMove with proximity value > EnterCloseProximity threshold 
  1338 	for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  1339 		{
  1340 		SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, aCloseProxEnterValue, ptrNum);
  1341 		AddExpectedPointerEvent(TPointerEvent::EEnterCloseProximity, ptrPos, aCloseProxEnterValue, 0, ptrNum);
  1342 		}
  1343 	
  1344 	// Simulate EPointerMove with proximity value < ExitCloseProximity threshold
  1345 	for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  1346 		{
  1347 		SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, aCloseProxExitValue, ptrNum);
  1348 		AddExpectedPointerEvent(TPointerEvent::EExitCloseProximity, ptrPos, aCloseProxExitValue, 0, ptrNum);
  1349 		}
  1350 	
  1351 	// Simulate EBUtton1Down with presure value > EnterHighPressure threshold
  1352 	for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  1353 		{
  1354 		SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, aHighPresEnterValue, ptrNum);
  1355 		AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, aHighPresEnterValue, 0, ptrNum);
  1356 		AddExpectedPointerEvent(TPointerEvent::EEnterHighPressure, ptrPos, aHighPresEnterValue, 0, ptrNum);
  1357 		}
  1358 	
  1359 	// Simulate EPointerMove with presure value < ExitHighPressure threshold
  1360 	for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  1361 		{
  1362 		SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, aHighPresExitValue, ptrNum);
  1363 		AddExpectedPointerEvent(TPointerEvent::EExitHighPressure, ptrPos, aHighPresExitValue, 0, ptrNum);
  1364 		}
  1365 	
  1366 	// Finally simulate Ebutton1Up with proximity value < ExitCloseProximity
  1367 	for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  1368 		{
  1369 		SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, aCloseProxExitValue, ptrNum);
  1370 		AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, aCloseProxExitValue, 0, ptrNum);
  1371 		AddExpectedPointerEvent(TPointerEvent::EExitCloseProximity, ptrPos, aCloseProxExitValue, 0, ptrNum);
  1372 		}
  1373 	}
  1374 
  1375 /**
  1376 @SYMTestCaseID			GRAPHICS-WSERV-ADVANCEDPOINTER-0035
  1377 @SYMPREQ				PREQ1226
  1378 @SYMREQ					REQ10887, REQ10886
  1379 @SYMTestPriority		High
  1380 @SYMTestCaseDesc		Negative tests for close Proximity and high Pressure events. 
  1381 @SYMTestStatus			Implemented
  1382 
  1383 @SYMTestActions			Set CloseProximity and HighPressure thresholds with positive and negative values.
  1384   						Simulate Enter/ExitCloseProximity and Enter/ExitHighPressure events.
  1385 @SYMTestExpectedResults The received events must match the simulated pointer events
  1386 */
  1387 void CTMultiPtrEventTest::NegativeTestsForProximityPressureEventsL()
  1388 	{
  1389 	TLogMessageText logText;
  1390 	_LIT(KSet, "Negative tests for pressure and proximity events: %d of 3");
  1391 	logText.AppendFormat(KSet, iEventSet);
  1392 	LOG_MESSAGE(logText);
  1393 	
  1394 	if (!iEventSet)
  1395 		{
  1396 		SetAutoFlush();
  1397 		NegativeTestingOfProximityPressureAPIsL();
  1398 		AddExpectedWsEvent(EEventFocusGained);
  1399 		}
  1400 	iMultiPtrEventClient->EventBuffer()->SetEventCount(0);
  1401 	switch(iEventSet++)
  1402 		{
  1403 		case 0:
  1404 			// This is to check close proximity threshold API can be given +ve values
  1405 			// and high pressure threshold API can begiven -ve values
  1406 			iMultiPtrEventClient->iWs.SetCloseProximityThresholds(50, 20);
  1407 			iMultiPtrEventClient->iWs.SetHighPressureThresholds(-20, -50);
  1408 			SimulateProximityAndPressureEvents(60, 10, -10, -60);
  1409 			break;
  1410 		case 1:
  1411 			// Repeat the above with +ve values
  1412 			iMultiPtrEventClient->iWs.SetCloseProximityThresholds(50, 20);
  1413 			iMultiPtrEventClient->iWs.SetHighPressureThresholds(50, 20);
  1414 			SimulateProximityAndPressureEvents(60, 10, 60, 10);
  1415 			break;
  1416 		case 2:
  1417 			// Repeat the above -ve values
  1418 			iMultiPtrEventClient->iWs.SetCloseProximityThresholds(-20, -50);
  1419 			iMultiPtrEventClient->iWs.SetHighPressureThresholds(-20, -50);
  1420 			SimulateProximityAndPressureEvents(-10, -60, -10, -60);
  1421 			break;
  1422 		default:
  1423 			SetThresholdValues(KMaxTInt, KMinTInt, KMaxTInt, KMinTInt);
  1424 			ResetFlushStopAS();
  1425 			break;
  1426 		}
  1427 
  1428 	LogEventsAdded();
  1429 	}
  1430 
  1431 
  1432 void CTMultiPtrEventTest::CreateGroupWinForCapturingL()
  1433 	{
  1434 	iGroupWinForCapturing = new(ELeave) CTWindowGroup(iMultiPtrEventClient);
  1435 	iGroupWinForCapturing->ConstructL();
  1436 	iGroupWinForCapturing->GroupWin()->AutoForeground(ETrue);
  1437 	iGroupWinForCapturing->GroupWin()->EnableFocusChangeEvents();
  1438 				
  1439 	iWinForCapturing = new(ELeave) CTBlankWindow();
  1440 	iWinForCapturing->ConstructL(*iGroupWinForCapturing);
  1441 	iWinForCapturing->SetExt(TPoint(), TSize(iPhysicalScreenSize.iWidth/2, iPhysicalScreenSize.iHeight));
  1442 	iWinForCapturing->SetColor(KRgbBlue);
  1443 	iWinForCapturing->BaseWin()->EnableAdvancedPointers();
  1444 	iWinForCapturing->Activate();
  1445 	}
  1446 
  1447 void CTMultiPtrEventTest::DeleteGroupWinForCapturing()
  1448 	{
  1449 	if (iWinForCapturing)
  1450 		{
  1451 		delete iWinForCapturing;
  1452 		iWinForCapturing = NULL;
  1453 		}
  1454 	if (iGroupWinForCapturing)
  1455 		{
  1456 		delete iGroupWinForCapturing;
  1457 		iGroupWinForCapturing = NULL;
  1458 		}
  1459 	}
  1460 
  1461 /**
  1462 @SYMTestCaseID			GRAPHICS-WSERV-ADVANCEDPOINTER-0019
  1463 @SYMPREQ				PREQ1226
  1464 @SYMREQ					REQ9677,REQ9683,
  1465 @SYMTestPriority		High
  1466 @SYMTestCaseDesc		Checks Wserv supports Capturing in case of multi pointer events.
  1467 @SYMTestStatus			Implemented
  1468 
  1469 @SYMTestActions			Create a window with group window as its parent. 
  1470 						Create another window with same parent and partially overlapping the first one. 
  1471 						SetPointerCapture for second window with TCaptureEnabled flag. 
  1472 						Simulate TRawEvent::EButton1Down from each pointer the device supports
  1473 						
  1474 						Repeat the above with TCaptureFlagAllGroups flag for SetPointerCapture 
  1475 						and creating windows from different window group
  1476    						
  1477 @SYMTestExpectedResults Even if events were simulated on first window events are delivered to 
  1478 						second window as it is capturing. 
  1479 						With TCaptureFlagAllGroups flag set	events are delivered to window which is
  1480 						capturing even if events were simulated on a window from different group
  1481 						
  1482 */
  1483 void CTMultiPtrEventTest::CapturingMultiPointerEvents()
  1484 	{
  1485 	// Test Capturing of multi pointer events
  1486 	// 1. Test Wserv supports Capturing in case of multi-pointer events
  1487 	// 2. Test pointer events are delivered correctly when Capturing is disabled.
  1488 	TLogMessageText logText;
  1489 	_LIT(KSet, "CapturingMultiPtrEvents SetOfEvents: %d of 3");
  1490 	logText.AppendFormat(KSet, iEventSet);
  1491 	LOG_MESSAGE(logText);
  1492 	
  1493 	if (!iEventSet)
  1494 		{
  1495 		SetAutoFlush();
  1496 		}
  1497 	iMultiPtrEventClient->EventBuffer()->SetEventCount(0);
  1498 
  1499 	TPoint ptrPos;
  1500 	TInt ptrNum;
  1501 		
  1502 	switch(iEventSet++)
  1503 		{
  1504 		case 0:
  1505 			INFO_PRINTF1(_L("Ensure pointer state is Out of Range"));
  1506 			AddExpectedWsEvent(EEventFocusGained);
  1507 			for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
  1508 				{
  1509 				SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum);
  1510 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, ptrNum);
  1511 				SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum);
  1512 				AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, ptrNum);
  1513 				}
  1514 			break;			
  1515 		case 1:
  1516 			INFO_PRINTF1(_L("Check Wserv supports Capturing in case of multi-pointer events, within window group"));
  1517 			iMultiPtrEventClient->ChildWin()->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled);
  1518 			TestCapturingForMultiPointer(EFalse);
  1519 			break;	
  1520 		case 2:
  1521 			INFO_PRINTF1(_L("Check Wserv supports Capturing in case of multi-pointer events, from different window groups"));
  1522 			TRAPD(err, CreateGroupWinForCapturingL());	// it cannot leave so trap and fail
  1523 			if (err != KErrNone)
  1524 				{
  1525 				Failed();
  1526 				}			
  1527 			AddExpectedWsEvent(EEventFocusLost);		// First group window losing focus because of second group creation
  1528 			AddExpectedWsEvent(EEventFocusGained);		// Second group window creation
  1529 			
  1530 			iWinForCapturing->BaseWin()->SetPointerCapture(RWindowBase::TCaptureEnabled|RWindowBase::TCaptureFlagAllGroups);
  1531 			TestCapturingForMultiPointer(ETrue);
  1532 			break;
  1533 		default:
  1534 			DeleteGroupWinForCapturing();
  1535 			ResetFlushStopAS();
  1536 			break;
  1537 		}
  1538 	LogEventsAdded();
  1539 	}
  1540 
  1541 /**
  1542 @SYMTestCaseID			GRAPHICS-WSERV-ADVANCEDPOINTER-0017
  1543 @SYMPREQ				PREQ1226
  1544 @SYMREQ					Negative Testing
  1545 @SYMTestPriority		High
  1546 @SYMTestCaseDesc		Out of bound value testing
  1547 @SYMTestStatus			Implemented
  1548 
  1549 @SYMTestActions			Simulate raw events of TRawEvent with pointer number greater than EPointerMaxPointers
  1550 						 						
  1551 @SYMTestExpectedResults The received events must match the events added to the buffer and check that out of bound events are ignored.
  1552  
  1553 */
  1554 void CTMultiPtrEventTest::OutOfBoundValueTesting()
  1555 	{
  1556 	// Test Wserv ignores pointer events which have a pointer number greater than EPointerMaxPointers. 	 
  1557 	TLogMessageText logText;
  1558 	_LIT(KSet, "OutOfBoundValueTesting SetOfEvents: %d of 1");
  1559 	logText.AppendFormat(KSet, iEventSet);
  1560 	LOG_MESSAGE(logText);
  1561 	
  1562 	if (!iEventSet)
  1563 		{
  1564 		SetAutoFlush();
  1565 		AddExpectedWsEvent(EEventFocusGained);
  1566 		}
  1567 	iMultiPtrEventClient->EventBuffer()->SetEventCount(0);
  1568 
  1569 	TPoint ptrPos;
  1570 	TInt ptrNum;
  1571 	TInt ptrNumOutOfBounds;
  1572 			
  1573 	switch(iEventSet++)
  1574 		{
  1575 		case 0:
  1576 			INFO_PRINTF1(_L("Checks Wserv ignores pointer events which have a pointer number greater than EPointerMaxPointers."));
  1577 			ptrPos.SetXY(0,0);
  1578 			ptrNum = iMaxDevPointers-1;				// Max value for ptrNum
  1579 			ptrNumOutOfBounds = iMaxDevPointers;	// Invalid ptrNum as pointer numbers are zero indexed
  1580 			
  1581 			SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum);
  1582 			SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNumOutOfBounds);
  1583 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX+10, ptrPos.iY+10, 0, ptrNum);
  1584 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX+10, ptrPos.iY+10, 0, ptrNumOutOfBounds);
  1585 			SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX+10, ptrPos.iY+10, 0, ptrNum);
  1586 			SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX+10, ptrPos.iY+10, 0, ptrNumOutOfBounds);
  1587 			AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, ptrNum);
  1588 			ptrPos.iX += 10; ptrPos.iY += 10;
  1589 			AddExpectedPointerEvent(TPointerEvent::EDrag, ptrPos, ptrNum);
  1590 			AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, ptrNum);
  1591 			break;	 
  1592 		default:
  1593 			ResetFlushStopAS();
  1594 			break;
  1595 		}
  1596 	LogEventsAdded();
  1597 	}
  1598 
  1599 void CTMultiPtrEventTest::SetThresholdValues(TInt aEnterCloseProx, TInt aExitCloseProx, TInt aEnterHighPres, TInt aExitHighPres)
  1600 	{
  1601 	iEnterCloseProximityThreshold = aEnterCloseProx;
  1602 	iExitCloseProximityThreshold = aExitCloseProx;
  1603 	iEnterHighPressureThreshold = aEnterHighPres;
  1604 	iExitHighPressureThreshold  = aExitHighPres;
  1605 	
  1606 	iMultiPtrEventClient->iWs.SetCloseProximityThresholds(iEnterCloseProximityThreshold,iExitCloseProximityThreshold);
  1607 	iMultiPtrEventClient->iWs.SetHighPressureThresholds(iEnterHighPressureThreshold,iExitHighPressureThreshold);
  1608 	}
  1609 
  1610 void CTMultiPtrEventTest::TestCloseProximityHighPressureAPIsL()
  1611 	{
  1612 	// These are some typical values which are used only for testing purposes.
  1613 	// 20mm to screen
  1614 	// 50mm to screen
  1615 	// 4N of pressure
  1616 	// 2N of pressure
  1617 	SetThresholdValues(-20,-50,4000,2000);
  1618 	
  1619 	if (iMultiPtrEventClient->iWs.GetEnterCloseProximityThreshold() != iEnterCloseProximityThreshold)
  1620 		{
  1621 		TLogMessageText logText;
  1622 		_LIT(KError, "Expected EnterCloseProximityThreshold = %d Actual EnterCloseProximityThreshold %d");
  1623 		logText.AppendFormat(KError, iEnterCloseProximityThreshold, iMultiPtrEventClient->iWs.GetEnterCloseProximityThreshold());
  1624 		LOG_MESSAGE(logText);
  1625 		User::Leave(ETestFailed);
  1626 		}
  1627 	
  1628 	if (iMultiPtrEventClient->iWs.GetExitCloseProximityThreshold() != iExitCloseProximityThreshold)
  1629 		{
  1630 		TLogMessageText logText;
  1631 		_LIT(KError, "Expected ExitCloseProximityThreshold = %d Actual ExitCloseProximityThreshold %d");
  1632 		logText.AppendFormat(KError, iExitCloseProximityThreshold, iMultiPtrEventClient->iWs.GetExitCloseProximityThreshold());
  1633 		LOG_MESSAGE(logText);		
  1634 		User::Leave(ETestFailed);
  1635 		}
  1636 	
  1637 	if (iMultiPtrEventClient->iWs.GetEnterHighPressureThreshold() != iEnterHighPressureThreshold)
  1638 		{
  1639 		TLogMessageText logText;
  1640 		_LIT(KError, "Expected EnterHighPressureThreshold = %d Actual EnterHighPressureThreshold %d");
  1641 		logText.AppendFormat(KError, iEnterHighPressureThreshold, iMultiPtrEventClient->iWs.GetEnterHighPressureThreshold());
  1642 		LOG_MESSAGE(logText);
  1643 		User::Leave(ETestFailed);
  1644 		}
  1645 	
  1646 	if (iMultiPtrEventClient->iWs.GetExitHighPressureThreshold() != iExitHighPressureThreshold)
  1647 		{
  1648 		TLogMessageText logText;
  1649 		_LIT(KError, "Expected ExitHighPressureThreshold = %d Actual ExitHighPressureThreshold %d");
  1650 		logText.AppendFormat(KError, iExitHighPressureThreshold, iMultiPtrEventClient->iWs.GetExitHighPressureThreshold());
  1651 		LOG_MESSAGE(logText);
  1652 		User::Leave(ETestFailed);
  1653 		}
  1654 	}
  1655 
  1656 /**
  1657 @SYMTestCaseID			GRAPHICS-WSERV-ADVANCEDPOINTER-0034
  1658 @SYMPREQ				PREQ1226
  1659 @SYMREQ					REQ10887,REQ10886
  1660 @SYMTestPriority		High
  1661 @SYMTestCaseDesc		Tests close Proximity and high Pressure event types. 
  1662 @SYMTestStatus			Implemented
  1663 
  1664 @SYMTestActions			Set CloseProximity and HighPressure thresholds and simulate events with different Z values  
  1665 @SYMTestExpectedResults The received events must match the simulated pointer events
  1666 */
  1667 void CTMultiPtrEventTest::CloseProximityAndHighPressureEventsL()
  1668 	{
  1669 	TLogMessageText logText;
  1670 	_LIT(KSet, "Close Proximity and High Pressure events: %d of 11");
  1671 	logText.AppendFormat(KSet, iEventSet);
  1672 	LOG_MESSAGE(logText);
  1673 	
  1674 	if (!iEventSet)
  1675 		{
  1676 		SetAutoFlush();
  1677 		TestCloseProximityHighPressureAPIsL();
  1678 		AddExpectedWsEvent(EEventFocusGained);
  1679 		}
  1680 	iMultiPtrEventClient->EventBuffer()->SetEventCount(0);
  1681 
  1682 	TPoint ptrPos(10,10);
  1683 	TInt proxValue;
  1684 	TInt prValue;
  1685 	TInt tempCount; 
  1686 	switch(iEventSet++)
  1687 		{
  1688 		case 0:
  1689 			iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterMove, 0);
  1690 			// One whole cycle of events
  1691 			// Simulate out-of-range from all pointers and don't expect out-of-range events
  1692 			// since all the pointers are already in same state
  1693 			for (TInt ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
  1694 				{
  1695 				SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum);
  1696 				}
  1697 			
  1698 			// Simulate moves with proximity value < EEnterCloseProximity
  1699 			proxValue = -30;
  1700 			for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  1701 				{
  1702 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum);
  1703 				AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, ptrNum);
  1704 				}
  1705 
  1706 			// Simulate moves with proximity value > EEnterCloseProximity
  1707 			proxValue = -10;
  1708 			for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  1709 				{
  1710 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum);
  1711 				AddExpectedPointerEvent(TPointerEvent::EEnterCloseProximity, ptrPos, proxValue, 0, ptrNum);
  1712 				}
  1713 			
  1714 			// Simulate EButton1Down with pressure value < EEnterHighPressure
  1715 			prValue = 1000;
  1716 			for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  1717 				{
  1718 				SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, prValue, ptrNum);
  1719 				AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, prValue, 0, ptrNum);
  1720 				}
  1721 			
  1722 			// Simulate moves with pressure value > EEnterHighPressure
  1723 			prValue = 5000;
  1724 			for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  1725 				{
  1726 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum);
  1727 				AddExpectedPointerEvent(TPointerEvent::EEnterHighPressure, ptrPos, prValue, 0, ptrNum);
  1728 				}
  1729 			
  1730 			// Simulate moves with pressure value < EExitHighPressure
  1731 			prValue = 1000;
  1732 			for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  1733 				{
  1734 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum);
  1735 				AddExpectedPointerEvent(TPointerEvent::EExitHighPressure, ptrPos, prValue, 0, ptrNum);
  1736 				}
  1737 			
  1738 			// Simulate EButton1Up with proximity value > EEnterCloseProximity
  1739 			proxValue = -10;
  1740 			for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  1741 				{
  1742 				SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, proxValue, ptrNum);
  1743 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, proxValue, 0, ptrNum);
  1744 				}
  1745 			
  1746 			// Simulate moves with proximity value < EExitCloseProximity
  1747 			proxValue = -60;
  1748 			for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  1749 				{
  1750 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum);
  1751 				AddExpectedPointerEvent(TPointerEvent::EExitCloseProximity, ptrPos, proxValue, 0, ptrNum);
  1752 				}
  1753 			break;
  1754 		case 1:
  1755 			// Simulate events to meet all scenarios 
  1756 			// Simulate EButton1Down with pressure value < EEnterHighPressure
  1757 			prValue = 1000;
  1758 			for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  1759 				{
  1760 				SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, prValue, ptrNum);
  1761 				AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, prValue, 0, ptrNum);
  1762 				}
  1763 			
  1764 			// Simulate EButton1Up with proximity value < EExitCloseProximity
  1765 			proxValue = -60;
  1766 			for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  1767 				{
  1768 				SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, proxValue, ptrNum);
  1769 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, proxValue, 0, ptrNum);
  1770 				AddExpectedPointerEvent(TPointerEvent::EExitCloseProximity, ptrPos, proxValue, 0, ptrNum);
  1771 				}
  1772 			
  1773 			// Simulate EButton1Down with pressure value > EEnterHighPressure
  1774 			prValue = 5000;
  1775 			for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  1776 				{
  1777 				SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, prValue, ptrNum);
  1778 				AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, prValue, 0, ptrNum);
  1779 				AddExpectedPointerEvent(TPointerEvent::EEnterHighPressure, ptrPos, prValue, 0, ptrNum);
  1780 				}
  1781 			
  1782 			// Simulate EButton1Up with proximity value < EExitCloseProximity
  1783 			proxValue = -60;
  1784 			for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  1785 				{
  1786 				SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, proxValue, ptrNum);
  1787 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, proxValue, 0, ptrNum);
  1788 				AddExpectedPointerEvent(TPointerEvent::EExitCloseProximity, ptrPos, proxValue, 0, ptrNum);
  1789 				}
  1790 			break;
  1791 		case 2:
  1792 			// Simulate moves with proximity value > EEnterCloseProximity
  1793 			proxValue = -10;
  1794 			for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  1795 				{
  1796 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum);
  1797 				AddExpectedPointerEvent(TPointerEvent::EEnterCloseProximity, ptrPos, proxValue, 0, ptrNum);
  1798 				}
  1799 			
  1800 			// Simulate EButton1Down with pressure value > EEnterHighPressure
  1801 			prValue = 5000;
  1802 			for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  1803 				{
  1804 				SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, prValue, ptrNum);
  1805 				AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, prValue, 0, ptrNum);
  1806 				AddExpectedPointerEvent(TPointerEvent::EEnterHighPressure, ptrPos, prValue, 0, ptrNum);
  1807 				}
  1808 			
  1809 			// Simulate EButton1Up with proximity value > EExitCloseProximity
  1810 			proxValue = -40;		// When you coming up, EEnterCloseProximity is of no use
  1811 			for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  1812 				{
  1813 				SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, proxValue, ptrNum);
  1814 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, proxValue, 0, ptrNum);
  1815 				}
  1816 			
  1817 			// Simulate out-of-range events
  1818 			for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  1819 				{
  1820 				SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum);
  1821 				AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, ptrNum);
  1822 				}
  1823 			break;
  1824 		case 3:
  1825 			// From out-of-range state to EButton1Down
  1826 			// Simulate EButton1Down with pressure value < EEnterHighPressure
  1827 			prValue = 1000;
  1828 			for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  1829 				{
  1830 				SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, prValue, ptrNum);
  1831 				AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, prValue, 0, ptrNum);
  1832 				}
  1833 			
  1834 			// Simulate EButton1Up with proximity value > EExitCloseProximity
  1835 			proxValue = -40;
  1836 			for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  1837 				{
  1838 				SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, proxValue, ptrNum);
  1839 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, proxValue, 0, ptrNum);
  1840 				}
  1841 			
  1842 			// Simulate out-of-range events
  1843 			for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  1844 				{
  1845 				SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum);
  1846 				AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, ptrNum);
  1847 				}
  1848 			
  1849 			// Simulate EButton1Down with pressure value > EEnterHighPressure
  1850 			prValue = 5000;
  1851 			for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  1852 				{
  1853 				SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, prValue, ptrNum);
  1854 				AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, prValue, 0, ptrNum);
  1855 				AddExpectedPointerEvent(TPointerEvent::EEnterHighPressure, ptrPos, prValue, 0, ptrNum);
  1856 				}
  1857 			
  1858 			// Simulate EButton1Up with proximity value > EExitCloseProximity
  1859 			proxValue = -40;
  1860 			for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  1861 				{
  1862 				SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, proxValue, ptrNum);
  1863 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, proxValue, 0, ptrNum);
  1864 				}
  1865 			
  1866 			// Simulate out-of-range events
  1867 			for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  1868 				{
  1869 				SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum);
  1870 				AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, ptrNum);
  1871 				}
  1872 			break;
  1873 		case 4:
  1874 			// Simulate EButton1Dowm with pressure value < EEnterHighPressure
  1875 			prValue = 1000;
  1876 			for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  1877 				{
  1878 				SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, prValue, ptrNum);
  1879 				AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, prValue, 0, ptrNum);
  1880 				}
  1881 			
  1882 			// Simulate EButton1Up with proximity value < EExitCloseProximity
  1883 			proxValue = -60;
  1884 			for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  1885 				{
  1886 				SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, proxValue, ptrNum);
  1887 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, proxValue, 0, ptrNum);
  1888 				AddExpectedPointerEvent(TPointerEvent::EExitCloseProximity, ptrPos, proxValue, 0, ptrNum);
  1889 				}
  1890 			
  1891 			// Simulate out-of-range from Up/OutOfCloseProximity
  1892 			for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  1893 				{
  1894 				SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum);
  1895 				AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, ptrNum);
  1896 				}
  1897 			break;
  1898 		case 5:
  1899 			// Purging of proximity and pressure events
  1900 			// Simulate EnterCloseProximity and ExitCloseProximity events which will be purged
  1901 			// when you send Button1Up events for KMaxQueueSize
  1902 			proxValue = -10;
  1903 			for (TInt ptrNum = 0; (ptrNum < iMaxDevPointers && ptrNum < 4); ptrNum++)
  1904 				{
  1905 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum);
  1906 				}
  1907 			proxValue = -60;
  1908 			for (TInt ptrNum = 0; (ptrNum < iMaxDevPointers && ptrNum < 4); ptrNum++)
  1909 				{
  1910 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum);
  1911 				}
  1912 			for (TInt count = 0; count < KMaxQueueSize; count++)
  1913 				{
  1914 				SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, proxValue, 0);
  1915 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, proxValue, 0, 0);
  1916 				}
  1917 			break;
  1918 		case 6:
  1919 			// Simulate EnterCloseProximity for 4 pointers. 
  1920 			// As we cannot create lone ExitCloseProximity events, so create just moves from next 4 pointers
  1921 			// Simulate out-of-range for these events on thier respective pointers
  1922 			// Then simulate EButton1Up events which will purge EnterCloseProximity and move events
  1923 			// which checks that lone EnterCloseProximity and lone move events will be purged
  1924 			proxValue = -10;
  1925 			for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  1926 				{
  1927 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum);
  1928 				SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum);
  1929 				AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, ptrNum);
  1930 				}
  1931 			proxValue = -60;
  1932 			for (TInt ptrNum = iMaxDevPointers/2; ptrNum < iMaxDevPointers; ptrNum++)
  1933 				{
  1934 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum);
  1935 				SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum);
  1936 				AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, ptrNum);
  1937 				}
  1938 			for (TInt count = 0; count < KMaxQueueSize-iMaxDevPointers; count++)
  1939 				{
  1940 				SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, proxValue, 0);
  1941 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, proxValue, 0, 0);
  1942 				}
  1943 			break;
  1944 		case 7:
  1945 			// Bring all other pointers to Up state, becasue of previous test
  1946 			// Then simulate out-of-range twice for all the pointers
  1947 			// Then simulate Button1Up which will cause purging of successive out-of-range events
  1948 			proxValue = -60;
  1949 			tempCount = 0;
  1950 			for (TInt ptrNum = 1; ptrNum < iMaxDevPointers; ptrNum++)
  1951 				{
  1952 				tempCount++;
  1953 				SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, proxValue, ptrNum);
  1954 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, proxValue, 0, ptrNum);
  1955 				}
  1956 			for (TInt ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
  1957 				{
  1958 				tempCount++;
  1959 				// Wserv does nothing if current state is outofrange and if receives again EOutOfRange event which is practically not possible
  1960 				SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum);
  1961 				SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum);
  1962 				AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, ptrNum);
  1963 				}
  1964 			for (TInt count = 0; count < KMaxQueueSize-tempCount; count++)
  1965 				{
  1966 				SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, proxValue, 0);
  1967 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, proxValue, 0, 0);
  1968 				}
  1969 			break;
  1970 		case 8:
  1971 			// Simulate EButton1Down with pressure value > EnterHIghPressure threshold
  1972 			// which will cause EButton1Down and EnterHighPressure to be filled in queue
  1973 			// Simulate ExitHighPressure and EButton1Up events for 2 pointers
  1974 			// Then simulate EButton1Up events from pointer0 so that all of the above events are purged
  1975 			prValue = 5000;
  1976 			for (TInt ptrNum = 0; (ptrNum < iMaxDevPointers && ptrNum < 2); ptrNum++)
  1977 				{
  1978 				SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, prValue, ptrNum);
  1979 				}
  1980 			prValue = 1000;
  1981 			for (TInt ptrNum = 0; (ptrNum < iMaxDevPointers && ptrNum < 2); ptrNum++)
  1982 				{
  1983 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum);
  1984 				// Here these events are purged becasue their correpsonding  down event would have been purged
  1985 				SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum);	
  1986 				}
  1987 			// All the above events get purged by this
  1988 			for (TInt count = 0; count < KMaxQueueSize; count++)
  1989 				{
  1990 				SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0);
  1991 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, 0);
  1992 				}
  1993 			break;
  1994 		case 9:
  1995 			// Simulate EButton1Down for 2 pointers, which will generate Button1Down and EnterHighPressure
  1996 			// Simulate Ebutton1Up events for MaxQueueSize from last pointer so that all the above events are purged  
  1997 			prValue = 5000;
  1998 			for (TInt ptrNum = 0; (ptrNum < iMaxDevPointers/2 && ptrNum < 2); ptrNum++)
  1999 				{
  2000 				SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, prValue, ptrNum);
  2001 				}
  2002 			
  2003 			// This will cause above down and enterhighpressure events to be purged
  2004 			// When pointer is in outofrange state and when EButton1Up event is sent Wserv sends EnterCloseProximity 
  2005 			// EnterCloseProximity cannot be purged unless the next event is EExitCloseProximity or EOutOfRange
  2006 			for (TInt count = 0; count < KMaxQueueSize; count++)
  2007 				{
  2008 				SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, iMaxDevPointers-1);
  2009 				AddExpectedPointerEvent((count ? TPointerEvent::EButton1Up : TPointerEvent::EEnterCloseProximity), ptrPos, 0, 0, iMaxDevPointers-1);
  2010 				}
  2011 
  2012 			// As the first 2 pointers are in down state, and if we send the move events with prValue = 1000
  2013 			// This will generate the exithigh pressure events, which will be ignored
  2014 			// This will also generate the Ebutton1Up event which will also be ignored
  2015 			prValue = 1000;
  2016 			for (TInt ptrNum = 0; (ptrNum < iMaxDevPointers/2  && ptrNum < 2); ptrNum++)
  2017 				{
  2018 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum);
  2019 				SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum);
  2020 				}
  2021 			break;
  2022 		case 10:
  2023 			// This is to just bring all the pointers to out-of-range state
  2024 			// to make all pointers in valid state for other test to run
  2025 			// Wserv processes EOutOfRange events only when its current state is not in outofrange. 
  2026 			for (TInt ptrNum = 0; ptrNum < iMaxDevPointers && ptrNum < 2; ptrNum++)
  2027 				{
  2028 				SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum);
  2029 				AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, ptrNum);
  2030 				}
  2031 			SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, iMaxDevPointers-1);
  2032 			AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, iMaxDevPointers-1);
  2033 			break;
  2034 		default:
  2035 			SetThresholdValues(KMaxTInt, KMinTInt, KMaxTInt, KMinTInt);
  2036 			ResetFlushStopAS();
  2037 			break;
  2038 		}
  2039 
  2040 	LogEventsAdded();
  2041 	}
  2042 
  2043 void CTMultiPtrEventTest::CreateAnimDllAndAnimL()
  2044 	{
  2045 	iAnimDll = new(ELeave) RAnimDll(iMultiPtrEventClient->iWs);
  2046 	User::LeaveIfError(iAnimDll->Load(KAnimDLLName));
  2047 	iAnim = RMultiPointerAnim::NewL(iMultiPtrEventClient->ParentWin()->BaseWin(), iAnimDll);
  2048 	}
  2049 
  2050 void CTMultiPtrEventTest::DestroyAnimDllAndAnim()
  2051 	{
  2052 	if (iAnim)
  2053 		{
  2054 		iAnim->Destroy();
  2055 		iAnim = NULL;
  2056 		}
  2057 	if (iAnimDll)
  2058 		{
  2059 		iAnimDll->Destroy();
  2060 		iAnimDll = NULL;
  2061 		}
  2062 	}
  2063 
  2064 void CTMultiPtrEventTest::CreateGroupWinL()
  2065 	{
  2066 	iGroupWinForEmul = new(ELeave) CTWindowGroup(iMultiPtrEventClient);
  2067 	iGroupWinForEmul->ConstructL();
  2068 	iGroupWinForEmul->GroupWin()->AutoForeground(ETrue);
  2069 	iGroupWinForEmul->GroupWin()->EnableFocusChangeEvents();
  2070 
  2071 	iWinForEmul = new(ELeave) CTBlankWindow();
  2072 	iWinForEmul->ConstructL(*iGroupWinForEmul);
  2073 	iWinForEmul->SetExt(TPoint(50,50), TSize(80,80));
  2074 	iWinForEmul->SetColor(KRgbDarkYellow);
  2075 	iWinForEmul->Activate();	
  2076 	}
  2077 
  2078 void CTMultiPtrEventTest::DeleteGroupWin()
  2079 	{
  2080 	if (iWinForEmul)
  2081 		{
  2082 		delete iWinForEmul;
  2083 		iWinForEmul = NULL;
  2084 		}
  2085 	if (iGroupWinForEmul)
  2086 		{
  2087 		delete iGroupWinForEmul;
  2088 		iGroupWinForEmul = NULL;
  2089 		}
  2090 	}
  2091 
  2092 /**
  2093 @SYMTestCaseID			GRAPHICS-WSERV-ADVANCEDPOINTER-0029
  2094 @SYMPREQ				PREQ1226
  2095 @SYMREQ					REQ9688
  2096 @SYMTestPriority		High
  2097 @SYMTestCaseDesc		Tests the emulation rules for Apps, Anims, Autofocus and Buffered delivery
  2098 @SYMTestStatus			Implemented
  2099 
  2100 @SYMTestActions			Simulate event to make a pointer primary. EnableAdvancedPointers API is not called. And then simulate events from other pointers  
  2101 @SYMTestExpectedResults The events from other pointer are not received
  2102 */
  2103 void CTMultiPtrEventTest::EmulationRulesForMultiplePointers()
  2104 	{
  2105 	TLogMessageText logText;
  2106 	_LIT(KSet, "Emulation rules set of events: %d of 15");
  2107 	logText.AppendFormat(KSet, iEventSet);
  2108 	LOG_MESSAGE(logText);
  2109 	
  2110 	if (!iEventSet)
  2111 		{
  2112 		SetExpectNonAdvancedPointerEvents();
  2113 		SetAutoFlush();
  2114 		AddExpectedWsEvent(EEventFocusGained);
  2115 		}
  2116 	iMultiPtrEventClient->EventBuffer()->SetEventCount(0);
  2117 	
  2118 	TPoint ptrPos(10,10);
  2119 	TInt proxValue = -iProximityStep;
  2120 	TInt prValue = iPressureStep;
  2121 	TInt ptrNum = 0;
  2122 	switch(iEventSet++)
  2123 		{
  2124 		case 0:
  2125 			// This event is for simulated/primary pointer
  2126 			iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterMove, 0);
  2127 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 0);
  2128 			AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2129 			
  2130 			// Parent window has not called EnableAdvancedPointers API
  2131 			// So even if we simulate moves and out-of-range these are not delivered to client
  2132 			for (ptrNum = 1; ptrNum < iMaxDevPointers; ptrNum++)
  2133 				{
  2134 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum);
  2135 				SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum);
  2136 				}
  2137 			break;
  2138 		case 1:
  2139 			// Since the primary pointer is 0, simulate EButton1Down for making pointer 1 as primary 
  2140 			SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 1);
  2141 			AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2142 			
  2143 			// Simulate move or Ebutton1Down from pointer0 they are NOT sent back to client
  2144 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 0);
  2145 			SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 0);
  2146 			SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0);
  2147 			
  2148 			SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 1);
  2149 			AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2150 			SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1);
  2151 			AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2152 			break;
  2153 		case 2:
  2154 			// Simulate EButton1Down from pointer0 to make it primary
  2155 			SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 0);
  2156 			AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, 0);
  2157 			
  2158 			// Move from pointer1
  2159 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 1);
  2160 			
  2161 			// Take the zero pointer out-of-range, this will not result in Pointer 1 becoming primary
  2162 			// and out-of-range event is sent to client
  2163 			SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0);
  2164 			AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, 0);
  2165 			SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0);
  2166 			AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, 0);
  2167 			
  2168 			// Send moves from pointer1, but these are not sent to the Client.
  2169 			ptrPos.iX += 10;
  2170 			ptrPos.iY += 10;
  2171 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 1);
  2172 			SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1);
  2173 			
  2174 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 1);
  2175 			AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2176 			
  2177 			SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1);
  2178 			AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2179 			break;
  2180 		case 3:
  2181 			// Simulate EButton1Down from pointer0 to make it primary
  2182 			SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 0);
  2183 			AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2184 			
  2185 			// Simulate EButton1Down from pointer1, which is not sent to client 
  2186 			SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 1);
  2187 			
  2188 			SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0);
  2189 			AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2190 			
  2191 			SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0);
  2192 			AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2193 			
  2194 			// Drag events are not sent becasue pointer1 has NOT become primary
  2195 			ptrPos.iX += 10;
  2196 			ptrPos.iY += 10;
  2197 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, 1);
  2198 			
  2199 			// Simulate up from pointer1, still not primary, so event is not sent
  2200 			SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 1);
  2201 			
  2202 			// Simulate out-of-range from pointer1, still not primary, so event is not sent
  2203 			SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1);
  2204 			
  2205 			// Now moves from out-of-range to move state 
  2206 			ptrPos.iX += 10;
  2207 			ptrPos.iY += 10;
  2208 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, 1);
  2209 			AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2210 			
  2211 			SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1);
  2212 			AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2213 			break;
  2214 		case 4:
  2215 			// pointer0 sends move (becomes primary)
  2216 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, 0);
  2217 			AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2218 			
  2219 			// pointer0 sends down
  2220 			SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 0);
  2221 			AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2222 			
  2223 			// pointer1 sends down, doesn't become primary
  2224 			SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 1);
  2225 
  2226 			// pointer0 sends up, stays primary
  2227 			SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0);
  2228 			AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2229 
  2230 			// pointer2, pointer3 and pointer4 sends move with proximity -5, -10, -15
  2231 			for (ptrNum = 2; ptrNum < iMaxDevPointers; ptrNum++, proxValue -= iProximityStep)
  2232 				{
  2233 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum);
  2234 				}
  2235 			
  2236 			// pointer0 sends out-of-range, loses primary pointer, But NO events are sent
  2237 			SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0);
  2238 			AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2239 			
  2240 			// Send moves for pointer2, pointer3 and pointer4.
  2241 			// None of the evnst are sent
  2242 			ptrPos.SetXY(0,0);
  2243 			for (ptrNum = 2; ptrNum < iMaxDevPointers; ptrNum++)
  2244 				{
  2245 				ptrPos.iX += 10;
  2246 				ptrPos.iY += 5;
  2247 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum);
  2248 				}
  2249 			
  2250 			// Drag from pointer1, NOT sent, since it is not primary
  2251 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, 1);
  2252 
  2253 			// Send out-of-range from all pointers
  2254 			for (ptrNum = 2; ptrNum < iMaxDevPointers; ptrNum++)
  2255 				{
  2256 				SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum);
  2257 				}
  2258 			
  2259 			// As the pointer1 is down, this will not become primary even if EButton1Up is called
  2260 			SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 1);
  2261 			
  2262 			// And now sending out-of-range will also not send the event to client as it is not primary
  2263 			SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1);
  2264 			break;
  2265 		case 5:
  2266 			// Test cases 5 - 7 represent one discrete test for PointerRepeatEvents
  2267 			// Case 5 simulates EButton1Down events only. This is to ensure the event is delivered to the client. 
  2268 			// If the event remained in the window queue the PointerRepeatEvent request would be cancelled when PointerRepeatPurgeCheck is performed.
  2269 			ptrPos.SetXY(0,0);
  2270 			
  2271 			// pointer0 sends down (become primary)
  2272 			SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 0);
  2273 			AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2274 			
  2275 			// pointer1 sends down, doesn't become primary
  2276 			SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 1);
  2277 			
  2278 			// pointer4 sends down
  2279 			if (4 < iMaxDevPointers)
  2280 				{
  2281 				SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 4);
  2282 				}
  2283 			break;
  2284 		case 6:
  2285 			ptrPos.SetXY(0,0);
  2286 			// Simulate client calling RequestPointerRepeatEvent in response to EButton1Down event being within a 'hitbox'.
  2287 			// Legacy API called which does not specify a pointer number. EButtonRepeat should be generated for primary pointer only.
  2288 			iMultiPtrEventClient->ParentWin()->BaseWin()->RequestPointerRepeatEvent(TTimeIntervalMicroSeconds32(100000),TRect(TPoint(0,0), TSize(20,20)));				
  2289 			User::After(200000);	
  2290 			AddExpectedPointerEvent(TPointerEvent::EButtonRepeat, ptrPos, TAdvancedPointerEvent::EDefaultPointerNumber);			
  2291 			break;
  2292 		case 7:
  2293 			// pointer0 sends up 
  2294 			SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0);
  2295 			AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, TAdvancedPointerEvent::EDefaultPointerNumber);
  2296 			
  2297 			// pointer2 sends out-of-range
  2298 			SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, ptrPos.iX, ptrPos.iY, 0, 0);
  2299 			AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, TAdvancedPointerEvent::EDefaultPointerNumber);
  2300 			
  2301 			// Send up and out-of-range for pointer1 and 4
  2302 			SimulatePointerEvent(TRawEvent::EButton1Up, 0, 0, 0, 1);
  2303 			SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1);
  2304 			
  2305 			if (4 < iMaxDevPointers)
  2306 				{
  2307 				SimulatePointerEvent(TRawEvent::EButton1Up, 0, 0, 0, 4);
  2308 				SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 4);
  2309 				}
  2310 			break;
  2311 		case 8:
  2312 			// Autofocus does not work for other than primary pointers
  2313 			// Create group window which will send focus lost and gained
  2314 			TRAPD(err, CreateGroupWinL());	// it cannot leave so trap and fail
  2315 			if (err != KErrNone)
  2316 				{
  2317 				Failed();
  2318 				}
  2319 			AddExpectedWsEvent(EEventFocusLost);
  2320 			AddExpectedWsEvent(EEventFocusGained);
  2321 			
  2322 			// Simulate Epointer down which will send focuslost, focusgained and focusgroupchanged events 
  2323 			SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 0);
  2324 			AddExpectedWsEvent(EEventFocusLost); 
  2325 			AddExpectedWsEvent(EEventFocusGained);
  2326 			AddExpectedWsEvent(EEventFocusGroupChanged);
  2327 			AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2328 			
  2329 			// Now simulate EButton1Down from first or second pointer on second group
  2330 			// This should not reflect the autofocus
  2331 			ptrPos.iX = 60;
  2332 			ptrPos.iY = 60;
  2333 			SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 1);
  2334 			if (2 < iMaxDevPointers)
  2335 				{
  2336 				SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 2);
  2337 				}
  2338 			SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1);
  2339 			if (2 < iMaxDevPointers)
  2340 				{
  2341 				SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 2);
  2342 				}
  2343 			SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0);
  2344 			AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2345 			SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0);
  2346 			AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2347 			break;
  2348 		case 9:
  2349 			// First thing to do in this case is to delete the group window created
  2350 			DeleteGroupWin();
  2351 			
  2352 			TRAP(err, CreateAnimDllAndAnimL());	// it cannot leave so trap and fail
  2353 			if (err != KErrNone)
  2354 				{
  2355 				Failed();
  2356 				}
  2357 
  2358 			// This is the first event which makes first pointer as primary
  2359 			// When the last argument is EFalse, it means that the event is not consumed by Anim
  2360 			iAnim->AddExpectedAnimPointerEvent(TRawEvent::EPointerMove, ptrPos, 0, 0, 0, EFalse);
  2361 			AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2362 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, 0);
  2363 			
  2364 			// Now simulate moves from other pointers and these events are not sent to anim
  2365 			for (ptrNum = 1; ptrNum < iMaxDevPointers; ptrNum++)
  2366 				{
  2367 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum);
  2368 				SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum);
  2369 				}
  2370 
  2371 			// This is to reset the primary pointer 
  2372 			iAnim->AddExpectedAnimPointerEvent(TRawEvent::EPointer3DOutOfRange, ptrPos, 0, 0, 0, EFalse);
  2373 			AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2374 			SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0);
  2375 	
  2376 			// Now simulate EButton1Down, which will make it as primary
  2377 			iAnim->AddExpectedAnimPointerEvent(TRawEvent::EButton1Down, ptrPos, 0, 0, 1, EFalse);
  2378 			AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2379 			SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 1);
  2380 			
  2381 			// Simulate move or Ebutton1Down from any other prointer they are not sent back to client
  2382 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 0);
  2383 			SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 0);
  2384 			SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0);
  2385 			
  2386 			iAnim->AddExpectedAnimPointerEvent(TRawEvent::EButton1Up, ptrPos, 0, 0, 1, EFalse);
  2387 			AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2388 			SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 1);
  2389 			
  2390 			iAnim->AddExpectedAnimPointerEvent(TRawEvent::EPointer3DOutOfRange, ptrPos, 0, 0, 1, EFalse);
  2391 			AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2392 			SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1);
  2393 
  2394 			// Set the primary pointer to Zero			
  2395 			iAnim->AddExpectedAnimPointerEvent(TRawEvent::EButton1Down, ptrPos, 0, 0, 0, EFalse);
  2396 			AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2397 			SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 0);
  2398 			
  2399 			// Move from second pointer
  2400 			// As EnableMultiPointer is not called and this is not a primary pointer so this event
  2401 			// will cause the pointer 1 into move state
  2402 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 1);
  2403 			
  2404 			// Take the zero pointer out-of-range 
  2405 			iAnim->AddExpectedAnimPointerEvent(TRawEvent::EButton1Up, ptrPos, 0, 0, 0, EFalse);
  2406 			AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2407 			SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0);
  2408 			
  2409 			iAnim->AddExpectedAnimPointerEvent(TRawEvent::EPointer3DOutOfRange, ptrPos, 0, 0, 0, EFalse);
  2410 			AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2411 			SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0);
  2412 			
  2413 			// These moves will not be sent
  2414 			ptrPos.iX += 10;
  2415 			ptrPos.iY += 10;
  2416 			
  2417 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 1);
  2418 			SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 1);
  2419 			SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1);		
  2420 
  2421 			TestAndDisplayAnimError();
  2422 			
  2423 			_LIT(KEventsChecked, "Events checked at server side = %d");
  2424 			logText.Format(KEventsChecked, 10);
  2425 			LOG_MESSAGE(logText);
  2426 			break;
  2427 		case 10:
  2428 			DestroyAnimDllAndAnim();
  2429 			
  2430 			// Test for PointerMove buffers
  2431 			// AllocPointerMoveBuffer, EnablePointerMoveBuffer and then simulate few moves
  2432 			// Add these moves to another points buffer for testing
  2433 			// Simulate moves from other pointers, these should not be delivered to clients.
  2434 			iMultiPtrEventClient->ParentWin()->BaseWin()->AllocPointerMoveBuffer(10, 0);
  2435 			iMultiPtrEventClient->ParentWin()->BaseWin()->EnablePointerMoveBuffer();
  2436 			
  2437 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, 0);
  2438 			AddExpectedWsEvent(EEventPointerBufferReady, EFalse, TAdvancedPointerEvent::EDefaultPointerNumber, (TUint)iMultiPtrEventClient->ParentWin());
  2439 			iMultiPtrEventClient->AddExpectedMovePoint(ptrPos);   // If this position is above some other window then we need to consider its window postion also
  2440 			ptrPos.iX += 10;
  2441 			ptrPos.iY += 10;
  2442 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, 0);
  2443 			iMultiPtrEventClient->AddExpectedMovePoint(ptrPos);
  2444 			ptrPos.iX += 10;
  2445 			ptrPos.iY += 10;
  2446 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, 0);
  2447 			iMultiPtrEventClient->AddExpectedMovePoint(ptrPos);
  2448 			
  2449 			// These events should not be added to buffer
  2450 			for (ptrNum = 1; ptrNum < iMaxDevPointers; ptrNum++)
  2451 				{
  2452 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, ptrNum);
  2453 				ptrPos.iX += 10;
  2454 				ptrPos.iY += 10;
  2455 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, ptrNum);
  2456 				SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum);
  2457 				}
  2458 			break;
  2459 		case 11:
  2460 			// Repeat the above for drag events
  2461 			SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 0);
  2462 			AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2463 			
  2464 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, 0);
  2465 			AddExpectedWsEvent(EEventPointerBufferReady, EFalse, TAdvancedPointerEvent::EDefaultPointerNumber, (TUint)iMultiPtrEventClient->ParentWin());
  2466 			iMultiPtrEventClient->AddExpectedMovePoint(ptrPos);
  2467 			ptrPos.iX += 10;
  2468 			ptrPos.iY += 10;
  2469 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, 0);
  2470 			iMultiPtrEventClient->AddExpectedMovePoint(ptrPos);
  2471 			ptrPos.iX += 10;
  2472 			ptrPos.iY += 10;
  2473 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, 0);
  2474 			iMultiPtrEventClient->AddExpectedMovePoint(ptrPos);
  2475 			
  2476 			// These events should not be added to buffer
  2477 			for (ptrNum = 1; ptrNum < iMaxDevPointers; ptrNum++)
  2478 				{
  2479 				SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum);
  2480 				ptrPos.iX += 10;
  2481 				ptrPos.iY += 10;
  2482 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, 0, ptrNum);
  2483 				SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum);
  2484 				SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum);
  2485 				}
  2486 			
  2487 			SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0);
  2488 			AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2489 			SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0);
  2490 			AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2491 			break;
  2492 		case 12:
  2493 			iMultiPtrEventClient->ParentWin()->BaseWin()->FreePointerMoveBuffer();
  2494 			iMultiPtrEventClient->ParentWin()->BaseWin()->DisablePointerMoveBuffer();
  2495 			
  2496 			// Pointer Cursor Position test 
  2497 			// This event is for simulating primary pointer
  2498 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 0);
  2499 			// Here I am not adding the event because this event is deleted by another move of same pointer
  2500 			if (ptrPos != iMultiPtrEventClient->iWs.PointerCursorPosition())
  2501 				{
  2502 				TEST(EFalse);
  2503 				Failed();
  2504 				}
  2505 			
  2506 			iMultiPtrEventClient->iWs.SetPointerCursorPosition(TPoint(20,20));
  2507 			if (TPoint(20,20) != iMultiPtrEventClient->iWs.PointerCursorPosition())
  2508 				{
  2509 				TEST(EFalse);
  2510 				Failed();
  2511 				}
  2512 			
  2513 			// Now simulate moves from other pointer, this should not have any effect on pointer cursor position
  2514 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 1);
  2515 
  2516 			// Now move the primary pointer, and check the pointer cursor position which should be same as position used for move
  2517 			ptrPos.iX = 30;
  2518 			ptrPos.iY = 30;
  2519 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 0);
  2520 			AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2521 			if (ptrPos != iMultiPtrEventClient->iWs.PointerCursorPosition())
  2522 				{
  2523 				TEST(EFalse);
  2524 				Failed();
  2525 				}
  2526 			
  2527 			// Send out-of-range event which will not lead to pointer 1 becoming primary
  2528 			SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0);
  2529 			AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2530 			
  2531 			// Now check the pointer cursor position, which should be same
  2532 			// as primary even if there is other pointer in up state, but that is not primary
  2533 			if (ptrPos != iMultiPtrEventClient->iWs.PointerCursorPosition())
  2534 				{
  2535 				TEST(EFalse);
  2536 				Failed();
  2537 				}
  2538 			
  2539 			// This is to bring the pointer1 to out-of-range state
  2540 			SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1);
  2541 			
  2542 			// then send move event and then again check the pointer cursor position
  2543 			ptrPos.iX = 20;
  2544 			ptrPos.iY = 20;
  2545 			SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 1);
  2546 			AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2547 			if (ptrPos != iMultiPtrEventClient->iWs.PointerCursorPosition())
  2548 				{
  2549 				TEST(EFalse);
  2550 				Failed();
  2551 				}
  2552 			
  2553 			SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 1);
  2554 			AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2555 			
  2556 			SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1);
  2557 			AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2558 			break;
  2559 		case 13:
  2560 			{
  2561 			// Pointer Cursor Area test-1
  2562 			iOrigPtrCursorArea = iMultiPtrEventClient->iWs.PointerCursorArea();
  2563 			TRect ptrCurArea(0,0,40,40);
  2564 			iMultiPtrEventClient->iWs.SetPointerCursorArea(ptrCurArea);
  2565 			
  2566 			// Simulate move from pointer0 in PointerCursorArea
  2567 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 0);
  2568 			AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2569 			
  2570 			// Simulate move from other pointer, This should have no effect
  2571 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 1);
  2572 			SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1);
  2573 			
  2574 			SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0);
  2575 			AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2576 
  2577 			// Repeat the above with moves outside pointer cursor area 
  2578 			ptrPos.iX = 50;
  2579 			ptrPos.iY = 50;
  2580 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 0);
  2581 			TPoint pointInCurArea(39, 39);
  2582 			AddExpectedPointerEvent(TPointerEvent::EMove, pointInCurArea, proxValue, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2583 			
  2584 			// Simulate move from other pointer, This should have no effect			
  2585 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, 1);
  2586 			SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1);
  2587 						
  2588 			SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0);
  2589 			AddExpectedPointerEvent(TPointerEvent::EOutOfRange, pointInCurArea, proxValue, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2590 			}
  2591 			break;
  2592 		case 14:
  2593 			{
  2594 			// Pointer Cursor Area test-2
  2595 			// repeat the above test with button1 down
  2596 			SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 0);
  2597 			AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2598 			
  2599 			// Simulate move from other pointer, This should have no effect
  2600 			SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 1);
  2601 			SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 1);
  2602 			SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1);
  2603 			
  2604 			SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0);
  2605 			AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2606 			
  2607 			SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0);
  2608 			AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2609 			
  2610 			// Repeat the above with moves outside pointer cursor area 
  2611 			ptrPos.iX = 50;
  2612 			ptrPos.iY = 50;
  2613 			TPoint pointInCurArea(39, 39);
  2614 			SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 0);
  2615 			AddExpectedPointerEvent(TPointerEvent::EButton1Down, pointInCurArea, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2616 			
  2617 			// Simulate move from other pointer, This should have no effect
  2618 			SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, 1);
  2619 			SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 1);
  2620 			SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 1);
  2621 			
  2622 			SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0);
  2623 			AddExpectedPointerEvent(TPointerEvent::EButton1Up, pointInCurArea, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2624 			
  2625 			SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, 0);
  2626 			AddExpectedPointerEvent(TPointerEvent::EOutOfRange, pointInCurArea, 0, 0, TAdvancedPointerEvent::EDefaultPointerNumber);
  2627 			}
  2628 			break;
  2629 		default:
  2630 			ClearExpectNonAdvancedPointerEvents();
  2631 			iMultiPtrEventClient->iWs.SetPointerCursorArea(iOrigPtrCursorArea);
  2632 			ResetFlushStopAS();
  2633 			break;
  2634 		}
  2635 	LogEventsAdded();
  2636 	}
  2637 
  2638 /**
  2639 @SYMTestCaseID			GRAPHICS-WSERV-ADVANCEDPOINTER-0026
  2640 @SYMPREQ				PREQ1226
  2641 @SYMREQ					REQ9677, REQ9683
  2642 @SYMTestPriority		High
  2643 @SYMTestCaseDesc		Checks Wserv supports Autofocus for multiple pointers
  2644 @SYMTestStatus			Implemented
  2645 
  2646 @SYMTestActions			Create 2 group window and respective client windows for it. And simulate EButton1Down on each window consecutively 
  2647 @SYMTestExpectedResults The received events must match the simulated pointer events
  2648 */
  2649 void CTMultiPtrEventTest::AutoForeGroundForMultiplePointersL()
  2650 	{
  2651 	TLogMessageText logText;
  2652 	_LIT(KSet, "Multiple pointer Auto foreground events: %d of 2");
  2653 	logText.AppendFormat(KSet, iEventSet);
  2654 	LOG_MESSAGE(logText);
  2655 	
  2656 	if (!iEventSet)
  2657 		{
  2658 		SetAutoFlush();
  2659 		AddExpectedWsEvent(EEventFocusGained);			// This if for the main groupwindow
  2660 		iMultiPtrEventClient->ConstructGroupBlankWinL();
  2661 		
  2662 		// These are for child group window creation
  2663 		AddExpectedWsEvent(EEventFocusLost);			// This if for the main groupwindow losing focus
  2664 		AddExpectedWsEvent(EEventFocusGained);			// First group window of this test creation
  2665 		
  2666 		AddExpectedWsEvent(EEventFocusLost);			// First group window losing focus because of second group creation
  2667 		AddExpectedWsEvent(EEventFocusGained);			// Second group window creation
  2668 		AddExpectedWsEvent(EEventFocusGroupChanged);	// First group window's Enable Focus changed flag is set
  2669 		}
  2670 	iMultiPtrEventClient->EventBuffer()->SetEventCount(0);
  2671 	
  2672 	TPoint win1PtrPos(20,20);
  2673 	TPoint win2PtrPos(60,60);
  2674 	TPoint ptrPos;
  2675 	TInt autoFocusWin;
  2676 	switch(iEventSet++)
  2677 		{
  2678 		case 0:
  2679 			for (TInt ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  2680 				{
  2681 				if ((ptrNum & 1) == 0)
  2682 					{
  2683 					ptrPos = win1PtrPos;
  2684 					autoFocusWin = 1;
  2685 					}
  2686 				else
  2687 					{
  2688 					ptrPos = win2PtrPos;
  2689 					autoFocusWin = 0;
  2690 					}
  2691 				SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum);
  2692 				AddExpectedWsEvent(EEventFocusLost);				// Second group window losing focus 
  2693 				AddExpectedWsEvent(EEventFocusGained);				// First group window gaining focus
  2694 				if (ptrNum == 0)
  2695 					{												// First group window has already received EEventFocusGroupChanged
  2696 					AddExpectedWsEvent(EEventFocusGroupChanged);	// Second group window's Enable Focus changed flag is set
  2697 					}
  2698 				// In the queue only once EEventFocusGroupChanged is sent
  2699 				AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum);
  2700 				
  2701 				SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum);
  2702 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, ptrNum);
  2703 				
  2704 				// These events are to clear out the pointer state
  2705 				SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum);
  2706 				AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, ptrNum);
  2707 				
  2708 				if (!iMultiPtrEventClient->CheckOrdinalPosition(autoFocusWin))
  2709 					{
  2710 					TEST(EFalse);
  2711 					Failed();
  2712 					}
  2713 				}
  2714 			break;
  2715 		case 1:
  2716 			for (TInt ptrNum = iMaxDevPointers/2; ptrNum < iMaxDevPointers; ptrNum++)
  2717 				{
  2718 				if ((ptrNum & 1) == 0)
  2719 					{
  2720 					ptrPos = win1PtrPos;
  2721 					autoFocusWin = 1;
  2722 					}
  2723 				else
  2724 					{
  2725 					ptrPos = win2PtrPos;
  2726 					autoFocusWin = 0;
  2727 					}
  2728 				SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum);
  2729 				AddExpectedWsEvent(EEventFocusLost);				// Second group window losing focus 
  2730 				AddExpectedWsEvent(EEventFocusGained);				// First group window gaining focus
  2731 				if (ptrNum == iMaxDevPointers/2) // first loop
  2732 					{												
  2733 					// When ever a group window changes focus, For all the group/client windows which have 
  2734 					// registered for receiving group window changes recive EEventFocusGroupChanged
  2735 					// EEventFocusGroupChanged is sent only once in one queue
  2736 					AddExpectedWsEvent(EEventFocusGroupChanged);
  2737 					AddExpectedWsEvent(EEventFocusGroupChanged);
  2738 					}
  2739 				AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum);
  2740 
  2741 				SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum);
  2742 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, ptrNum);
  2743 				
  2744 				// These events are to clear out the pointer state
  2745 				SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum);
  2746 				AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, 0, 0, ptrNum);
  2747 				if (!iMultiPtrEventClient->CheckOrdinalPosition(autoFocusWin))
  2748 					{
  2749 					TEST(EFalse);
  2750 					Failed();
  2751 					}
  2752 				}
  2753 			break;
  2754 		default:
  2755 			iMultiPtrEventClient->DeleteGroupBlankWin();
  2756 			ResetFlushStopAS();
  2757 			break;
  2758 		}
  2759 	
  2760 	LogEventsAdded();
  2761 	}
  2762 
  2763 /**
  2764 @SYMTestCaseID			GRAPHICS-WSERV-ADVANCEDPOINTER-0015
  2765 @SYMPREQ				PREQ1226
  2766 @SYMREQ					REQ9684
  2767 @SYMTestPriority		High
  2768 @SYMTestCaseDesc		Checks Wserv supports out-of-range and pointer Enter/Exit events.
  2769 @SYMTestStatus			Implemented
  2770 
  2771 @SYMTestActions			Simulate moves and EPointer3DOutOfRange from different pointers
  2772 @SYMTestExpectedResults The received events must match the simulated pointer events
  2773 */
  2774 void CTMultiPtrEventTest::MultiPointerOutOfRangeEvents()
  2775 	{
  2776 	TLogMessageText logText;
  2777 	_LIT(KSet, "OutOfRange & Enter/Exit events: %d of 4");
  2778 	logText.AppendFormat(KSet, iEventSet);
  2779 	LOG_MESSAGE(logText);
  2780 	
  2781 	if (!iEventSet)
  2782 		{
  2783 		SetAutoFlush();
  2784 		AddExpectedWsEvent(EEventFocusGained);
  2785 		}
  2786 	iMultiPtrEventClient->EventBuffer()->SetEventCount(0);
  2787 	
  2788 	TPoint ptrPos(10,10);
  2789 	TInt proxValue = -iProximityStep; 
  2790 	switch(iEventSet++)
  2791 		{
  2792 		case 0:
  2793 			// Simulate moves and EPointer3DOutOfRange from all pointers
  2794 			iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterMove, 0);
  2795 			for (TInt ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
  2796 				{
  2797 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum);
  2798 				AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, ptrNum);
  2799 				
  2800 				SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum);
  2801 				AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, ptrNum);
  2802 				// Here I am not enabling the enter/exit events filter so not getting those 
  2803 				}
  2804 			break;
  2805 		case 1:
  2806 			// Repeat the above by enabling the enter/exit events
  2807 			iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterEnterExit, 0);
  2808 			for (TInt ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum = ptrNum+2)
  2809 				{
  2810 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum);
  2811 				AddExpectedWsEvent(EEventPointerEnter, EFalse, ptrNum);
  2812 				AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, ptrNum);
  2813 				
  2814 				SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum);
  2815 				AddExpectedWsEvent(EEventPointerExit, EFalse, ptrNum);
  2816 				AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, ptrNum);
  2817 				}
  2818 			break;
  2819 		case 2:
  2820 			// Check the moves from one window to other
  2821 			for (TInt ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum = ptrNum+2)
  2822 				{
  2823 				ptrPos.iX = 10;
  2824 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum);
  2825 				AddExpectedWsEvent(EEventPointerEnter, EFalse, ptrNum);
  2826 				AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, ptrNum);
  2827 				
  2828 				ptrPos.iX = (iMultiPtrEventClient->ParentWin()->Size().iWidth)/2 + 10;
  2829 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum);
  2830 				AddExpectedWsEvent(EEventPointerExit, EFalse, ptrNum); // move and enter of child window is filtered out
  2831 				}
  2832 			break;
  2833 		case 3:
  2834 			// Since all the pointers are now on child and when we change the pointer filter
  2835 			// wserv sends enter event to all pointers
  2836 			iMultiPtrEventClient->ChildWin()->BaseWin()->PointerFilter(EPointerFilterEnterExit, 0);
  2837 			for (TInt ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum = ptrNum+2)
  2838 				{
  2839 				AddExpectedWsEvent(EEventPointerEnter, EFalse, ptrNum);
  2840 				}
  2841 			for (TInt ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum = ptrNum+2)
  2842 				{
  2843 				ptrPos.iX = ptrPos.iY =10;
  2844 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum);
  2845 				AddExpectedWsEvent(EEventPointerExit, EFalse, ptrNum);
  2846 				AddExpectedWsEvent(EEventPointerEnter, EFalse, ptrNum);
  2847 				AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, ptrNum);
  2848 				
  2849 				SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, 0, 0, 0, ptrNum);
  2850 				AddExpectedWsEvent(EEventPointerExit, EFalse, ptrNum);
  2851 				AddExpectedPointerEvent(TPointerEvent::EOutOfRange, ptrPos, proxValue, 0, ptrNum);
  2852 				}
  2853 			break;			
  2854 		default:
  2855 			ResetFlushStopAS();
  2856 			break;
  2857 		}
  2858 	
  2859 	LogEventsAdded();
  2860 	}
  2861 
  2862 /**
  2863 @SYMTestCaseID			GRAPHICS-WSERV-ADVANCEDPOINTER-0032
  2864 @SYMPREQ				PREQ1226
  2865 @SYMREQ					REQ9677
  2866 @SYMTestPriority		High
  2867 @SYMTestCaseDesc		Checks Wserv supports Double click events for multi pointer events.
  2868 @SYMTestStatus			Implemented
  2869 
  2870 @SYMTestActions			Simulate double click events from different pointers 			
  2871 @SYMTestExpectedResults The received events must match the simulated pointer events
  2872 */
  2873 void CTMultiPtrEventTest::DoubleClickForMultiplePointers()
  2874 	{
  2875 	// Logic involved, double click settings are global no need to test them
  2876 	// Check that double click events are sent by wserv for all pointers
  2877 	TLogMessageText logText;
  2878 	_LIT(KSet, "Double click settings and events: %d of 1");
  2879 	logText.AppendFormat(KSet, iEventSet);
  2880 	LOG_MESSAGE(logText);
  2881 	
  2882 	if (!iEventSet)
  2883 		{
  2884 		SetAutoFlush();
  2885 		AddExpectedWsEvent(EEventFocusGained);
  2886 		}
  2887 	iMultiPtrEventClient->EventBuffer()->SetEventCount(0);
  2888 	
  2889 	TPoint ptrPos(10,10);
  2890 	switch(iEventSet++)
  2891 		{
  2892 		case 0:
  2893 			for (TInt ptrNum = 0; ptrNum < Min(iMaxDevPointers, 7); ptrNum++)
  2894 				{
  2895 				SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum);
  2896 				SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum);
  2897 				AddExpectedPointerDownUp(ptrPos, 0, ptrNum);
  2898 				AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, EModifierDoubleClick, ptrNum);
  2899 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, ptrNum);
  2900 				}
  2901 			break;
  2902 		default:
  2903 			ResetFlushStopAS();
  2904 			break;
  2905 		}
  2906 	
  2907 	LogEventsAdded();
  2908 	}
  2909 
  2910 
  2911 /**
  2912 @SYMTestCaseID			GRAPHICS-WSERV-ADVANCEDPOINTER-0031
  2913 @SYMPREQ				PREQ1226
  2914 @SYMREQ					REQ9677
  2915 @SYMTestPriority		High
  2916 @SYMTestCaseDesc		Checks Wserv supports Virtual keyboard for multi pointer events.
  2917 @SYMTestStatus			Implemented
  2918 
  2919 @SYMTestActions			Create virtual keyboard by AddKeyRect() to a window and simulate pointer events from all pointers			
  2920 @SYMTestExpectedResults The received events must match the simulated Key events
  2921 */
  2922 void CTMultiPtrEventTest::VirtualKeyBoardForMultiplePointers()
  2923 	{
  2924 	TLogMessageText logText;
  2925 	_LIT(KSet, "VirtualKeyboard SetOfEvents: %d of 8");
  2926 	logText.AppendFormat(KSet, iEventSet);
  2927 	LOG_MESSAGE(logText);
  2928 
  2929 	// Create virtual keyboard for 8 keys on parent window
  2930 	// give a 5 pixel spacing at start/end and in between keys
  2931 	const TInt noVirtualKeys = iMaxDevPointers;
  2932 	const TInt keySpacing = 5;
  2933 	const TInt keyWidth = ((iPhysicalScreenSize.iWidth/2) - ((noVirtualKeys+1)*keySpacing))/noVirtualKeys;
  2934 	const TInt keyHeight = keyWidth/2; 
  2935 	TInt startX = keySpacing;
  2936 	const TInt baseChar ='A';
  2937 	
  2938 	if (!iEventSet)
  2939 		{
  2940 		SetAutoFlush();
  2941 		for (TInt count=0; count < noVirtualKeys; count++)
  2942 			{
  2943 			iMultiPtrEventClient->ParentWin()->BaseWin()->AddKeyRect(TRect(startX, keySpacing, startX+keyWidth, keySpacing+keyHeight), baseChar+count,EFalse);
  2944 			startX+=(keyWidth+keySpacing);
  2945 			}
  2946 		AddExpectedWsEvent(EEventFocusGained);
  2947 		}
  2948 	
  2949 	iMultiPtrEventClient->EventBuffer()->SetEventCount(0);
  2950 	TPoint ptrPos(keySpacing+(keyWidth/2), keySpacing+(keyHeight/2));
  2951 
  2952 	TInt count = 0;
  2953 	if (iEventSet < iMaxDevPointers)
  2954 		{
  2955 		for (; ptrPos.iX < (iPhysicalScreenSize.iWidth/2)-5; ptrPos.iX += (keySpacing+keyWidth), count++)
  2956 			{
  2957 			SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, iEventSet);
  2958 			AddExpectedKeyDownUp(baseChar+count);
  2959 			}
  2960 		}
  2961 	else
  2962 		{
  2963 		ResetFlushStopAS();
  2964 		}
  2965 	iEventSet++;
  2966 
  2967 	LogEventsAdded();
  2968 	}
  2969 
  2970 /**
  2971 @SYMTestCaseID			GRAPHICS-WSERV-ADVANCEDPOINTER-0021
  2972 @SYMPREQ				PREQ1226
  2973 @SYMREQ					REQ9677,REQ9683,
  2974 @SYMTestPriority		High
  2975 @SYMTestCaseDesc		Checks Wserv supports Grabbing in case of multi pointer events.
  2976 @SYMTestStatus			Implemented
  2977 
  2978 @SYMTestActions			Simulate EButton1Down events on iParentWin. Simulate Drag and Button1Up events on iChildWin.
  2979  						SetPointerGrab is called on iParentWin for first test and disabled for the second. 
  2980 @SYMTestExpectedResults The Drag and Button1Up events contain a handle to iParentWin when Grabbing active. 
  2981 						The Drag and Button1Up events contain a handle to iChildWin when Grabbing disabled.
  2982 */
  2983 void CTMultiPtrEventTest::GrabbingMultiPointerEvents()
  2984 	{
  2985 	// Test Grabbing of multi pointer events
  2986 	// 1. Test Wserv supports Grabbing in case of multi-pointer events
  2987 	// 2. Test pointer events are delivered correctly when Grabbing is disabled.
  2988 	TLogMessageText logText;
  2989 	_LIT(KSet, "GrabbingMultiPtrEvents SetOfEvents: %d of 2");
  2990 	logText.AppendFormat(KSet, iEventSet);
  2991 	LOG_MESSAGE(logText);
  2992 	
  2993 	if (!iEventSet)
  2994 		{
  2995 		SetAutoFlush();
  2996 		}
  2997 	
  2998 	iMultiPtrEventClient->EventBuffer()->SetEventCount(0);
  2999 
  3000 	TPoint ptrPos;
  3001 		
  3002 	switch(iEventSet++)
  3003 		{
  3004 		case 0:
  3005 			INFO_PRINTF1(_L("Check Wserv supports Grabbing in case of multi-pointer events"));
  3006 			// Check pointer events are delivered to the window where the EButton1Down event occured, 
  3007 			// even if subsequent events are simulated outside this window.
  3008 			AddExpectedWsEvent(EEventFocusGained);
  3009 			iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterDrag, 0);
  3010 			iMultiPtrEventClient->ParentWin()->BaseWin()->SetPointerGrab(ETrue);
  3011 			TestGrabbingForMultiPointer(ETrue);
  3012 			break;	
  3013 		case 1:
  3014 			INFO_PRINTF1(_L("Check pointer events are delivered correctly when Grabbing is disabled."));
  3015 			// Check pointer events are delivered to the window on which they occured.					
  3016 			iMultiPtrEventClient->ParentWin()->BaseWin()->SetPointerGrab(EFalse);
  3017 			TestGrabbingForMultiPointer(EFalse);
  3018 			break;	
  3019 		default:
  3020 			ResetFlushStopAS();
  3021 			break;
  3022 		}
  3023 	LogEventsAdded();
  3024 	}
  3025 
  3026 /**
  3027 @SYMTestCaseID			GRAPHICS-WSERV-ADVANCEDPOINTER-0025
  3028 @SYMPREQ				PREQ1226
  3029 @SYMREQ					REQ9677,REQ9683,
  3030 @SYMTestPriority		High
  3031 @SYMTestCaseDesc		Checks Wserv supports Filtering in case of multi pointer events.
  3032 @SYMTestStatus			Implemented
  3033 
  3034 @SYMTestActions			Simulate Move and Drag events. Add only Button1Up and Button1Down to TWsEvent buffer.
  3035    						Disable Filtering and repeat test with the addition of Move and Drag events to TWsEvent buffer. 
  3036 @SYMTestExpectedResults The received events must match the expected simulated raw events
  3037 						The received events must match the simulated raw events
  3038 */
  3039 void CTMultiPtrEventTest::FilteringMultiPointerEvents()
  3040 	{
  3041 	// Test Filtering of multi pointer events
  3042 	// 1. Test pointer move and drag events are filtered correctly by Wserv
  3043 	// 2. Test pointer events are delivered correctly when Filtered is disabled.
  3044 	TLogMessageText logText;
  3045 	_LIT(KSet, "FilteringMultiPtrEvents SetOfEvents: %d of 2");
  3046 	logText.AppendFormat(KSet, iEventSet);
  3047 	LOG_MESSAGE(logText);
  3048 	
  3049 	if (!iEventSet)
  3050 		{
  3051 		SetAutoFlush();
  3052 		}
  3053 	
  3054 	iMultiPtrEventClient->EventBuffer()->SetEventCount(0);
  3055 
  3056 	TPoint ptrPos;
  3057 		
  3058 	switch(iEventSet++)
  3059 		{
  3060 		case 0:
  3061 			INFO_PRINTF1(_L("Check pointer move and drag events are filtered with multi-pointer events"));
  3062 			// Check pointer move and drag events are filtered by Wserv
  3063 			AddExpectedWsEvent(EEventFocusGained);
  3064 			
  3065 			// Ensure default values are set i.e. Drag and Move events are filtered out and not delivered to the client.
  3066 			iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterDrag|EPointerFilterMove,
  3067 																		EPointerFilterDrag|EPointerFilterMove);
  3068 			TestFilteringForMultiPointer(ETrue);
  3069 			break;	
  3070 		case 1:
  3071 			INFO_PRINTF1(_L("Check pointer move and drag events are not filtered, with multi-pointer events, when filtering is disabled"));
  3072 			// Check move and drag events are not filtered by Wserv when filtering is disabled					
  3073 
  3074 			// Enable Drag and Move events
  3075 			iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterDrag|EPointerFilterMove, 0);
  3076 			TestFilteringForMultiPointer(EFalse);
  3077 			break;				
  3078 		default:
  3079 			ResetFlushStopAS();
  3080 			break;
  3081 		}
  3082 	LogEventsAdded();
  3083 	}
  3084 
  3085 void CTMultiPtrEventTest::SetDefaultScreenMode()
  3086 	{
  3087 	iMultiPtrEventClient->iScreen->SetAppScreenMode(0);
  3088 	TheClient->iScreen->SetAppScreenMode(0);
  3089 	iMultiPtrEventClient->iScreen->SetScreenMode(0);
  3090 	iMultiPtrEventClient->iScreen->SetCurrentRotations(0, CFbsBitGc::EGraphicsOrientationNormal);
  3091 	}
  3092 
  3093 TPoint PhysicalToLogical(TPoint aPhysicalPt, TPoint aOrigin, TSize aSize)
  3094 	{
  3095 	return PhysicalToLogical(aPhysicalPt-aOrigin, aSize);
  3096 	}
  3097 
  3098 TPoint CTMultiPtrEventTest::GetPointerPostionOnRotatedMode(TPoint aPointerPos, CFbsBitGc::TGraphicsOrientation aRotation)
  3099 	{
  3100 	if (aRotation == CFbsBitGc::EGraphicsOrientationNormal)
  3101 		{
  3102 		return aPointerPos;
  3103 		}
  3104 	else if (aRotation == CFbsBitGc::EGraphicsOrientationRotated90)
  3105 		{
  3106 		// here width is actually height in rotated mode
  3107 		return TPoint(iPhysicalScreenSize.iWidth - aPointerPos.iY - 1, aPointerPos.iX);
  3108 		}
  3109 	else if (aRotation == CFbsBitGc::EGraphicsOrientationRotated180)
  3110 		{
  3111 		return TPoint(iPhysicalScreenSize.iWidth - aPointerPos.iX - 1, iPhysicalScreenSize.iHeight - aPointerPos.iY - 1);
  3112 		}
  3113 	else if (aRotation == CFbsBitGc::EGraphicsOrientationRotated270)
  3114 		{
  3115 		// here width is actually height in rotated mode
  3116 		return TPoint(aPointerPos.iY, iPhysicalScreenSize.iHeight - aPointerPos.iX -1);
  3117 		}
  3118 	return TPoint(0,0);
  3119 	}
  3120 
  3121 /**
  3122 @SYMTestCaseID			GRAPHICS-WSERV-ADVANCEDPOINTER-0028
  3123 @SYMPREQ				PREQ1226
  3124 @SYMREQ					REQ9677, REQ9683
  3125 @SYMTestPriority		High 
  3126 @SYMTestCaseDesc		To check Wserv sends multi pointer events in Different screen modes
  3127 @SYMTestStatus			Implemented
  3128 
  3129 @SYMTestActions			Simulate multi pointer events in Different screenmodes
  3130 @SYMTestExpectedResults The received events must match the simulated raw events  
  3131 */
  3132 void CTMultiPtrEventTest::MultiPointerEventsInDiffScreenModes()
  3133 	{
  3134 	// Logic inloved, For a particular screen mode check pointer down/up, moves and drags
  3135 	// for different pointers and for different co-ordinates.
  3136 	// For each screen mode check these events on diffferent rotation that screen mode supports
  3137 	// During the last switch case increment the screenmode
  3138 	TLogMessageText logText;
  3139 	_LIT(KSet, "Multi pointer events in screenmode(%d): %d of 2");
  3140 	logText.AppendFormat(KSet, iCurrentScreenMode+1, iEventSet);
  3141 	LOG_MESSAGE(logText);
  3142 	
  3143 	TInt numScrMode = iMultiPtrEventClient->iScreen->NumScreenModes();
  3144 	iMultiPtrEventClient->EventBuffer()->SetEventCount(0);
  3145 	
  3146 	if (!iEventSet && !iChangeScreenMode)
  3147 		{
  3148 		SetAutoFlush();
  3149 		iChangeScreenMode = ETrue;
  3150 		AddExpectedWsEvent(EEventFocusGained);
  3151 		}
  3152 	else
  3153 		{
  3154 		if (iChangeScreenMode)
  3155 			{
  3156 			if (iCurrentScreenMode >= numScrMode)
  3157 				{
  3158 EndFun:
  3159 				SetDefaultScreenMode();
  3160 				ResetFlushStopAS();
  3161 				return;
  3162 				}
  3163 			}
  3164 		}
  3165 
  3166 	if (iChangeScreenMode)
  3167 		{
  3168 		iMultiPtrEventClient->iScreen->SetAppScreenMode(iCurrentScreenMode);
  3169 		TheClient->iScreen->SetAppScreenMode(iCurrentScreenMode);
  3170 		iMultiPtrEventClient->iScreen->SetScreenMode(iCurrentScreenMode);
  3171 		iChangeScreenMode = EFalse;
  3172 		}
  3173 	
  3174 	CArrayFixFlat<TInt>* rotations = NULL;
  3175 	TRAPD(err, 
  3176 			rotations = new(ELeave) CArrayFixFlat<TInt>(1);
  3177 			iMultiPtrEventClient->iScreen->GetRotationsList(iCurrentScreenMode, rotations));
  3178 	if (err != KErrNone)
  3179 		{
  3180 		if (iEventSet)
  3181 			{
  3182 			goto EndFun;
  3183 			}
  3184 		else
  3185 			{
  3186 			return;
  3187 			}
  3188 		}
  3189 
  3190 #if !defined(__WINS__)	
  3191 	TPoint ptrRotatedPos;
  3192 	TPoint ptrNormalPos;
  3193 #else
  3194 	TPoint ptrPhyPos;
  3195 #endif
  3196 	TPoint ptrLogPos;	
  3197 	
  3198 	TInt ptrNum = 0;
  3199 	TInt proxValue = 0;
  3200 	// Since screenmode positioning and screenmode scaling is not supported in NGA wserv2
  3201 	// but it is supported in Non NGA. But for NGA it will return (0,0) as origin and (1,1) as scale.
  3202 	TPoint screenOrigin(iMultiPtrEventClient->iScreen->GetDefaultScreenModeOrigin());
  3203 	TPoint scaledScreenOrigin(iMultiPtrEventClient->iScreen->GetCurrentScreenModeScaledOrigin());
  3204 	TSize scale(iMultiPtrEventClient->iScreen->GetCurrentScreenModeScale());
  3205 	
  3206 	switch(iEventSet++)
  3207 		{
  3208 		case 0:
  3209 			// Simulate Pointer down/up for different rotations of a screenmode
  3210 			for (TInt rotCou = 0; rotCou < rotations->Count(); rotCou++)
  3211 				{
  3212 				CFbsBitGc::TGraphicsOrientation newOrientation = static_cast<CFbsBitGc::TGraphicsOrientation>(rotations[0][rotCou]);
  3213 				iMultiPtrEventClient->iScreen->SetCurrentRotations(iCurrentScreenMode, newOrientation);
  3214 				
  3215 #if !defined(__WINS__)
  3216 				ptrNormalPos = screenOrigin;
  3217 				ptrRotatedPos = GetPointerPostionOnRotatedMode(ptrNormalPos, newOrientation);
  3218 				SimulatePointerDownUp(ptrRotatedPos.iX, ptrRotatedPos.iY, 0, ptrNum);
  3219 				ptrLogPos = PhysicalToLogical(ptrNormalPos, screenOrigin, scale);				
  3220 				AddExpectedPointerDownUp(ptrLogPos, 0, ptrNum);
  3221 				
  3222 				ptrNormalPos.iX += 10;
  3223 				ptrNormalPos.iY += 5;
  3224 				ptrNum = iMaxDevPointers/2;
  3225 				ptrRotatedPos = GetPointerPostionOnRotatedMode(ptrNormalPos, newOrientation);
  3226 				SimulatePointerDownUp(ptrRotatedPos.iX, ptrRotatedPos.iY, 0, ptrNum);
  3227 				ptrLogPos = PhysicalToLogical(ptrNormalPos, screenOrigin, scale);				
  3228 				AddExpectedPointerDownUp(ptrLogPos, 0, ptrNum);
  3229 				
  3230 				ptrNormalPos.iX += 5;
  3231 				ptrNormalPos.iY += 10;
  3232 				ptrNum = iMaxDevPointers-1;
  3233 				ptrRotatedPos = GetPointerPostionOnRotatedMode(ptrNormalPos, newOrientation);
  3234 				SimulatePointerDownUp(ptrRotatedPos.iX, ptrRotatedPos.iY, 0, ptrNum);
  3235 				ptrLogPos = PhysicalToLogical(ptrNormalPos, screenOrigin, scale);				
  3236 				AddExpectedPointerDownUp(ptrLogPos, 0, ptrNum);
  3237 				ptrNum = 0;
  3238 #else
  3239 				// This is not needed for NGA, becasue NGA wserv does not support positioning and scaling 
  3240 				// but for early access we are deliverying for NonNGA so we need it. 
  3241 				ptrPhyPos = screenOrigin;
  3242 				ptrLogPos = PhysicalToLogical(ptrPhyPos, screenOrigin, scale);
  3243 				SimulatePointerDownUp(ptrPhyPos.iX, ptrPhyPos.iY, 0, ptrNum);
  3244 				AddExpectedPointerDownUp(ptrLogPos, 0, ptrNum);
  3245 				ptrPhyPos.iX += 10;
  3246 				ptrPhyPos.iY += 5;
  3247 				ptrNum = iMaxDevPointers/2;
  3248 				ptrLogPos = PhysicalToLogical(ptrPhyPos, screenOrigin, scale);
  3249 				SimulatePointerDownUp(ptrPhyPos.iX, ptrPhyPos.iY, 0, ptrNum);
  3250 				AddExpectedPointerDownUp(ptrLogPos, 0, ptrNum);
  3251 				ptrPhyPos.iX += 5;
  3252 				ptrPhyPos.iY += 10;
  3253 				ptrNum = iMaxDevPointers-1;
  3254 				ptrLogPos = PhysicalToLogical(ptrPhyPos, screenOrigin, scale);
  3255 				SimulatePointerDownUp(ptrPhyPos.iX, ptrPhyPos.iY, 0, ptrNum);
  3256 				AddExpectedPointerDownUp(ptrLogPos, 0, ptrNum);
  3257 				ptrNum = 0;
  3258 #endif
  3259 				}
  3260 			break;
  3261 		case 1:
  3262 			// Simulate moves for different rotations of a screenmode with different Proximity
  3263 			iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterMove,0);
  3264 			for (TInt rotCou = 0; rotCou < rotations->Count(); rotCou++)
  3265 				{
  3266 				CFbsBitGc::TGraphicsOrientation newOrientation = static_cast<CFbsBitGc::TGraphicsOrientation>(rotations[0][rotCou]);
  3267 				iMultiPtrEventClient->iScreen->SetCurrentRotations(iCurrentScreenMode, newOrientation);
  3268 				
  3269 #if !defined(__WINS__)				
  3270 				ptrNormalPos = screenOrigin;
  3271 				ptrRotatedPos = GetPointerPostionOnRotatedMode(ptrNormalPos, newOrientation);
  3272 				proxValue = -iProximityStep;
  3273 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrRotatedPos.iX, ptrRotatedPos.iY, proxValue, ptrNum);
  3274 				ptrLogPos = PhysicalToLogical(ptrNormalPos, screenOrigin, scale);			
  3275 				AddExpectedPointerEvent(TPointerEvent::EMove, ptrLogPos, proxValue, 0, ptrNum);
  3276 				SimulatePointerDownUp(ptrRotatedPos.iX, ptrRotatedPos.iY, 0, ptrNum);
  3277 				AddExpectedPointerDownUp(ptrLogPos, 0, ptrNum);
  3278 				
  3279 				ptrNormalPos.iX += 10;
  3280 				ptrNormalPos.iY += 5;
  3281 				ptrNum = iMaxDevPointers/2;
  3282 				if (proxValue-iProximityStep > iMaxProximity)
  3283 					{
  3284 					proxValue -= iProximityStep;
  3285 					}
  3286 				ptrRotatedPos = GetPointerPostionOnRotatedMode(ptrNormalPos, newOrientation);
  3287 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrRotatedPos.iX, ptrRotatedPos.iY, proxValue, ptrNum);
  3288 				ptrLogPos = PhysicalToLogical(ptrNormalPos, screenOrigin, scale);								
  3289 				AddExpectedPointerEvent(TPointerEvent::EMove, ptrLogPos, proxValue, 0, ptrNum);
  3290 				SimulatePointerDownUp(ptrRotatedPos.iX, ptrRotatedPos.iY, 0, ptrNum);
  3291 				AddExpectedPointerDownUp(ptrLogPos, 0, ptrNum);
  3292 				ptrNum = 0;
  3293 #else
  3294 				ptrPhyPos = screenOrigin;
  3295 				proxValue = -iProximityStep;
  3296 				ptrLogPos = PhysicalToLogical(ptrPhyPos, screenOrigin, scale);
  3297 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPhyPos.iX, ptrPhyPos.iY, proxValue, ptrNum);
  3298 				AddExpectedPointerEvent(TPointerEvent::EMove, ptrLogPos, proxValue, 0, ptrNum);
  3299 				SimulatePointerDownUp(ptrPhyPos.iX, ptrPhyPos.iY, 0, ptrNum);
  3300 				AddExpectedPointerDownUp(ptrLogPos, 0, ptrNum);
  3301 				
  3302 				ptrPhyPos.iX += 10;
  3303 				ptrPhyPos.iY += 5;
  3304 				ptrNum = iMaxDevPointers/2;
  3305 				if (proxValue-iProximityStep > iMaxProximity)
  3306 					{
  3307 					proxValue -= iProximityStep;
  3308 					}
  3309 				ptrLogPos = PhysicalToLogical(ptrPhyPos, screenOrigin, scale);
  3310 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPhyPos.iX, ptrPhyPos.iY, proxValue, ptrNum);
  3311 				AddExpectedPointerEvent(TPointerEvent::EMove, ptrLogPos, proxValue, 0, ptrNum);
  3312 				SimulatePointerDownUp(ptrPhyPos.iX, ptrPhyPos.iY, 0, ptrNum);
  3313 				AddExpectedPointerDownUp(ptrLogPos, 0, ptrNum);
  3314 				ptrNum = 0;
  3315 #endif
  3316 				}
  3317 			break;
  3318 		case 2:
  3319 			{
  3320 			// Simulate drags for different rotations of a screenmode
  3321 #if !defined(__WINS__)
  3322 			TPoint intNormalPt;
  3323 			TPoint intRotatedPt;
  3324 #else
  3325 			TPoint interPhyPt;
  3326 			TPoint interLogPt;
  3327 #endif			
  3328 			iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterDrag,0);
  3329 			for (TInt rotCou = 0; rotCou < rotations->Count(); rotCou++)
  3330 				{
  3331 				CFbsBitGc::TGraphicsOrientation newOrientation = static_cast<CFbsBitGc::TGraphicsOrientation>(rotations[0][rotCou]);
  3332 				iMultiPtrEventClient->iScreen->SetCurrentRotations(iCurrentScreenMode, newOrientation);
  3333 #if !defined(__WINS__)				
  3334 				ptrNormalPos = screenOrigin;
  3335 				intNormalPt.iX = ptrNormalPos.iX+4;
  3336 				intNormalPt.iY = ptrNormalPos.iY+5;
  3337 				ptrRotatedPos = GetPointerPostionOnRotatedMode(ptrNormalPos, newOrientation);
  3338 				intRotatedPt = GetPointerPostionOnRotatedMode(intNormalPt, newOrientation);				
  3339 				SimulatePointerEvent(TRawEvent::EButton1Down, ptrRotatedPos.iX, ptrRotatedPos.iY, 0, ptrNum);
  3340 				SimulatePointerEvent(TRawEvent::EPointerMove, intRotatedPt.iX, intRotatedPt.iY, 0, ptrNum);
  3341 				SimulatePointerEvent(TRawEvent::EButton1Up, intRotatedPt.iX, intRotatedPt.iY, 0, ptrNum);
  3342 				ptrLogPos = PhysicalToLogical(ptrNormalPos, screenOrigin, scale);				
  3343 				AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrLogPos, 0, 0, ptrNum);
  3344 				TPoint intLogPt = PhysicalToLogical(intNormalPt, screenOrigin, scale);				
  3345 				AddExpectedPointerEvent(TPointerEvent::EDrag, intLogPt, 0, 0, ptrNum);
  3346 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, intLogPt, 0, 0, ptrNum);
  3347 				
  3348 				ptrNormalPos.iX += 10;
  3349 				ptrNormalPos.iY += 5;
  3350 				ptrNum = iMaxDevPointers-1;
  3351 				intNormalPt.iX = ptrNormalPos.iX+5;
  3352 				intNormalPt.iY = ptrNormalPos.iY+4;
  3353 				ptrRotatedPos = GetPointerPostionOnRotatedMode(ptrNormalPos, newOrientation);
  3354 				intRotatedPt = GetPointerPostionOnRotatedMode(intNormalPt, newOrientation);
  3355 				SimulatePointerEvent(TRawEvent::EButton1Down, ptrRotatedPos.iX, ptrRotatedPos.iY, 0, ptrNum);
  3356 				SimulatePointerEvent(TRawEvent::EPointerMove, intRotatedPt.iX, intRotatedPt.iY, 0, ptrNum);
  3357 				SimulatePointerEvent(TRawEvent::EButton1Up, intRotatedPt.iX, intRotatedPt.iY, 0, ptrNum);
  3358 				ptrLogPos = PhysicalToLogical(ptrNormalPos, screenOrigin, scale);
  3359 				AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrLogPos, 0, 0, ptrNum);
  3360 				intLogPt = PhysicalToLogical(intNormalPt, screenOrigin, scale);
  3361 				AddExpectedPointerEvent(TPointerEvent::EDrag, intLogPt, 0, 0, ptrNum);
  3362 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, intLogPt, 0, 0, ptrNum);
  3363 
  3364 				ptrNum = 0;
  3365 #else
  3366 				ptrPhyPos = screenOrigin;
  3367 				interPhyPt.iX = ptrPhyPos.iX+4;
  3368 				interPhyPt.iY = ptrPhyPos.iY+5;
  3369 				ptrLogPos = PhysicalToLogical(ptrPhyPos, screenOrigin, scale);
  3370 				interLogPt = PhysicalToLogical(interPhyPt, screenOrigin, scale);
  3371 				SimulatePointerEvent(TRawEvent::EButton1Down, ptrPhyPos.iX, ptrPhyPos.iY, 0, ptrNum);
  3372 				SimulatePointerEvent(TRawEvent::EPointerMove, interPhyPt.iX, interPhyPt.iY, 0, ptrNum);
  3373 				SimulatePointerEvent(TRawEvent::EButton1Up, interPhyPt.iX, interPhyPt.iY, 0, ptrNum);
  3374 				interLogPt = PhysicalToLogical(interPhyPt, screenOrigin, scale);
  3375 				AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrLogPos, 0, 0, ptrNum);
  3376 				AddExpectedPointerEvent(TPointerEvent::EDrag, interLogPt, 0, 0, ptrNum);
  3377 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, interLogPt, 0, 0, ptrNum);
  3378 				
  3379 				ptrPhyPos.iX += 10;
  3380 				ptrPhyPos.iY += 5;
  3381 				ptrNum = iMaxDevPointers-1;
  3382 				interPhyPt.iX = ptrPhyPos.iX+5;
  3383 				interPhyPt.iY = ptrPhyPos.iY+4;
  3384 				
  3385 				SimulatePointerEvent(TRawEvent::EButton1Down, ptrPhyPos.iX, ptrPhyPos.iY, 0, ptrNum);
  3386 				SimulatePointerEvent(TRawEvent::EPointerMove, interPhyPt.iX, interPhyPt.iY, 0, ptrNum);
  3387 				SimulatePointerEvent(TRawEvent::EButton1Up, interPhyPt.iX, interPhyPt.iY, 0, ptrNum);
  3388 				
  3389 				ptrLogPos = PhysicalToLogical(ptrPhyPos, screenOrigin, scale);
  3390 				interLogPt = PhysicalToLogical(interPhyPt, screenOrigin, scale);
  3391 				AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrLogPos, 0, 0, ptrNum);
  3392 				AddExpectedPointerEvent(TPointerEvent::EDrag, interLogPt, 0, 0, ptrNum);
  3393 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, interLogPt, 0, 0, ptrNum);
  3394 				ptrNum = 0;
  3395 #endif
  3396 				}
  3397 			}
  3398 			iChangeScreenMode = ETrue;
  3399 			iEventSet = 0;
  3400 			iCurrentScreenMode++;
  3401 			break;
  3402 		default:
  3403 			break;
  3404 		}
  3405 	
  3406 	delete rotations;
  3407 	
  3408 	LogEventsAdded();
  3409 	}
  3410 
  3411 /* 
  3412  Checks if pointer click plugin has an error when testing its events
  3413  If so then it gets the error deescription and displays the same
  3414  */
  3415 void CTMultiPtrEventTest::TestAndDisplayPtrClickError()
  3416 	{
  3417 	TPckgBuf<TInt> intPkg;
  3418 	TInt retErr = iClick.CommandReply(EMultiPtrClickEventError, intPkg);
  3419 	if (retErr != KErrNone)
  3420 		{
  3421 		_LIT(KError, "Failed in Pointer click plugin");
  3422 		LOG_MESSAGE(KError);
  3423 		// Error is ignored here, becasue this function should not leave
  3424 		TRAPD(errMem, iErrDesc = iHeap->AllocL(KErrDescSize));
  3425 		if (errMem == KErrNone)
  3426 			{
  3427 			intPkg() = reinterpret_cast<TUint8*>(iErrDesc) - iChunk.Base() ;
  3428 			
  3429 			// get the error desccription, print it out and stop the tests
  3430 			TInt retVal = iClick.CommandReply(EADllMultiPtrEventErrorDesc, intPkg);
  3431 			if (retVal > KErrNone)
  3432 				{
  3433 				TPtr8 memPtr2(reinterpret_cast<TUint8*>(iErrDesc), retVal, retVal);
  3434 				HBufC16* buf16 = NULL;
  3435 				TRAPD(err, buf16 = HBufC16::NewL(retVal));		// Error is ignored here
  3436 				if (err == KErrNone)
  3437 					{
  3438 					buf16->Des().Copy(memPtr2);
  3439 					LOG_MESSAGE(buf16->Des());
  3440 					delete buf16;
  3441 					}
  3442 				}
  3443 			iHeap->Free(iErrDesc);
  3444 			}
  3445 		Failed();
  3446 		}
  3447 	iClick.CommandReply(EMultiPtrClickEventReset, intPkg);
  3448 	}
  3449 
  3450 void CTMultiPtrEventTest::AddExpectedMultiPtrClickEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle)
  3451 	{
  3452 	TPckgBuf<TWsEvent> evtPkg;
  3453 	TWsEvent& event=evtPkg();
  3454 	event.SetType(EEventPointer);
  3455 	iMultiPtrEventClient->CalculatePtrPosAndSet3Ddata(event, aType, aPos, aModifier, aZ, aPointerNumber, aHandle);
  3456 	
  3457 	// change the parent position here as they r with respect to screen corodinates.
  3458 	event.Pointer()->iParentPosition = aPos;
  3459 	
  3460 	iClick.CommandReply(EMultiPtrClickEventAdd, evtPkg);
  3461 	AddExpectedMultiPtrClickOtherEvent(aType, aPos, aZ, aModifier, aPointerNumber, aHandle);
  3462 	}
  3463 
  3464 void CTMultiPtrEventTest::AddExpectedMultiPtrClickOtherEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle)
  3465 	{
  3466 	TWsEvent event;
  3467 	event.SetType(EEventPointer);
  3468 	iMultiPtrEventClient->CalculatePtrPosAndSet3Ddata(event, aType, aPos, aModifier, aZ, aPointerNumber, aHandle);
  3469 
  3470 	TPointerEventData otherEvent;
  3471 	otherEvent.iClientHandle = event.Handle();
  3472 	otherEvent.iCurrentPos = aPos;
  3473 	otherEvent.iPointerEvent = *event.Pointer();
  3474 	
  3475 	TPckgBuf<TPointerEventData> evtPkg(otherEvent);
  3476 	iClick.CommandReply(EMultiPtrOtherEventAdd, evtPkg);
  3477 	}
  3478 
  3479 /* 
  3480  Function of creating 
  3481  1. Pointer click plugin
  3482  2. RChunk for transfering error description from pointer click plugin to current test
  3483  3. RHeap for allocating memory in RChunk
  3484 */
  3485 void CTMultiPtrEventTest::CreatePointerClickPluginL()
  3486 	{
  3487 	// tranfer this to another function
  3488 	iClick=RSoundPlugIn(TheClient->iWs);
  3489 	User::LeaveIfError(iClick.Construct(TUid::Uid(MULTIPTR_CLICK_THIRD_UID)));
  3490 	TBool ptrPluginLoadable = EFalse;
  3491 	iClick.IsLoaded(ptrPluginLoadable);
  3492 	if (ptrPluginLoadable)
  3493 		{
  3494 		User::LeaveIfError(iClick.Load(KMultiPtrPluginDll));
  3495 		iPtrPluginLoaded = ETrue;
  3496 		}
  3497 	iClick.SetPenClick(ETrue);
  3498 	iHeap = UserHeap::ChunkHeap(&KMultiPtrClickChunk, 128, 256, 10);
  3499 	if (iHeap == NULL)
  3500 		{
  3501 		User::LeaveNoMemory();
  3502 		}
  3503 	User::LeaveIfError(iChunk.OpenGlobal(KMultiPtrClickChunk, ETrue));
  3504 	}
  3505 
  3506 /**
  3507 @SYMTestCaseID			GRAPHICS-WSERV-ADVANCEDPOINTER-0027
  3508 @SYMPREQ				PREQ1226
  3509 @SYMREQ					REQ9677, REQ9683
  3510 @SYMTestPriority		High 
  3511 @SYMTestCaseDesc		To check Wserv sends multi pointer events to PointerClickPlugin
  3512 @SYMTestStatus			Implemented
  3513 
  3514 @SYMTestActions			Simulate multi pointer events for PointerClickPlugin
  3515 @SYMTestExpectedResults The received events must match the simulated raw events  
  3516 */
  3517 void CTMultiPtrEventTest::MultiPointerEventsForPointerClickL()
  3518 	{
  3519 	TLogMessageText logText;
  3520 	_LIT(KSet, "Multi pointer events for PointerClickPlugin: %d of 4");
  3521 	logText.AppendFormat(KSet, iEventSet);
  3522 	LOG_MESSAGE(logText);
  3523 	
  3524 	iMultiPtrEventClient->EventBuffer()->SetEventCount(0);
  3525 	if (!iEventSet)
  3526 		{
  3527 		SetAutoFlush();
  3528 		}
  3529 	
  3530 	TPoint ptrPos;
  3531 	TInt ptrNum = 0;
  3532 	TInt prValue = 0;
  3533 	TInt proxValue = 0;
  3534 	TInt xInc = iPhysicalScreenSize.iWidth/iMaxDevPointers;
  3535 	TInt yInc = iPhysicalScreenSize.iHeight/iMaxDevPointers;
  3536  	
  3537 	switch(iEventSet++)
  3538 		{
  3539 		case 0:
  3540 			// Creates RSoundPlugin, loads the plugin DLL, create RChunk and RHeap
  3541 			CreatePointerClickPluginL();
  3542 			AddExpectedWsEvent(EEventFocusGained);
  3543 			for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
  3544 				{
  3545 				AddExpectedMultiPtrClickEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum);
  3546 				AddExpectedMultiPtrClickEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, ptrNum);
  3547 				AddExpectedPointerDownUp(ptrPos, 0, ptrNum);
  3548 				SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum);
  3549 				ptrPos.iX += xInc;
  3550 				ptrPos.iY += yInc;
  3551 				}
  3552 			TestAndDisplayPtrClickError();
  3553 			break;
  3554 		case 1:
  3555 			// Simulate moves from different pointer with different pressure
  3556 			iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterMove,0);
  3557 			iMultiPtrEventClient->ChildWin()->BaseWin()->PointerFilter(EPointerFilterMove,0);
  3558 			ptrPos.SetXY(0,0);
  3559 			prValue = iPressureStep;
  3560 			for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
  3561 				{
  3562 				AddExpectedMultiPtrClickEvent(TPointerEvent::EMove, ptrPos, prValue, 0, ptrNum);
  3563 				AddExpectedMultiPtrClickEvent(TPointerEvent::EButton1Down,ptrPos,0,0,ptrNum);
  3564 				AddExpectedMultiPtrClickEvent(TPointerEvent::EButton1Up,ptrPos,0,0,ptrNum);
  3565 				AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, prValue, 0, ptrNum);
  3566 				AddExpectedPointerDownUp(ptrPos, 0, ptrNum);
  3567 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum);
  3568 				SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum);
  3569 				ptrPos.iX += xInc;
  3570 				ptrPos.iY += yInc;
  3571 				}
  3572 			TestAndDisplayPtrClickError();
  3573 			break;
  3574 		case 2:
  3575 			// Simulate moves from different pointer with different proximity
  3576 			ptrPos.SetXY(0,0);
  3577 			proxValue = -iProximityStep;
  3578 			for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
  3579 				{
  3580 				AddExpectedMultiPtrClickEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, ptrNum);
  3581 				AddExpectedMultiPtrClickEvent(TPointerEvent::EButton1Down,ptrPos,0,0,ptrNum);
  3582 				AddExpectedMultiPtrClickEvent(TPointerEvent::EButton1Up,ptrPos,0,0,ptrNum);
  3583 				AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, ptrNum);
  3584 				AddExpectedPointerDownUp(ptrPos, 0, ptrNum);
  3585 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum);
  3586 				SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum);
  3587 				ptrPos.iX += xInc;
  3588 				ptrPos.iY += yInc;
  3589 				}
  3590 			TestAndDisplayPtrClickError();
  3591 			break;
  3592 		case 3:
  3593 			{
  3594 			// Simulate drags from all pointers
  3595 			iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterDrag,0);
  3596 			iMultiPtrEventClient->ChildWin()->BaseWin()->PointerFilter(EPointerFilterDrag,0);
  3597 			ptrPos.SetXY(0,0);
  3598 			TPoint interPt;
  3599 			for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
  3600 				{
  3601 				AddExpectedMultiPtrClickEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum);
  3602 				interPt.iX = ptrPos.iX+1;
  3603 				interPt.iY = ptrPos.iY+2;
  3604 				AddExpectedMultiPtrClickEvent(TPointerEvent::EDrag, interPt, 0, 0, ptrNum);
  3605 				AddExpectedMultiPtrClickEvent(TPointerEvent::EButton1Up, interPt, 0, 0, ptrNum);
  3606 				
  3607 				AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum);
  3608 				AddExpectedPointerEvent(TPointerEvent::EDrag, interPt, 0, 0, ptrNum);
  3609 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, interPt, 0, 0, ptrNum);
  3610 				
  3611 				SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum);
  3612 				SimulatePointerEvent(TRawEvent::EPointerMove, interPt.iX, interPt.iY, 0, ptrNum);
  3613 				SimulatePointerEvent(TRawEvent::EButton1Up, interPt.iX, interPt.iY, 0, ptrNum);
  3614 				
  3615 				ptrPos.iX += xInc;
  3616 				ptrPos.iY += yInc;
  3617 				}
  3618 			TestAndDisplayPtrClickError();
  3619 			}
  3620 			break;
  3621 		default:
  3622 			iClick.Unload();
  3623 			iClick.Close();
  3624 			iPtrPluginLoaded = EFalse;
  3625 			iHeap->Close();
  3626 			iHeap = NULL;
  3627 			iChunk.Close();
  3628 			ResetFlushStopAS();
  3629 			break;
  3630 		}
  3631 
  3632 	LogEventsAdded();
  3633 	}
  3634 
  3635 void CTMultiPtrEventTest::GetRemainingEventsFromSecondaryClient()
  3636 	{
  3637 	if (iSecMultiPtrEventClient->EventBuffer()->EventsRemaining() != 0)
  3638 		{
  3639 		iSecMultiPtrEventClient->EventBuffer()->SetNestedLoopState(ETrue);
  3640 		CActiveScheduler::Start();
  3641 		}	
  3642 	}
  3643 
  3644 /**
  3645 @SYMTestCaseID			GRAPHICS-WSERV-ADVANCEDPOINTER-0011
  3646 @SYMPREQ				PREQ1226
  3647 @SYMREQ					REQ9677,REQ9674,
  3648 @SYMTestPriority		High 
  3649 @SYMTestCaseDesc		To check Wserv sends Multi Pointer events to correct clients
  3650 @SYMTestStatus			Implemented
  3651 
  3652 @SYMTestActions			Simulate multi pointer events on windows from different client.
  3653 @SYMTestExpectedResults The received events must match the simulated raw events 
  3654 */
  3655 void CTMultiPtrEventTest::MultiClientMultiPointerEvents()
  3656 	{
  3657 	// Logic for this test code
  3658 	// Create a secondary client when running this test
  3659 	// Simulate events for both main client and secondary simulataneously
  3660 	// Get events from DoRunL() of event buffer class
  3661 	// Before running next set of events, get all the events from secondary client
  3662 	// If test fails on any client make sure both active scheduler are stopped
  3663 	TLogMessageText logText;
  3664 	_LIT(KSet, "Multi pointer events for Multi client: %d of 5");
  3665 	logText.AppendFormat(KSet, iEventSet);
  3666 	LOG_MESSAGE(logText);
  3667 	
  3668 	iMultiPtrEventClient->EventBuffer()->SetEventCount(0);
  3669 	iSecMultiPtrEventClient->EventBuffer()->SetEventCount(0);
  3670 	if (!iEventSet)
  3671 		{
  3672 		SetAutoFlush();
  3673 		iSecClientFlush = iSecMultiPtrEventClient->iWs.SetAutoFlush(ETrue);
  3674 		}
  3675 	
  3676 	TPoint ptrPos;
  3677 	TInt ptrNum = 0;
  3678 	TInt prValue = 0;
  3679 	TInt proxValue = 0;
  3680 	TInt xInc = (iPhysicalScreenSize.iWidth/2)/iMaxDevPointers;
  3681 	TInt yInc = iPhysicalScreenSize.iHeight/iMaxDevPointers;
  3682 	TPoint secPt(iPhysicalScreenSize.iWidth/2,0);
  3683 	TInt ptrSecNum = iMaxDevPointers-1;
  3684  	
  3685 	switch(iEventSet++)
  3686 		{
  3687 		case 0:
  3688 			ptrPos.SetXY(0,0);
  3689 			
  3690 			// These events are generated when primary client is created and its group 
  3691 			// window constructed and then when button down for primary client is called
  3692 			AddExpectedWsEvent(EEventFocusGained);
  3693 			AddExpectedWsEvent(EEventFocusLost);
  3694 			AddExpectedWsEvent(EEventFocusGained);
  3695 			
  3696 			// Simulate pointer down/up events for primary client from 0,1,3... pointers and 6,5,4... pointers for secondary client
  3697 			for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  3698 				{
  3699 				SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum);
  3700 				AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum);
  3701 							
  3702 				SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum);
  3703 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, ptrNum);
  3704 				
  3705 				ptrPos.iX += xInc;
  3706 				ptrPos.iY += yInc;
  3707 				}
  3708 			
  3709 			ptrPos.iX = iPhysicalScreenSize.iWidth/2;
  3710 			ptrPos.iY = 0;
  3711 			
  3712 			// These events are generated when secondary cleint is created and then when
  3713 			// button down for primary client is called, then when SetOrdinalPosition is 
  3714 			// called on secondary cleint's group window
  3715 			AddExpectedWsEvent(EEventFocusGained, ETrue);
  3716 			AddExpectedWsEvent(EEventFocusLost, ETrue);
  3717 			iSecMultiPtrEventClient->iGroup->GroupWin()->SetOrdinalPosition(0, 1);
  3718 			AddExpectedWsEvent(EEventFocusGained, ETrue);
  3719 
  3720 			AddExpectedWsEvent(EEventFocusLost);
  3721 			
  3722 			for (ptrNum = iMaxDevPointers/2; ptrNum < iMaxDevPointers; ptrNum++)
  3723 				{
  3724 				SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum);
  3725 				AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum, (TUint)iSecMultiPtrEventClient->ParentWin(), ETrue);
  3726 							
  3727 				SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum);
  3728 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, ptrNum, (TUint)iSecMultiPtrEventClient->ParentWin(), ETrue);
  3729 				
  3730 				ptrPos.iX += xInc;
  3731 				ptrPos.iY += yInc;
  3732 				}
  3733 			break;
  3734 		case 1:
  3735 			// Simulate move events from primary and secondary client simultaneously with pressure
  3736 			iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterMove, 0);
  3737 			iSecMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterMove, 0);
  3738 			
  3739 			ptrPos.SetXY(0,0);
  3740 			prValue = iPressureStep;
  3741 				
  3742 			for (ptrNum = 0; (ptrNum < iMaxDevPointers/2 && ptrSecNum >= iMaxDevPointers/2); ptrNum++, ptrSecNum--)
  3743 				{
  3744 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum);
  3745 				AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, prValue, 0, ptrNum);
  3746 				ptrPos.iX += xInc;
  3747 				ptrPos.iY += yInc;
  3748 				
  3749 				SimulatePointerEvent(TRawEvent::EPointerMove, secPt.iX, secPt.iY, prValue, ptrSecNum);
  3750 				AddExpectedPointerEvent(TPointerEvent::EMove, secPt, prValue, 0, ptrSecNum, (TUint)iSecMultiPtrEventClient->ParentWin(), ETrue);
  3751 				secPt.iX += xInc;
  3752 				secPt.iY += yInc;
  3753 				}
  3754 			break;
  3755 		case 2:
  3756 			// Simulate move events from primary and secondary client simultaneously with proximity
  3757 			ptrPos.SetXY(0,0);
  3758 			proxValue = -iProximityStep;
  3759 			
  3760 			for (ptrNum = 0; (ptrNum < iMaxDevPointers/2 && ptrSecNum >= iMaxDevPointers/2); ptrNum++, ptrSecNum--)
  3761 				{
  3762 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum);
  3763 				AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, ptrNum);
  3764 				ptrPos.iX += xInc;
  3765 				ptrPos.iY += yInc;
  3766 				
  3767 				SimulatePointerEvent(TRawEvent::EPointerMove, secPt.iX, secPt.iY, proxValue, ptrSecNum);
  3768 				AddExpectedPointerEvent(TPointerEvent::EMove, secPt, proxValue, 0, ptrSecNum, (TUint)iSecMultiPtrEventClient->ParentWin(), ETrue);
  3769 				secPt.iX += xInc;
  3770 				secPt.iY += yInc;
  3771 				}
  3772 			break;
  3773 		case 3:
  3774 			{
  3775 			// Simulate drag events on different clients window one after the other 
  3776 			iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterDrag, 0);
  3777 			iSecMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterDrag, 0);
  3778 			
  3779 			ptrPos.SetXY(0,0);
  3780 			secPt.iX = iPhysicalScreenSize.iWidth/2;
  3781 			secPt.iY = 0; 
  3782 			ptrSecNum = iMaxDevPointers-1;
  3783 			TPoint interPt;
  3784 			for (ptrNum = 0; (ptrNum < iMaxDevPointers/2 && ptrSecNum >= iMaxDevPointers/2); ptrNum++, ptrSecNum--)
  3785 				{
  3786 				SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum);
  3787 				AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum);
  3788 				interPt.iX = ptrPos.iX+2;
  3789 				interPt.iY = ptrPos.iY+1;
  3790 				SimulatePointerEvent(TRawEvent::EPointerMove, interPt.iX, interPt.iY, 0, ptrNum);
  3791 				AddExpectedPointerEvent(TPointerEvent::EDrag, interPt, 0, 0, ptrNum);
  3792 				SimulatePointerEvent(TRawEvent::EButton1Up, interPt.iX, interPt.iY, 0, ptrNum);
  3793 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, interPt, 0, 0, ptrNum);
  3794 				ptrPos.iX += xInc;
  3795 				ptrPos.iY += yInc;
  3796 				
  3797 				SimulatePointerEvent(TRawEvent::EButton1Down, secPt.iX, secPt.iY, 0, ptrSecNum);
  3798 				AddExpectedPointerEvent(TPointerEvent::EButton1Down, secPt, 0, 0, ptrSecNum, (TUint)iSecMultiPtrEventClient->ParentWin(), ETrue);
  3799 				interPt.iX = secPt.iX+2;
  3800 				interPt.iY = secPt.iY+1;
  3801 				SimulatePointerEvent(TRawEvent::EPointerMove, interPt.iX, interPt.iY, 0, ptrSecNum);
  3802 				AddExpectedPointerEvent(TPointerEvent::EDrag, interPt, 0, 0, ptrSecNum, (TUint)iSecMultiPtrEventClient->ParentWin(), ETrue);
  3803 				SimulatePointerEvent(TRawEvent::EButton1Up, interPt.iX, interPt.iY, 0, ptrSecNum);
  3804 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, interPt, 0, 0, ptrSecNum, (TUint)iSecMultiPtrEventClient->ParentWin(), ETrue);
  3805 				secPt.iX += xInc;
  3806 				secPt.iY += yInc;
  3807 				}
  3808 			}
  3809 			break;
  3810 		case 4:
  3811 			{
  3812 			// Simulate drag events on different clients, but interleaved each other 
  3813 			ptrPos.SetXY(0,0);
  3814 			secPt.iX = iPhysicalScreenSize.iWidth/2;
  3815 			secPt.iY = 0; 
  3816 			ptrSecNum = iMaxDevPointers-1;
  3817 			TPoint interPt;
  3818 			
  3819 			for (ptrNum = 0; (ptrNum < iMaxDevPointers/2 && ptrSecNum >= iMaxDevPointers/2); ptrNum++, ptrSecNum--)
  3820 				{
  3821 				SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum);
  3822 				AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum);
  3823 				ptrPos.iX += xInc;
  3824 				ptrPos.iY += yInc;
  3825 				
  3826 				SimulatePointerEvent(TRawEvent::EButton1Down, secPt.iX, secPt.iY, 0, ptrSecNum);
  3827 				AddExpectedPointerEvent(TPointerEvent::EButton1Down, secPt, 0, 0, ptrSecNum, (TUint)iSecMultiPtrEventClient->ParentWin(), ETrue);
  3828 				secPt.iX += xInc;
  3829 				secPt.iY += yInc;
  3830 				}
  3831 			
  3832 			ptrPos.SetXY(0,0);
  3833 			secPt.iX = iPhysicalScreenSize.iWidth/2;
  3834 			secPt.iY = 0;
  3835 			ptrSecNum = iMaxDevPointers-1;
  3836 			for (ptrNum = 0; (ptrNum < iMaxDevPointers/2 && ptrSecNum >= iMaxDevPointers/2); ptrNum++, ptrSecNum--)
  3837 				{
  3838 				interPt.iX = ptrPos.iX+2;
  3839 				interPt.iY = ptrPos.iY+1;
  3840 				SimulatePointerEvent(TRawEvent::EPointerMove, interPt.iX, interPt.iY, 0, ptrNum);
  3841 				AddExpectedPointerEvent(TPointerEvent::EDrag, interPt, 0, 0, ptrNum);
  3842 				ptrPos.iX += xInc;
  3843 				ptrPos.iY += yInc;
  3844 				
  3845 
  3846 				interPt.iX = secPt.iX+2;
  3847 				interPt.iY = secPt.iY+1;
  3848 				SimulatePointerEvent(TRawEvent::EPointerMove, interPt.iX, interPt.iY, 0, ptrSecNum);
  3849 				AddExpectedPointerEvent(TPointerEvent::EDrag, interPt, 0, 0, ptrSecNum, (TUint)iSecMultiPtrEventClient->ParentWin(), ETrue);
  3850 				secPt.iX += xInc;
  3851 				secPt.iY += yInc;
  3852 				}
  3853 
  3854 			ptrPos.SetXY(0,0);
  3855 			secPt.iX = iPhysicalScreenSize.iWidth/2;
  3856 			secPt.iY = 0;
  3857 			ptrSecNum = iMaxDevPointers-1;
  3858 			for (ptrNum = 0; (ptrNum < iMaxDevPointers/2 && ptrSecNum >= iMaxDevPointers/2); ptrNum++, ptrSecNum--)
  3859 				{
  3860 				interPt.iX = ptrPos.iX+2;
  3861 				interPt.iY = ptrPos.iY+1;
  3862 				SimulatePointerEvent(TRawEvent::EButton1Up, interPt.iX, interPt.iY, 0, ptrNum);
  3863 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, interPt, 0, 0, ptrNum);
  3864 				ptrPos.iX += xInc;
  3865 				ptrPos.iY += yInc;
  3866 				
  3867 				interPt.iX = secPt.iX+2;
  3868 				interPt.iY = secPt.iY+1;
  3869 				SimulatePointerEvent(TRawEvent::EButton1Up, interPt.iX, interPt.iY, 0, ptrSecNum);
  3870 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, interPt, 0, 0, ptrSecNum, (TUint)iSecMultiPtrEventClient->ParentWin(), ETrue);
  3871 				secPt.iX += xInc;
  3872 				secPt.iY += yInc;
  3873 				}
  3874 			}
  3875 			break;
  3876 		default:
  3877 			ResetFlushStopAS();
  3878 			iSecMultiPtrEventClient->iWs.SetAutoFlush(iSecClientFlush);
  3879 			break;
  3880 		}
  3881 	
  3882 	_LIT(KEventsAdded, "Events added to Primary client's buffer = %d");
  3883 	logText.Format(KEventsAdded, iMultiPtrEventClient->EventBuffer()->EventsRemaining());
  3884 	LOG_MESSAGE(logText);
  3885 	_LIT(KEventsAdded1, "Events added to Secondary client's buffer = %d");
  3886 	logText.Format(KEventsAdded1, iSecMultiPtrEventClient->EventBuffer()->EventsRemaining());
  3887 	LOG_MESSAGE(logText);
  3888 	}
  3889 
  3890 
  3891 // RMultiPointerAnim
  3892 RMultiPointerAnim* RMultiPointerAnim::NewL(RWindowBase* aWin, RAnimDll* aDll)
  3893 	{
  3894 	RMultiPointerAnim* self=new(ELeave) RMultiPointerAnim(aDll);
  3895 	CleanupStack::PushL(TCleanupItem(DestroyAnim,self));
  3896 	User::LeaveIfError(self->Construct(*aWin, EAnimTypeMultiPointer, TPtrC8()));
  3897 	CleanupStack::Pop(self);
  3898 	return self;
  3899 	}
  3900 
  3901 TInt RMultiPointerAnim::AddExpectedAnimPointerEvent(TRawEvent::TType aType, TPoint aPos, TInt aZ, TUint /*aModifier*/, TUint8 aPointerNumber, TBool aEat /*= ETrue*/)
  3902 	{
  3903 	TRawEvent rawEvent;
  3904 	rawEvent.Set(aType, aPos.iX, aPos.iY, aZ, aPointerNumber);
  3905 	TAnimRawEvent animEvent;
  3906 	animEvent.iRawEvent = rawEvent;
  3907 	animEvent.iEat = aEat;
  3908 	TPckgBuf<TAnimRawEvent> param;
  3909 	param()=animEvent;
  3910 	return CommandReply(EADllAddExpectedMultiPtrEvent, param);
  3911 	}
  3912 
  3913 void CTMultiPtrEventTest::TestAndDisplayAnimError()
  3914 	{
  3915 	TInt err = iAnim->CommandReply(EADllMultiPtrEventError);
  3916 	if (err != KErrNone)
  3917 		{
  3918 		_LIT(KError, "Failed in Anim dll");
  3919 		LOG_MESSAGE(KError);
  3920 		TBuf<255> errDesc;
  3921 		errDesc.SetMax();
  3922 		TIpcArgs ipcArgs;
  3923 		ipcArgs.Set(KIpcSlot,&errDesc);
  3924 		// get the error desccription, print it out and stop the tests
  3925 		TInt retVal = iAnim->CommandReply(EADllMultiPtrEventErrorDesc, KNullDesC8, ipcArgs);
  3926 		if (retVal == KErrNone)
  3927 			{
  3928 			LOG_MESSAGE(errDesc);
  3929 			}
  3930 		Failed();
  3931 		}
  3932 	iAnim->CommandReply(EADllMultiPtrEventReset);
  3933 	}
  3934 
  3935 /**
  3936 @SYMTestCaseID			GRAPHICS-WSERV-ADVANCEDPOINTER-0013
  3937 @SYMPREQ				PREQ1226
  3938 @SYMREQ					REQ9677,REQ9683,
  3939 @SYMTestPriority		High 
  3940 @SYMTestCaseDesc		To check Wserv sends Multi Pointer events to Anims
  3941 @SYMTestStatus			Implemented
  3942 
  3943 @SYMTestActions			Simulate multi pointer events for anims
  3944 @SYMTestExpectedResults The received events must match the simulated raw events 
  3945 */
  3946 void CTMultiPtrEventTest::MultiPointerEventsForAnimsL()
  3947 	{
  3948 	// The logic behind these tests is
  3949 	// Create an anim, which creates animation at server side(which swicthes raw event handling on)
  3950 	// Add the required events to the animtaion at server side buffer
  3951 	// Simulate those events and check simulated events are same as required at server side
  3952 	// If any test fail, error description is got from server and displayed in the log file
  3953 	TLogMessageText logText;
  3954 	_LIT(KSet, "Multi pointer events for Anims: %d of 3");
  3955 	logText.AppendFormat(KSet, iEventSet);
  3956 	LOG_MESSAGE(logText);
  3957 	_LIT(KEventsChecked, "Events checked at server side = %d");
  3958 	
  3959 	iMultiPtrEventClient->EventBuffer()->SetEventCount(0);
  3960 	if (!iEventSet)
  3961 		{
  3962 		SetAutoFlush();
  3963 		iAnimDll = new(ELeave) RAnimDll(iMultiPtrEventClient->iWs);
  3964 		User::LeaveIfError(iAnimDll->Load(KAnimDLLName));
  3965 		}
  3966 	
  3967 	TPoint ptrPos;
  3968 	TInt ptrNum = 0;
  3969 	TInt prValue = 0;
  3970 	TInt proxValue = 0;
  3971 	TInt xInc = iPhysicalScreenSize.iWidth/iMaxDevPointers;
  3972 	TInt yInc = iPhysicalScreenSize.iHeight/iMaxDevPointers;
  3973  	
  3974 	switch(iEventSet++)
  3975 		{
  3976 		case 0:
  3977 			// Simulate downup events for all pointers
  3978 			iAnim = RMultiPointerAnim::NewL(iMultiPtrEventClient->ParentWin()->BaseWin(), iAnimDll);
  3979 			AddExpectedWsEvent(EEventFocusGained);
  3980 			for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
  3981 				{
  3982 				iAnim->AddExpectedAnimPointerEvent(TRawEvent::EButton1Down,ptrPos,0,0,ptrNum);
  3983 				iAnim->AddExpectedAnimPointerEvent(TRawEvent::EButton1Up,ptrPos,0,0,ptrNum);
  3984 				SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum);
  3985 				ptrPos.iX += xInc;
  3986 				ptrPos.iY += yInc;
  3987 				}
  3988 			TestAndDisplayAnimError();
  3989 			logText.Format(KEventsChecked, iMaxDevPointers*2);
  3990 			LOG_MESSAGE(logText);
  3991 			break;
  3992 		case 1:
  3993 			// Simulate moves from different pointer with different pressure
  3994 			// Here there is no need for events to be exaclty on the anim window. 
  3995 			// becasue when the animtaions ask for events it will be delivered all the events
  3996 			// irrespective of where they occured.
  3997 			ptrPos.SetXY(0,0);
  3998 			prValue = iPressureStep;
  3999 			for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
  4000 				{
  4001 				iAnim->AddExpectedAnimPointerEvent(TRawEvent::EPointerMove, ptrPos, prValue, 0, ptrNum);
  4002 				iAnim->AddExpectedAnimPointerEvent(TRawEvent::EButton1Down,ptrPos,0,0,ptrNum);
  4003 				iAnim->AddExpectedAnimPointerEvent(TRawEvent::EButton1Up,ptrPos,0,0,ptrNum);
  4004 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum);
  4005 				SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum);
  4006 				ptrPos.iX += xInc;
  4007 				ptrPos.iY += yInc;
  4008 				}
  4009 			TestAndDisplayAnimError();
  4010 			
  4011 			// This is for just to add run the next test
  4012 			SimulatePointerEvent(TRawEvent::EPointerSwitchOn, 0, 0, 0, 0);
  4013 			
  4014 			logText.Format(KEventsChecked, iMaxDevPointers*3);
  4015 			LOG_MESSAGE(logText);
  4016 			break;
  4017 		case 2:
  4018 			// Simulate moves from different pointer with different proximity
  4019 			ptrPos.SetXY(0,0);
  4020 			proxValue = -iProximityStep;
  4021 			for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
  4022 				{
  4023 				iAnim->AddExpectedAnimPointerEvent(TRawEvent::EPointerMove, ptrPos, proxValue, 0, ptrNum);
  4024 				iAnim->AddExpectedAnimPointerEvent(TRawEvent::EButton1Down,ptrPos,0,0,ptrNum);
  4025 				iAnim->AddExpectedAnimPointerEvent(TRawEvent::EButton1Up,ptrPos,0,0,ptrNum);
  4026 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum);
  4027 				SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum);
  4028 				ptrPos.iX += xInc;
  4029 				ptrPos.iY += yInc;
  4030 				}
  4031 			TestAndDisplayAnimError();
  4032 			
  4033 			// This is for just to add run the next test
  4034 			SimulatePointerEvent(TRawEvent::EPointerSwitchOn, 0, 0, 0, 0);
  4035 			
  4036 			logText.Format(KEventsChecked, iMaxDevPointers*3);
  4037 			LOG_MESSAGE(logText);
  4038 			break;
  4039 		default:
  4040 			DestroyAnimDllAndAnim();
  4041 			ResetFlushStopAS();
  4042 			break;
  4043 		}
  4044 
  4045 	LogEventsAdded();
  4046 	}
  4047 
  4048 
  4049 /**
  4050 @SYMTestCaseID			GRAPHICS-WSERV-ADVANCEDPOINTER-0014
  4051 @SYMPREQ				PREQ1226
  4052 @SYMREQ					REQ9677,REQ9683,
  4053 @SYMTestPriority		High 
  4054 @SYMTestCaseDesc		To check Wserv purges multi pointer events with standard rules
  4055 @SYMTestStatus			Implemented
  4056 
  4057 @SYMTestActions			Simulate raw events to be purged  
  4058 @SYMTestExpectedResults The purged events should not be delivered to client 
  4059 */
  4060 void CTMultiPtrEventTest::PurgingMultiPointerEvents()
  4061 	{
  4062 	// Test purging of multi pointer events
  4063 	// 1. Test down/up pairs are purged
  4064 	// 2. Test moves events are purged
  4065 	// 3. Test drag events are purged
  4066 	// 4. Test lone down events are purged
  4067 	// 5. And finally test lone up events are also purged 
  4068 	TLogMessageText logText;
  4069 	_LIT(KSet, "Purging of multi pointer events: %d of 6");
  4070 	logText.AppendFormat(KSet, iEventSet);
  4071 	LOG_MESSAGE(logText);
  4072 	
  4073 	iMultiPtrEventClient->EventBuffer()->SetEventCount(0);
  4074 	TInt xInc = iPhysicalScreenSize.iWidth/KMaxQueueSize;
  4075 	TInt yInc = iPhysicalScreenSize.iHeight/KMaxQueueSize;
  4076 	TPoint ptrPos(xInc,yInc);
  4077 	TInt ptrNum = 0;
  4078 	TInt prValue = 0;
  4079 	TInt proxValue = 0;
  4080 	
  4081 	if (!iEventSet)
  4082 		{
  4083 		SetAutoFlush();
  4084 		}
  4085 	
  4086 	// Point to note is that Kernel has an event queue size of 40
  4087 	// So make sure that you don't send more than 40 events
  4088 	switch(iEventSet++)
  4089 		{
  4090 		case 0:
  4091 			// Simulate pointer down/up events for all pointers
  4092 			// Simulate many up events from any pointer which will purge down/up events
  4093 			AddExpectedWsEvent(EEventFocusGained);
  4094 			for (ptrNum = 0; (ptrNum < iMaxDevPointers && ptrNum < 4); ptrNum++)
  4095 				{
  4096 				SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum);
  4097 				}
  4098 			SimulateAndAddLoneUpEvents(KMaxQueueSize, KMaxQueueSize-1, ptrPos);
  4099 			break;
  4100 		case 1:
  4101 			// Repeat the same for Move events
  4102 			// Simulate moves for all pointers with different pressure and proximity value
  4103 			iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterMove, 0);
  4104 			iMultiPtrEventClient->ChildWin()->BaseWin()->PointerFilter(EPointerFilterMove, 0);
  4105 			prValue = iPressureStep;
  4106 			for (ptrNum = 0; (ptrNum < iMaxDevPointers && prValue < iMaxPressure && ptrNum < 4); ptrNum++,prValue+=iPressureStep)
  4107 				{
  4108 				ptrPos.iX += xInc/2;
  4109 				ptrPos.iY += yInc/2;
  4110 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum);
  4111 				}
  4112 			ptrPos.iX = xInc;
  4113 			ptrPos.iY = yInc;
  4114 			proxValue = -iProximityStep;
  4115 			for (ptrNum = 0; (ptrNum < iMaxDevPointers && proxValue > iMaxProximity && ptrNum < 4); ptrNum++,proxValue-=iProximityStep)
  4116 				{
  4117 				ptrPos.iX += xInc/2;
  4118 				ptrPos.iY += yInc/2;
  4119 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum);
  4120 				}
  4121 			SimulateAndAddLoneUpEvents(KMaxQueueSize, KMaxQueueSize, ptrPos);
  4122 			break;
  4123 		case 2:
  4124 			{
  4125 			// Repeat the same for drag events
  4126 			iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterDrag, 0);
  4127 			iMultiPtrEventClient->ChildWin()->BaseWin()->PointerFilter(EPointerFilterDrag, 0);
  4128 			ptrPos.iX = xInc;
  4129 			ptrPos.iY = yInc;
  4130 			for (ptrNum = 0; (ptrNum < iMaxDevPointers && ptrNum < 2); ptrNum++)
  4131 				{
  4132 				SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum);
  4133 				ptrPos.iX += xInc/2;
  4134 				ptrPos.iY += yInc/2;
  4135 				}
  4136 			ptrPos.iX = xInc;
  4137 			ptrPos.iY = yInc;
  4138 			TPoint interPt = ptrPos;
  4139 			for (ptrNum = 0; (ptrNum < iMaxDevPointers && ptrNum < 2); ptrNum++)
  4140 				{	
  4141 				interPt.iX += 2;
  4142 				interPt.iY += 1;
  4143 				SimulatePointerEvent(TRawEvent::EPointerMove, interPt.iX, interPt.iY, 0, ptrNum);
  4144 				ptrPos.iX += xInc/2;
  4145 				ptrPos.iY += yInc/2;
  4146 				interPt = ptrPos; 
  4147 				}
  4148 			ptrPos.iX = xInc;
  4149 			ptrPos.iY = yInc;
  4150 			interPt = ptrPos;
  4151 			for (ptrNum = 0; (ptrNum < iMaxDevPointers && ptrNum < 2); ptrNum++)
  4152 				{
  4153 				interPt.iX += 2;
  4154 				interPt.iY += 1;
  4155 				SimulatePointerEvent(TRawEvent::EButton1Up, interPt.iX, interPt.iY, 0, ptrNum);
  4156 				ptrPos.iX += xInc/2;
  4157 				ptrPos.iY += yInc/2;
  4158 				interPt = ptrPos; 
  4159 				}
  4160 			SimulateAndAddLoneUpEvents(KMaxQueueSize, KMaxQueueSize, ptrPos);
  4161 			}
  4162 			break;
  4163 		case 3:
  4164 			// Repeat the same for lone down events
  4165 			ptrPos.iX = xInc;
  4166 			ptrPos.iY = yInc;
  4167 			for (ptrNum = 0; (ptrNum < iMaxDevPointers && ptrNum < 3); ptrNum++)
  4168 				{
  4169 				SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum);
  4170 				ptrPos.iX += xInc/2;
  4171 				ptrPos.iY += yInc/2;
  4172 				}
  4173 			SimulateAndAddLoneUpEvents(KMaxQueueSize+1, KMaxQueueSize, ptrPos);
  4174 
  4175 			// Before this we had to send dummy 7 EButton1Up events from 1 to 7 pointers so that iLastUnmatchedDown1
  4176 			// variable to be reset and that consecutive events was not sent to client. But now EPointer3DOutOfRange
  4177 			// resets all the variables.
  4178 			for (ptrNum = 1; (ptrNum < iMaxDevPointers && ptrNum < 3); ptrNum++)
  4179 				{
  4180 				SimulatePointerEvent(TRawEvent::EPointer3DOutOfRange, ptrPos.iX, ptrPos.iY, 0, ptrNum);
  4181 				}
  4182 			break;
  4183 		case 4:
  4184 			// Finally for even lone up events, check that when you send events more then the queuesize
  4185 			// the events are not sent back and they are ignored in wserv
  4186 			ptrPos.iX = xInc;
  4187 			ptrPos.iY = yInc;
  4188 			for (ptrNum = 0; (ptrNum < iMaxDevPointers && ptrNum < 4); ptrNum++)
  4189 				{
  4190 				SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum);
  4191 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, ptrNum);
  4192 				ptrPos.iX += xInc/2;
  4193 				ptrPos.iY += yInc/2;
  4194 				}
  4195 			ptrPos.iX = xInc;
  4196 			ptrPos.iY = yInc;
  4197 			for (TInt count = 0; count < KMaxQueueSize; count++)
  4198 				{
  4199 				SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0);
  4200 				// For all up events more then KMaxQueueSize, wserv igoners then as the queue if full
  4201 				if (count < (KMaxQueueSize - iMaxDevPointers))
  4202 					{
  4203 					AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, 0);
  4204 					}
  4205 				}
  4206 			break;
  4207 		case 5:
  4208 			// Check PurgePointerEvents works with multi pointer events
  4209 			ptrPos.iX = xInc;
  4210 			ptrPos.iY = yInc;
  4211 			for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
  4212 				{
  4213 				SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum);
  4214 				ptrPos.iX += xInc/2;
  4215 				ptrPos.iY += yInc/2;
  4216 				}
  4217 			ptrPos.iX = xInc;
  4218 			ptrPos.iY = yInc;
  4219 			iMultiPtrEventClient->iWs.PurgePointerEvents();
  4220 			SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0);
  4221 			AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, 0);
  4222 			break;
  4223 		default:
  4224 			ResetFlushStopAS();
  4225 			break;
  4226 		}
  4227 	LogEventsAdded();
  4228 	}
  4229 
  4230 void CTMultiPtrEventTest::MultiPointerEvents()
  4231 	{
  4232 	TLogMessageText logText;
  4233 	_LIT(KSet, "MultiPtrEvents SetOfEvents: %d of 9");
  4234 	logText.AppendFormat(KSet, iEventSet);
  4235 	LOG_MESSAGE(logText);
  4236 
  4237 	if (!iEventSet)
  4238 		{
  4239 		SetAutoFlush();
  4240 		}
  4241 	iMultiPtrEventClient->EventBuffer()->SetEventCount(0);
  4242 
  4243 	TPoint ptrPos;
  4244 	TInt ptrNum = 0;
  4245 	TInt prValue = 0;
  4246 	TInt proxValue = 0;
  4247 	TInt xInc = iPhysicalScreenSize.iWidth/iMaxDevPointers;
  4248 	TInt yInc = iPhysicalScreenSize.iHeight/iMaxDevPointers;
  4249 	
  4250 	switch(iEventSet++)
  4251 		{
  4252 		case 0:
  4253 			/**
  4254 			@SYMTestCaseID			GRAPHICS-WSERV-ADVANCEDPOINTER-0001
  4255 			@SYMPREQ				PREQ1226
  4256 			@SYMREQ					REQ9674,REQ9687,
  4257 			@SYMTestPriority		High 
  4258 			@SYMTestCaseDesc		Checks Wserv sends multi touch pointer events received by it
  4259 			@SYMTestStatus			Implemented
  4260 
  4261 			@SYMTestActions			Simulate raw events from different pointers 
  4262 			@SYMTestExpectedResults The received events must match the simulated raw events
  4263 			*/
  4264 			INFO_PRINTF1(_L("Simulate pointer events from all pointers"));
  4265 			INFO_PRINTF1(_L("Test pattern is PointerDown0/PointerUp0, PointerDown1/PointerUp1, PointerDown2/PointerUp2..."));
  4266 			// Test pattern is down0/up0, down1/up1, down2/up2, down3/up3....
  4267 			AddExpectedWsEvent(EEventFocusGained);
  4268 			for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
  4269 				{
  4270 				SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum);
  4271 				AddExpectedPointerDownUp(ptrPos, 0, ptrNum);
  4272 				ptrPos.iX += xInc;
  4273 				ptrPos.iY += yInc;
  4274 				}
  4275 			break;
  4276 		case 1:
  4277 			/**
  4278 			@SYMTestCaseID			GRAPHICS-WSERV-ADVANCEDPOINTER-0003
  4279 			@SYMPREQ				PREQ1226
  4280 			@SYMREQ					REQ9674,REQ9687,
  4281 			@SYMTestPriority		High 
  4282 			@SYMTestCaseDesc		To check Wserv sends simultaneous multi touch pointer events 
  4283 			@SYMTestStatus			Implemented
  4284 
  4285 			@SYMTestActions			Simulate simultaneous raw events from different pointers 
  4286 			@SYMTestExpectedResults The received events must match the simulated raw events
  4287 			*/
  4288 			INFO_PRINTF1(_L("Test pattern PointerDown0/PointerDown1/PointerDown2/... PointerUp0/PointerUp1/PointerUp2..."));
  4289 			// Test pattern is pointer0Down/pointer1Down/pointer2Down/pointer3Down.... pointer0Up/pointer1Up/pointer2Up/pointer3Up.... 
  4290 			ptrPos.SetXY(0,0);
  4291 			for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
  4292 				{
  4293 				SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum);
  4294 				AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum);
  4295 				ptrPos.iX += xInc;
  4296 				ptrPos.iY += yInc;
  4297 				}
  4298 
  4299 			ptrPos.SetXY(0,0);
  4300 			for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
  4301 				{
  4302 				SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum);
  4303 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, ptrNum);
  4304 				ptrPos.iX += xInc;
  4305 				ptrPos.iY += yInc;				
  4306 				}
  4307 			break;
  4308 		case 2:
  4309 			/**
  4310 			@SYMTestCaseID			GRAPHICS-WSERV-ADVANCEDPOINTER-0005
  4311 			@SYMPREQ				PREQ1226
  4312 			@SYMREQ					REQ9676
  4313 			@SYMTestPriority		High 
  4314 			@SYMTestCaseDesc		To check Wserv sends the multi touch pointer events received 
  4315 									by it along with the Pressure or Proximity 
  4316 			@SYMTestStatus			Implemented
  4317 
  4318 			@SYMTestActions			Simulate raw events with pressure and proximity from different pointers  
  4319 			@SYMTestExpectedResults The received events must match the simulated raw events
  4320 			*/
  4321 			// Simulate Button1Down with differet pressure
  4322 			// Simulate Button1Up with zero pressure
  4323 			INFO_PRINTF1(_L("Simulate pointer events with different pressure values"));
  4324 			ptrPos.SetXY(0,0);
  4325 			prValue = iPressureStep;
  4326 			for (; (prValue <= iMaxPressure && ptrPos.iX < iPhysicalScreenSize.iWidth && ptrPos.iY < iPhysicalScreenSize.iHeight); prValue+=iPressureStep)
  4327 				{
  4328 				SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, prValue, 0);
  4329 				SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0);
  4330 				AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, prValue, 0, 0);
  4331 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, 0);
  4332 				ptrPos.iX += xInc;
  4333 				ptrPos.iY += yInc;
  4334 				}
  4335 			
  4336 			// Test with max pressure it might be that the width may cross the physical screen size
  4337 			ptrPos.SetXY(0,0);
  4338 			prValue = iMaxPressure;
  4339 			SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, prValue, 0);
  4340 			SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, 0);
  4341 			AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, prValue, 0, 0);
  4342 			AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, 0);
  4343 			break;
  4344 		case 3:
  4345 			// Simulate EPointerMove with different pressure values and for differernt pointers
  4346 			INFO_PRINTF1(_L("Simulate pointer events with different pressure values and from different pointers"));
  4347 			ptrPos.SetXY(0,0);
  4348 			prValue = iPressureStep;
  4349 			
  4350 			// Enable move events 
  4351 			iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterMove, 0);
  4352 			iMultiPtrEventClient->ChildWin()->BaseWin()->PointerFilter(EPointerFilterMove, 0);
  4353 			
  4354 			// Right now when 2 or more moves occur, wserv deletes all the moves except the last one.
  4355 			// So test only one move per Pointer and then one set of button down and button up
  4356 			// Then repeat the same for different pressure values
  4357 			for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
  4358 				{
  4359 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum);
  4360 				AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, prValue, 0, ptrNum);
  4361 				ptrPos.iX += xInc;
  4362 				ptrPos.iY += yInc;
  4363 				}
  4364 			
  4365 			ptrPos.SetXY(0,0);
  4366 			for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
  4367 				{
  4368 				SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum);
  4369 				AddExpectedPointerDownUp(ptrPos, 0, ptrNum);
  4370 				ptrPos.iX += xInc;
  4371 				ptrPos.iY += yInc;
  4372 				}
  4373 			
  4374 			// Test moves with different pressure 
  4375 			ptrPos.SetXY(0,0);
  4376 			if ((prValue+iPressureStep) <= iMaxPressure)
  4377 				{
  4378 				prValue += iPressureStep;
  4379 				}
  4380 			ptrNum = 0;
  4381 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum);
  4382 			AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, prValue, 0, ptrNum);
  4383 			break;
  4384 		case 4:
  4385 			INFO_PRINTF1(_L("Simulate pointer events with different proximity values"));
  4386 			// Repeat the same test of case 3 for different proximity values
  4387 			ptrPos.SetXY(0,0);
  4388 			
  4389 			proxValue = -iProximityStep;
  4390 			for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
  4391 				{
  4392 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum);
  4393 				AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, ptrNum);
  4394 				ptrPos.iX += xInc;
  4395 				ptrPos.iY += yInc;
  4396 				}
  4397 			
  4398 			ptrPos.SetXY(0,0);
  4399 			for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
  4400 				{
  4401 				SimulatePointerDownUp(ptrPos.iX, ptrPos.iY, 0, ptrNum);
  4402 				AddExpectedPointerDownUp(ptrPos, 0, ptrNum);
  4403 				ptrPos.iX += xInc;
  4404 				ptrPos.iY += yInc;
  4405 				}
  4406 
  4407 			ptrPos.SetXY(0,0);
  4408 			if ((proxValue-iProximityStep) > iMaxProximity)
  4409 				{
  4410 				proxValue -= iProximityStep;
  4411 				}
  4412 			ptrNum = 0;
  4413 			SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum);
  4414 			AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, ptrNum);
  4415 			break;
  4416 		case 5:
  4417 			/**
  4418 			@SYMTestCaseID			GRAPHICS-WSERV-ADVANCEDPOINTER-0007
  4419 			@SYMPREQ				PREQ1226
  4420 			@SYMREQ					REQ9677
  4421 			@SYMTestPriority		High 
  4422 			@SYMTestCaseDesc		To check Wserv sends move/drags of different pointers  
  4423 			@SYMTestStatus			Implemented
  4424 
  4425 			@SYMTestActions			Simulate raw move and drag events from different pointers  
  4426 			@SYMTestExpectedResults The received events must match the simulated raw events
  4427 			*/
  4428 			INFO_PRINTF1(_L("Simulate pointer drag events"));
  4429 			ptrPos.SetXY(0,0);
  4430 			iMultiPtrEventClient->ParentWin()->BaseWin()->PointerFilter(EPointerFilterDrag, 0);
  4431 			
  4432 			// Simulate EButton1Down and then one move and then EButton1Up event  
  4433 			// which will lead to corresponding drag, do it for all the pointers
  4434 			for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
  4435 				{
  4436 				TestDragForMultiPointer(ptrPos, 0, ptrNum);
  4437 				ptrPos.iX += xInc/2;
  4438 				ptrPos.iY += yInc/2;
  4439 				}
  4440 
  4441 			// Check the drag with different pressure value with different pointer
  4442 			prValue = iPressureStep;
  4443 			ptrPos.iX = xInc;
  4444 			ptrPos.iY = yInc;
  4445 			if ((prValue+iPressureStep) <= iMaxPressure)
  4446 				{
  4447 				prValue += iPressureStep;
  4448 				}
  4449 			ptrNum = 0;
  4450 			TestDragForMultiPointer(ptrPos, prValue, ptrNum);
  4451 			break;
  4452 		case 6:
  4453 			{
  4454 			/**
  4455 			@SYMTestCaseID			GRAPHICS-WSERV-ADVANCEDPOINTER-0009
  4456 			@SYMPREQ				PREQ1226
  4457 			@SYMREQ					REQ9677, REQ9674
  4458 			@SYMTestPriority		High 
  4459 			@SYMTestCaseDesc		To check Wserv sends simultaneous move/drags of different pointers  
  4460 			@SYMTestStatus			Implemented
  4461 
  4462 			@SYMTestActions			Simulate simulatneous raw move and drag events from different pointers  
  4463 			@SYMTestExpectedResults The received events must match the simulated raw events
  4464 			*/
  4465 			INFO_PRINTF1(_L("Simulate pointer drag events in different pattern"));
  4466 			// Dragging done in this pattern
  4467 			// pointer0Down/pointer1Down/pointer2Down/pointer3Down... pointer0Up/pointer1Up/pointer2Up/pointer3Up....
  4468 			
  4469 			ptrPos.SetXY(0,0);
  4470 			for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
  4471 				{
  4472 				SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum);
  4473 				AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum);
  4474 				ptrPos.iX += xInc/2;
  4475 				ptrPos.iY += yInc/2;
  4476 				}
  4477 			
  4478 			ptrPos.SetXY(0,0);
  4479 			TPoint interPt = ptrPos;
  4480 			for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
  4481 				{
  4482 				interPt.iX += 2;
  4483 				interPt.iY += 1;
  4484 				SimulatePointerEvent(TRawEvent::EPointerMove, interPt.iX, interPt.iY, 0, ptrNum);
  4485 				AddExpectedPointerEvent(TPointerEvent::EDrag, interPt, 0, 0, ptrNum);
  4486 				ptrPos.iX += xInc/2;
  4487 				ptrPos.iY += yInc/2;
  4488 				interPt = ptrPos; 
  4489 				}
  4490 		
  4491 			ptrPos.SetXY(0,0);
  4492 			interPt = ptrPos;
  4493 			for (ptrNum = 0; ptrNum < iMaxDevPointers; ptrNum++)
  4494 				{
  4495 				interPt.iX += 2;
  4496 				interPt.iY += 1;
  4497 				SimulatePointerEvent(TRawEvent::EButton1Up, interPt.iX, interPt.iY, 0, ptrNum);
  4498 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, interPt, 0, 0, ptrNum);
  4499 				ptrPos.iX += xInc/2;
  4500 				ptrPos.iY += yInc/2;
  4501 				interPt = ptrPos; 
  4502 				}
  4503 			break;
  4504 			}
  4505 		case 7:
  4506 			{
  4507 			// Mixing of drag and moves of different pointers
  4508 			ptrPos.SetXY(0,0);
  4509 			for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  4510 				{
  4511 				SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum);
  4512 				AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum);
  4513 				ptrPos.iX += xInc/2;
  4514 				ptrPos.iY += yInc/2;
  4515 				}
  4516 			ptrPos.SetXY(0,0);
  4517 			TPoint interPt = ptrPos;
  4518 			for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  4519 				{
  4520 				interPt.iX += 2;
  4521 				interPt.iY += 1;
  4522 				SimulatePointerEvent(TRawEvent::EPointerMove, interPt.iX, interPt.iY, 0, ptrNum);
  4523 				AddExpectedPointerEvent(TPointerEvent::EDrag, interPt, 0, 0, ptrNum);
  4524 				ptrPos.iX += xInc/2;
  4525 				ptrPos.iY += yInc/2;
  4526 				interPt = ptrPos; 
  4527 				}
  4528 		
  4529 			ptrPos.SetXY(0,0);
  4530 			interPt = ptrPos;
  4531 			for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  4532 				{
  4533 				interPt.iX += 2;
  4534 				interPt.iY += 1;
  4535 				SimulatePointerEvent(TRawEvent::EButton1Up, interPt.iX, interPt.iY, 0, ptrNum);
  4536 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, interPt, 0, 0, ptrNum);
  4537 				ptrPos.iX += xInc/2;
  4538 				ptrPos.iY += yInc/2;
  4539 				interPt = ptrPos; 
  4540 				}
  4541 			
  4542 			ptrPos.SetXY(0,0);
  4543 			prValue = iPressureStep;
  4544 			for (ptrNum = 0; ptrNum < iMaxDevPointers/2 && prValue < iMaxPressure; ptrNum++, prValue+=iPressureStep)
  4545 				{
  4546 				SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum);
  4547 				AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, prValue, 0, ptrNum);
  4548 				ptrPos.iX += xInc;
  4549 				ptrPos.iY += yInc;
  4550 				}
  4551 			}
  4552 			break;
  4553 		case 8:
  4554 			{
  4555 			INFO_PRINTF1(_L("Check intermediate Moves and Drags are deleted except last event"));
  4556 			// Check if intermediate move and drag events are deleted
  4557 			// The deletion is done with respect to same pointer and same window
  4558 			xInc = iPhysicalScreenSize.iWidth/KMaxQueueSize;
  4559 			yInc = iPhysicalScreenSize.iHeight/KMaxQueueSize;
  4560 			ptrPos.iX = xInc;
  4561 			ptrPos.iY = yInc;
  4562 			TInt count = 0;
  4563 			
  4564 			for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  4565 				{
  4566 				// Make sure that ptrPos does not go out of screen area, i,e the loop count should not exceed 4
  4567 				for (count = proxValue = 0; proxValue > iMaxProximity && count < 4; proxValue=proxValue-(4*iProximityStep), count++)
  4568 					{
  4569 					ptrPos.iX += xInc/2;
  4570 					ptrPos.iY += yInc/2;
  4571 					SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, proxValue, ptrNum);
  4572 					}
  4573 				// Since the for loop increments the variables at the end
  4574 				proxValue = proxValue + (4*iProximityStep);
  4575 				AddExpectedPointerEvent(TPointerEvent::EMove, ptrPos, proxValue, 0, ptrNum);
  4576 				}
  4577 			
  4578 			ptrPos.iX = xInc;
  4579 			ptrPos.iY = yInc;
  4580 			for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  4581 				{
  4582 				ptrPos.iX += xInc/2;
  4583 				ptrPos.iY += yInc/2;
  4584 				SimulatePointerEvent(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, 0, ptrNum);
  4585 				AddExpectedPointerEvent(TPointerEvent::EButton1Down, ptrPos, 0, 0, ptrNum);
  4586 				}
  4587 
  4588 			ptrPos.iX = xInc;
  4589 			ptrPos.iY = yInc;
  4590 			for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  4591 				{
  4592 				// Make sure that ptrPos does not go out of screen area, i,e the loop count shuld not exceed 4
  4593 				for (count = prValue = 0; prValue < iMaxPressure && count < 4; prValue=prValue+(4*iPressureStep), count++)
  4594 					{
  4595 					ptrPos.iX += xInc/2;
  4596 					ptrPos.iY += yInc/2;
  4597 					SimulatePointerEvent(TRawEvent::EPointerMove, ptrPos.iX, ptrPos.iY, prValue, ptrNum);
  4598 					}
  4599 				prValue = prValue-(4*iPressureStep);
  4600 				AddExpectedPointerEvent(TPointerEvent::EDrag, ptrPos, prValue, 0, ptrNum);
  4601 				}
  4602 			
  4603 			ptrPos.iX = xInc;
  4604 			ptrPos.iY = yInc;
  4605 			for (ptrNum = 0; ptrNum < iMaxDevPointers/2; ptrNum++)
  4606 				{
  4607 				ptrPos.iX += xInc/2;
  4608 				ptrPos.iY += yInc/2;
  4609 				SimulatePointerEvent(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, 0, ptrNum);
  4610 				AddExpectedPointerEvent(TPointerEvent::EButton1Up, ptrPos, 0, 0, ptrNum);
  4611 				}
  4612 			}
  4613 			break;
  4614 		default:
  4615 			ResetFlushStopAS();
  4616 			break;
  4617 		}
  4618 	
  4619 	LogEventsAdded();
  4620 	}
  4621 
  4622 // Logs number of events added to test buffer for comaparison
  4623 void CTMultiPtrEventTest::LogEventsAdded()
  4624 	{
  4625 	TLogMessageText logText1;
  4626 	_LIT(KEventsAdded, "Events added to buffer = %d");
  4627 	logText1.AppendFormat(KEventsAdded, iMultiPtrEventClient->EventBuffer()->EventsRemaining());
  4628 	LOG_MESSAGE(logText1);	
  4629 	}
  4630 
  4631 // If any of the Tests fails, bring the wserv in a consistent state for other test to run, 
  4632 // stop ActiveScheduler and display some logs where the fail occured.
  4633 void CTMultiPtrEventTest::Failed()
  4634 	{
  4635 	switch (iTest->iState)
  4636 		{
  4637 		case 2:		// Anim tests
  4638 			DestroyAnimDllAndAnim();
  4639 			break;
  4640 		case 3:		// MultiClient tests
  4641 			if (iMultiPtrEventClient->EventBuffer()->NestedLoopState())
  4642 				{
  4643 				iSecMultiPtrEventClient->EventBuffer()->SetNestedLoopState(EFalse);
  4644 				CActiveScheduler::Stop();
  4645 				}
  4646 			break;
  4647 		case 4:		//PtrClick tests
  4648 			if (iPtrPluginLoaded)
  4649 				{
  4650 				iPtrPluginLoaded = EFalse;
  4651 				iClick.Unload();
  4652 				iClick.Close();
  4653 				}
  4654 			if (iHeap)
  4655 				{
  4656 				iHeap->Close();
  4657 				iHeap = NULL;
  4658 				iChunk.Close();
  4659 				}
  4660 			break;
  4661 		case 5:		//Screen mode tests
  4662 			SetDefaultScreenMode();
  4663 			break;
  4664 		case 11:
  4665 			iMultiPtrEventClient->DeleteGroupBlankWin();
  4666 			break;
  4667 		case 12:	//Emulation tests, iEventSet is incremented in main switch case.
  4668 			switch (iEventSet)
  4669 				{
  4670 				case 9:
  4671 					DeleteGroupWin();
  4672 					break;
  4673 				case 10:
  4674 					DestroyAnimDllAndAnim();
  4675 					break;
  4676 				case 11:
  4677 				case 12:
  4678 					iMultiPtrEventClient->ParentWin()->BaseWin()->FreePointerMoveBuffer();
  4679 					iMultiPtrEventClient->ParentWin()->BaseWin()->DisablePointerMoveBuffer();
  4680 					break;
  4681 				case 14:
  4682 				case 15:
  4683 					iMultiPtrEventClient->iWs.SetPointerCursorArea(iOrigPtrCursorArea);
  4684 					break;
  4685 				default:
  4686 					break;
  4687 				}
  4688 			break;
  4689 		case 15:
  4690 			if (iEventSet > 1)
  4691 				{
  4692 				DeleteGroupWinForCapturing();
  4693 				}
  4694 			break;
  4695 		case 13:
  4696 		case 16:
  4697 			SetThresholdValues(KMaxTInt, KMinTInt, KMaxTInt, KMinTInt);
  4698 			break;
  4699 		default:
  4700 			break;
  4701 		}
  4702 	
  4703 	if (iActiveSchedulerStarted)
  4704 		{
  4705 		iActiveSchedulerStarted = EFalse;
  4706 		CActiveScheduler::Stop();
  4707 		}
  4708 	
  4709 	// Display the test case number, subtest case number and number of events left in the buffer which can be used to
  4710 	// find out which event actually caused the failure when any test fails
  4711 	TLogMessageText logText1;
  4712 	_LIT(KEventsAdded, "Test case number %d Sub test case number %d Events remaining in the buffer %d \n");
  4713 	logText1.AppendFormat(KEventsAdded, iTest->iState, iEventSet, iMultiPtrEventClient->EventBuffer()->EventsRemaining());
  4714 	LOG_MESSAGE(logText1);
  4715 	RDebug::Printf("Test case number %d Sub test case number %d Events remaining in the buffer %d \n", iTest->iState, iEventSet, iMultiPtrEventClient->EventBuffer()->EventsRemaining());
  4716 	
  4717 	iFailed=ETrue;
  4718 	}
  4719 
  4720 // This function is called by TestExecute Framework, through which all the testcases are run
  4721 void CTMultiPtrEventTest::RunTestCaseL(TInt /*aCurTestCase*/)
  4722 	{
  4723 	_LIT(KTest0, "MultiPointerEvents with Pressure and Proximity");
  4724 	_LIT(KTest1, "Purging Of MultiPointerEvents");
  4725 	_LIT(KTest2, "MultiPointerEvents for Anims");
  4726 	_LIT(KTest3, "MultiPointerEvents from multi client");
  4727 	_LIT(KTest4, "MultiPointerEvents for pointer click plugin");
  4728 	_LIT(KTest5, "MultiPointerEvents In Different ScreenModes");
  4729 	_LIT(KTest6, "Filtering Of MultiPointerEvents");
  4730 	_LIT(KTest7, "Grabbing Of MultiPointerEvents");
  4731 	_LIT(KTest8, "VirtualKeyboard for Multiple Pointers");
  4732 	_LIT(KTest9, "DoubleClick events for Multiple Pointer");
  4733 	_LIT(KTest10, "OutOfRange & EnterExit for Multiple Pointer");
  4734 	_LIT(KTest11, "Auto foreground for Multiple Pointer");
  4735 	_LIT(KTest12, "Emulation rules for Mulitple Pointers");
  4736 	_LIT(KTest13, "Close proximity and High Pressure events");
  4737 	_LIT(KTest14, "Out of bound value testing");
  4738 	_LIT(KTest15, "Capturing Of MultiPointerEvents");
  4739 	_LIT(KTest16, "Negative testing for Proximity and Pressure events");
  4740 	_LIT(KTest17, "PointerRepeatEvent for Multiple Pointers");
  4741 	
  4742 	if (!TestBase()->ConfigurationSupportsPointerEventTesting())
  4743 	    {
  4744 	    INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing"));
  4745 	    TestComplete();
  4746 	    return;
  4747 	    }
  4748 	
  4749 	switch(iTest->iState)
  4750 		{
  4751 	case 0:
  4752 		iTest->LogSubTest(KTest0);
  4753 		RunTestsL();
  4754 		break;
  4755 	case 1:
  4756 		iTest->LogSubTest(KTest1);
  4757 		RunTestsL();
  4758 		break;
  4759 	case 2:
  4760 		iTest->LogSubTest(KTest2);
  4761 		RunTestsL();
  4762 		break;
  4763 	case 3:
  4764 		iTest->LogSubTest(KTest3);
  4765 		RunTestsL();
  4766 		break;
  4767 	case 4:
  4768 		iTest->LogSubTest(KTest4);
  4769 		RunTestsL();
  4770 		break;
  4771 	case 5:
  4772 		iTest->LogSubTest(KTest5);
  4773 		RunTestsL();
  4774 		break;
  4775 	case 6:
  4776 		iTest->LogSubTest(KTest6);
  4777 		RunTestsL();
  4778 		break;	
  4779 	case 7:
  4780 		iTest->LogSubTest(KTest7);
  4781 		RunTestsL();
  4782 		break;	
  4783 	case 8:
  4784 		iTest->LogSubTest(KTest8);
  4785 		RunTestsL();
  4786 		break;
  4787 	case 9:
  4788 		iTest->LogSubTest(KTest9);
  4789 		RunTestsL();
  4790 		break;
  4791 	case 10:
  4792 		iTest->LogSubTest(KTest10);
  4793 		RunTestsL();
  4794 		break;
  4795 	case 11:
  4796 		iTest->LogSubTest(KTest11);
  4797 		RunTestsL();
  4798 		break;
  4799 	case 12:
  4800 		iTest->LogSubTest(KTest12);
  4801 		RunTestsL();
  4802 		break;
  4803 	case 13:
  4804 		iTest->LogSubTest(KTest13);
  4805 		RunTestsL();
  4806 		break;
  4807 	case 14:
  4808 		iTest->LogSubTest(KTest14);
  4809 		RunTestsL();
  4810 		break;
  4811 	case 15:
  4812 		iTest->LogSubTest(KTest15);
  4813 		RunTestsL();
  4814 		break;
  4815 	case 16:
  4816 		iTest->LogSubTest(KTest16);
  4817 		RunTestsL();
  4818 		break;	
  4819 	case 17:
  4820 		iTest->LogSubTest(KTest17);
  4821 		RunTestsL();
  4822 		break;	
  4823 	case 18:
  4824 		// Keep this code in last case statement for main test completion 
  4825 		TestComplete();
  4826 		break;
  4827 	default:
  4828 		AutoPanic(EAutoPanicWrongTest);
  4829 		}
  4830 
  4831 	// 
  4832 	if (iFailed)
  4833 		{
  4834 		TEST(EFalse);
  4835 		iFailed=EFalse;
  4836 		}
  4837 	++iTest->iState;
  4838 	}
  4839 
  4840 // Macro which is used for construction of CTMultiPtrEventTestStep object
  4841 // and also used to call CreateTestL() which creates CTMultiPtrEventTest and CTestBase objects
  4842 __WS_CONSTRUCT_STEP__(MultiPtrEventTest)