os/graphics/windowing/windowserver/test/tauto/TEVENT.H
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 1996-2010 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 
    23 #ifndef __TEVENT_H__
    24 #define __TEVENT_H__
    25 
    26 #include <e32std.h>
    27 #include <e32cmn.h>
    28 #include <w32std.h>
    29 #include "../tlib/testbase.h"
    30 #include "AUTO.H"
    31 #include "AUTODLL.H"
    32 #include "../TClick/CLICK.H"
    33 #include "TGraphicsHarness.h"
    34 #ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA 
    35 #include <graphics/surfacemanager.h>
    36 #include <graphics/surfaceupdateclient.h>
    37 #endif //TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA 
    38 
    39 const TInt EMaxEventQueueSize=32;
    40 const TInt EMinQueueSize = 2;
    41 const TUint KModifiersIgnore = 0xffffffff;
    42 
    43 
    44 class CTEventTest;
    45 class CTQueueClient;
    46 
    47 class TWsQTEvent : public TWsEvent
    48 	{
    49 	friend class CTEventTest;
    50 public:
    51 	inline TTime& Time() {return iTime;}
    52 	};
    53 
    54 class CTQueueTestEvent : public CTEvent
    55 	{
    56 	enum {EEventBufferSize=40};
    57 public:
    58 	CTQueueTestEvent(RWsSession *aWs, CTEventTest *aTest);
    59 	void ConstructL();
    60 	void AddExpectedEvent(TWsEvent &aEvent);
    61 	inline void ResetCount(TInt aSet) {iEventCount=0;iEventSet=aSet;iLastEventError=EFalse;}
    62 	TInt EventsLeft();
    63 	inline void SetCheckTimeStamp(TBool aCheck) {iCheckTimeStamp = aCheck;}
    64 protected:
    65 	void doRunL();
    66 private:
    67 	void TestL(TInt aTest);
    68 private:
    69 	CCirBuf<TWsEvent> iEventBuffer;
    70 	CTEventTest *iTest;
    71 	TInt iEventCount;
    72 	TInt iEventSet;
    73 	TBool iCheckTimeStamp;
    74 	TPartialRedrawType iRedrawType;
    75 	TBool iLastEventError;
    76 	};
    77 
    78 const TInt EWinPositionX=6;
    79 const TInt EWinPositionY=9;
    80 const TInt EWinWidth=100;
    81 const TInt EWinHeight=50;
    82 // (6,9)
    83 // +----------------------+
    84 // |   (31,21)            |
    85 // |   +--------------+   |
    86 // |   |              |   |
    87 // |   |              |   |
    88 // |   +--------------+   |
    89 // |            (81,46)   |
    90 // +----------------------+ (106,59)
    91 
    92 class CTQueueClient : public CTClient
    93 	{
    94 private:
    95 	enum {EMaxKeysDown=50};
    96 public:
    97 	CTQueueClient(CTEventTest *aTest);
    98 	~CTQueueClient();
    99 	void ConstructL(TBool aCreateChild);
   100 	void ConstructEventHandlerL();
   101 	void AddExpectedEvent(TWsEvent &aEvent);
   102 	TInt WindowGroupIdentifier();
   103 	CTWinBase* GetHandle(TPoint& aPos);
   104 	void SetChildCapture(TInt aCaptureFlags);
   105 	inline void ResetCount(TInt aSet) {EventQueue()->ResetCount(aSet);}
   106 	inline void EnableFocusChangeEvents() {iGroup->GroupWin()->EnableFocusChangeEvents();}
   107 	inline void DisableFocusChangeEvents() {iGroup->GroupWin()->DisableFocusChangeEvents();}
   108 	inline void EnableGroupListChangeEvents() {iGroup->GroupWin()->EnableGroupListChangeEvents();}
   109 	inline void DisableGroupListChangeEvents() {iGroup->GroupWin()->DisableGroupListChangeEvents();}
   110 	inline CTQueueTestEvent* EventQueue() {return STATIC_CAST(CTQueueTestEvent*,iEventHandler);}
   111 	inline TPoint ChildTopLeft() {return TPoint(EWinWidth/4,EWinHeight/4);}
   112 	inline TSize ChildSize() {return TSize(EWinWidth/2,EWinHeight/2);}
   113 	void CreateEventTestGroupOnSecondScreenL();
   114 	void CloseEventTestGroupOnSecondScreen();
   115 private:
   116 	inline TPoint ParentTopLeft() {return TPoint(EWinPositionX,EWinPositionY);}
   117 	inline TPoint ChildAbsTopLeft() {return ParentTopLeft()+ChildTopLeft();}
   118 private:
   119 	TInt iKeysDown[EMaxKeysDown];
   120 	TInt iNumKeysDown;
   121 	CTEventTest *iTest;
   122 public:
   123 	CTBackedUpWin *iChildWin;
   124 	CTBackedUpWin *iWin;
   125 	TBool iChildCapturing;
   126 	TBool iCapturing;
   127 	CWsScreenDevice* iSndScreen;
   128 	RWindowGroup* iWinGp1;
   129 	RWindowGroup* iWinGp2;
   130 	};
   131 
   132 class REventAnimBase : public RTestAnim
   133 	{
   134 public:
   135 	enum EAnimationType
   136 		{
   137 		EEventAnim,
   138 		EEventPostingAnim
   139 		};
   140 	REventAnimBase(RAnimDll* aDll) :RTestAnim(*aDll) {}
   141 	virtual void Destroy();
   142 	void Reset();
   143 	TInt ErrorCode();
   144 	TInt NumberOfEventsReceived();
   145 	TInt AddExpectedEvent(TBool aEat, const TRawEvent& aEvent);
   146 	TInt AddExpectedEvent(const TAnimRawEvent& aEvent);	
   147 	static RAnimDll* LoadL();
   148 	};
   149 
   150 /**
   151  Client side handle to server-side anim class used for Anim Event tests
   152  @internalComponent
   153  @test
   154  */
   155 class REventAnim : public REventAnimBase
   156 	{
   157 public:
   158 	static REventAnim* NewL(RWindowBase* aWin, RAnimDll* aDll, REventAnimBase::EAnimationType aType=EEventAnim);
   159 	inline REventAnim(RAnimDll* aDll) : REventAnimBase(aDll) {}
   160 	inline TInt AddEvent(const TAnimRawEvent& aEvent) {return REventAnimBase::AddExpectedEvent(aEvent);};
   161 	inline TInt GetError() {return REventAnimBase::ErrorCode();};
   162 	inline TInt GetNumEvents() {return REventAnimBase::NumberOfEventsReceived();};
   163 	TInt TestFail(TInt aNoEvents);
   164 	};
   165 
   166 /**
   167  Client side handle to server-side anim class used for Event Handler Removal tests
   168  
   169  RRemovableAnim is an anim which removes itself from the event handler list 
   170  after receiving n events, where n is the 'lifetime' of the anim measured in events received.
   171  
   172  @internalComponent
   173  @test
   174  */
   175 class RRemovableAnim : public REventAnimBase
   176 	{
   177 public:
   178 	static RRemovableAnim* NewLC(RWindowBase* aWin, RAnimDll* aDll);
   179 	inline RRemovableAnim(RAnimDll* aDll) : REventAnimBase(aDll) {}
   180 	inline TInt AddExpectedEvent(const TRawEvent& aEvent) {return REventAnimBase::AddExpectedEvent(EFalse, aEvent);};
   181 	TInt SetEventHandlerLifetime(TInt aEventCount);
   182 	TInt EventHandlerLifetime();
   183 	TInt AddToEventHandlers();
   184 	TInt RemoveFromEventHandlers();
   185 	TBool TestPassed();
   186 	};
   187 
   188 class CTEventTest : public CTWsGraphicsBase
   189 	{
   190 	enum {
   191 		EKeyboardInitialRepeat1=1234567,
   192 		EKeyboardRepeat1=555666,
   193 		EKeyboardInitialRepeat2=2121212,
   194 		EKeyboardRepeat2=20000,
   195 		EDoubleClickTime1=900000,
   196 		EDoubleClickGap1=10,
   197 		EDoubleClickTime2=4000000,
   198 		EDoubleClickGap2=5,
   199 		ENumVisWins=2,
   200 		EPointerCursorUpdateGap=50000,		//0.05secs Same as WsPointer::EPointerUpdateGapInMicroSeconds
   201 		EKeyboardInitialRepeat3=2147483447, // Max value
   202 		EKeyboardRepeat3=8000, // for repeat 3
   203 		EKeyboardInitialRepeat4=-2, // Min value
   204 		EKeyboardRepeat4=6000, // for repeat 4
   205 		EKeyboardRepeat5=7000, // for repeat 4z
   206 		EKeyboardRepeat6=-30000, // for repeat 4
   207 		EKeyboardRepeat7=2147483447, // for repeat 4
   208 		};
   209 public:
   210 	CTEventTest(CTestStep* aStep);
   211 	~CTEventTest();
   212 	//TestState DoTestL();
   213 	void ConstructL();
   214 	void General();
   215 	void General2();
   216 	void Failed();
   217 	//void QueuePurgingL();
   218 	//void SendEventL();
   219 	//void InvisibleWindowL();
   220 	//void JavaAdditionsL();
   221 	void WindowCapBugL();
   222 	//void XyInputTypeL();
   223 	//void MovingPointerCursorL();
   224 	//void RotatedModeL();
   225 	//void AnimEvent();
   226 	void CheckTimeInterval(const TTimeIntervalMicroSeconds32 &aTime,TInt EKeyboardRepeat1);
   227 	void KeyRepeatRate(TInt aInitialRepeat, TInt aRepeat);
   228 	void KeyRepeatRateNegTest(TInt aInitialRepeat, TInt aRepeat);
   229 	void DoubleClickSettings(TInt aInterval, TInt aDistance);
   230 	void NextSetOfEventsL();
   231 	inline void ResetCount(TInt aSet) {iQueueClient->ResetCount(aSet);}
   232 protected:
   233 //from 	CTGraphicsStep
   234 	virtual void RunTestCaseL(TInt aCurTestCase);
   235 private:
   236 	enum
   237 		{
   238 		EDoRot0  =0x01,
   239 		EDoRot90 =0x02,
   240 		EDoRot180=0x04,
   241 		EDoScale=0x80,
   242 		};
   243 	enum TClients
   244 		{
   245 		ETheClient,
   246 		EQueueClient,
   247 		};
   248 	enum TCaptureKeyApis
   249 		{
   250 		ECaptureKey1,
   251 		ECaptureKey2,
   252 		ECaptureKeyUpAndDowns1,
   253 		ECaptureKeyUpAndDowns2,
   254 		ECaptureLongKey1,
   255 		ECaptureLongKey2,
   256 		// Add additional enum values before this line
   257 		EMaxCaptureKeyApis 
   258 		};
   259 	enum TCancelCaptureKeyApis
   260 		{
   261 		ECancelCaptureKey,		
   262 		ECancelCaptureKeyUpAndDowns,		
   263 		ECancelCaptureLongKey,
   264 		// Add additional enum values before this line
   265 		EMaxCancelCaptureKeyApis
   266 		};
   267 	enum TLongkeyCapPriorityTests
   268 		{
   269 		ELongkeyCaptureSamePriority,
   270 		ELongkeyCaptureDiffPriority
   271 		};
   272 private:
   273 	void RunTestsL(TBool aNeedChildWindows=EFalse);
   274 	void RunTestsRestoreAreaL(TBool aNeedChildWindows);
   275 	void QueuePurge_NextSetOfEventsL();
   276 	void InitializeQueueSizeTestL(TBool aEventReadyCancel);
   277 	void SendEventTest_NextSetOfEvents();
   278 	void InvisibleWindow_NextSetOfEvents();
   279 	void JavaAdditions_NextSetOfEvents();
   280 	void XyInputType_NextSetOfEvents();
   281 	void MovingPointerCursor_NextSetOfEventsL();
   282 	void WinCap_NextSetOfEvents();
   283 	void RotatedMode_NextSetOfEventsL();
   284 	void ScreenScaling_NextSetOfEventsL();
   285 	void AnimEvent_NextSetOfEventsL();
   286 	void FocusChanged_NextSetOfEventsL();
   287 	void StopEvents_NextSetOfEventsL();
   288 	void VirtualKeyboard_NextSetOfEventsL();
   289 	void KeyClicks_NextSetOfEvents();
   290 	void CaptureLong_NextSetOfEventsL();
   291 	void Password_NextSetOfEvents();
   292 	void GroupListChanged_NextSetOfEventsL();
   293 	void VisibilityChanged_NextSetOfEventsL();
   294 #ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA  	
   295 	void KeyEventTranslation_NextSetOfEventsL();
   296 	void KeyEventBlocking_NextSetOfEventsL();
   297 	void KeyEventAppRestriction_NextSetOfEventsL();
   298 	void KeyEventAppPriority_NextSetOfEventsL();
   299 #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS	
   300 	void SurfaceVisibilityChanged1_NextSetOfEventsL();
   301 	void SurfaceVisibilityChanged2_NextSetOfEventsL();
   302 	void SurfaceVisibilityChanged3_NextSetOfEventsL();
   303 #endif //SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
   304 #endif //TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
   305 	void CheckTimeStamp_NextSetOfEventsL();
   306 	void RepeatableKeysL();
   307 	void PointerCapture_NextSetOfEventsL();
   308 	void PointerBufferPurge_NextSetOfEventsL();
   309 	void MismatchedCapture_NextSetOfEventsL();	
   310 	void EventHandlerRemoval_NextSetOfEventsL();
   311 	void EventHandlerRemoval_CreateAnimsL(TInt aAnimCount);
   312 	void EventHandlerRemoval_PrepareAnims(const TInt* aLifeTimes, TInt aAnimCount);
   313 	void EventHandlerRemoval_CreateExpectedEvents(TInt aEventCount, TInt aLiveAnimCount);
   314 	void EventHandlerRemoval_AddExpectedEvent(TRawEvent aEvent, TInt aLiveAnimCount);
   315 	void EventHandlerRemoval_CheckExpectedEventsReceivedByAnims();
   316 	void EventHandlerRemoval_CheckRecursionOfProcessRawEvent();
   317 	void EventHandlerRemoval_ManuallyRemoveAllAnims();
   318 	void EventHandlerRemoval_ResetAllAnims();
   319 	void EventHandlerRemoval_RemoveAndResetAllAnims();
   320 	void EventHandlerRemoval_DestroyAllAnims();
   321 	void EventHandlerRemoval_AddEventHandlerMultipleTimes();
   322 	void CheckPointerCursorInDifferentScreenMode(TSizeMode aMode,TPoint aOrigin);
   323 	void SimulateAndCheck(TPoint aOrigin,TSize aScale,TInt aXOffset,TInt aYOffset,TPointerEvent::TType aEventType,TRect aPointerCursorArea);
   324 	void AddExpectedKey(TInt aEventCode, TInt aScanCode, TInt aCode=0, TInt aRepeats=0, TUint aModifiers=KModifiersIgnore);
   325 	void AddExpectedKeyDownUp(TInt aScanCode, TInt aCode=0, TInt aRepeats=0, TUint aModifiers=KModifiersIgnore);
   326 	void AddExpectedEvent(TInt aEventCode, CTWinBase* aWin);
   327 	void AddExpectedEvent(TInt aEventCode);
   328 	void AddExpectedEvent(TInt aEventCode,RWindowGroup* aWindow);
   329 	void AddExpectedErrorMessage(TWsErrorMessage::TErrorCategory aCategory, TInt aError);
   330 	void CalculatePointerEvent(TWsEvent& aEvent,TPointerEvent::TType aType, TPoint aPos);
   331 	void CalculatePointerCaptureEvent(TWsEvent& aEvent,TPointerEvent::TType aType, TPoint aPos, TInt aHandle=0);
   332 	void AddExpectedPointer(TPointerEvent::TType aType, TPoint aPos);
   333 	void AddExpectedPointerCapture(TPointerEvent::TType aType, TPoint aPos, TInt aHandle=0);
   334 	void AddExpectedPointerClick(TPointerEvent::TType aType, TPoint aPos);
   335 	void AddExpectedPointerDownUp(TPoint aPos);
   336 	inline void AddExpectedPointerScr(TPointerEvent::TType aType, TPoint aPos);
   337 	inline void AddExpectedPointerDownUpScr(TPoint aPos);
   338 	void AddExpectedModifiersChanged(TInt aChangedModifiers, TInt aModifiers);
   339 	void AddExpectedEnterExit(TInt aEventCode, TPoint aPos);
   340 	void AddExpectedKeyAnim(TRawEvent::TType aEventCode, TInt aScanCode,TBool aEat);
   341 	void AddExpectedPointerAnim(TRawEvent::TType aEventCode, TPoint aPoint, TBool aEat=ETrue);
   342 	void AddExpectedVisibilityChange(TUint aFlags);
   343 	void AddExpectedVisibilityChange(TUint aFlags, CTBlankWindow* aWindow);
   344 	inline void SimulatePointerWin(TRawEvent::TType aType, TInt aX, TInt aY);
   345 	inline void SimulatePointerDownUpWin(TInt aX, TInt aY);
   346 	inline void SimulatePointer(TRawEvent::TType aType, TInt aX, TInt aY);
   347 	void doSendEvent(TWsEvent &aEvent);
   348 	void SendKey(TInt aEventCode, TInt aScanCode, TInt aCode=0, TInt iRepeats=0);
   349 	void SendEvent(TInt aEventCode);
   350 	void CreateEventTestGroup();
   351 	void CloseEventTestGroup();
   352 	void CreateAndCloseEventTestGroup();
   353 	void TriggerOomMessage(TTimeIntervalMinutes aPeriod);
   354 	TBool SetClickType(TClickOutputModes aType);
   355 	CTBlankWindow* NewBlueForgroundWindowL();
   356 	CTBlankWindow* NewBlueForgroundWindow();
   357 	TInt KeyRepeatTime() const;
   358 	void EventQueuePtrCrashTest();
   359 	TInt ClickCommandReply(TInt aCommand,TInt aData);
   360 	TInt CreateGroupWindow(RWindowGroup& aWinGp,TClients aClient,TInt& aWinGpId);
   361 	void CloseGroupWindow(RWindowGroup& aWinGp,TInt aWinGpId);
   362 	void CloseWindow(RWindowBase& aWin,TInt aHandle,TInt aWinGpId);
   363 	void EventQueueExpansionTestL();
   364 	void RawEventRepeatTest_NextSetOfEventsL();
   365 	void SimulateRepeatEvent(TInt aScanCode, TInt aRepeats=0);
   366 #if !defined(TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA)
   367 	void SimulateButton1DownWithSimulatedMove(TInt aX, TInt aY);
   368 #endif
   369 	void TestCaptureAndCancelCapturePair(TCaptureKeyApis aCaptureApi, TCancelCaptureKeyApis aCancelCaptureApi);
   370 	static TInt GenerateAnEvent(TAny* aEventTest);
   371 	void CheckLongkeyCaptureWithPriority(TLongkeyCapPriorityTests aTestType);
   372 	void DelayForRepeatEvents(TInt aNumeratorFracVal, TInt aDenominatorFracVal);
   373 #ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA 	
   374 	void SpawnCaptureAppL(RProcess& aProcess);
   375 #endif
   376 private:
   377 	CTBlankWindow* iBlankWin;
   378 	RBlankWindow iBackingWindow;
   379 	TSize iPhysicalScreenSize;
   380 	TSize iWinSize;
   381 	RWindowGroup iEventTestGroup;
   382 	CTWindowGroup *iEventTestGroup2;
   383 	CTWindowGroup *iEventTestGroup3;
   384 	CTWindowGroup *iEventTestGroup4;
   385 	TInt iEventSet;
   386 	CTQueueClient *iQueueClient;
   387 	TBool iFailed;
   388 	REventAnim* iAnim;
   389 	TUint iScreenModeTests; //currently contains supported rotation and if screen scaling is possible
   390 	TInt iNumScrModes;
   391 	RSoundPlugIn iClick;
   392 	TBool iAddToClick;
   393 	TInt iCaptureKey;
   394 	TBool iTurnBackOnCapsLock;
   395 	TInt iCurrentMode;
   396 	TSizeMode iSizeMode;
   397 	TBool iTheClientFlush;
   398 	TBool iQuequeClientFlush;
   399 	CTBlankWindow* iVisWins1;
   400 	CTBlankWindow* iVisWins2;
   401 	CTBlankWindow* iVisWins3;
   402 	CTransWindow* iTransWin;
   403 	RAnimDll* iAnimDll;
   404 	RPointerArray<RRemovableAnim>* iRemovableAnims;
   405 	TBool iIs3DPointer;
   406 	TBool iPtrPluginLoaded;
   407 	TInt iYOffset;
   408 	TTimeIntervalMicroSeconds32 iKeyBoardRepeatInitialDelay;
   409 	TTimeIntervalMicroSeconds32 iKeyBoardRepeatNextDelay;
   410 #ifndef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA 	
   411 	RProcess iCaptureApp1;
   412 	RProcess iCaptureApp2;
   413 #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS	
   414 	TSurfaceId iSurfaceId;
   415 	RSurfaceManager iSurfaceManager;
   416 	CPeriodic* iTimeOutCallback;
   417 #endif // SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
   418 #endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
   419 	};
   420 
   421 class CTQueueWindowGroup : public CTWindowGroup
   422 	{
   423 public:
   424 	CTQueueWindowGroup(CTClient *aClient);
   425 	void ConstructL();
   426 private:
   427 	TInt iNumOnEvents;
   428 	};
   429 
   430 class CTEventTestStep : public CTGraphicsStep
   431 	{
   432 public:
   433 	CTEventTestStep();
   434 protected:
   435 	//from CTGraphicsStep
   436 	virtual CTGraphicsBase* CreateTestL();
   437 	};
   438 
   439 _LIT(KTEventTestStep,"TEventTest");
   440 
   441 
   442 #endif