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 capture
21 @internalComponent - Internal Symbian test code
28 _LIT(ClickOnMe,"Click on me");
33 CPcConnection::CPcConnection(CTPointerCapture *aTest) : iTest(aTest)
37 CPcConnection::~CPcConnection()
41 void CPcConnection::ConstructL()
43 CTClient::SetScreenNumber(iTest->TestBase()->ScreenNumber());
44 CTClient::ConstructL();
45 iGroup=new(ELeave) CTWindowGroup(this);
47 iGroup->GroupWin()->SetOrdinalPosition(0,1);
48 iGroup->GroupWin()->EnableReceiptOfFocus(EFalse);
53 // CPcWindow, base class //
56 CPcWindowBase::CPcWindowBase(CTPointerCapture *aTest) : CTWin(), iTest(aTest)
60 void CPcWindowBase::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc)
62 ConstructExtLD(*parent,pos,size);
63 iWin.SetBackgroundColor(iBack);
68 void CPcWindowBase::SetUpL(TPoint pos,TSize size,CTWinBase *parent)
70 SetUpL(pos,size,parent,*iTest->Client()->iGc);
73 void CPcWindowBase::SubStateChanged()
76 Client()->iWs.Flush();
79 void CPcWindowBase::Draw(TDesC &aBuf)
82 iGc->SetPenColor(iBack.Gray4()>1 ? TRgb(0,0,0) : TRgb(255,255,255));
83 iGc->DrawText(aBuf, TPoint(10,20));
86 void CPcWindowBase::PointerL(const TPointerEvent &pointer,const TTime &)
89 _LIT(KLog1,"Pointer Event Recieved Type=%S State=%d SubState=%d");
92 iTest->LOG_MESSAGE4(KLog1,&(pointer.iType?KUp():KDown()),iTest->State(),iTest->SubState());
94 if (pointer.iType==TPointerEvent::EButton1Down && !iTest->iFailed)
96 if (iTest->SubState()==ERootWindow) // Root window click, must not be inside this window
98 if (TRect(Size()).Contains(pointer.iPosition))
105 if ((ret=PointerDown())==EFailed)
108 iTest->IncSubStateL(ret==ENeedsDDEvent);
111 _LIT(KLog2,"End of processing Pointer Event");
112 iTest->LOG_MESSAGE(KLog2);
116 void CPcWindowBase::DragDropL(const TPointerEvent &pointer,const TTime &)
119 _LIT(KLog,"CPcWindowBase::DragDropL Type=%d State=%d SubState=%d");
120 iTest->LOG_MESSAGE4(KLog,pointer.iType,iTest->State(),iTest->SubState());
122 switch(iTest->State())
124 case ENormalCaptureWithoutFocus:
125 if (iTest->SubState()==0)
127 case ECaptureDisabled:
129 case ECaptureAllGroups:
133 if (pointer.iType==TPointerEvent::EButton1Down && !iTest->iFailed)
135 if (DragDrop()==EFailed)
143 CPcWindowMain::CPcWindowMain(CTPointerCapture *aTest) : CPcWindowBase(aTest)
145 iBack=TRgb::Gray256(236);
148 TPointerCheckRet CPcWindowMain::PointerDown()
151 _LIT(KLog1,"CPcWindowMain::PointerDown State=%d SubState=%d");
152 iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState());
154 switch(iTest->State())
156 case ECaptureDisabled:
157 if (iTest->SubState()==EMainWindow)
161 switch(iTest->SubState())
170 case ECaptureAllGroups:
171 switch(iTest->SubState())
182 case EDragDropCapture:
183 switch(iTest->SubState())
186 return(ENeedsDDEvent);
193 case EDragDropCaptureAllGroups:
194 switch(iTest->SubState())
199 return(ENeedsDDEvent);
206 case ENormalCaptureWithoutFocus:
207 switch(iTest->SubState())
219 _LIT(KLog2,"CPcWindowMain::PointerDown FAILED State=%d SubState=%d");
220 iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState());
225 TPointerCheckRet CPcWindowMain::DragDrop()
228 _LIT(KLog1,"CPcWindowMain::DragDrop State=%d SubState=%d");
229 iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState());
231 switch(iTest->State())
233 case EDragDropCapture:
234 case EDragDropCaptureAllGroups:
235 switch(iTest->SubState())
247 _LIT(KLog2,"CPcWindowMain::DragDrop FAILED State=%d SubState=%d");
248 iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState());
253 void CPcWindowMain::Draw()
256 if (iTest->State()==ECaptureDisabled)
258 switch(iTest->SubState())
267 switch(iTest->SubState())
278 _LIT(ClickOnRoot,"Click on the root window");
279 if (iTest->State()<ENormalCaptureWithoutFocus)
280 buf.Copy(ClickOnRoot);
283 _LIT(AndEscape,", then press <Escape>");
284 buf.Copy(ClickOnRoot);
285 buf.Append(AndEscape);
291 CPcWindowBase::Draw(buf);
294 void CPcWindowMain::WinKeyL(const TKeyEvent &aKey,const TTime &)
302 if (iTest->SubState()==ERootWindow)
303 iTest->IncSubStateL(EFalse);
310 CPcWindowChild::CPcWindowChild(CTPointerCapture *aTest) : CPcWindowBase(aTest)
312 iBack=TRgb::Gray256(85);
315 TPointerCheckRet CPcWindowChild::PointerDown()
318 _LIT(KLog1,"CPcWindowChild::PointerDown State=%d SubState=%d");
319 iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState());
321 switch(iTest->State())
323 case ECaptureDisabled:
326 switch(iTest->SubState())
336 _LIT(KLog2,"CPcWindowChild::PointerDown FAILED State=%d SubState=%d");
337 iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState());
342 TPointerCheckRet CPcWindowChild::DragDrop()
345 _LIT(KLog1,"CPcWindowChild::PointerDown State=%d SubState=%d");
346 iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState());
348 switch(iTest->State())
350 case EDragDropCapture:
351 case EDragDropCaptureAllGroups:
352 switch(iTest->SubState())
364 _LIT(KLog2,"CPcWindowChild::PointerDown FAILED State=%d SubState=%d");
365 iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState());
370 void CPcWindowChild::Draw()
373 if (iTest->State()!=ECaptureDisabled)
375 switch(iTest->SubState())
384 CPcWindowBase::Draw(buf);
389 CPcWindowNickFocusGroup::CPcWindowNickFocusGroup(CTPointerCapture *aTest, CTClient *aClient) : CTWindowGroup(aClient), iTest(aTest)
393 void CPcWindowNickFocusGroup::KeyL(const TKeyEvent &aKey,const TTime &)
395 if (aKey.iCode==EKeyEscape)
396 iTest->IncSubStateL(EFalse);
401 CPcWindowAltGroup::CPcWindowAltGroup(CTPointerCapture *aTest) : CPcWindowBase(aTest)
403 iBack=TRgb::Gray256(236);
406 TPointerCheckRet CPcWindowAltGroup::PointerDown()
409 _LIT(KLog1,"CPcWindowAltGroup::PointerDown State=%d SubState=%d");
410 iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState());
412 switch(iTest->State())
414 case ECaptureDisabled:
415 if (iTest->SubState()==EChildWindow)
419 case EDragDropCapture:
420 case ENormalCaptureWithoutFocus:
421 switch(iTest->SubState())
433 _LIT(KLog2,"CPcWindowAltGroup::PointerDown FAILED State=%d SubState=%d");
434 iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState());
439 TPointerCheckRet CPcWindowAltGroup::DragDrop()
442 _LIT(KLog1,"CPcWindowAltGroup::DragDrop State=%d SubState=%d");
443 iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState());
445 switch(iTest->State())
447 case EDragDropCapture:
448 case EDragDropCaptureAllGroups:
449 switch(iTest->SubState())
461 _LIT(KLog2,"CPcWindowAltGroup::DragDrop FAILED State=%d SubState=%d");
462 iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState());
467 void CPcWindowAltGroup::Draw()
470 if (iTest->State()==ECaptureDisabled)
472 switch(iTest->SubState())
483 switch(iTest->SubState())
492 CPcWindowBase::Draw(buf);
497 CPcWindowAltConnection::CPcWindowAltConnection(CTPointerCapture *aTest) : CPcWindowBase(aTest)
499 iBack=TRgb::Gray256(236);
502 TPointerCheckRet CPcWindowAltConnection::PointerDown()
505 _LIT(KLog1,"CPcWindowAltConnection::PointerDown State=%d SubState=%d");
506 iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState());
508 switch(iTest->State())
510 case ECaptureDisabled:
511 if (iTest->SubState()==EChildWindow)
515 case EDragDropCapture:
516 case ENormalCaptureWithoutFocus:
517 switch(iTest->SubState())
529 _LIT(KLog2,"CPcWindowAltConnection::PointerDown FAILED State=%d SubState=%d");
530 iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState());
535 TPointerCheckRet CPcWindowAltConnection::DragDrop()
538 _LIT(KLog1,"CPcWindowAltConnection::DragDrop State=%d SubState=%d");
539 iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState());
541 switch(iTest->State())
543 case EDragDropCapture:
544 case EDragDropCaptureAllGroups:
545 switch(iTest->SubState())
557 _LIT(KLog2,"CPcWindowAltConnection::DragDrop FAILED State=%d SubState=%d");
558 iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState());
563 void CPcWindowAltConnection::Draw()
566 if (iTest->State()!=ECaptureDisabled)
568 switch(iTest->SubState())
577 CPcWindowBase::Draw(buf);
582 CTPointerCapture::CTPointerCapture(CTestStep* aStep) : CTWsGraphicsBase(aStep)
588 CTPointerCapture::~CTPointerCapture()
590 delete iNickFocusBlankWin;
591 delete iNickFocusGroup;
592 delete iAltConnectionWin;
593 delete iAltConnection;
601 void CTPointerCapture::TestFailed()
605 _LIT(KLog,"Test Failed State=%d SubState=%d");
606 LOG_MESSAGE3(KLog,iTest->iState,iSubState);
608 __ASSERT_DEBUG(iFailed==EFalse,AutoPanic(ETManPanicPcFailed));
610 #if !defined(DISABLE_FAIL_DIALOG)
611 Client()->iGroup->GroupWin()->SetOrdinalPosition(0,10); // Put error dialog on top of test windows
612 TRAPD(err,dRet=doTestFailedL());
613 Client()->iGroup->GroupWin()->SetOrdinalPosition(0,0);
626 TInt CTPointerCapture::doTestFailedL()
628 CTDialog *dialog=new(ELeave) CTDialog();
629 dialog->SetTitle(_L("Pointer capture test failed"));
630 dialog->SetNumButtons(2);
631 dialog->SetButtonText(0,_L("Retest"));
632 dialog->SetButtonText(1,_L("Fail"));
633 dialog->ConstructLD(*Client()->iGroup,*Client()->iGc);
634 return dialog->Display();
637 TInt CTPointerCapture::State() const
639 return(iTest->iState);
642 TInt CTPointerCapture::SubState() const
647 void CTPointerCapture::doIncSubStateL()
651 switch(iTest->iState)
653 case ECaptureDisabled:
659 case ECaptureAllGroups:
662 case EDragDropCapture:
665 case EDragDropCaptureAllGroups:
668 case ENormalCaptureWithoutFocus:
672 //SubState 4 has been broken by something in the framework
673 if (iSubState==max || iSubState==4)
676 _LIT(KLog,"IncState OldState=%d SubState=%d");
677 LOG_MESSAGE3(KLog,iTest->iState,iSubState);
682 TheClient->WaitForRedrawsToFinish();
687 void CTPointerCapture::GotDDL()
689 if (iDDState==DDStateWaiting)
695 void CTPointerCapture::IncSubStateL(TBool aNeedsDD)
699 if (iDDState!=DDStateNull)
704 else if (iDDState==DDStateGot)
707 iDDState=DDStateWaiting;
710 void CTPointerCapture::StateChanged()
712 iDDState=DDStateNull;
713 iChildWin->SubStateChanged();
714 iMainWin->SubStateChanged();
715 iAltGroupWin->SubStateChanged();
716 iAltConnectionWin->SubStateChanged();
719 void CTPointerCapture::AbortTests()
724 void CTPointerCapture::NextTest()
729 _LIT(KLog,"SubTest %d failed");
730 LOG_MESSAGE2(KLog,iTest->iState);
736 _LIT(KLog,"Done NextTest NewSubTest %d");
737 LOG_MESSAGE2(KLog,iTest->iState);
740 void CTPointerCapture::ConstructL()
742 TheClient->iWs.SetPointerCursorArea(iTest->iNormalPointerCursorArea);
743 iScreenSize=TSize(TheClient->iScreen->SizeInPixels());
744 TInt winWidth2=iScreenSize.iWidth/2-EWinBorderSize*2;
745 TInt winWidth4=iScreenSize.iWidth/4-EWinBorderSize*2;
746 TInt winHeight=iScreenSize.iHeight/2-EWinBorderSize*2;
748 iMainGroup=new(ELeave) CTWindowGroup(Client());
749 iMainGroup->ConstructL();
750 iMainGroup->GroupWin()->SetOrdinalPosition(0,1);
751 iMainWin=new(ELeave) CPcWindowMain(this);
752 iMainWin->SetUpL(TPoint(EWinBorderSize,EWinBorderSize) ,TSize(winWidth2,winHeight) ,iMainGroup);
753 iMainGroup->SetCurrentWindow(iMainWin);
754 iChildWin=new(ELeave) CPcWindowChild(this);
755 iChildWin->SetUpL(TPoint(0,winHeight/2) ,TSize(winWidth2,winHeight/2) ,iMainWin);
757 iAltGroup=new(ELeave) CTWindowGroup(Client());
758 iAltGroup->ConstructL();
759 iAltGroup->GroupWin()->SetOrdinalPosition(0,1);
760 iAltGroup->GroupWin()->EnableReceiptOfFocus(EFalse);
761 iAltGroupWin=new(ELeave) CPcWindowAltGroup(this);
762 iAltGroupWin->SetUpL(TPoint(iScreenSize.iWidth/2+EWinBorderSize,EWinBorderSize) ,TSize(winWidth4,winHeight) ,iAltGroup);
764 iAltConnection=new(ELeave) CPcConnection(this);
765 iAltConnection->ConstructL();
766 iAltConnectionWin=new(ELeave) CPcWindowAltConnection(this);
767 iAltConnectionWin->SetUpL(TPoint(iScreenSize.iWidth/4*3+EWinBorderSize,EWinBorderSize) ,TSize(winWidth4,winHeight),iAltConnection->iGroup,*iAltConnection->iGc);
768 iTest->DelayIfFullRomL();
772 void CTPointerCapture::NickFocusL()
774 iNickFocusGroup=new(ELeave) CPcWindowNickFocusGroup(this,Client());
775 iNickFocusGroup->ConstructL();
776 iNickFocusGroup->GroupWin()->SetOrdinalPosition(0,2);
777 iNickFocusBlankWin=new(ELeave) CTBlankWindow();
778 iNickFocusBlankWin->ConstructL(*iNickFocusGroup);
779 iNickFocusBlankWin->SetSize(TSize(1,1));
780 iNickFocusBlankWin->Activate();
783 void CTPointerCapture::SetCapture(TInt aCaptureFlags)
786 _LIT(KLog,"Change Capture State=%d CaptureFlags=0x%x");
787 LOG_MESSAGE3(KLog,iTest->iState,aCaptureFlags);
789 iMainWin->Win()->SetPointerCapture(aCaptureFlags);
792 void CTPointerCapture::SendEventsL()
795 _LIT(KLog,"SendEvent State=%d SubState=%d");
796 LOG_MESSAGE3(KLog,iTest->iState,iSubState);
801 iTest->SimulatePointerDownUp(iScreenSize.iWidth/4,iScreenSize.iHeight/8+EWinBorderSize/2);
804 if (iTest->iState>ECaptureDisabled)
806 iTest->SimulatePointerDownUp(iScreenSize.iWidth/4,3*iScreenSize.iHeight/8-EWinBorderSize/2);
810 iTest->SimulatePointerDownUp(5*iScreenSize.iWidth/8,iScreenSize.iHeight/4);
813 iTest->SimulatePointerDownUp(7*iScreenSize.iWidth/8,iScreenSize.iHeight/4);
816 if (iTest->IsFullRomL())
817 iTest->SimulateKeyDownUp(EStdKeyEnter);
819 iTest->SimulatePointerDownUp(0,0);
820 if (iTest->iState==ENormalCaptureWithoutFocus)
822 iTest->SimulateKeyDownUp(EStdKeyEscape);
829 TheClient->iWs.Flush();
832 void CTPointerCapture::RunTestCaseL(TInt /*aCurTestCase*/)
834 _LIT(TestNoCapture,"No capture");
835 _LIT(TestNormalCapture,"Normal capture");
836 _LIT(TestAllGroups,"All groups");
837 _LIT(TestDragDrop,"Drag & Drop");
838 _LIT(TestDragDropAllGroups,"Drag & Drop All groups");
839 _LIT(TestWithoutFocus,"Without focus");
842 if (!TestBase()->ConfigurationSupportsPointerEventTesting())
844 INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing"));
849 ((CTPointerCaptureStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
850 switch(iTest->iState)
854 @SYMTestCaseID GRAPHICS-WSERV-0290
858 @SYMTestCaseDesc Test pointer capture can be disabled
860 @SYMTestPriority High
862 @SYMTestStatus Implemented
864 @SYMTestActions Disable the pointer capture to the screen and simulate
865 capture with the pointer
867 @SYMTestExpectedResults The pointer capture has been disabled
870 case ECaptureDisabled:
871 ((CTPointerCaptureStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0290"));
872 if (TheClient->iScreen->GetScreenNumber()>0)
874 _LIT(KLog,"Cannot run this test on the 2nd screen - all pointer events goto the 1st screen");
878 iTest->LogSubTest(TestNoCapture);
879 SetCapture(RWindowBase::TCaptureDisabled);
883 @SYMTestCaseID GRAPHICS-WSERV-0291
887 @SYMTestCaseDesc Test pointer capture can be enabled
889 @SYMTestPriority High
891 @SYMTestStatus Implemented
893 @SYMTestActions Enable the pointer capture to the screen and simulate
894 capture with the pointer
896 @SYMTestExpectedResults The pointer capture has been enabled and works
901 ((CTPointerCaptureStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0291"));
902 iTest->LogSubTest(TestNormalCapture);
903 SetCapture(RWindowBase::TCaptureEnabled);
907 @SYMTestCaseID GRAPHICS-WSERV-0292
911 @SYMTestCaseDesc Test pointer capture can be enabled for
912 windows belonging to any group
914 @SYMTestPriority High
916 @SYMTestStatus Implemented
918 @SYMTestActions Enable the pointer capture to all windows and simulate
919 capture with the pointer
921 @SYMTestExpectedResults The pointer capture has been enabled and works
925 case ECaptureAllGroups:
926 ((CTPointerCaptureStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0292"));
927 iTest->LogSubTest(TestAllGroups);
928 SetCapture(RWindowBase::TCaptureEnabled|RWindowBase::TCaptureFlagAllGroups);
932 @SYMTestCaseID GRAPHICS-WSERV-0293
936 @SYMTestCaseDesc Test drag and drop pointer capture can be enabled for
937 windows belonging to any group
939 @SYMTestPriority High
941 @SYMTestStatus Implemented
943 @SYMTestActions Enable drag and drop pointer capture to all windows and simulate
944 capture with the pointer
946 @SYMTestExpectedResults The pointer capture has been enabled and works
950 case EDragDropCapture:
951 ((CTPointerCaptureStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0293"));
952 iTest->LogSubTest(TestDragDrop);
953 SetCapture(RWindowBase::TCaptureDragDrop&~RWindowBase::TCaptureFlagAllGroups);
957 @SYMTestCaseID GRAPHICS-WSERV-0294
961 @SYMTestCaseDesc Test drag and drop pointer capture can be enabled
963 @SYMTestPriority High
965 @SYMTestStatus Implemented
967 @SYMTestActions Enable drag and drop pointer capture and simulate
968 capture with the pointer
970 @SYMTestExpectedResults The pointer capture has been enabled and works
974 case EDragDropCaptureAllGroups:
975 ((CTPointerCaptureStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0294"));
976 iTest->LogSubTest(TestDragDropAllGroups);
977 SetCapture(RWindowBase::TCaptureDragDrop);
981 @SYMTestCaseID GRAPHICS-WSERV-0295
985 @SYMTestCaseDesc Test pointer capture can be enabled
987 @SYMTestPriority High
989 @SYMTestStatus Implemented
991 @SYMTestActions Enable the pointer capture to the screen and simulate capture
992 with the pointer when the screen does not have the focus
994 @SYMTestExpectedResults The pointer capture has been enabled and works
998 case ENormalCaptureWithoutFocus:
999 ((CTPointerCaptureStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0295"));
1000 iTest->LogSubTest(TestWithoutFocus);
1002 SetCapture(RWindowBase::TCaptureEnabled);
1005 ((CTPointerCaptureStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
1006 ((CTPointerCaptureStep*)iStep)->CloseTMSGraphicsStep();
1010 ((CTPointerCaptureStep*)iStep)->RecordTestResultL();
1014 __WS_CONSTRUCT_STEP__(PointerCapture)