sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @test sl@0: @internalComponent - Internal Symbian test code sl@0: */ sl@0: sl@0: #ifndef TMULTIPTREVENT_H_ sl@0: #define TMULTIPTREVENT_H_ sl@0: sl@0: #include sl@0: #include sl@0: #include "w32std.h" sl@0: #include "../tlib/testbase.h" sl@0: #include "AUTO.H" sl@0: #include "AUTODLL.H" sl@0: #include "../TClick/multiptrclick.h" sl@0: #include "TGraphicsHarness.h" sl@0: sl@0: class CTMultiPtrEventTest; sl@0: class CTMultiPtrEventClient; sl@0: sl@0: /* sl@0: * CTEvent derived class which acts as eventhandler and eventbuffer sl@0: * Stores the events in buffer, which is used for comparing events received from wserv. sl@0: */ sl@0: class CTMultiPtrEventBuffer : public CTEvent sl@0: { sl@0: enum {EEventBufferSize=40, EMovePtsBuffer=10}; sl@0: public: sl@0: CTMultiPtrEventBuffer(RWsSession *aWs, CTMultiPtrEventTest *aTest, CTMultiPtrEventClient* aClient); sl@0: void ConstructL(); sl@0: void AddExpectedEvent(TWsEvent &aEvent); sl@0: void AddExpectedMovePtEvent(TPoint &aMovePt); sl@0: TInt EventsRemaining(); sl@0: void SetEventCount(TInt aCount) {iEventCount = aCount;} sl@0: void SetNestedLoopState(TBool aLoopStart) {iNestedLoopStarted = aLoopStart;} sl@0: TBool NestedLoopState() {return iNestedLoopStarted;} sl@0: void GetMoveBufferAndCompareL(); sl@0: protected: sl@0: // Pure virtual from CTEventBase sl@0: void doRunL(); sl@0: private: sl@0: void TestL(TInt aTest); sl@0: void TestL(TInt aTest, TInt aVal1, TInt aVal2,const char *oper, const char *aTestStr, sl@0: const TWsEvent *aEvent, const TWsEvent *aExpected, const char *aFile, TUint aLine); sl@0: void TestL(TInt aTest, TPoint aVal1, TPoint aVal2,const char *oper, const char *aTestStr, sl@0: const TWsEvent *aEvent, const TWsEvent *aExpected, const char *aFile, TUint aLine); sl@0: private: sl@0: CCirBuf iEventBuffer; sl@0: CCirBuf iMovePtsBuffer; sl@0: CTMultiPtrEventTest* iTest; sl@0: TInt iEventCount; sl@0: CTMultiPtrEventClient* iClient; sl@0: TBool iNestedLoopStarted; sl@0: }; sl@0: sl@0: sl@0: /* sl@0: * CTClient derived class which gives Wserv client environment sl@0: * i,e iWs, iScreen, iGc, iGroup, iEventHandler etc... sl@0: * Owns CTMultiPtrEventBuffer and stores in iEventhandler of its base class sl@0: * Accepts the event from test class and passes them on to buffer class sl@0: */ sl@0: class CTMultiPtrEventClient : public CTClient sl@0: { sl@0: public: sl@0: CTMultiPtrEventClient(CTMultiPtrEventTest *aTest, TBool aSecondaryClient = EFalse); sl@0: ~CTMultiPtrEventClient(); sl@0: void ConstructL(); sl@0: sl@0: inline CTBlankWindow* ParentWin() { return iParentWin; } sl@0: inline CTBlankWindow* ChildWin() { return iChildWin; } sl@0: inline CTMultiPtrEventBuffer* EventBuffer() {return static_cast(iEventHandler);} sl@0: inline void SetExpectNonAdvancedPointerEvents() {iExpectNonAdvancedPointerEvents=ETrue;}; sl@0: inline void ClearExpectNonAdvancedPointerEvents() {iExpectNonAdvancedPointerEvents=EFalse;}; sl@0: sl@0: TBool IsSecondaryClient() {return iSecondaryClient;} sl@0: sl@0: void AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TUint8 aPointerNumber, TUint aHandle = 0); sl@0: void AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle = 0); sl@0: void AddExpectedWsEvent(TEventCode aType, TInt aPointerNumber = 0, TUint aHandle = 0); sl@0: void AddExpectedMovePoint(TPoint aPos); sl@0: void CalculatePtrPosAndSet3Ddata(TWsEvent& aEvent, TPointerEvent::TType aType, TPoint aPos, TUint aModifiers, TInt aZ, TUint8 aPointerNumber, TUint aHandle); sl@0: void ConstructGroupBlankWinL(); sl@0: void DeleteGroupBlankWin(); sl@0: TBool CheckOrdinalPosition(TInt aWinAutoFocus1); sl@0: sl@0: // Virtual from CTClient sl@0: void ConstructEventHandlerL(); sl@0: sl@0: private: sl@0: CTMultiPtrEventTest* iTest; sl@0: TSize iParentWinSize; sl@0: TPoint iParentWinPos; sl@0: TSize iChildWinSize; sl@0: TPoint iChildWinPos; sl@0: CTBlankWindow* iParentWin; sl@0: CTBlankWindow* iChildWin; sl@0: sl@0: TBool iSecondaryClient; sl@0: sl@0: // For AutoFocus test sl@0: CTWindowGroup* iGroupWinAutoFocus1; sl@0: CTWindowGroup* iGroupWinAutoFocus2; sl@0: CTBlankWindow* iWinAutoFocus1; sl@0: CTBlankWindow* iWinAutoFocus2; sl@0: sl@0: TSize iWinSizeAutoFocus1; sl@0: TPoint iWinPosAutoFocus1; sl@0: TSize iWinSizeAutoFocus2; sl@0: TPoint iWinPosAutoFocus2; sl@0: TBool iExpectNonAdvancedPointerEvents; sl@0: }; sl@0: sl@0: class RMultiPointerAnim : public RTestAnim sl@0: { sl@0: public: sl@0: static RMultiPointerAnim* NewL(RWindowBase* aWin, RAnimDll* aDll); sl@0: RMultiPointerAnim(RAnimDll* aDll) :RTestAnim(*aDll) {} sl@0: TInt AddExpectedAnimPointerEvent(TRawEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TBool aEat = ETrue); sl@0: }; sl@0: sl@0: /* sl@0: * CTWsGraphicsBase derived class which implements RunTestCaseL pure virtual. sl@0: * Runs all the testcases for multi poniter events. sl@0: * For each test case it creates CTMultiPtrEventClient object and creates a nested activescheduler sl@0: * Calls NextSetOfEventsL() which in turn calls respective tests depending upong the testcase number sl@0: * For each test simulates the events and adds the same event to CTMultiPtrEventBuffer sl@0: * When all the tests for a particular testcase completes stops activescheduler sl@0: * Repeats the same for all testcases sl@0: */ sl@0: class CTMultiPtrEventTest : public CTWsGraphicsBase sl@0: { sl@0: public: sl@0: CTMultiPtrEventTest(CTestStep* aStep); sl@0: ~CTMultiPtrEventTest(); sl@0: void ConstructL(); sl@0: void NextSetOfEventsL(); sl@0: void Failed(); sl@0: sl@0: // Functions for simulating events, which use UserSvr::AddEvent sl@0: void SimulatePointerEvent(TRawEvent::TType aType, TInt aX, TInt aY, TUint8 aPointerNumber); sl@0: void SimulatePointerEvent(TRawEvent::TType aType, TInt aX, TInt aY, TInt aZ, TUint8 aPointerNumber); sl@0: void SimulatePointerDownUp(TInt aX, TInt aY, TInt aZ, TUint8 aPointerNumber); sl@0: sl@0: // Functions for adding event, calls the client's AddExpectedPointer sl@0: void AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TUint8 aPointerNumber, TUint aHandle = 0); sl@0: void AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle = 0, TBool aSecondaryClient = EFalse); sl@0: void AddExpectedPointerDownUp(TPoint aPos, TInt aZ, TUint8 aPointerNumber); sl@0: void AddExpectedWsEvent(TEventCode aType, TBool aSecondaryClient = EFalse, TInt aPointerNumber = 0, TUint aHandle = 0); sl@0: void AddExpectedMultiPtrClickEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle = 0); sl@0: void AddExpectedMultiPtrClickOtherEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle); sl@0: sl@0: void AddExpectedKey(TInt aEventCode, TInt aScanCode, TInt aCode/*=0*/, TInt aRepeats/*=0*/, TUint aModifiers/*=0*/); sl@0: void AddExpectedKeyDownUp(TInt aScanCode, TInt aCode=0, TInt aRepeats=0, TUint aModifiers=0); sl@0: sl@0: // Supplementary function for tests sl@0: void TestDragForMultiPointer(TPoint aPtrPos, TInt aPrValue, TUint8 aPointerNumber); sl@0: void SimulateAndAddLoneUpEvents(TInt aNumSimulation, TInt aNumAddition, TPoint aPos); sl@0: void TestAndDisplayAnimError(); sl@0: void GetRemainingEventsFromSecondaryClient(); sl@0: void TestAndDisplayPtrClickError(); sl@0: void CreatePointerClickPluginL(); sl@0: void SetAutoFlush(); sl@0: void ResetFlushStopAS(); sl@0: void TestFilteringForMultiPointer(TBool aFiltering); sl@0: void TestGrabbingForMultiPointer(TBool aGrabbing); sl@0: void CreateGroupWinL(); sl@0: void DeleteGroupWin(); sl@0: void CreateGroupWinForCapturingL(); sl@0: void DeleteGroupWinForCapturing(); sl@0: void CreateAnimDllAndAnimL(); sl@0: void DestroyAnimDllAndAnim(); sl@0: void TestCloseProximityHighPressureAPIsL(); sl@0: void TestCapturingForMultiPointer(TBool aAllGroups); sl@0: void SetThresholdValues(TInt aEnterCloseProx, TInt aExitCloseProx, TInt aEnterHighPres, TInt aExitHighPres); sl@0: void NegativeTestingOfProximityPressureAPIsL(); sl@0: void TestErrorCodeL(TInt aExpErrCode, TInt aActualErrCode); sl@0: void SimulateProximityAndPressureEvents(TInt aCloseProxEnterValue, TInt aCloseProxExitValue, TInt aHighPresEnterValue, TInt aHighPresExitValue); sl@0: void SetDefaultScreenMode(); sl@0: TPoint GetPointerPostionOnRotatedMode(TPoint aPointerPos, CFbsBitGc::TGraphicsOrientation aRotation); sl@0: void LogEventsAdded(); sl@0: sl@0: // All tests sl@0: void MultiPointerEvents(); sl@0: void PurgingMultiPointerEvents(); sl@0: void MultiPointerEventsForAnimsL(); sl@0: void MultiClientMultiPointerEvents(); sl@0: void MultiPointerEventsForPointerClickL(); sl@0: void MultiPointerEventsInDiffScreenModes(); sl@0: void FilteringMultiPointerEvents(); sl@0: void GrabbingMultiPointerEvents(); sl@0: void VirtualKeyBoardForMultiplePointers(); sl@0: void DoubleClickForMultiplePointers(); sl@0: void MultiPointerOutOfRangeEvents(); sl@0: void AutoForeGroundForMultiplePointersL(); sl@0: void EmulationRulesForMultiplePointers(); sl@0: void CloseProximityAndHighPressureEventsL(); sl@0: void OutOfBoundValueTesting(); sl@0: void CapturingMultiPointerEvents(); sl@0: void NegativeTestsForProximityPressureEventsL(); sl@0: void PointerRepeatEventForMultiplePointers(); sl@0: void SetExpectNonAdvancedPointerEvents(TBool aSecondaryClient=EFalse); sl@0: void ClearExpectNonAdvancedPointerEvents(TBool aSecondaryClient=EFalse); sl@0: sl@0: protected: sl@0: void RunTestCaseL(TInt aCurTestCase); sl@0: private: sl@0: void RunTestsL(); sl@0: private: sl@0: TInt iEventSet; // Set of events for one particular test case sl@0: TBool iFailed; sl@0: TBool iActiveSchedulerStarted; sl@0: TBool iTheClientFlush; sl@0: TBool iClientFlush; sl@0: TBool iSecClientFlush; sl@0: TSize iPhysicalScreenSize; sl@0: TRect iOrigPtrCursorArea; sl@0: sl@0: TUint iPointerNumber; sl@0: TInt iMaxDevPointers; sl@0: TInt iMaxUiPointers; sl@0: TInt iMaxPressure; sl@0: TInt iPressureStep; sl@0: TInt iMaxProximity; sl@0: TInt iProximityStep; sl@0: sl@0: TInt iEnterCloseProximityThreshold; sl@0: TInt iExitCloseProximityThreshold; sl@0: TInt iEnterHighPressureThreshold; sl@0: TInt iExitHighPressureThreshold; sl@0: sl@0: CTMultiPtrEventClient *iMultiPtrEventClient; sl@0: CTMultiPtrEventClient *iSecMultiPtrEventClient; sl@0: sl@0: RAnimDll* iAnimDll; sl@0: RMultiPointerAnim* iAnim; sl@0: sl@0: RSoundPlugIn iClick; sl@0: TBool iPtrPluginLoaded; sl@0: RChunk iChunk; sl@0: RHeap* iHeap; sl@0: TAny* iErrDesc; sl@0: sl@0: TInt iCurrentScreenMode; sl@0: TBool iChangeScreenMode; sl@0: sl@0: CTWindowGroup* iGroupWinForEmul; sl@0: CTBlankWindow* iWinForEmul; sl@0: sl@0: CTWindowGroup* iGroupWinForCapturing; sl@0: CTBlankWindow* iWinForCapturing; sl@0: sl@0: TInt iYOffset; sl@0: }; sl@0: sl@0: class CTMultiPtrEventTestStep : public CTGraphicsStep sl@0: { sl@0: public: sl@0: CTMultiPtrEventTestStep(); sl@0: protected: sl@0: //from CTGraphicsStep sl@0: virtual CTGraphicsBase* CreateTestL(); sl@0: }; sl@0: sl@0: _LIT(KTMultiPtrEventTestStep, "TMultiPtrEventTest"); sl@0: sl@0: #endif /*TMULTIPTREVENT_H_*/