First public contribution.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Test pointer event handling
15 // Coverted from TMan test code (TMPOINTR.CPP) October 2000
22 @internalComponent - Internal Symbian test code
31 LOCAL_D TLogMessageText LogMessageText;
35 CPointerWindow::CPointerWindow(CTPointer *aTest) : CTWin(), iTest(aTest)
38 void CPointerWindow::SetState(TInt aState)
41 _LIT(KState,"CPointerWindow::SetState(%d) OldState=%d");
42 LogMessageText.Format(KState,aState,iState);
43 TheClient->LogMessage(LogMessageText);
49 case KStateWaitingForTest1:
50 case KStateWaitingForTest2:
51 case KStateWaitingForTest3:
52 case KStateWaitingForTest4:
53 case KStateWaitingForTest5:
54 case KStateWaitingForTest6:
55 case KStateWaitingForTest8:
56 case KStateWaitingForTest7:
61 Client()->iWs.Flush();
66 TheClient->WaitForRedrawsToFinish();
70 void CPointerWindow::ResetTest(TInt aState)
72 TInt newState=KStateFinished;
76 newState=KStateWaitingForTest1;
79 newState=KStateWaitingForTest2;
82 newState=KStateWaitingForTest3;
85 newState=KStateWaitingForTest4;
88 newState=KStateWaitingForTest5;
91 newState=KStateWaitingForTest6;
94 newState=KStateWaitingForTest8;
97 newState=KStateWaitingForTest7;
100 TheClient->iWs.PurgePointerEvents();
104 void CPointerWindow::SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc)
106 ConstructExtLD(*parent,pos,size);
111 SetState(KStateWaitingForTest1);
112 BaseWin()->EnableOnEvents();
115 void CPointerWindow::Draw()
118 iGc->DrawRect(Size());
119 iGc->DrawRect(iRepeatRect);
124 case KStateWaitingForTest1:
126 _LIT(Draw1,"Click anywhere in the window and hold the pointer steady");
132 _LIT(Draw2,"Hold pointer inside the box");
136 case KStateWaitingForTest2:
138 _LIT(Draw3,"Release the pointer then click in the window and hold the pointer steady");
144 _LIT(Draw4,"Drag the pointer outside the box");
148 case KStateWaitingForTest3:
150 _LIT(Draw5,"Release the pointer then click in the window and hold the pointer steady");
156 _LIT(Draw6,"Release the pointer");
160 case KStateWaitingForTest4:
162 _LIT(Draw7,"Click anywhere in the window and move the pointer slightly");
168 _LIT(Draw8,"Release the pointer");
172 case KStateWaitingForTest5:
174 _LIT(Draw9,"Click anywhere in the window and move the pointer slightly");
180 _LIT(Draw10,"Release the pointer");
184 case KStateWaitingForTest6:
186 _LIT(Draw11,"Click anywhere in the window");
192 _LIT(Draw12,"Move the pointer");
196 case KStateWaitingForTest8:
198 _LIT(Draw13,"Click anywhere in the window, and keep the pointer pressed");
203 buf.Format(KNullDesC);
205 case KStateWaitingForTest7:
207 _LIT(Draw14,"Switch off and touch the center of the screen");
212 buf.Format(KNullDesC);
219 _LIT(Repeat2,"Repeat (%d/%d), interval=%d.%d");
220 buf2.Format(Repeat2,iRepeatCount,KRepeatCount,iInterval.Int()/1000000,(iInterval.Int()%1000000)/100000);
226 _LIT(Repeat1,"Repeat (%d), interval=%d.%d");
227 buf2.Format(Repeat1,iRepeatCount,iInterval.Int()/1000000,(iInterval.Int()%1000000)/100000);
231 iGc->DrawText(buf,TPoint(10,20));
232 iGc->DrawText(buf2,TPoint(10,40));
235 void CPointerWindow::FinishedTests()
237 iState=KStateFinished;
240 void CPointerWindow::StartNextRepeatTest()
244 if (iState==KStateWaitingForTest4)
245 User::After(TTimeIntervalMicroSeconds32(1000000));
246 else if (iState==KStateWaitingForTest5)
247 User::After(TTimeIntervalMicroSeconds32(1000000));
251 case KStateWaitingForTest1:
252 SetState(KStateTesting1);
254 case KStateWaitingForTest2:
255 SetState(KStateTesting2);
257 case KStateWaitingForTest3:
258 SetState(KStateTesting3);
260 case KStateWaitingForTest4:
261 SetState(KStateTesting4);
263 case KStateWaitingForTest5:
264 SetState(KStateTesting5);
266 case KStateWaitingForTest6:
267 SetState(KStateTesting6);
269 case KStateWaitingForTest8:
270 SetState(KStateTesting8);
272 case KStateWaitingForTest7:
273 SetState(KStateTesting7);
278 void CPointerWindow::QueueNextRepeat()
280 iInterval=iInterval.Int()+KRepeatIntervalIncrements;
282 /*_LIT(KRequestRepeat,"Request Repeat, State=%d, Interval=%d");
284 buf.Format(KRequestRepeat,iState,iInterval.Int());
285 TheClient->LogMessage(buf);*/
287 iWin.RequestPointerRepeatEvent(TTimeIntervalMicroSeconds32(iInterval),TRect(iRepeatRect));
288 iPrevTime.HomeTime();
292 void CPointerWindow::PointerL(const TPointerEvent &aPointer,const TTime &aTime)
295 _LIT(KPointer,"CPointerWindow::PointerL(Type=%d, Pos=(%d,%d), ParPos=(%d,%d), Mod=0x%x) State=%d");
296 LogMessageText.Format(KPointer,aPointer.iType,aPointer.iPosition.iX,aPointer.iPosition.iY,aPointer.iParentPosition.iX,aPointer.iParentPosition.iY,aPointer.iModifiers,iState);
297 TheClient->LogMessage(LogMessageText);
299 if (aPointer.iType==TPointerEvent::EButtonRepeat)
301 if (iState!=KStateTesting1 && iState!=KStateTesting2 && iState!=KStateTesting3 && iState!=KStateTesting4)
305 TTimeIntervalMicroSeconds32 interval(I64LOW(aTime.MicroSecondsFrom(iPrevTime).Int64()));
306 TBool fail1=(interval.Int()<(iInterval.Int()-KRepeatMargin) || interval.Int()>(iInterval.Int()+KRepeatMargin));
309 _LIT(KPointerRepeat1,"Pointer Repeat Interval, Exp=%d, Act=%d, F1=%d, F2=%d");
311 TBool fail2=(interval.Int()<(iInterval.Int()-2*KRepeatMargin) || interval.Int()>(iInterval.Int()+3*KRepeatMargin));
312 buf.Format(KPointerRepeat1,iInterval.Int(),interval.Int(),fail1,fail2);
313 TheClient->LogMessage(buf);
315 if (interval.Int()<(iInterval.Int()-
316 #if defined(__MARM_ARM4__)
319 KRepeatMargin) || interval.Int()>(iInterval.Int()+
320 #if defined(__MARM_ARM4__)
327 if (!iRepeatRect.Contains(aPointer.iPosition) ||
328 aPointer.iParentPosition!=(aPointer.iPosition+iWin.InquireOffset(*Parent()->WinTreeNode())))
333 if (iState==KStateTesting1 && iRepeatCount==KRepeatCount)
336 Client()->iWs.Flush();
337 User::After(TTimeIntervalMicroSeconds32(iRepeatCount*KRepeatIntervalIncrements));
338 iWin.CancelPointerRepeatEventRequest();
339 SetState(KStateWaitingForTest2);
349 case KStateWaitingForTest1:
350 case KStateWaitingForTest2:
351 case KStateWaitingForTest3:
352 case KStateWaitingForTest4:
353 case KStateWaitingForTest8:
354 if (aPointer.iType==TPointerEvent::EButton1Down)
356 iRepeatRect.iTl=aPointer.iPosition-TPoint(KRepeatRectXExtra,KRepeatRectYExtra);
357 iRepeatRect.iBr=aPointer.iPosition+TPoint(KRepeatRectXExtra,KRepeatRectYExtra);
358 StartNextRepeatTest();
361 case KStateWaitingForTest5:
362 if (aPointer.iType==TPointerEvent::EButton1Down)
364 iRepeatRect.iTl=aPointer.iPosition;
365 iRepeatRect.iBr=aPointer.iPosition+TPoint(1,1);
366 StartNextRepeatTest();
369 case KStateWaitingForTest6:
370 if (aPointer.iType==TPointerEvent::EButton1Down)
372 iRepeatRect.iTl=aPointer.iPosition+TPoint(KRepeatRectXExtra,KRepeatRectYExtra);
373 iRepeatRect.iBr=aPointer.iPosition+TPoint(2*KRepeatRectXExtra,2*KRepeatRectYExtra);
374 StartNextRepeatTest();
379 TBool isDrag=(aPointer.iType==TPointerEvent::EDrag);
383 iTest->SimulatePointer(TRawEvent::EButton1Down,aPointer.iPosition.iX,aPointer.iPosition.iY);
384 iTest->SimulatePointer(TRawEvent::EButton1Up,aPointer.iPosition.iX,aPointer.iPosition.iY);
389 if (aPointer.iType==TPointerEvent::EDrag)
390 SetState(KStateWaitingForTest3);
395 if (aPointer.iType==TPointerEvent::EButton1Up)
396 SetState(KStateWaitingForTest4);
401 if (aPointer.iType==TPointerEvent::EButton1Up)
402 SetState(KStateWaitingForTest5);
407 if (aPointer.iType==TPointerEvent::EButton1Up)
408 SetState(KStateWaitingForTest6);
409 else if (aPointer.iType!=TPointerEvent::EDrag)
413 if (aPointer.iType==TPointerEvent::EDrag)
415 //#if !defined(__WINS__) // Can't emulate touching dig when switched off under WINS
416 // if (iTest->Digitiser())
417 SetState(KStateWaitingForTest7);
420 SetState(KStateWaitingForTest8);*/
425 case KStateWaitingForTest7:
426 if (aPointer.iType==TPointerEvent::EButton1Down || aPointer.iType==TPointerEvent::ESwitchOn)
430 if (aPointer.iType!=TPointerEvent::ESwitchOn)
433 SetState(KStateWaitingForTest8);
440 void CPointerWindow::TestFailed(TBool aRetest/*=EFalse*/)
442 if (iState!=KStateFailed)
444 TInt oldState=iState;
446 if (iTest->TestFailed(oldState,aRetest) || aRetest)
451 void CPointerWindow::WinKeyL(const TKeyEvent &aKey,const TTime &)
454 _LIT(KKey,"CPointerWindow::WinKeyL(Code=%d, ScanCode=%d) State=%d");
455 LogMessageText.Format(KKey,aKey.iCode,aKey.iScanCode,iState);
456 TheClient->LogMessage(LogMessageText);
458 if (aKey.iCode==EKeyEscape)
459 FinishedTests(); // Simply skip this test if the Escape key is pressed
462 void CPointerWindow::SwitchOn(const TTime &)
465 _LIT(KOn,"CPointerWindow::SwitchOn() State=%d");
466 LogMessageText.Format(KOn,iState);
467 TheClient->LogMessage(LogMessageText);
469 if (iState==KStateWaitingForTest7)
470 SetState(KStateTesting7);
475 void CPointerWindow::SendEvent()
478 _LIT(KSend,"CPointerWindow::SendEvent() State=%d");
479 LogMessageText.Format(KSend,iState);
480 TheClient->LogMessage(LogMessageText);
484 case KStateWaitingForTest1:
485 iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+iSize.iWidth/4,iTl.iY+iSize.iHeight/4);
487 //case KStateTesting1: //Do Nothing
489 case KStateWaitingForTest2:
490 iTest->SimulatePointer(TRawEvent::EButton1Up,iTl.iX+iSize.iWidth/4,iTl.iY+iSize.iHeight/4);
491 iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+iSize.iWidth/2,iTl.iY+iSize.iHeight/4);
494 iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+5*iSize.iWidth/8,iTl.iY+iSize.iHeight/4+2);
495 iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+3*iSize.iWidth/4,iTl.iY+iSize.iHeight/4+4);
497 case KStateWaitingForTest3:
498 iTest->SimulatePointer(TRawEvent::EButton1Up,iTl.iX+3*iSize.iWidth/4,iTl.iY+iSize.iHeight/4+4);
499 iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+iSize.iWidth/4,iTl.iY+iSize.iHeight/2);
502 iTest->SimulatePointer(TRawEvent::EButton1Up,iTl.iX+iSize.iWidth/4,iTl.iY+iSize.iHeight/2);
504 case KStateWaitingForTest4:
505 iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+iSize.iWidth/2,iTl.iY+iSize.iHeight/2);
506 iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+iSize.iWidth/2+3,iTl.iY+iSize.iHeight/2+1);
507 iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+iSize.iWidth/2+6,iTl.iY+iSize.iHeight/2+2);
508 iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+iSize.iWidth/2+9,iTl.iY+iSize.iHeight/2+3);
509 iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+iSize.iWidth/2+12,iTl.iY+iSize.iHeight/2+4);
512 iTest->SimulatePointer(TRawEvent::EButton1Up,iTl.iX+iSize.iWidth/2+12,iTl.iY+iSize.iHeight/2+4);
514 case KStateWaitingForTest5:
515 iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+iSize.iWidth/2,iTl.iY+3*iSize.iHeight/4);
516 iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+iSize.iWidth/2+3,iTl.iY+3*iSize.iHeight/4+1);
517 iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+iSize.iWidth/2+6,iTl.iY+3*iSize.iHeight/4+2);
518 iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+iSize.iWidth/2+9,iTl.iY+3*iSize.iHeight/4+3);
519 iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+iSize.iWidth/2+12,iTl.iY+3*iSize.iHeight/4+4);
522 iTest->SimulatePointer(TRawEvent::EButton1Up,iTl.iX+iSize.iWidth/2+12,iTl.iY+3*iSize.iHeight/4+4);
524 case KStateWaitingForTest6:
525 iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+3*iSize.iWidth/4,iTl.iY+3*iSize.iHeight/4);
528 iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+3*iSize.iWidth/4+4,iTl.iY+3*iSize.iHeight/4+2);
529 iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+3*iSize.iWidth/4+8,iTl.iY+3*iSize.iHeight/4+4);
530 iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+3*iSize.iWidth/4+12,iTl.iY+3*iSize.iHeight/4+6);
531 iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+3*iSize.iWidth/4+16,iTl.iY+3*iSize.iHeight/4+8);
533 case KStateWaitingForTest8:
534 iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+iSize.iWidth/2,iTl.iY+3*iSize.iHeight/4);
538 case KStateWaitingForTest7:
539 iTest->SimulatePointer(TRawEvent::EButton1Up,iTl.iX+3*iSize.iWidth/4+16,iTl.iY+3*iSize.iHeight/4+8);
540 iTest->SimulateEvent(TRawEvent::ESwitchOn);
541 iTest->SimulatePointer(TRawEvent::EPointerSwitchOn,iTl.iX+iSize.iWidth/2-1,iTl.iY+iSize.iHeight/2-1);
543 //case KStateTesting7: //Do Nothing
556 CGrabWindow::CGrabWindow(CTPointer *aTest) : iTest(aTest)
560 void CGrabWindow::SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc)
562 ConstructExtLD(*parent,pos,size);
567 SetState(KGrabStateWaitingForDown);
570 void CGrabWindow::Draw()
573 iGc->DrawRect(Size());
577 case KGrabStateWaitingForDown:
578 case KGrabStateWaitingForDown2:
579 case KGrabStateWaitingForDown5:
581 _LIT(Draw1,"Press the pointer inside the window");
585 case KGrabStateWaitingForDown3:
586 case KGrabStateWaitingForUp3a:
588 _LIT(Draw2,"Press and release the pointer inside the window");
592 case KGrabStateWaitingForDragOut:
594 _LIT(Draw3,"Drag the pointer outside into the outside window");
598 case KGrabStateWaitingForUp:
599 case KGrabStateWaitingForUp2b:
600 case KGrabStateWaitingForUp5:
602 _LIT(Draw4,"Release the pointer");
606 case KGrabStateWaitingForDown4:
608 _LIT(Draw5,"Press then release the pointer");
614 iGc->DrawText(buf,TPoint(10,20));
617 void CGrabWindow::PointerL(const TPointerEvent &aPointer,const TTime&)
620 _LIT(KPointer,"CGrabWindow::PointerL(Type=%d, Pos=(%d,%d), ParPos=(%d,%d), Mod=0x%x) State=%d");
621 LogMessageText.Format(KPointer,aPointer.iType,aPointer.iPosition.iX,aPointer.iPosition.iY,aPointer.iParentPosition.iX,aPointer.iParentPosition.iY,aPointer.iModifiers,iState);
622 TheClient->LogMessage(LogMessageText);
626 case KGrabStateWaitingForDown:
627 if (aPointer.iType==TPointerEvent::EButton1Down)
628 SetState(KGrabStateWaitingForDragOut);
630 case KGrabStateWaitingForDragOut:
631 if (aPointer.iType!=TPointerEvent::EDrag)
635 if (!TRect(Size()).Contains(aPointer.iPosition))
636 SetState(KGrabStateWaitingForUp);
639 case KGrabStateWaitingForUp:
640 if (aPointer.iType==TPointerEvent::EDrag)
642 if (aPointer.iType==TPointerEvent::EButton1Up)
643 SetState(KGrabStateWaitingForDown2);
647 case KGrabStateWaitingForDown2:
648 if (aPointer.iType!=TPointerEvent::EButton1Down)
652 iTest->GrabWin2()->BaseWin()->ClaimPointerGrab();
653 iTest->GrabWin2()->BaseWin()->ClaimPointerGrab(); // Call twice to check it's harmless
654 SetState(KGrabStateWaitingForUp2a);
657 case KGrabStateWaitingForUp2a:
658 SetState(KGrabStateWaitingForDrag2);
660 case KGrabStateWaitingForDrag2:
662 case KGrabStateWaitingForUp2b:
665 case KGrabStateWaitingForDown3:
666 if (aPointer.iType!=TPointerEvent::EButton1Down)
669 SetState(KGrabStateWaitingForUp3a);
671 case KGrabStateWaitingForUp3a:
672 if (aPointer.iType==TPointerEvent::EButton1Up)
674 iTest->GrabWin2()->BaseWin()->ClaimPointerGrab();
675 SetState(KGrabStateWaitingForUp3b);
678 case KGrabStateWaitingForUp3b:
681 case KGrabStateWaitingForDown5:
682 if (aPointer.iType!=TPointerEvent::EButton1Down)
686 iTest->GrabWin2()->BaseWin()->ClaimPointerGrab(EFalse);
687 SetState(KGrabStateWaitingForDrag5);
690 case KGrabStateWaitingForDrag5:
691 if (aPointer.iType==TPointerEvent::EButton1Up)
694 case KGrabStateWaitingForUp5:
697 case KGrabStateWaitingForDown4:
698 iWin.Close(); // Close the window with the grab captured in it
699 SetState(KGrabStateWaitingForUp4);
701 case KGrabStateFinished:
706 void CGrabWindow::ResetTest()
708 TheClient->iWs.PurgePointerEvents();
709 SetState(KGrabStateWaitingForDown);
712 void CGrabWindow::Pointer2(const TPointerEvent &aPointer)
716 case KGrabStateWaitingForDrag2:
718 if (aPointer.iType==TPointerEvent::EDrag)
720 SetState(KGrabStateWaitingForUp2b);
724 if (iTest->TestFailed(iState))
729 case KGrabStateWaitingForUp2b:
730 if (aPointer.iType==TPointerEvent::EDrag) // Harmless
732 if (aPointer.iType==TPointerEvent::EButton1Up)
733 SetState(KGrabStateWaitingForDown3);
737 case KGrabStateWaitingForUp3b:
738 if (aPointer.iType==TPointerEvent::EButton1Up)
739 SetState(KGrabStateWaitingForDown5);
743 case KGrabStateWaitingForUp4:
746 case KGrabStateWaitingForDrag5:
748 if (aPointer.iType==TPointerEvent::EDrag)
749 SetState(KGrabStateWaitingForUp5);
750 else if (iTest->TestFailed(iState))
754 case KGrabStateWaitingForUp5:
755 if (aPointer.iType==TPointerEvent::EDrag) // Harmless
757 if (aPointer.iType==TPointerEvent::EButton1Up)
758 SetState(KGrabStateWaitingForDown4);
766 void CGrabWindow::SetState(TInt aState)
769 if (aState!=KGrabStateWaitingForUp4)
771 TheClient->WaitForRedrawsToFinish();
775 void CGrabWindow::TestFailed()
778 _LIT(KFail,"CGrabWindow::TestFailed() State=%d");
779 LogMessageText.Format(KFail,iState);
780 TheClient->LogMessage(LogMessageText);
782 if (iState!=KStateFailed)
784 TInt oldState=iState;
786 if (iTest->TestFailed(oldState))
791 void CGrabWindow::FinishedTests()
793 iState=KGrabStateFinished;
796 void CGrabWindow::WinKeyL(const TKeyEvent &aKey,const TTime &)
799 _LIT(KKey,"CGrabWindow::WinKeyL(Code=%d, ScanCode=%d) State=%d");
800 LogMessageText.Format(KKey,aKey.iCode,aKey.iScanCode,iState);
801 TheClient->LogMessage(LogMessageText);
803 if (aKey.iCode==EKeyEscape)
804 FinishedTests(); // Simply skip this test if the Escape key is pressed
807 void CGrabWindow::SendEvent()
811 case KGrabStateWaitingForDown:
812 iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+iSize.iWidth/3,iTl.iY+iSize.iHeight/3);
814 case KGrabStateWaitingForDragOut:
815 iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+iSize.iWidth/6,iTl.iY+iSize.iHeight/6);
816 iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+1,iTl.iY+1);
817 iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX-10,iTl.iY-10);
819 case KGrabStateWaitingForUp:
820 iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX-8,iTl.iY-8);
821 iTest->SimulatePointer(TRawEvent::EButton1Up,iTl.iX-5,iTl.iY-5);
823 case KGrabStateWaitingForDown2:
824 iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+2*iSize.iWidth/3,iTl.iY+iSize.iHeight/3);
826 /*case KGrabStateWaitingForUp2a: //Don't need to do anything for these cases
828 case KGrabStateWaitingForDrag2:
830 case KGrabStateWaitingForUp2b:
831 iTest->SimulatePointer(TRawEvent::EPointerMove,iTl.iX+2*iSize.iWidth/3-3,iTl.iY+iSize.iHeight/3+3);
832 iTest->SimulatePointer(TRawEvent::EButton1Up,iTl.iX+2*iSize.iWidth/3,iTl.iY+iSize.iHeight/3);
834 case KGrabStateWaitingForDown3:
835 iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+2*iSize.iWidth/3,2*iTl.iY+iSize.iHeight/3);
837 case KGrabStateWaitingForUp3a:
838 iTest->SimulatePointer(TRawEvent::EButton1Up,iTl.iX+2*iSize.iWidth/3,2*iTl.iY+iSize.iHeight/3);
840 case KGrabStateWaitingForUp3b:
842 case KGrabStateWaitingForDown4:
843 iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+2*iSize.iWidth/5,iTl.iY+iSize.iHeight/3);
845 case KGrabStateWaitingForUp4:
846 iTest->SimulatePointer(TRawEvent::EButton1Up,iTl.iX+2*iSize.iWidth/5,iTl.iY+iSize.iHeight/3);
848 case KGrabStateWaitingForDown5:
849 iTest->SimulatePointer(TRawEvent::EButton1Down,iTl.iX+iSize.iWidth/3,2*iTl.iY+iSize.iHeight/3);
851 case KGrabStateWaitingForUp5:
852 iTest->SimulatePointer(TRawEvent::EButton1Up,iTl.iX+iSize.iWidth/3,2*iTl.iY+iSize.iHeight/3);
854 //case KGrabStateWaitingForDrag5: //Don't need to do anything for these cases
858 case KGrabStateFinished:
862 TheClient->iWs.Flush();
867 // CGrabWindow2, used as part of grab tests //
870 CGrabWindow2::CGrabWindow2(CGrabWindow *aWindow) : iGrabWindow(aWindow)
874 void CGrabWindow2::Draw()
876 iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
877 iGc->SetBrushColor(TRgb::Gray4(2));
878 iGc->DrawRect(Size());
881 void CGrabWindow2::PointerL(const TPointerEvent &aPointer,const TTime&)
884 _LIT(KPointer,"CGrabWindow2::PointerL(Type=%d, Pos=(%d,%d), ParPos=(%d,%d), Mod=0x%x)");
885 LogMessageText.Format(KPointer,aPointer.iType,aPointer.iPosition.iX,aPointer.iPosition.iY,aPointer.iParentPosition.iX,aPointer.iParentPosition.iY,aPointer.iModifiers);
886 TheClient->LogMessage(LogMessageText);
888 iGrabWindow->Pointer2(aPointer);
895 CTPointer::CTPointer(CTestStep* aStep) : CTWsGraphicsBase(aStep)
901 CTPointer::~CTPointer()
903 HAL::Set(HALData::EPenDisplayOn,iOldPointerState);
907 Client()->ResetFocus();
911 void CTPointer::ConstructL()
913 iTimeOut=new(ELeave) CTimeOut();
914 iTimeOut->ConstructL();
915 iTimeOut->Start(KTimeOutAfter,TCallBack(CTPointer::TimeOut,this));
917 TheClient->iWs.SetPointerCursorArea(iTest->iNormalPointerCursorArea);
918 iRepeatWin=new(ELeave) CPointerWindow(this);
919 TSize screenSize(Client()->iScreen->SizeInPixels());
920 if (TestBase()->ConfigurationSupportsPointerEventTesting())
922 iRepeatWin->SetUpLD(TPoint(screenSize.iWidth/8,screenSize.iHeight/8),TSize(screenSize.iWidth*3/4,screenSize.iHeight*3/4),Client()->iGroup,*Client()->iGc);
924 Client()->iGroup->SetCurrentWindow(iRepeatWin);
926 TInt err=HAL::Get(HALData::EPenDisplayOn,iOldPointerState);
927 if (err==KErrNotSupported)
929 else if (err==KErrNone)
930 err=HAL::Set(HALData::EPenDisplayOn,ETrue);
931 if (err==KErrNotSupported)
932 iNoDigitiser=(!iOldPointerState);
937 INFO_PRINTF3(_L("HAL::Set(HALData::EPenDisplayOn,ETrue) return value - Expected: %d, Actual: %d"), KErrNone, err);
942 TInt CTPointer::TimeOut(TAny* aTest) //static
944 static_cast<CTPointer*>(aTest)->TimeOut();
948 void CTPointer::TimeOut()
951 _LIT(KPointerTimeOut,"TIMEOUT: Pointer Test, %d, %S");
952 buf.AppendFormat(KPointerTimeOut,iState,&(iTest->iSubTitle));
953 TheClient->LogMessage(buf);
955 if (!TestFailed(-1) && iState<2)
957 iTimeOut->Start(KTimeOutAfter,TCallBack(CTPointer::TimeOut,this));
961 TBool CTPointer::TestFailed(TInt aCase,TBool aRetry/*=EFalse*/)
963 _LIT(KPointerTest,": Pointer Test, %d, %S, Case %d");
964 _LIT(KRetry,"Retry");
975 buf.AppendFormat(KPointerTest,iState,&(iTest->iSubTitle),aCase);
976 TheClient->LogMessage(buf);
977 #if !defined(DISABLE_FAIL_DIALOG)
981 TRAPD(err,ret=doTestFailedL());
987 return(ETrue); // Re-try test
994 TInt CTPointer::doTestFailedL()
996 //_LIT(Failed,"Pointer repeat test failed");
997 _LIT(Retest,"Retest");
999 CTDialog *dialog=new(ELeave) CTDialog();
1000 dialog->SetNumButtons(2);
1001 dialog->SetButtonText(0,Retest);
1002 dialog->SetButtonText(1,Fail);
1003 dialog->ConstructLD(*Client()->iGroup,*Client()->iGc);
1004 dialog->SetTitle(_L("Pointer repeat test failed"));
1005 dialog->SetFlags(CTDialog::EDialogWaitForButtonUp);
1006 return dialog->Display();
1009 CGrabWindow2 *CTPointer::GrabWin2() const
1014 void CTPointer::StartGrabTestL()
1016 iGrabWin=new(ELeave) CGrabWindow(this);
1017 iGrabWin2=new(ELeave) CGrabWindow2(iGrabWin);
1019 TSize screenSize(Client()->iScreen->SizeInPixels());
1020 iGrabWin2->SetUpL(TPoint(screenSize.iWidth/8,screenSize.iHeight/8),TSize(screenSize.iWidth*3/4,screenSize.iHeight*3/4),Client()->iGroup,*Client()->iGc);
1021 Client()->iGroup->SetCurrentWindow(iGrabWin2);
1023 iGrabWin->SetUpLD(TPoint(screenSize.iWidth/4,screenSize.iHeight/4),TSize(screenSize.iWidth/2,screenSize.iHeight/2),Client()->iGroup,*Client()->iGc);
1024 Client()->iGroup->SetCurrentWindow(iGrabWin);
1029 void CTPointer::RunTestCaseL(TInt /*aCurTestCase*/)
1031 _LIT(Repeat,"Repeat tests");
1032 _LIT(Grab,"Grab tests");
1034 iTest->iState=iState;
1036 if (!TestBase()->ConfigurationSupportsPointerEventTesting())
1038 INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing"));
1043 ((CTPointerStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
1047 ((CTPointerStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
1048 iTest->LogSubTest(Repeat);
1053 @SYMTestCaseID GRAPHICS-WSERV-0310
1057 @SYMTestCaseDesc Test pointer event handling
1059 @SYMTestPriority High
1061 @SYMTestStatus Implemented
1063 @SYMTestActions Simulate pointer events and check the events are then handled correctly
1065 @SYMTestExpectedResults Pointer events are handled correctly
1069 ((CTPointerStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0310"));
1070 iTest->LogSubTest(Grab);
1076 ((CTPointerStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
1077 ((CTPointerStep*)iStep)->CloseTMSGraphicsStep();
1079 if (iTimeOutCount>0) TEST(EFalse);
1080 if (iTest->IsFullRomL()) User::After(5000000);
1083 ((CTPointerStep*)iStep)->RecordTestResultL();
1087 __WS_CONSTRUCT_STEP__(Pointer)