windowing/windowserver/test/tauto/tmultiptrevent.h
changeset 110 7f25ef56562d
equal deleted inserted replaced
98:bf7481649c98 110:7f25ef56562d
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @test
       
    19  @internalComponent - Internal Symbian test code 
       
    20 */
       
    21 
       
    22 #ifndef TMULTIPTREVENT_H_
       
    23 #define TMULTIPTREVENT_H_
       
    24 
       
    25 #include <e32std.h>
       
    26 #include <e32cmn.h>
       
    27 #include "w32std.h"
       
    28 #include "../tlib/testbase.h"
       
    29 #include "AUTO.H"
       
    30 #include "AUTODLL.H"
       
    31 #include "../TClick/multiptrclick.h"
       
    32 #include "TGraphicsHarness.h"
       
    33 
       
    34 class CTMultiPtrEventTest;
       
    35 class CTMultiPtrEventClient;
       
    36 
       
    37 /*
       
    38  * CTEvent derived class which acts as eventhandler and eventbuffer 
       
    39  * Stores the events in buffer, which is used for comparing events received from wserv.
       
    40  */ 
       
    41 class CTMultiPtrEventBuffer : public CTEvent
       
    42 	{
       
    43 	enum {EEventBufferSize=40, EMovePtsBuffer=10};
       
    44 public:
       
    45 	CTMultiPtrEventBuffer(RWsSession *aWs, CTMultiPtrEventTest *aTest, CTMultiPtrEventClient* aClient);
       
    46 	void ConstructL();
       
    47 	void AddExpectedEvent(TWsEvent &aEvent);
       
    48 	void AddExpectedMovePtEvent(TPoint &aMovePt);
       
    49 	TInt EventsRemaining();
       
    50 	void SetEventCount(TInt aCount) {iEventCount = aCount;}
       
    51 	void SetNestedLoopState(TBool aLoopStart) {iNestedLoopStarted = aLoopStart;}
       
    52 	TBool NestedLoopState() {return iNestedLoopStarted;}
       
    53 	void GetMoveBufferAndCompareL();
       
    54 protected:
       
    55 	// Pure virtual from CTEventBase
       
    56 	void doRunL();
       
    57 private:
       
    58 	void TestL(TInt aTest);
       
    59 	void TestL(TInt aTest, TInt aVal1, TInt aVal2,const char *oper, const char *aTestStr, 
       
    60 	           const TWsEvent *aEvent, const TWsEvent *aExpected, const char *aFile, TUint aLine);
       
    61     void TestL(TInt aTest, TPoint aVal1, TPoint aVal2,const char *oper, const char *aTestStr, 
       
    62                const TWsEvent *aEvent, const TWsEvent *aExpected, const char *aFile, TUint aLine);
       
    63 private:
       
    64 	CCirBuf<TWsEvent> iEventBuffer;
       
    65 	CCirBuf<TPoint> iMovePtsBuffer;
       
    66 	CTMultiPtrEventTest* iTest;
       
    67 	TInt iEventCount;
       
    68 	CTMultiPtrEventClient* iClient;
       
    69 	TBool iNestedLoopStarted;
       
    70 	};
       
    71 
       
    72 
       
    73 /* 
       
    74  * CTClient derived class which gives Wserv client environment 
       
    75  * i,e iWs, iScreen, iGc, iGroup, iEventHandler etc...
       
    76  * Owns CTMultiPtrEventBuffer and stores in iEventhandler of its base class
       
    77  * Accepts the event from test class and passes them on to buffer class
       
    78  */ 
       
    79 class CTMultiPtrEventClient : public CTClient
       
    80 	{
       
    81 public:
       
    82 	CTMultiPtrEventClient(CTMultiPtrEventTest *aTest, TBool aSecondaryClient = EFalse);
       
    83 	~CTMultiPtrEventClient();
       
    84 	void ConstructL();
       
    85 	
       
    86 	inline CTBlankWindow* ParentWin() { return iParentWin; }
       
    87 	inline CTBlankWindow* ChildWin() { return iChildWin; }
       
    88 	inline CTMultiPtrEventBuffer* EventBuffer() {return static_cast<CTMultiPtrEventBuffer*>(iEventHandler);}
       
    89 	inline void SetExpectNonAdvancedPointerEvents() {iExpectNonAdvancedPointerEvents=ETrue;};
       
    90 	inline void ClearExpectNonAdvancedPointerEvents() {iExpectNonAdvancedPointerEvents=EFalse;};
       
    91 
       
    92 	TBool IsSecondaryClient() {return iSecondaryClient;}
       
    93 	
       
    94 	void AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TUint8 aPointerNumber, TUint aHandle = 0);
       
    95 	void AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle = 0);
       
    96 	void AddExpectedWsEvent(TEventCode aType, TInt aPointerNumber = 0, TUint aHandle = 0);
       
    97 	void AddExpectedMovePoint(TPoint aPos);
       
    98 	void CalculatePtrPosAndSet3Ddata(TWsEvent& aEvent, TPointerEvent::TType aType, TPoint aPos, TUint aModifiers, TInt aZ, TUint8 aPointerNumber, TUint aHandle);
       
    99 	void ConstructGroupBlankWinL();
       
   100 	void DeleteGroupBlankWin();
       
   101 	TBool CheckOrdinalPosition(TInt aWinAutoFocus1);
       
   102 	
       
   103 	// Virtual from CTClient
       
   104 	void ConstructEventHandlerL();
       
   105 	
       
   106 private:
       
   107 	CTMultiPtrEventTest* iTest;
       
   108 	TSize iParentWinSize;
       
   109 	TPoint iParentWinPos;
       
   110 	TSize iChildWinSize;
       
   111 	TPoint iChildWinPos;
       
   112 	CTBlankWindow* iParentWin;
       
   113 	CTBlankWindow* iChildWin;
       
   114 
       
   115 	TBool iSecondaryClient;
       
   116 	
       
   117 	// For AutoFocus test
       
   118 	CTWindowGroup* iGroupWinAutoFocus1;
       
   119 	CTWindowGroup* iGroupWinAutoFocus2;
       
   120 	CTBlankWindow* iWinAutoFocus1;
       
   121 	CTBlankWindow* iWinAutoFocus2;
       
   122 	
       
   123 	TSize iWinSizeAutoFocus1;
       
   124 	TPoint iWinPosAutoFocus1;
       
   125 	TSize iWinSizeAutoFocus2;
       
   126 	TPoint iWinPosAutoFocus2;
       
   127 	TBool iExpectNonAdvancedPointerEvents;
       
   128 	};
       
   129 
       
   130 class RMultiPointerAnim : public RTestAnim
       
   131 	{
       
   132 public:
       
   133 	static RMultiPointerAnim* NewL(RWindowBase* aWin, RAnimDll* aDll);
       
   134 	RMultiPointerAnim(RAnimDll* aDll) :RTestAnim(*aDll) {}
       
   135 	TInt AddExpectedAnimPointerEvent(TRawEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TBool aEat = ETrue);
       
   136 	};
       
   137 
       
   138 /*
       
   139  * CTWsGraphicsBase derived class which implements RunTestCaseL pure virtual.
       
   140  * Runs all the testcases for multi poniter events.
       
   141  * For each test case it creates CTMultiPtrEventClient object and creates a nested activescheduler
       
   142  * Calls NextSetOfEventsL() which in turn calls respective tests depending upong the testcase number
       
   143  * For each test simulates the events and adds the same event to CTMultiPtrEventBuffer
       
   144  * When all the tests for a particular testcase completes stops activescheduler
       
   145  * Repeats the same for all testcases
       
   146  */ 
       
   147 class CTMultiPtrEventTest : public CTWsGraphicsBase
       
   148 	{
       
   149 public:
       
   150 	CTMultiPtrEventTest(CTestStep* aStep);
       
   151 	~CTMultiPtrEventTest();
       
   152 	void ConstructL();
       
   153 	void NextSetOfEventsL();
       
   154 	void Failed();
       
   155 	
       
   156 	// Functions for simulating events, which use UserSvr::AddEvent
       
   157 	void SimulatePointerEvent(TRawEvent::TType aType, TInt aX, TInt aY, TUint8 aPointerNumber);
       
   158 	void SimulatePointerEvent(TRawEvent::TType aType, TInt aX, TInt aY, TInt aZ, TUint8 aPointerNumber);
       
   159 	void SimulatePointerDownUp(TInt aX, TInt aY, TInt aZ, TUint8 aPointerNumber);
       
   160 	
       
   161 	// Functions for adding event, calls the client's AddExpectedPointer
       
   162 	void AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TUint8 aPointerNumber, TUint aHandle = 0);
       
   163 	void AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle = 0, TBool aSecondaryClient = EFalse);
       
   164 	void AddExpectedPointerDownUp(TPoint aPos, TInt aZ, TUint8 aPointerNumber);
       
   165 	void AddExpectedWsEvent(TEventCode aType, TBool aSecondaryClient = EFalse, TInt aPointerNumber = 0, TUint aHandle = 0);
       
   166 	void AddExpectedMultiPtrClickEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle = 0);
       
   167 	void AddExpectedMultiPtrClickOtherEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle);
       
   168 	
       
   169 	void AddExpectedKey(TInt aEventCode, TInt aScanCode, TInt aCode/*=0*/, TInt aRepeats/*=0*/, TUint aModifiers/*=0*/);
       
   170 	void AddExpectedKeyDownUp(TInt aScanCode, TInt aCode=0, TInt aRepeats=0, TUint aModifiers=0);	
       
   171 	
       
   172 	// Supplementary function for tests
       
   173 	void TestDragForMultiPointer(TPoint aPtrPos, TInt aPrValue, TUint8 aPointerNumber);
       
   174 	void SimulateAndAddLoneUpEvents(TInt aNumSimulation, TInt aNumAddition, TPoint aPos);
       
   175 	void TestAndDisplayAnimError();
       
   176 	void GetRemainingEventsFromSecondaryClient();
       
   177 	void TestAndDisplayPtrClickError();
       
   178 	void CreatePointerClickPluginL();
       
   179 	void SetAutoFlush();
       
   180 	void ResetFlushStopAS();
       
   181 	void TestFilteringForMultiPointer(TBool aFiltering);
       
   182 	void TestGrabbingForMultiPointer(TBool aGrabbing);
       
   183 	void CreateGroupWinL();
       
   184 	void DeleteGroupWin();
       
   185 	void CreateGroupWinForCapturingL();
       
   186 	void DeleteGroupWinForCapturing();
       
   187 	void CreateAnimDllAndAnimL();
       
   188 	void DestroyAnimDllAndAnim();
       
   189 	void TestCloseProximityHighPressureAPIsL();
       
   190 	void TestCapturingForMultiPointer(TBool aAllGroups);
       
   191 	void SetThresholdValues(TInt aEnterCloseProx, TInt aExitCloseProx, TInt aEnterHighPres, TInt aExitHighPres);
       
   192 	void NegativeTestingOfProximityPressureAPIsL();
       
   193 	void TestErrorCodeL(TInt aExpErrCode, TInt aActualErrCode);
       
   194 	void SimulateProximityAndPressureEvents(TInt aCloseProxEnterValue, TInt aCloseProxExitValue, TInt aHighPresEnterValue, TInt aHighPresExitValue);
       
   195 	void SetDefaultScreenMode();
       
   196 	TPoint GetPointerPostionOnRotatedMode(TPoint aPointerPos, CFbsBitGc::TGraphicsOrientation aRotation);
       
   197 	void LogEventsAdded();
       
   198 	
       
   199 	// All tests
       
   200 	void MultiPointerEvents();
       
   201 	void PurgingMultiPointerEvents();
       
   202 	void MultiPointerEventsForAnimsL();
       
   203 	void MultiClientMultiPointerEvents();
       
   204 	void MultiPointerEventsForPointerClickL();
       
   205 	void MultiPointerEventsInDiffScreenModes();
       
   206 	void FilteringMultiPointerEvents();
       
   207 	void GrabbingMultiPointerEvents();
       
   208 	void VirtualKeyBoardForMultiplePointers();
       
   209 	void DoubleClickForMultiplePointers();
       
   210 	void MultiPointerOutOfRangeEvents();
       
   211 	void AutoForeGroundForMultiplePointersL();
       
   212 	void EmulationRulesForMultiplePointers();
       
   213     void CloseProximityAndHighPressureEventsL();
       
   214 	void OutOfBoundValueTesting();
       
   215 	void CapturingMultiPointerEvents();
       
   216 	void NegativeTestsForProximityPressureEventsL();
       
   217 	void PointerRepeatEventForMultiplePointers();
       
   218 	void SetExpectNonAdvancedPointerEvents(TBool aSecondaryClient=EFalse);
       
   219 	void ClearExpectNonAdvancedPointerEvents(TBool aSecondaryClient=EFalse);
       
   220 	
       
   221 protected:
       
   222 	void RunTestCaseL(TInt aCurTestCase);
       
   223 private:
       
   224 	void RunTestsL();
       
   225 private:
       
   226 	TInt iEventSet;			// Set of events for one particular test case
       
   227 	TBool iFailed;
       
   228 	TBool iActiveSchedulerStarted;
       
   229 	TBool iTheClientFlush;
       
   230 	TBool iClientFlush;
       
   231 	TBool iSecClientFlush;
       
   232 	TSize iPhysicalScreenSize;
       
   233 	TRect iOrigPtrCursorArea;
       
   234 	
       
   235 	TUint iPointerNumber;
       
   236 	TInt iMaxDevPointers;
       
   237 	TInt iMaxUiPointers;
       
   238 	TInt iMaxPressure;
       
   239 	TInt iPressureStep;
       
   240 	TInt iMaxProximity;
       
   241 	TInt iProximityStep;
       
   242 
       
   243 	TInt iEnterCloseProximityThreshold;
       
   244 	TInt iExitCloseProximityThreshold;
       
   245 	TInt iEnterHighPressureThreshold;
       
   246 	TInt iExitHighPressureThreshold;	
       
   247 	 
       
   248 	CTMultiPtrEventClient *iMultiPtrEventClient;
       
   249 	CTMultiPtrEventClient *iSecMultiPtrEventClient;
       
   250 	
       
   251 	RAnimDll* iAnimDll;
       
   252 	RMultiPointerAnim* iAnim;
       
   253 	
       
   254 	RSoundPlugIn iClick;
       
   255 	TBool iPtrPluginLoaded;
       
   256 	RChunk iChunk;
       
   257 	RHeap* iHeap;
       
   258 	TAny* iErrDesc;
       
   259 	
       
   260 	TInt iCurrentScreenMode;
       
   261 	TBool iChangeScreenMode;
       
   262 	
       
   263 	CTWindowGroup* iGroupWinForEmul;
       
   264 	CTBlankWindow* iWinForEmul;
       
   265 	
       
   266 	CTWindowGroup* iGroupWinForCapturing;
       
   267 	CTBlankWindow* iWinForCapturing;
       
   268 	
       
   269 	TInt iYOffset;
       
   270 	};
       
   271 
       
   272 class CTMultiPtrEventTestStep : public CTGraphicsStep
       
   273 	{
       
   274 public:
       
   275 	CTMultiPtrEventTestStep();
       
   276 protected:
       
   277 	//from CTGraphicsStep
       
   278 	virtual CTGraphicsBase* CreateTestL();
       
   279 	};
       
   280 
       
   281 _LIT(KTMultiPtrEventTestStep, "TMultiPtrEventTest");
       
   282 
       
   283 #endif /*TMULTIPTREVENT_H_*/