sl@0: // Copyright (c) 1996-2010 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: sl@0: #ifndef __TEVENT_H__ sl@0: #define __TEVENT_H__ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include "../tlib/testbase.h" sl@0: #include "AUTO.H" sl@0: #include "AUTODLL.H" sl@0: #include "../TClick/CLICK.H" sl@0: #include "TGraphicsHarness.h" sl@0: #ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA sl@0: #include sl@0: #include sl@0: #endif //TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA sl@0: sl@0: const TInt EMaxEventQueueSize=32; sl@0: const TInt EMinQueueSize = 2; sl@0: const TUint KModifiersIgnore = 0xffffffff; sl@0: sl@0: sl@0: class CTEventTest; sl@0: class CTQueueClient; sl@0: sl@0: class TWsQTEvent : public TWsEvent sl@0: { sl@0: friend class CTEventTest; sl@0: public: sl@0: inline TTime& Time() {return iTime;} sl@0: }; sl@0: sl@0: class CTQueueTestEvent : public CTEvent sl@0: { sl@0: enum {EEventBufferSize=40}; sl@0: public: sl@0: CTQueueTestEvent(RWsSession *aWs, CTEventTest *aTest); sl@0: void ConstructL(); sl@0: void AddExpectedEvent(TWsEvent &aEvent); sl@0: inline void ResetCount(TInt aSet) {iEventCount=0;iEventSet=aSet;iLastEventError=EFalse;} sl@0: TInt EventsLeft(); sl@0: inline void SetCheckTimeStamp(TBool aCheck) {iCheckTimeStamp = aCheck;} sl@0: protected: sl@0: void doRunL(); sl@0: private: sl@0: void TestL(TInt aTest); sl@0: private: sl@0: CCirBuf iEventBuffer; sl@0: CTEventTest *iTest; sl@0: TInt iEventCount; sl@0: TInt iEventSet; sl@0: TBool iCheckTimeStamp; sl@0: TPartialRedrawType iRedrawType; sl@0: TBool iLastEventError; sl@0: }; sl@0: sl@0: const TInt EWinPositionX=6; sl@0: const TInt EWinPositionY=9; sl@0: const TInt EWinWidth=100; sl@0: const TInt EWinHeight=50; sl@0: // (6,9) sl@0: // +----------------------+ sl@0: // | (31,21) | sl@0: // | +--------------+ | sl@0: // | | | | sl@0: // | | | | sl@0: // | +--------------+ | sl@0: // | (81,46) | sl@0: // +----------------------+ (106,59) sl@0: sl@0: class CTQueueClient : public CTClient sl@0: { sl@0: private: sl@0: enum {EMaxKeysDown=50}; sl@0: public: sl@0: CTQueueClient(CTEventTest *aTest); sl@0: ~CTQueueClient(); sl@0: void ConstructL(TBool aCreateChild); sl@0: void ConstructEventHandlerL(); sl@0: void AddExpectedEvent(TWsEvent &aEvent); sl@0: TInt WindowGroupIdentifier(); sl@0: CTWinBase* GetHandle(TPoint& aPos); sl@0: void SetChildCapture(TInt aCaptureFlags); sl@0: inline void ResetCount(TInt aSet) {EventQueue()->ResetCount(aSet);} sl@0: inline void EnableFocusChangeEvents() {iGroup->GroupWin()->EnableFocusChangeEvents();} sl@0: inline void DisableFocusChangeEvents() {iGroup->GroupWin()->DisableFocusChangeEvents();} sl@0: inline void EnableGroupListChangeEvents() {iGroup->GroupWin()->EnableGroupListChangeEvents();} sl@0: inline void DisableGroupListChangeEvents() {iGroup->GroupWin()->DisableGroupListChangeEvents();} sl@0: inline CTQueueTestEvent* EventQueue() {return STATIC_CAST(CTQueueTestEvent*,iEventHandler);} sl@0: inline TPoint ChildTopLeft() {return TPoint(EWinWidth/4,EWinHeight/4);} sl@0: inline TSize ChildSize() {return TSize(EWinWidth/2,EWinHeight/2);} sl@0: void CreateEventTestGroupOnSecondScreenL(); sl@0: void CloseEventTestGroupOnSecondScreen(); sl@0: private: sl@0: inline TPoint ParentTopLeft() {return TPoint(EWinPositionX,EWinPositionY);} sl@0: inline TPoint ChildAbsTopLeft() {return ParentTopLeft()+ChildTopLeft();} sl@0: private: sl@0: TInt iKeysDown[EMaxKeysDown]; sl@0: TInt iNumKeysDown; sl@0: CTEventTest *iTest; sl@0: public: sl@0: CTBackedUpWin *iChildWin; sl@0: CTBackedUpWin *iWin; sl@0: TBool iChildCapturing; sl@0: TBool iCapturing; sl@0: CWsScreenDevice* iSndScreen; sl@0: RWindowGroup* iWinGp1; sl@0: RWindowGroup* iWinGp2; sl@0: }; sl@0: sl@0: class REventAnimBase : public RTestAnim sl@0: { sl@0: public: sl@0: enum EAnimationType sl@0: { sl@0: EEventAnim, sl@0: EEventPostingAnim sl@0: }; sl@0: REventAnimBase(RAnimDll* aDll) :RTestAnim(*aDll) {} sl@0: virtual void Destroy(); sl@0: void Reset(); sl@0: TInt ErrorCode(); sl@0: TInt NumberOfEventsReceived(); sl@0: TInt AddExpectedEvent(TBool aEat, const TRawEvent& aEvent); sl@0: TInt AddExpectedEvent(const TAnimRawEvent& aEvent); sl@0: static RAnimDll* LoadL(); sl@0: }; sl@0: sl@0: /** sl@0: Client side handle to server-side anim class used for Anim Event tests sl@0: @internalComponent sl@0: @test sl@0: */ sl@0: class REventAnim : public REventAnimBase sl@0: { sl@0: public: sl@0: static REventAnim* NewL(RWindowBase* aWin, RAnimDll* aDll, REventAnimBase::EAnimationType aType=EEventAnim); sl@0: inline REventAnim(RAnimDll* aDll) : REventAnimBase(aDll) {} sl@0: inline TInt AddEvent(const TAnimRawEvent& aEvent) {return REventAnimBase::AddExpectedEvent(aEvent);}; sl@0: inline TInt GetError() {return REventAnimBase::ErrorCode();}; sl@0: inline TInt GetNumEvents() {return REventAnimBase::NumberOfEventsReceived();}; sl@0: TInt TestFail(TInt aNoEvents); sl@0: }; sl@0: sl@0: /** sl@0: Client side handle to server-side anim class used for Event Handler Removal tests sl@0: sl@0: RRemovableAnim is an anim which removes itself from the event handler list sl@0: after receiving n events, where n is the 'lifetime' of the anim measured in events received. sl@0: sl@0: @internalComponent sl@0: @test sl@0: */ sl@0: class RRemovableAnim : public REventAnimBase sl@0: { sl@0: public: sl@0: static RRemovableAnim* NewLC(RWindowBase* aWin, RAnimDll* aDll); sl@0: inline RRemovableAnim(RAnimDll* aDll) : REventAnimBase(aDll) {} sl@0: inline TInt AddExpectedEvent(const TRawEvent& aEvent) {return REventAnimBase::AddExpectedEvent(EFalse, aEvent);}; sl@0: TInt SetEventHandlerLifetime(TInt aEventCount); sl@0: TInt EventHandlerLifetime(); sl@0: TInt AddToEventHandlers(); sl@0: TInt RemoveFromEventHandlers(); sl@0: TBool TestPassed(); sl@0: }; sl@0: sl@0: class CTEventTest : public CTWsGraphicsBase sl@0: { sl@0: enum { sl@0: EKeyboardInitialRepeat1=1234567, sl@0: EKeyboardRepeat1=555666, sl@0: EKeyboardInitialRepeat2=2121212, sl@0: EKeyboardRepeat2=20000, sl@0: EDoubleClickTime1=900000, sl@0: EDoubleClickGap1=10, sl@0: EDoubleClickTime2=4000000, sl@0: EDoubleClickGap2=5, sl@0: ENumVisWins=2, sl@0: EPointerCursorUpdateGap=50000, //0.05secs Same as WsPointer::EPointerUpdateGapInMicroSeconds sl@0: EKeyboardInitialRepeat3=2147483447, // Max value sl@0: EKeyboardRepeat3=8000, // for repeat 3 sl@0: EKeyboardInitialRepeat4=-2, // Min value sl@0: EKeyboardRepeat4=6000, // for repeat 4 sl@0: EKeyboardRepeat5=7000, // for repeat 4z sl@0: EKeyboardRepeat6=-30000, // for repeat 4 sl@0: EKeyboardRepeat7=2147483447, // for repeat 4 sl@0: }; sl@0: public: sl@0: CTEventTest(CTestStep* aStep); sl@0: ~CTEventTest(); sl@0: //TestState DoTestL(); sl@0: void ConstructL(); sl@0: void General(); sl@0: void General2(); sl@0: void Failed(); sl@0: //void QueuePurgingL(); sl@0: //void SendEventL(); sl@0: //void InvisibleWindowL(); sl@0: //void JavaAdditionsL(); sl@0: void WindowCapBugL(); sl@0: //void XyInputTypeL(); sl@0: //void MovingPointerCursorL(); sl@0: //void RotatedModeL(); sl@0: //void AnimEvent(); sl@0: void CheckTimeInterval(const TTimeIntervalMicroSeconds32 &aTime,TInt EKeyboardRepeat1); sl@0: void KeyRepeatRate(TInt aInitialRepeat, TInt aRepeat); sl@0: void KeyRepeatRateNegTest(TInt aInitialRepeat, TInt aRepeat); sl@0: void DoubleClickSettings(TInt aInterval, TInt aDistance); sl@0: void NextSetOfEventsL(); sl@0: inline void ResetCount(TInt aSet) {iQueueClient->ResetCount(aSet);} sl@0: protected: sl@0: //from CTGraphicsStep sl@0: virtual void RunTestCaseL(TInt aCurTestCase); sl@0: private: sl@0: enum sl@0: { sl@0: EDoRot0 =0x01, sl@0: EDoRot90 =0x02, sl@0: EDoRot180=0x04, sl@0: EDoScale=0x80, sl@0: }; sl@0: enum TClients sl@0: { sl@0: ETheClient, sl@0: EQueueClient, sl@0: }; sl@0: enum TCaptureKeyApis sl@0: { sl@0: ECaptureKey1, sl@0: ECaptureKey2, sl@0: ECaptureKeyUpAndDowns1, sl@0: ECaptureKeyUpAndDowns2, sl@0: ECaptureLongKey1, sl@0: ECaptureLongKey2, sl@0: // Add additional enum values before this line sl@0: EMaxCaptureKeyApis sl@0: }; sl@0: enum TCancelCaptureKeyApis sl@0: { sl@0: ECancelCaptureKey, sl@0: ECancelCaptureKeyUpAndDowns, sl@0: ECancelCaptureLongKey, sl@0: // Add additional enum values before this line sl@0: EMaxCancelCaptureKeyApis sl@0: }; sl@0: enum TLongkeyCapPriorityTests sl@0: { sl@0: ELongkeyCaptureSamePriority, sl@0: ELongkeyCaptureDiffPriority sl@0: }; sl@0: private: sl@0: void RunTestsL(TBool aNeedChildWindows=EFalse); sl@0: void RunTestsRestoreAreaL(TBool aNeedChildWindows); sl@0: void QueuePurge_NextSetOfEventsL(); sl@0: void InitializeQueueSizeTestL(TBool aEventReadyCancel); sl@0: void SendEventTest_NextSetOfEvents(); sl@0: void InvisibleWindow_NextSetOfEvents(); sl@0: void JavaAdditions_NextSetOfEvents(); sl@0: void XyInputType_NextSetOfEvents(); sl@0: void MovingPointerCursor_NextSetOfEventsL(); sl@0: void WinCap_NextSetOfEvents(); sl@0: void RotatedMode_NextSetOfEventsL(); sl@0: void ScreenScaling_NextSetOfEventsL(); sl@0: void AnimEvent_NextSetOfEventsL(); sl@0: void FocusChanged_NextSetOfEventsL(); sl@0: void StopEvents_NextSetOfEventsL(); sl@0: void VirtualKeyboard_NextSetOfEventsL(); sl@0: void KeyClicks_NextSetOfEvents(); sl@0: void CaptureLong_NextSetOfEventsL(); sl@0: void Password_NextSetOfEvents(); sl@0: void GroupListChanged_NextSetOfEventsL(); sl@0: void VisibilityChanged_NextSetOfEventsL(); sl@0: #ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA sl@0: void KeyEventTranslation_NextSetOfEventsL(); sl@0: void KeyEventBlocking_NextSetOfEventsL(); sl@0: void KeyEventAppRestriction_NextSetOfEventsL(); sl@0: void KeyEventAppPriority_NextSetOfEventsL(); sl@0: #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS sl@0: void SurfaceVisibilityChanged1_NextSetOfEventsL(); sl@0: void SurfaceVisibilityChanged2_NextSetOfEventsL(); sl@0: void SurfaceVisibilityChanged3_NextSetOfEventsL(); sl@0: #endif //SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS sl@0: #endif //TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA sl@0: void CheckTimeStamp_NextSetOfEventsL(); sl@0: void RepeatableKeysL(); sl@0: void PointerCapture_NextSetOfEventsL(); sl@0: void PointerBufferPurge_NextSetOfEventsL(); sl@0: void MismatchedCapture_NextSetOfEventsL(); sl@0: void EventHandlerRemoval_NextSetOfEventsL(); sl@0: void EventHandlerRemoval_CreateAnimsL(TInt aAnimCount); sl@0: void EventHandlerRemoval_PrepareAnims(const TInt* aLifeTimes, TInt aAnimCount); sl@0: void EventHandlerRemoval_CreateExpectedEvents(TInt aEventCount, TInt aLiveAnimCount); sl@0: void EventHandlerRemoval_AddExpectedEvent(TRawEvent aEvent, TInt aLiveAnimCount); sl@0: void EventHandlerRemoval_CheckExpectedEventsReceivedByAnims(); sl@0: void EventHandlerRemoval_CheckRecursionOfProcessRawEvent(); sl@0: void EventHandlerRemoval_ManuallyRemoveAllAnims(); sl@0: void EventHandlerRemoval_ResetAllAnims(); sl@0: void EventHandlerRemoval_RemoveAndResetAllAnims(); sl@0: void EventHandlerRemoval_DestroyAllAnims(); sl@0: void EventHandlerRemoval_AddEventHandlerMultipleTimes(); sl@0: void CheckPointerCursorInDifferentScreenMode(TSizeMode aMode,TPoint aOrigin); sl@0: void SimulateAndCheck(TPoint aOrigin,TSize aScale,TInt aXOffset,TInt aYOffset,TPointerEvent::TType aEventType,TRect aPointerCursorArea); sl@0: void AddExpectedKey(TInt aEventCode, TInt aScanCode, TInt aCode=0, TInt aRepeats=0, TUint aModifiers=KModifiersIgnore); sl@0: void AddExpectedKeyDownUp(TInt aScanCode, TInt aCode=0, TInt aRepeats=0, TUint aModifiers=KModifiersIgnore); sl@0: void AddExpectedEvent(TInt aEventCode, CTWinBase* aWin); sl@0: void AddExpectedEvent(TInt aEventCode); sl@0: void AddExpectedEvent(TInt aEventCode,RWindowGroup* aWindow); sl@0: void AddExpectedErrorMessage(TWsErrorMessage::TErrorCategory aCategory, TInt aError); sl@0: void CalculatePointerEvent(TWsEvent& aEvent,TPointerEvent::TType aType, TPoint aPos); sl@0: void CalculatePointerCaptureEvent(TWsEvent& aEvent,TPointerEvent::TType aType, TPoint aPos, TInt aHandle=0); sl@0: void AddExpectedPointer(TPointerEvent::TType aType, TPoint aPos); sl@0: void AddExpectedPointerCapture(TPointerEvent::TType aType, TPoint aPos, TInt aHandle=0); sl@0: void AddExpectedPointerClick(TPointerEvent::TType aType, TPoint aPos); sl@0: void AddExpectedPointerDownUp(TPoint aPos); sl@0: inline void AddExpectedPointerScr(TPointerEvent::TType aType, TPoint aPos); sl@0: inline void AddExpectedPointerDownUpScr(TPoint aPos); sl@0: void AddExpectedModifiersChanged(TInt aChangedModifiers, TInt aModifiers); sl@0: void AddExpectedEnterExit(TInt aEventCode, TPoint aPos); sl@0: void AddExpectedKeyAnim(TRawEvent::TType aEventCode, TInt aScanCode,TBool aEat); sl@0: void AddExpectedPointerAnim(TRawEvent::TType aEventCode, TPoint aPoint, TBool aEat=ETrue); sl@0: void AddExpectedVisibilityChange(TUint aFlags); sl@0: void AddExpectedVisibilityChange(TUint aFlags, CTBlankWindow* aWindow); sl@0: inline void SimulatePointerWin(TRawEvent::TType aType, TInt aX, TInt aY); sl@0: inline void SimulatePointerDownUpWin(TInt aX, TInt aY); sl@0: inline void SimulatePointer(TRawEvent::TType aType, TInt aX, TInt aY); sl@0: void doSendEvent(TWsEvent &aEvent); sl@0: void SendKey(TInt aEventCode, TInt aScanCode, TInt aCode=0, TInt iRepeats=0); sl@0: void SendEvent(TInt aEventCode); sl@0: void CreateEventTestGroup(); sl@0: void CloseEventTestGroup(); sl@0: void CreateAndCloseEventTestGroup(); sl@0: void TriggerOomMessage(TTimeIntervalMinutes aPeriod); sl@0: TBool SetClickType(TClickOutputModes aType); sl@0: CTBlankWindow* NewBlueForgroundWindowL(); sl@0: CTBlankWindow* NewBlueForgroundWindow(); sl@0: TInt KeyRepeatTime() const; sl@0: void EventQueuePtrCrashTest(); sl@0: TInt ClickCommandReply(TInt aCommand,TInt aData); sl@0: TInt CreateGroupWindow(RWindowGroup& aWinGp,TClients aClient,TInt& aWinGpId); sl@0: void CloseGroupWindow(RWindowGroup& aWinGp,TInt aWinGpId); sl@0: void CloseWindow(RWindowBase& aWin,TInt aHandle,TInt aWinGpId); sl@0: void EventQueueExpansionTestL(); sl@0: void RawEventRepeatTest_NextSetOfEventsL(); sl@0: void SimulateRepeatEvent(TInt aScanCode, TInt aRepeats=0); sl@0: #if !defined(TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA) sl@0: void SimulateButton1DownWithSimulatedMove(TInt aX, TInt aY); sl@0: #endif sl@0: void TestCaptureAndCancelCapturePair(TCaptureKeyApis aCaptureApi, TCancelCaptureKeyApis aCancelCaptureApi); sl@0: static TInt GenerateAnEvent(TAny* aEventTest); sl@0: void CheckLongkeyCaptureWithPriority(TLongkeyCapPriorityTests aTestType); sl@0: void DelayForRepeatEvents(TInt aNumeratorFracVal, TInt aDenominatorFracVal); sl@0: #ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA sl@0: void SpawnCaptureAppL(RProcess& aProcess); sl@0: #endif sl@0: private: sl@0: CTBlankWindow* iBlankWin; sl@0: RBlankWindow iBackingWindow; sl@0: TSize iPhysicalScreenSize; sl@0: TSize iWinSize; sl@0: RWindowGroup iEventTestGroup; sl@0: CTWindowGroup *iEventTestGroup2; sl@0: CTWindowGroup *iEventTestGroup3; sl@0: CTWindowGroup *iEventTestGroup4; sl@0: TInt iEventSet; sl@0: CTQueueClient *iQueueClient; sl@0: TBool iFailed; sl@0: REventAnim* iAnim; sl@0: TUint iScreenModeTests; //currently contains supported rotation and if screen scaling is possible sl@0: TInt iNumScrModes; sl@0: RSoundPlugIn iClick; sl@0: TBool iAddToClick; sl@0: TInt iCaptureKey; sl@0: TBool iTurnBackOnCapsLock; sl@0: TInt iCurrentMode; sl@0: TSizeMode iSizeMode; sl@0: TBool iTheClientFlush; sl@0: TBool iQuequeClientFlush; sl@0: CTBlankWindow* iVisWins1; sl@0: CTBlankWindow* iVisWins2; sl@0: CTBlankWindow* iVisWins3; sl@0: CTransWindow* iTransWin; sl@0: RAnimDll* iAnimDll; sl@0: RPointerArray* iRemovableAnims; sl@0: TBool iIs3DPointer; sl@0: TBool iPtrPluginLoaded; sl@0: TInt iYOffset; sl@0: TTimeIntervalMicroSeconds32 iKeyBoardRepeatInitialDelay; sl@0: TTimeIntervalMicroSeconds32 iKeyBoardRepeatNextDelay; sl@0: #ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA sl@0: RProcess iCaptureApp1; sl@0: RProcess iCaptureApp2; sl@0: #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS sl@0: TSurfaceId iSurfaceId; sl@0: RSurfaceManager iSurfaceManager; sl@0: CPeriodic* iTimeOutCallback; sl@0: #endif // SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS sl@0: #endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA sl@0: }; sl@0: sl@0: class CTQueueWindowGroup : public CTWindowGroup sl@0: { sl@0: public: sl@0: CTQueueWindowGroup(CTClient *aClient); sl@0: void ConstructL(); sl@0: private: sl@0: TInt iNumOnEvents; sl@0: }; sl@0: sl@0: class CTEventTestStep : public CTGraphicsStep sl@0: { sl@0: public: sl@0: CTEventTestStep(); sl@0: protected: sl@0: //from CTGraphicsStep sl@0: virtual CTGraphicsBase* CreateTestL(); sl@0: }; sl@0: sl@0: _LIT(KTEventTestStep,"TEventTest"); sl@0: sl@0: sl@0: #endif