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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 @internalComponent - Internal Symbian test code
29 #include "../tlib/testbase.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
39 const TInt EMaxEventQueueSize=32;
40 const TInt EMinQueueSize = 2;
41 const TUint KModifiersIgnore = 0xffffffff;
47 class TWsQTEvent : public TWsEvent
49 friend class CTEventTest;
51 inline TTime& Time() {return iTime;}
54 class CTQueueTestEvent : public CTEvent
56 enum {EEventBufferSize=40};
58 CTQueueTestEvent(RWsSession *aWs, CTEventTest *aTest);
60 void AddExpectedEvent(TWsEvent &aEvent);
61 inline void ResetCount(TInt aSet) {iEventCount=0;iEventSet=aSet;iLastEventError=EFalse;}
63 inline void SetCheckTimeStamp(TBool aCheck) {iCheckTimeStamp = aCheck;}
67 void TestL(TInt aTest);
69 CCirBuf<TWsEvent> iEventBuffer;
73 TBool iCheckTimeStamp;
74 TPartialRedrawType iRedrawType;
75 TBool iLastEventError;
78 const TInt EWinPositionX=6;
79 const TInt EWinPositionY=9;
80 const TInt EWinWidth=100;
81 const TInt EWinHeight=50;
83 // +----------------------+
85 // | +--------------+ |
88 // | +--------------+ |
90 // +----------------------+ (106,59)
92 class CTQueueClient : public CTClient
95 enum {EMaxKeysDown=50};
97 CTQueueClient(CTEventTest *aTest);
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();
116 inline TPoint ParentTopLeft() {return TPoint(EWinPositionX,EWinPositionY);}
117 inline TPoint ChildAbsTopLeft() {return ParentTopLeft()+ChildTopLeft();}
119 TInt iKeysDown[EMaxKeysDown];
123 CTBackedUpWin *iChildWin;
125 TBool iChildCapturing;
127 CWsScreenDevice* iSndScreen;
128 RWindowGroup* iWinGp1;
129 RWindowGroup* iWinGp2;
132 class REventAnimBase : public RTestAnim
140 REventAnimBase(RAnimDll* aDll) :RTestAnim(*aDll) {}
141 virtual void Destroy();
144 TInt NumberOfEventsReceived();
145 TInt AddExpectedEvent(TBool aEat, const TRawEvent& aEvent);
146 TInt AddExpectedEvent(const TAnimRawEvent& aEvent);
147 static RAnimDll* LoadL();
151 Client side handle to server-side anim class used for Anim Event tests
155 class REventAnim : public REventAnimBase
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);
167 Client side handle to server-side anim class used for Event Handler Removal tests
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.
175 class RRemovableAnim : public REventAnimBase
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();
188 class CTEventTest : public CTWsGraphicsBase
191 EKeyboardInitialRepeat1=1234567,
192 EKeyboardRepeat1=555666,
193 EKeyboardInitialRepeat2=2121212,
194 EKeyboardRepeat2=20000,
195 EDoubleClickTime1=900000,
197 EDoubleClickTime2=4000000,
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
210 CTEventTest(CTestStep* aStep);
212 //TestState DoTestL();
217 //void QueuePurgingL();
219 //void InvisibleWindowL();
220 //void JavaAdditionsL();
221 void WindowCapBugL();
222 //void XyInputTypeL();
223 //void MovingPointerCursorL();
224 //void RotatedModeL();
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);}
233 //from CTGraphicsStep
234 virtual void RunTestCaseL(TInt aCurTestCase);
252 ECaptureKeyUpAndDowns1,
253 ECaptureKeyUpAndDowns2,
256 // Add additional enum values before this line
259 enum TCancelCaptureKeyApis
262 ECancelCaptureKeyUpAndDowns,
263 ECancelCaptureLongKey,
264 // Add additional enum values before this line
265 EMaxCancelCaptureKeyApis
267 enum TLongkeyCapPriorityTests
269 ELongkeyCaptureSamePriority,
270 ELongkeyCaptureDiffPriority
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);
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);
377 CTBlankWindow* iBlankWin;
378 RBlankWindow iBackingWindow;
379 TSize iPhysicalScreenSize;
381 RWindowGroup iEventTestGroup;
382 CTWindowGroup *iEventTestGroup2;
383 CTWindowGroup *iEventTestGroup3;
384 CTWindowGroup *iEventTestGroup4;
386 CTQueueClient *iQueueClient;
389 TUint iScreenModeTests; //currently contains supported rotation and if screen scaling is possible
394 TBool iTurnBackOnCapsLock;
397 TBool iTheClientFlush;
398 TBool iQuequeClientFlush;
399 CTBlankWindow* iVisWins1;
400 CTBlankWindow* iVisWins2;
401 CTBlankWindow* iVisWins3;
402 CTransWindow* iTransWin;
404 RPointerArray<RRemovableAnim>* iRemovableAnims;
406 TBool iPtrPluginLoaded;
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
421 class CTQueueWindowGroup : public CTWindowGroup
424 CTQueueWindowGroup(CTClient *aClient);
430 class CTEventTestStep : public CTGraphicsStep
435 //from CTGraphicsStep
436 virtual CTGraphicsBase* CreateTestL();
439 _LIT(KTEventTestStep,"TEventTest");