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