First public contribution.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 @internalComponent - Internal Symbian test code
22 #ifndef TMULTIPTREVENT_H_
23 #define TMULTIPTREVENT_H_
28 #include "../tlib/testbase.h"
31 #include "../TClick/multiptrclick.h"
32 #include "TGraphicsHarness.h"
34 class CTMultiPtrEventTest;
35 class CTMultiPtrEventClient;
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.
41 class CTMultiPtrEventBuffer : public CTEvent
43 enum {EEventBufferSize=40, EMovePtsBuffer=10};
45 CTMultiPtrEventBuffer(RWsSession *aWs, CTMultiPtrEventTest *aTest, CTMultiPtrEventClient* aClient);
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();
55 // Pure virtual from CTEventBase
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);
64 CCirBuf<TWsEvent> iEventBuffer;
65 CCirBuf<TPoint> iMovePtsBuffer;
66 CTMultiPtrEventTest* iTest;
68 CTMultiPtrEventClient* iClient;
69 TBool iNestedLoopStarted;
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
79 class CTMultiPtrEventClient : public CTClient
82 CTMultiPtrEventClient(CTMultiPtrEventTest *aTest, TBool aSecondaryClient = EFalse);
83 ~CTMultiPtrEventClient();
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;};
92 TBool IsSecondaryClient() {return iSecondaryClient;}
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);
103 // Virtual from CTClient
104 void ConstructEventHandlerL();
107 CTMultiPtrEventTest* iTest;
108 TSize iParentWinSize;
109 TPoint iParentWinPos;
112 CTBlankWindow* iParentWin;
113 CTBlankWindow* iChildWin;
115 TBool iSecondaryClient;
117 // For AutoFocus test
118 CTWindowGroup* iGroupWinAutoFocus1;
119 CTWindowGroup* iGroupWinAutoFocus2;
120 CTBlankWindow* iWinAutoFocus1;
121 CTBlankWindow* iWinAutoFocus2;
123 TSize iWinSizeAutoFocus1;
124 TPoint iWinPosAutoFocus1;
125 TSize iWinSizeAutoFocus2;
126 TPoint iWinPosAutoFocus2;
127 TBool iExpectNonAdvancedPointerEvents;
130 class RMultiPointerAnim : public RTestAnim
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);
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
147 class CTMultiPtrEventTest : public CTWsGraphicsBase
150 CTMultiPtrEventTest(CTestStep* aStep);
151 ~CTMultiPtrEventTest();
153 void NextSetOfEventsL();
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);
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);
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);
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();
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();
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);
222 void RunTestCaseL(TInt aCurTestCase);
226 TInt iEventSet; // Set of events for one particular test case
228 TBool iActiveSchedulerStarted;
229 TBool iTheClientFlush;
231 TBool iSecClientFlush;
232 TSize iPhysicalScreenSize;
233 TRect iOrigPtrCursorArea;
235 TUint iPointerNumber;
236 TInt iMaxDevPointers;
243 TInt iEnterCloseProximityThreshold;
244 TInt iExitCloseProximityThreshold;
245 TInt iEnterHighPressureThreshold;
246 TInt iExitHighPressureThreshold;
248 CTMultiPtrEventClient *iMultiPtrEventClient;
249 CTMultiPtrEventClient *iSecMultiPtrEventClient;
252 RMultiPointerAnim* iAnim;
255 TBool iPtrPluginLoaded;
260 TInt iCurrentScreenMode;
261 TBool iChangeScreenMode;
263 CTWindowGroup* iGroupWinForEmul;
264 CTBlankWindow* iWinForEmul;
266 CTWindowGroup* iGroupWinForCapturing;
267 CTBlankWindow* iWinForCapturing;
272 class CTMultiPtrEventTestStep : public CTGraphicsStep
275 CTMultiPtrEventTestStep();
277 //from CTGraphicsStep
278 virtual CTGraphicsBase* CreateTestL();
281 _LIT(KTMultiPtrEventTestStep, "TMultiPtrEventTest");
283 #endif /*TMULTIPTREVENT_H_*/