1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/windowing/windowserver/test/tauto/TEVENT.H Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,442 @@
1.4 +// Copyright (c) 1996-2010 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +/**
1.20 + @file
1.21 + @test
1.22 + @internalComponent - Internal Symbian test code
1.23 +*/
1.24 +
1.25 +
1.26 +#ifndef __TEVENT_H__
1.27 +#define __TEVENT_H__
1.28 +
1.29 +#include <e32std.h>
1.30 +#include <e32cmn.h>
1.31 +#include <w32std.h>
1.32 +#include "../tlib/testbase.h"
1.33 +#include "AUTO.H"
1.34 +#include "AUTODLL.H"
1.35 +#include "../TClick/CLICK.H"
1.36 +#include "TGraphicsHarness.h"
1.37 +#ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
1.38 +#include <graphics/surfacemanager.h>
1.39 +#include <graphics/surfaceupdateclient.h>
1.40 +#endif //TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
1.41 +
1.42 +const TInt EMaxEventQueueSize=32;
1.43 +const TInt EMinQueueSize = 2;
1.44 +const TUint KModifiersIgnore = 0xffffffff;
1.45 +
1.46 +
1.47 +class CTEventTest;
1.48 +class CTQueueClient;
1.49 +
1.50 +class TWsQTEvent : public TWsEvent
1.51 + {
1.52 + friend class CTEventTest;
1.53 +public:
1.54 + inline TTime& Time() {return iTime;}
1.55 + };
1.56 +
1.57 +class CTQueueTestEvent : public CTEvent
1.58 + {
1.59 + enum {EEventBufferSize=40};
1.60 +public:
1.61 + CTQueueTestEvent(RWsSession *aWs, CTEventTest *aTest);
1.62 + void ConstructL();
1.63 + void AddExpectedEvent(TWsEvent &aEvent);
1.64 + inline void ResetCount(TInt aSet) {iEventCount=0;iEventSet=aSet;iLastEventError=EFalse;}
1.65 + TInt EventsLeft();
1.66 + inline void SetCheckTimeStamp(TBool aCheck) {iCheckTimeStamp = aCheck;}
1.67 +protected:
1.68 + void doRunL();
1.69 +private:
1.70 + void TestL(TInt aTest);
1.71 +private:
1.72 + CCirBuf<TWsEvent> iEventBuffer;
1.73 + CTEventTest *iTest;
1.74 + TInt iEventCount;
1.75 + TInt iEventSet;
1.76 + TBool iCheckTimeStamp;
1.77 + TPartialRedrawType iRedrawType;
1.78 + TBool iLastEventError;
1.79 + };
1.80 +
1.81 +const TInt EWinPositionX=6;
1.82 +const TInt EWinPositionY=9;
1.83 +const TInt EWinWidth=100;
1.84 +const TInt EWinHeight=50;
1.85 +// (6,9)
1.86 +// +----------------------+
1.87 +// | (31,21) |
1.88 +// | +--------------+ |
1.89 +// | | | |
1.90 +// | | | |
1.91 +// | +--------------+ |
1.92 +// | (81,46) |
1.93 +// +----------------------+ (106,59)
1.94 +
1.95 +class CTQueueClient : public CTClient
1.96 + {
1.97 +private:
1.98 + enum {EMaxKeysDown=50};
1.99 +public:
1.100 + CTQueueClient(CTEventTest *aTest);
1.101 + ~CTQueueClient();
1.102 + void ConstructL(TBool aCreateChild);
1.103 + void ConstructEventHandlerL();
1.104 + void AddExpectedEvent(TWsEvent &aEvent);
1.105 + TInt WindowGroupIdentifier();
1.106 + CTWinBase* GetHandle(TPoint& aPos);
1.107 + void SetChildCapture(TInt aCaptureFlags);
1.108 + inline void ResetCount(TInt aSet) {EventQueue()->ResetCount(aSet);}
1.109 + inline void EnableFocusChangeEvents() {iGroup->GroupWin()->EnableFocusChangeEvents();}
1.110 + inline void DisableFocusChangeEvents() {iGroup->GroupWin()->DisableFocusChangeEvents();}
1.111 + inline void EnableGroupListChangeEvents() {iGroup->GroupWin()->EnableGroupListChangeEvents();}
1.112 + inline void DisableGroupListChangeEvents() {iGroup->GroupWin()->DisableGroupListChangeEvents();}
1.113 + inline CTQueueTestEvent* EventQueue() {return STATIC_CAST(CTQueueTestEvent*,iEventHandler);}
1.114 + inline TPoint ChildTopLeft() {return TPoint(EWinWidth/4,EWinHeight/4);}
1.115 + inline TSize ChildSize() {return TSize(EWinWidth/2,EWinHeight/2);}
1.116 + void CreateEventTestGroupOnSecondScreenL();
1.117 + void CloseEventTestGroupOnSecondScreen();
1.118 +private:
1.119 + inline TPoint ParentTopLeft() {return TPoint(EWinPositionX,EWinPositionY);}
1.120 + inline TPoint ChildAbsTopLeft() {return ParentTopLeft()+ChildTopLeft();}
1.121 +private:
1.122 + TInt iKeysDown[EMaxKeysDown];
1.123 + TInt iNumKeysDown;
1.124 + CTEventTest *iTest;
1.125 +public:
1.126 + CTBackedUpWin *iChildWin;
1.127 + CTBackedUpWin *iWin;
1.128 + TBool iChildCapturing;
1.129 + TBool iCapturing;
1.130 + CWsScreenDevice* iSndScreen;
1.131 + RWindowGroup* iWinGp1;
1.132 + RWindowGroup* iWinGp2;
1.133 + };
1.134 +
1.135 +class REventAnimBase : public RTestAnim
1.136 + {
1.137 +public:
1.138 + enum EAnimationType
1.139 + {
1.140 + EEventAnim,
1.141 + EEventPostingAnim
1.142 + };
1.143 + REventAnimBase(RAnimDll* aDll) :RTestAnim(*aDll) {}
1.144 + virtual void Destroy();
1.145 + void Reset();
1.146 + TInt ErrorCode();
1.147 + TInt NumberOfEventsReceived();
1.148 + TInt AddExpectedEvent(TBool aEat, const TRawEvent& aEvent);
1.149 + TInt AddExpectedEvent(const TAnimRawEvent& aEvent);
1.150 + static RAnimDll* LoadL();
1.151 + };
1.152 +
1.153 +/**
1.154 + Client side handle to server-side anim class used for Anim Event tests
1.155 + @internalComponent
1.156 + @test
1.157 + */
1.158 +class REventAnim : public REventAnimBase
1.159 + {
1.160 +public:
1.161 + static REventAnim* NewL(RWindowBase* aWin, RAnimDll* aDll, REventAnimBase::EAnimationType aType=EEventAnim);
1.162 + inline REventAnim(RAnimDll* aDll) : REventAnimBase(aDll) {}
1.163 + inline TInt AddEvent(const TAnimRawEvent& aEvent) {return REventAnimBase::AddExpectedEvent(aEvent);};
1.164 + inline TInt GetError() {return REventAnimBase::ErrorCode();};
1.165 + inline TInt GetNumEvents() {return REventAnimBase::NumberOfEventsReceived();};
1.166 + TInt TestFail(TInt aNoEvents);
1.167 + };
1.168 +
1.169 +/**
1.170 + Client side handle to server-side anim class used for Event Handler Removal tests
1.171 +
1.172 + RRemovableAnim is an anim which removes itself from the event handler list
1.173 + after receiving n events, where n is the 'lifetime' of the anim measured in events received.
1.174 +
1.175 + @internalComponent
1.176 + @test
1.177 + */
1.178 +class RRemovableAnim : public REventAnimBase
1.179 + {
1.180 +public:
1.181 + static RRemovableAnim* NewLC(RWindowBase* aWin, RAnimDll* aDll);
1.182 + inline RRemovableAnim(RAnimDll* aDll) : REventAnimBase(aDll) {}
1.183 + inline TInt AddExpectedEvent(const TRawEvent& aEvent) {return REventAnimBase::AddExpectedEvent(EFalse, aEvent);};
1.184 + TInt SetEventHandlerLifetime(TInt aEventCount);
1.185 + TInt EventHandlerLifetime();
1.186 + TInt AddToEventHandlers();
1.187 + TInt RemoveFromEventHandlers();
1.188 + TBool TestPassed();
1.189 + };
1.190 +
1.191 +class CTEventTest : public CTWsGraphicsBase
1.192 + {
1.193 + enum {
1.194 + EKeyboardInitialRepeat1=1234567,
1.195 + EKeyboardRepeat1=555666,
1.196 + EKeyboardInitialRepeat2=2121212,
1.197 + EKeyboardRepeat2=20000,
1.198 + EDoubleClickTime1=900000,
1.199 + EDoubleClickGap1=10,
1.200 + EDoubleClickTime2=4000000,
1.201 + EDoubleClickGap2=5,
1.202 + ENumVisWins=2,
1.203 + EPointerCursorUpdateGap=50000, //0.05secs Same as WsPointer::EPointerUpdateGapInMicroSeconds
1.204 + EKeyboardInitialRepeat3=2147483447, // Max value
1.205 + EKeyboardRepeat3=8000, // for repeat 3
1.206 + EKeyboardInitialRepeat4=-2, // Min value
1.207 + EKeyboardRepeat4=6000, // for repeat 4
1.208 + EKeyboardRepeat5=7000, // for repeat 4z
1.209 + EKeyboardRepeat6=-30000, // for repeat 4
1.210 + EKeyboardRepeat7=2147483447, // for repeat 4
1.211 + };
1.212 +public:
1.213 + CTEventTest(CTestStep* aStep);
1.214 + ~CTEventTest();
1.215 + //TestState DoTestL();
1.216 + void ConstructL();
1.217 + void General();
1.218 + void General2();
1.219 + void Failed();
1.220 + //void QueuePurgingL();
1.221 + //void SendEventL();
1.222 + //void InvisibleWindowL();
1.223 + //void JavaAdditionsL();
1.224 + void WindowCapBugL();
1.225 + //void XyInputTypeL();
1.226 + //void MovingPointerCursorL();
1.227 + //void RotatedModeL();
1.228 + //void AnimEvent();
1.229 + void CheckTimeInterval(const TTimeIntervalMicroSeconds32 &aTime,TInt EKeyboardRepeat1);
1.230 + void KeyRepeatRate(TInt aInitialRepeat, TInt aRepeat);
1.231 + void KeyRepeatRateNegTest(TInt aInitialRepeat, TInt aRepeat);
1.232 + void DoubleClickSettings(TInt aInterval, TInt aDistance);
1.233 + void NextSetOfEventsL();
1.234 + inline void ResetCount(TInt aSet) {iQueueClient->ResetCount(aSet);}
1.235 +protected:
1.236 +//from CTGraphicsStep
1.237 + virtual void RunTestCaseL(TInt aCurTestCase);
1.238 +private:
1.239 + enum
1.240 + {
1.241 + EDoRot0 =0x01,
1.242 + EDoRot90 =0x02,
1.243 + EDoRot180=0x04,
1.244 + EDoScale=0x80,
1.245 + };
1.246 + enum TClients
1.247 + {
1.248 + ETheClient,
1.249 + EQueueClient,
1.250 + };
1.251 + enum TCaptureKeyApis
1.252 + {
1.253 + ECaptureKey1,
1.254 + ECaptureKey2,
1.255 + ECaptureKeyUpAndDowns1,
1.256 + ECaptureKeyUpAndDowns2,
1.257 + ECaptureLongKey1,
1.258 + ECaptureLongKey2,
1.259 + // Add additional enum values before this line
1.260 + EMaxCaptureKeyApis
1.261 + };
1.262 + enum TCancelCaptureKeyApis
1.263 + {
1.264 + ECancelCaptureKey,
1.265 + ECancelCaptureKeyUpAndDowns,
1.266 + ECancelCaptureLongKey,
1.267 + // Add additional enum values before this line
1.268 + EMaxCancelCaptureKeyApis
1.269 + };
1.270 + enum TLongkeyCapPriorityTests
1.271 + {
1.272 + ELongkeyCaptureSamePriority,
1.273 + ELongkeyCaptureDiffPriority
1.274 + };
1.275 +private:
1.276 + void RunTestsL(TBool aNeedChildWindows=EFalse);
1.277 + void RunTestsRestoreAreaL(TBool aNeedChildWindows);
1.278 + void QueuePurge_NextSetOfEventsL();
1.279 + void InitializeQueueSizeTestL(TBool aEventReadyCancel);
1.280 + void SendEventTest_NextSetOfEvents();
1.281 + void InvisibleWindow_NextSetOfEvents();
1.282 + void JavaAdditions_NextSetOfEvents();
1.283 + void XyInputType_NextSetOfEvents();
1.284 + void MovingPointerCursor_NextSetOfEventsL();
1.285 + void WinCap_NextSetOfEvents();
1.286 + void RotatedMode_NextSetOfEventsL();
1.287 + void ScreenScaling_NextSetOfEventsL();
1.288 + void AnimEvent_NextSetOfEventsL();
1.289 + void FocusChanged_NextSetOfEventsL();
1.290 + void StopEvents_NextSetOfEventsL();
1.291 + void VirtualKeyboard_NextSetOfEventsL();
1.292 + void KeyClicks_NextSetOfEvents();
1.293 + void CaptureLong_NextSetOfEventsL();
1.294 + void Password_NextSetOfEvents();
1.295 + void GroupListChanged_NextSetOfEventsL();
1.296 + void VisibilityChanged_NextSetOfEventsL();
1.297 +#ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
1.298 + void KeyEventTranslation_NextSetOfEventsL();
1.299 + void KeyEventBlocking_NextSetOfEventsL();
1.300 + void KeyEventAppRestriction_NextSetOfEventsL();
1.301 + void KeyEventAppPriority_NextSetOfEventsL();
1.302 +#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
1.303 + void SurfaceVisibilityChanged1_NextSetOfEventsL();
1.304 + void SurfaceVisibilityChanged2_NextSetOfEventsL();
1.305 + void SurfaceVisibilityChanged3_NextSetOfEventsL();
1.306 +#endif //SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
1.307 +#endif //TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
1.308 + void CheckTimeStamp_NextSetOfEventsL();
1.309 + void RepeatableKeysL();
1.310 + void PointerCapture_NextSetOfEventsL();
1.311 + void PointerBufferPurge_NextSetOfEventsL();
1.312 + void MismatchedCapture_NextSetOfEventsL();
1.313 + void EventHandlerRemoval_NextSetOfEventsL();
1.314 + void EventHandlerRemoval_CreateAnimsL(TInt aAnimCount);
1.315 + void EventHandlerRemoval_PrepareAnims(const TInt* aLifeTimes, TInt aAnimCount);
1.316 + void EventHandlerRemoval_CreateExpectedEvents(TInt aEventCount, TInt aLiveAnimCount);
1.317 + void EventHandlerRemoval_AddExpectedEvent(TRawEvent aEvent, TInt aLiveAnimCount);
1.318 + void EventHandlerRemoval_CheckExpectedEventsReceivedByAnims();
1.319 + void EventHandlerRemoval_CheckRecursionOfProcessRawEvent();
1.320 + void EventHandlerRemoval_ManuallyRemoveAllAnims();
1.321 + void EventHandlerRemoval_ResetAllAnims();
1.322 + void EventHandlerRemoval_RemoveAndResetAllAnims();
1.323 + void EventHandlerRemoval_DestroyAllAnims();
1.324 + void EventHandlerRemoval_AddEventHandlerMultipleTimes();
1.325 + void CheckPointerCursorInDifferentScreenMode(TSizeMode aMode,TPoint aOrigin);
1.326 + void SimulateAndCheck(TPoint aOrigin,TSize aScale,TInt aXOffset,TInt aYOffset,TPointerEvent::TType aEventType,TRect aPointerCursorArea);
1.327 + void AddExpectedKey(TInt aEventCode, TInt aScanCode, TInt aCode=0, TInt aRepeats=0, TUint aModifiers=KModifiersIgnore);
1.328 + void AddExpectedKeyDownUp(TInt aScanCode, TInt aCode=0, TInt aRepeats=0, TUint aModifiers=KModifiersIgnore);
1.329 + void AddExpectedEvent(TInt aEventCode, CTWinBase* aWin);
1.330 + void AddExpectedEvent(TInt aEventCode);
1.331 + void AddExpectedEvent(TInt aEventCode,RWindowGroup* aWindow);
1.332 + void AddExpectedErrorMessage(TWsErrorMessage::TErrorCategory aCategory, TInt aError);
1.333 + void CalculatePointerEvent(TWsEvent& aEvent,TPointerEvent::TType aType, TPoint aPos);
1.334 + void CalculatePointerCaptureEvent(TWsEvent& aEvent,TPointerEvent::TType aType, TPoint aPos, TInt aHandle=0);
1.335 + void AddExpectedPointer(TPointerEvent::TType aType, TPoint aPos);
1.336 + void AddExpectedPointerCapture(TPointerEvent::TType aType, TPoint aPos, TInt aHandle=0);
1.337 + void AddExpectedPointerClick(TPointerEvent::TType aType, TPoint aPos);
1.338 + void AddExpectedPointerDownUp(TPoint aPos);
1.339 + inline void AddExpectedPointerScr(TPointerEvent::TType aType, TPoint aPos);
1.340 + inline void AddExpectedPointerDownUpScr(TPoint aPos);
1.341 + void AddExpectedModifiersChanged(TInt aChangedModifiers, TInt aModifiers);
1.342 + void AddExpectedEnterExit(TInt aEventCode, TPoint aPos);
1.343 + void AddExpectedKeyAnim(TRawEvent::TType aEventCode, TInt aScanCode,TBool aEat);
1.344 + void AddExpectedPointerAnim(TRawEvent::TType aEventCode, TPoint aPoint, TBool aEat=ETrue);
1.345 + void AddExpectedVisibilityChange(TUint aFlags);
1.346 + void AddExpectedVisibilityChange(TUint aFlags, CTBlankWindow* aWindow);
1.347 + inline void SimulatePointerWin(TRawEvent::TType aType, TInt aX, TInt aY);
1.348 + inline void SimulatePointerDownUpWin(TInt aX, TInt aY);
1.349 + inline void SimulatePointer(TRawEvent::TType aType, TInt aX, TInt aY);
1.350 + void doSendEvent(TWsEvent &aEvent);
1.351 + void SendKey(TInt aEventCode, TInt aScanCode, TInt aCode=0, TInt iRepeats=0);
1.352 + void SendEvent(TInt aEventCode);
1.353 + void CreateEventTestGroup();
1.354 + void CloseEventTestGroup();
1.355 + void CreateAndCloseEventTestGroup();
1.356 + void TriggerOomMessage(TTimeIntervalMinutes aPeriod);
1.357 + TBool SetClickType(TClickOutputModes aType);
1.358 + CTBlankWindow* NewBlueForgroundWindowL();
1.359 + CTBlankWindow* NewBlueForgroundWindow();
1.360 + TInt KeyRepeatTime() const;
1.361 + void EventQueuePtrCrashTest();
1.362 + TInt ClickCommandReply(TInt aCommand,TInt aData);
1.363 + TInt CreateGroupWindow(RWindowGroup& aWinGp,TClients aClient,TInt& aWinGpId);
1.364 + void CloseGroupWindow(RWindowGroup& aWinGp,TInt aWinGpId);
1.365 + void CloseWindow(RWindowBase& aWin,TInt aHandle,TInt aWinGpId);
1.366 + void EventQueueExpansionTestL();
1.367 + void RawEventRepeatTest_NextSetOfEventsL();
1.368 + void SimulateRepeatEvent(TInt aScanCode, TInt aRepeats=0);
1.369 +#if !defined(TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA)
1.370 + void SimulateButton1DownWithSimulatedMove(TInt aX, TInt aY);
1.371 +#endif
1.372 + void TestCaptureAndCancelCapturePair(TCaptureKeyApis aCaptureApi, TCancelCaptureKeyApis aCancelCaptureApi);
1.373 + static TInt GenerateAnEvent(TAny* aEventTest);
1.374 + void CheckLongkeyCaptureWithPriority(TLongkeyCapPriorityTests aTestType);
1.375 + void DelayForRepeatEvents(TInt aNumeratorFracVal, TInt aDenominatorFracVal);
1.376 +#ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
1.377 + void SpawnCaptureAppL(RProcess& aProcess);
1.378 +#endif
1.379 +private:
1.380 + CTBlankWindow* iBlankWin;
1.381 + RBlankWindow iBackingWindow;
1.382 + TSize iPhysicalScreenSize;
1.383 + TSize iWinSize;
1.384 + RWindowGroup iEventTestGroup;
1.385 + CTWindowGroup *iEventTestGroup2;
1.386 + CTWindowGroup *iEventTestGroup3;
1.387 + CTWindowGroup *iEventTestGroup4;
1.388 + TInt iEventSet;
1.389 + CTQueueClient *iQueueClient;
1.390 + TBool iFailed;
1.391 + REventAnim* iAnim;
1.392 + TUint iScreenModeTests; //currently contains supported rotation and if screen scaling is possible
1.393 + TInt iNumScrModes;
1.394 + RSoundPlugIn iClick;
1.395 + TBool iAddToClick;
1.396 + TInt iCaptureKey;
1.397 + TBool iTurnBackOnCapsLock;
1.398 + TInt iCurrentMode;
1.399 + TSizeMode iSizeMode;
1.400 + TBool iTheClientFlush;
1.401 + TBool iQuequeClientFlush;
1.402 + CTBlankWindow* iVisWins1;
1.403 + CTBlankWindow* iVisWins2;
1.404 + CTBlankWindow* iVisWins3;
1.405 + CTransWindow* iTransWin;
1.406 + RAnimDll* iAnimDll;
1.407 + RPointerArray<RRemovableAnim>* iRemovableAnims;
1.408 + TBool iIs3DPointer;
1.409 + TBool iPtrPluginLoaded;
1.410 + TInt iYOffset;
1.411 + TTimeIntervalMicroSeconds32 iKeyBoardRepeatInitialDelay;
1.412 + TTimeIntervalMicroSeconds32 iKeyBoardRepeatNextDelay;
1.413 +#ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
1.414 + RProcess iCaptureApp1;
1.415 + RProcess iCaptureApp2;
1.416 +#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
1.417 + TSurfaceId iSurfaceId;
1.418 + RSurfaceManager iSurfaceManager;
1.419 + CPeriodic* iTimeOutCallback;
1.420 +#endif // SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
1.421 +#endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
1.422 + };
1.423 +
1.424 +class CTQueueWindowGroup : public CTWindowGroup
1.425 + {
1.426 +public:
1.427 + CTQueueWindowGroup(CTClient *aClient);
1.428 + void ConstructL();
1.429 +private:
1.430 + TInt iNumOnEvents;
1.431 + };
1.432 +
1.433 +class CTEventTestStep : public CTGraphicsStep
1.434 + {
1.435 +public:
1.436 + CTEventTestStep();
1.437 +protected:
1.438 + //from CTGraphicsStep
1.439 + virtual CTGraphicsBase* CreateTestL();
1.440 + };
1.441 +
1.442 +_LIT(KTEventTestStep,"TEventTest");
1.443 +
1.444 +
1.445 +#endif