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.
15 // Coverted from TMan test code (TMCAPKEY.CPP) October 2000
22 @internalComponent - Internal Symbian test code
33 CAbortHandler::CAbortHandler(RWsSession *aWs, CCKAbortConnection *aConnection) : CTEventBase(aWs, 10), iConnection(aConnection)
37 CAbortHandler::~CAbortHandler()
42 void CAbortHandler::Request()
44 iWs->PriorityKeyReady(&iStatus);
48 void CAbortHandler::DoCancel()
50 iWs->PriorityKeyReadyCancel();
53 void CAbortHandler::doRunL()
55 TWsPriorityKeyEvent abortEvent;
56 iWs->GetPriorityKey(abortEvent);
57 iConnection->ReceivedAbortEvent(abortEvent.Handle(),abortEvent.Key());
63 CCKConnectionBase::CCKConnectionBase(CTCaptureKey *aTest) : iTest(aTest)
67 void CCKConnectionBase::ConstructL()
69 CTClient::SetScreenNumber(iTest->ScreenNumber());
70 CTClient::ConstructL();
71 iGroup=new(ELeave) CCKWindowGroup(this, iTest);
75 CCKConnection::CCKConnection(CTCaptureKey *aTest, TInt aConnIndex) : CCKConnectionBase(aTest), iConnIndex(aConnIndex)
79 CCKConnection::~CCKConnection()
81 for(TInt index=0;index<numCapKeys;index++)
82 if (capKeys[index].connIndex==iConnIndex)
83 iGroup->GroupWin()->CancelCaptureKey(capKeyHandle[index]);
84 for(TInt index1=0;index1<numCapKeysWithPriority;index1++)
85 if (capKeysWithPriority[index1].connIndex==iConnIndex)
86 iGroup->GroupWin()->CancelCaptureKey(capKeyWithPriorityHandle[index1]);
87 for(TInt index2=0;index2<numUpDownKeys;index2++)
88 if (capUpAndDownKeys[index2].connIndex==iConnIndex)
89 iGroup->GroupWin()->CancelCaptureKeyUpAndDowns(capUpDownKeyHandle[index2]);
90 for(TInt index3=0;index3<numUpDownKeysWithPriority;index3++)
91 if (capUpAndDownKeysWithPriority[index3].connIndex==iConnIndex)
92 iGroup->GroupWin()->CancelCaptureKeyUpAndDowns(capUpDownKeyWithPriorityHandle[index3]);
96 void CCKConnection::SubStateChanged()
102 void CCKConnection::ConstructL()
104 CCKConnectionBase::ConstructL();
105 for(TInt index=0;index<numCapKeys;index++)
106 if (capKeys[index].connIndex==iConnIndex)
107 capKeyHandle[index]=User::LeaveIfError(iGroup->GroupWin()->CaptureKey(capKeys[index].keyCode,capKeys[index].modifier_mask,capKeys[index].modifiers));
108 for(TInt index1=0;index1<numCapKeysWithPriority;index1++)
109 if (capKeysWithPriority[index1].connIndex==iConnIndex)
110 capKeyWithPriorityHandle[index1]=User::LeaveIfError(iGroup->GroupWin()->CaptureKey(capKeysWithPriority[index1].keyCode,capKeysWithPriority[index1].modifier_mask,capKeysWithPriority[index1].modifiers,capKeysWithPriority[index1].priority));
111 for(TInt index2=0;index2<numUpDownKeys;index2++)
112 if (capUpAndDownKeys[index2].connIndex==iConnIndex)
113 capUpDownKeyHandle[index2]=User::LeaveIfError(iGroup->GroupWin()->CaptureKeyUpAndDowns(capUpAndDownKeys[index2].keyCode,
114 capUpAndDownKeys[index2].modifier_mask,capUpAndDownKeys[index2].modifiers));
115 for(TInt index3=0;index3<numUpDownKeysWithPriority;index3++)
116 if (capUpAndDownKeysWithPriority[index3].connIndex==iConnIndex)
117 capUpDownKeyWithPriorityHandle[index3]=User::LeaveIfError(iGroup->GroupWin()->CaptureKeyUpAndDowns(capUpAndDownKeysWithPriority[index3].keyCode,
118 capUpAndDownKeysWithPriority[index3].modifier_mask,capUpAndDownKeysWithPriority[index3].modifiers,capUpAndDownKeysWithPriority[index3].priority));
119 TSize screenSize=iGroup->Size();
120 TInt winWidth=screenSize.iWidth/2;
121 TInt winHeight=screenSize.iHeight-10;
122 iGroup->GroupWin()->AutoForeground(EFalse); // Don't allow clicking to cause foreground, might mess up test
123 CCKWindow *win=new(ELeave) CCKWindow(iTest, iConnIndex);
124 win->SetUpL(TPoint(5,5),TSize(winWidth,winHeight),iGroup,*iGc);
128 void CCKConnection::KeyTestL(TInt aBool)
132 CTDialog *dialog= new(ELeave) CTDialog();
136 dialog->ConstructLD(*iGroup,*iGc);
137 dialog->SetTitle(_L("Invalid key press"));
138 dialog->SetLine1(_L("Try again?"));
139 dialog->SetNumButtons(2);
140 dialog->SetButtonText(0,_L("Fail"));
141 dialog->SetButtonText(1,_L("Retry"));
142 ret=dialog->Display();
144 User::Leave(ret==1 ? ECapKeyRetry : ECapKeyFail);
148 void CCKConnection::CheckKeyL(const SCapKeyTestParams &aKeyTest, const TKeyEvent &aKey)
150 KeyTestL(aKeyTest.keyCode==aKey.iCode);
151 KeyTestL(aKeyTest.modifiers==(aKey.iModifiers&aKeyTest.modifier_mask));
154 void CCKConnection::CheckUpDownL(const SCapKeyTestParams &aKeyTest, const TKeyEvent &aKey)
156 if(iTest->Mode()==EModeKeyUpsAndDownsWithPriority)
157 KeyTestL(aKeyTest.connIndex==iTest->SubState()-15);
158 KeyTestL(aKeyTest.connIndex==iConnIndex);
159 KeyTestL(aKeyTest.keyCode==(TUint)aKey.iScanCode);
160 KeyTestL(aKeyTest.modifiers==(aKey.iModifiers&aKeyTest.modifier_mask));
163 void CCKConnection::KeyL(const TKeyEvent &aKey,const TTime &)
166 _LIT(KLog,"CCKConnection::KeyL State=%d SubState=%d Mode=%d KeyCode=%d ScanCode=%d Mod=0x%x");
167 iTest->LOG_MESSAGE7(KLog,iTest->State(),iTest->SubState(),iTest->Mode(),aKey.iCode,aKey.iScanCode,aKey.iModifiers);
169 if (iTest->Mode()==EModeNormalCapture || iTest->Mode()==EModeNormalCaptureWithPriority)
171 //if (aKey.iCode==EKeyEscape)
173 if(iTest->Mode()==EModeNormalCaptureWithPriority)
175 SCapKeyTestParams tmpCapKeyTest=capKeyTests[iTest->SubState()];
176 KeyTestL(tmpCapKeyTest.connIndex==iTest->SubState()-8);
178 TRAPD(ret,CheckKeyL(capKeyTests[iTest->SubState()],aKey));
179 if (ret==ECapKeyOkay)
180 iTest->IncSubState();
183 iTest->TEST(ret==ECapKeyRetry);
184 if (ret!=ECapKeyRetry)
185 iTest->INFO_PRINTF3(_L("CheckKeyL(capKeyTests[iTest->SubState()],aKey) return value - Expected: %d, Actual: %d"), ECapKeyRetry, ret);
191 void CCKConnection::CheckUpDownL(const TKeyEvent &aKey)
193 CheckUpDownL(capKeyTests[iTest->SubState()],aKey);
196 CCKAbortConnection::CCKAbortConnection(CTCaptureKey *aTest) : CCKConnectionBase(aTest)
200 CCKAbortConnection::~CCKAbortConnection()
202 iGroup->GroupWin()->RemovePriorityKey(3,EModifierCtrl,EModifierCtrl);
203 delete iAbortHandler;
206 void CCKAbortConnection::ConstructL()
208 CCKConnectionBase::ConstructL();
209 User::LeaveIfError(iGroup->GroupWin()->AddPriorityKey(abortKeyTests[0].keyCode,abortKeyTests[0].modifier_mask,abortKeyTests[0].modifiers));
210 User::LeaveIfError(iGroup->GroupWin()->AddPriorityKey(abortKeyTests[1].keyCode,abortKeyTests[1].modifier_mask,abortKeyTests[1].modifiers));
211 User::LeaveIfError(iGroup->GroupWin()->AddPriorityKey(abortKeyTests[2].keyCode,abortKeyTests[2].modifier_mask,abortKeyTests[2].modifiers));
212 iAbortHandler=new(ELeave) CAbortHandler(&iWs, this);
213 iAbortHandler->Construct();
217 void CCKAbortConnection::ReceivedAbortEvent(TInt aHandle,TKeyEvent* aKey)
220 _LIT(KLog,"CCKAbortConnection::ReceivedAbortEvent State=%d SubState=%d Mode=%d KeyCode=%d ScanCode=%d Mod=0x%x");
221 iTest->LOG_MESSAGE7(KLog,iTest->State(),iTest->SubState(),iTest->Mode(),aKey->iCode,aKey->iScanCode,aKey->iModifiers);
223 TInt group=reinterpret_cast<TInt>(iGroup);
224 iTest->TEST(aHandle==group);
227 _LIT(KLog,"Event Handle is not for the right group, expected=%d actual=%d");
228 iTest->LOG_MESSAGE3(KLog,group,aHandle);
231 iTest->TEST(aKey->iCode==abortKeyTests[iAbortKeyIndex].keyCode);
232 if (aKey->iCode!=abortKeyTests[iAbortKeyIndex].keyCode)
234 _LIT(KLog,"The event KeyCode is not right, expected=%d actual=%d");
235 iTest->LOG_MESSAGE3(KLog,abortKeyTests[iAbortKeyIndex].keyCode,aKey->iCode);
238 iTest->TEST((aKey->iModifiers&abortKeyTests[iAbortKeyIndex].modifier_mask)==abortKeyTests[iAbortKeyIndex].modifiers);
239 if ((aKey->iModifiers&abortKeyTests[iAbortKeyIndex].modifier_mask)!=abortKeyTests[iAbortKeyIndex].modifiers)
241 _LIT(KLog,"The event modifiers are not right, expected=0x%x actual=0x%x (0x%x) mask=0x%x");
242 iTest->LOG_MESSAGE5(KLog,abortKeyTests[iAbortKeyIndex].modifiers,aKey->iModifiers&abortKeyTests[iAbortKeyIndex].modifier_mask
243 ,aKey->iModifiers,abortKeyTests[iAbortKeyIndex].modifier_mask);
246 iTest->IncSubState();
249 void CCKAbortConnection::Foreground()
251 iGroup->GroupWin()->SetOrdinalPosition(0);
256 // CCKWindowGroup class //
259 CCKWindowGroup::CCKWindowGroup(CTClient *aClient, CTCaptureKey *aTest) : CTWindowGroup(aClient), iTest(aTest)
262 void CCKWindowGroup::KeyL(const TKeyEvent &aKey,const TTime &time)
265 _LIT(KLog,"CCKWindowGroup::KeyL State=%d SubState=%d Mode=%d KeyCode=%d ScanCode=%d Mod=0x%x");
266 iTest->LOG_MESSAGE7(KLog,iTest->State(),iTest->SubState(),iTest->Mode(),aKey.iCode,aKey.iScanCode,aKey.iModifiers);
268 if (iTest->Mode()==EModeWaitingForFirstNormalCapWithPriority)
269 iTest->SetMode(EModeNormalCaptureWithPriority);
271 iCurWin->WinKeyL(aKey,time);
273 ((CCKConnection *)iClient)->KeyL(aKey,time);
276 void CCKWindowGroup::KeyDownL(const TKeyEvent &aKey,const TTime &)
279 _LIT(KLog,"CCKWindowGroup::KeyDownL State=%d SubState=%d Mode=%d KeyCode=%d ScanCode=%d Mod=0x%x");
280 iTest->LOG_MESSAGE7(KLog,iTest->State(),iTest->SubState(),iTest->Mode(),aKey.iCode,aKey.iScanCode,aKey.iModifiers);
282 if (aKey.iScanCode!=EStdKeyLeftShift && aKey.iScanCode!=EStdKeyRightShift)
284 if (iTest->Mode()==EModeWaitingForFirstDown)
285 iTest->SetMode(EModeKeyUpsAndDowns);
286 if (iTest->Mode()==EModeWaitingForFirstDownWithPriority)
287 iTest->SetMode(EModeKeyUpsAndDownsWithPriority);
288 if (iTest->Mode()==EModeKeyUpsAndDowns || iTest->Mode()==EModeKeyUpsAndDownsWithPriority)
289 ((CCKConnection *)iClient)->CheckUpDownL(aKey);
293 void CCKWindowGroup::KeyUpL(const TKeyEvent &aKey,const TTime &)
296 _LIT(KLog,"CCKWindowGroup::KeyUpL State=%d SubState=%d Mode=%d KeyCode=%d ScanCode=%d Mod=0x%x");
297 iTest->LOG_MESSAGE7(KLog,iTest->State(),iTest->SubState(),iTest->Mode(),aKey.iCode,aKey.iScanCode,aKey.iModifiers);
299 if (aKey.iScanCode!=EStdKeyLeftShift && aKey.iScanCode!=EStdKeyRightShift)
301 if (iTest->Mode()==EModeKeyUpsAndDowns || iTest->Mode()==EModeKeyUpsAndDownsWithPriority)
303 ((CCKConnection *)iClient)->CheckUpDownL(aKey);
304 iTest->IncSubState();
310 // CCKWindow, class //
313 CCKWindow::CCKWindow(CTCaptureKey *aTest, TInt aConnIndex) : CTWin(), iConnIndex(aConnIndex), iTest(aTest)
315 iBack=TRgb::Gray256(230);
318 void CCKWindow::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc)
320 ConstructExtLD(*parent,pos,size);
321 iWin.SetBackgroundColor(iBack);
326 void CCKWindow::Draw()
331 TInt test=iTest->SubState();
333 iGc->DrawText(TPtrC(capKeyTests[test].txt), TPoint(10,20));
339 CTCaptureKey::CTCaptureKey(CTestStep* aStep) : CTWsGraphicsBase(aStep)
343 CTCaptureKey::~CTCaptureKey()
345 ((CTCaptureKeyStep*)iStep)->CloseTMSGraphicsStep();
352 void CTCaptureKey::ConstructL()
354 iAbortConn=new(ELeave) CCKAbortConnection(this);
355 iAbortConn->ConstructL();
356 iConn3=new(ELeave) CCKConnection(this,2);
357 iConn3->ConstructL();
358 iConn2=new(ELeave) CCKConnection(this,1);
359 iConn2->ConstructL();
360 iConn1=new(ELeave) CCKConnection(this,0);
361 iConn1->ConstructL();
362 iMode=EModeNormalCapture;
364 TUint mods=TheClient->iWs.GetModifierState();
365 _LIT(KLog,"Initial Modifiers state 0x%x (ideally should be zero)");
366 LOG_MESSAGE2(KLog,mods);
369 TInt CTCaptureKey::SubState() const
374 void CTCaptureKey::IncSubState()
378 _LIT(KLog,"IncSubState State=%d SubState=%d Mode=%d");
379 LOG_MESSAGE4(KLog,iState,iSubState,iMode);
381 iConn1->SubStateChanged();
382 iConn2->SubStateChanged();
383 iConn3->SubStateChanged();
386 case EModeNormalCapture:
387 if (iSubState==numCapKeyTests)
393 case EModeNormalCaptureWithPriority:
394 if (iSubState==numCapKeyTests+numCapKeyWithPriorityTests)
400 case EModeKeyUpsAndDowns:
401 if (iSubState==(numCapKeyTests+numCapKeyWithPriorityTests+numUpDownKeyTests))
407 case EModeKeyUpsAndDownsWithPriority:
408 if (iSubState==(numCapKeyTests+numCapKeyWithPriorityTests+numUpDownKeyTests+numUpDownKeyWithPriorityTests))
410 SetSelfDrive(EFalse);
415 if (iSubState==(numCapKeyTests+numCapKeyWithPriorityTests+numUpDownKeyTests+numUpDownKeyWithPriorityTests+numAbortKeyTests))
417 TheClient->WaitForRedrawsToFinish();
422 TheClient->WaitForRedrawsToFinish();
426 void CTCaptureKey::CapKeyPurgingL()
428 TInt base=Client()->iWs.ResourceCount();
429 RWindowGroup groupWin(Client()->iWs);
430 User::LeaveIfError(groupWin.Construct(ENullWsHandle));
431 TInt capHandle=User::LeaveIfError(groupWin.CaptureKey('a',EModifierFunc,EModifierFunc));
432 User::LeaveIfError(groupWin.CaptureKey('b',EModifierFunc,EModifierFunc));
433 TInt retVal = Client()->iWs.ResourceCount();
434 TEST(retVal==(base+3));
435 if (retVal!=(base+3))
436 INFO_PRINTF3(_L("Client()->iWs.ResourceCount() return value - Expected: %d, Actual: %d"), retVal, (base+3));
438 groupWin.CancelCaptureKey(capHandle);
439 retVal = Client()->iWs.ResourceCount();
440 TEST(retVal==(base+2));
441 if (retVal!=(base+2))
442 INFO_PRINTF3(_L("Client()->iWs.ResourceCount() return value - Expected: %d, Actual: %d"), retVal, (base+2));
445 // Check it also freed the extra capture key
446 retVal = Client()->iWs.ResourceCount();
449 INFO_PRINTF3(_L("Client()->iWs.ResourceCount() return value - Expected: %d, Actual: %d"), retVal, base);
453 void CTCaptureKey::BadParams()
456 TInt resCount=Client()->iWs.ResourceCount();
457 for(TInt index=0;index<numErrorKeys;index++)
459 retVal = Client()->iGroup->GroupWin()->CaptureKey(errorKeys[index].keyCode,errorKeys[index].modifier_mask,errorKeys[index].modifiers, errorKeys[index].priority);
460 TEST(retVal==KErrArgument);
461 if (retVal!=KErrArgument)
463 _LIT(KMsg, "CaptureKey() with bad parameter set %d returned %d - expected KErrArgument (%d)");
464 LOG_MESSAGE4(KMsg, index, retVal, KErrArgument);
467 retVal = Client()->iGroup->GroupWin()->CaptureKeyUpAndDowns(errorKeys[index].keyCode, errorKeys[index].modifier_mask, errorKeys[index].modifiers, errorKeys[index].priority);
468 TEST(retVal == KErrArgument);
469 if (retVal != KErrArgument)
471 _LIT(KMsg, "CaptureKeyUpAndDowns() with bad parameter set %d returned %d - expected KErrArgument (%d)");
472 LOG_MESSAGE4(KMsg, index, retVal, KErrArgument);
475 retVal = Client()->iGroup->GroupWin()->CaptureLongKey(errorKeys[index].keyCode, errorKeys[index].keyCode, errorKeys[index].modifier_mask, errorKeys[index].modifiers, errorKeys[index].priority, ELongCaptureNormal);
476 TEST(retVal == KErrArgument);
477 if (retVal != KErrArgument)
479 _LIT(KMsg, "CaptureLongKey() with bad parameter set %d returned %d - expected KErrArgument (%d)");
480 LOG_MESSAGE4(KMsg, index, retVal, KErrArgument);
484 retVal = Client()->iWs.ResourceCount();
485 TEST(retVal==resCount);
486 if (retVal!=resCount)
488 _LIT(KMsg, "Resource count %d - expected %d");
489 LOG_MESSAGE3(KMsg, retVal, resCount);
493 void CTCaptureKey::SetMode(TTestMode aMode)
496 _LIT(KLog,"SetMode State=%d SubState=%d OldMode=%d NewMode=%d");
497 LOG_MESSAGE5(KLog,State(),SubState(),iMode,aMode);
502 TTestMode CTCaptureKey::Mode()
507 void CTCaptureKey::SetUpPriorityKeyTest()
509 iMode=EModeAbortKeys;
510 iAbortConn->Foreground();
513 void CTCaptureKey::CaptureWithPriorityTest() //normal key capture but with priority
515 iMode=EModeWaitingForFirstNormalCapWithPriority;
518 void CTCaptureKey::CaptureUpsAndDownsTest()
520 iMode=EModeWaitingForFirstDown;
523 void CTCaptureKey::CaptureUpsAndDownsWithPriorityTest()
525 iMode=EModeWaitingForFirstDownWithPriority;
528 void CTCaptureKey::SendEvents()
531 _LIT(KLog,"SendEvents State=%d SubState=%d");
532 LOG_MESSAGE3(KLog,iState,iSubState);
537 iTest->SimulateKeyDownUp('Q');
540 iTest->SimulateKeyDownUpWithModifiers('W',EModifierAlt);
543 iTest->SimulateKeyDownUp('A');
546 iTest->SimulateKeyDownUpWithModifiers('S',EModifierAlt|EModifierCtrl);
549 iTest->SimulateKeyDownUpWithModifiers('N',EModifierAlt);
552 iTest->SimulateKeyDownUpWithModifiers('B',EModifierAlt|EModifierCtrl);
555 iTest->SimulateKeyDownUpWithModifiers('D',EModifierAlt);
558 iTest->SimulateKeyDownUpWithModifiers('C',EModifierAlt|EModifierCtrl);
561 iTest->SimulateKeyDownUp('H');//state EModeNormalCaptureWithPriority
564 iTest->SimulateKeyDownUp('J');
567 iTest->SimulateKeyDownUp('K');
570 iTest->SimulateKeyDownUp(EStdKeySpace);
573 iTest->SimulateKeyDownUp(EStdKeyEnter);
576 iTest->SimulateKeyDownUpWithModifiers(EStdKeySpace,EModifierShift);
579 iTest->SimulateKeyDownUpWithModifiers(EStdKeyEnter,EModifierShift);
582 iTest->SimulateKeyDownUp('H');//state EModeKeyUpsAndDownsWithPriority
585 iTest->SimulateKeyDownUp('J');
588 iTest->SimulateKeyDownUp('K');
591 iTest->SimulateKeyDownUpWithModifiers('C',EModifierCtrl);
594 iTest->SimulateKeyDownUpWithModifiers('D',EModifierCtrl);
597 iTest->SimulateKeyDownUp('Z');
602 TheClient->iWs.Flush();
605 void CTCaptureKey::CapKeyPowerOffL()
607 const TUint protKey=0xF844; //This value needs to be defined in the WSINI.INI file as a key only capturable by a certain application
609 User::LeaveIfError(ws.Connect());
610 CleanupClosePushL(ws);
612 // assign to the correct screen
613 CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
614 CleanupStack::PushL(screen);
615 User::LeaveIfError(screen->Construct(iTest->iScreenNumber));
617 RWindowGroup group(ws);
618 group.Construct(ENullWsHandle);
619 CleanupClosePushL(group);
620 group.EnableReceiptOfFocus(EFalse);
621 group.SetOrdinalPosition(0,5);
622 RBlankWindow blank(ws);
623 blank.Construct(group,ENullWsHandle);
624 CleanupClosePushL(blank);
625 blank.EnableBackup();
627 _LIT(kGroupName1,"Hello");
628 group.SetName(kGroupName1);
629 TInt capHandle = group.CaptureKey(EKeyDevice2,EModifierFunc,EModifierFunc);
630 TEST(capHandle==KErrPermissionDenied);
631 if (capHandle!=KErrPermissionDenied)
633 _LIT(KLog1,"Capture Key suceeded when it should of failed, Error/Handle=%d (expected: %d)");
634 LOG_MESSAGE3(KLog1,capHandle,KErrPermissionDenied);
635 _LIT(KLog2,"This is indicative of a bad WSINI file");
639 capHandle=group.CaptureKeyUpAndDowns(protKey,0,0);
640 TEST(capHandle==KErrPermissionDenied);
641 if (capHandle!=KErrPermissionDenied)
643 _LIT(KLog,"Capture Key Up & Down suceeded when it should of failed, Error/Handle=%d (expected: %d)");
644 LOG_MESSAGE3(KLog,capHandle,KErrPermissionDenied);
647 _LIT(kGroupName2,"SysApp");
648 group.SetName(kGroupName2);
649 capHandle = group.CaptureKey(EKeyDevice2,EModifierFunc,EModifierFunc);
653 _LIT(KLog,"Capture Key failed when it should of succeeded, Error=%d");
654 LOG_MESSAGE2(KLog,capHandle);
657 group.CancelCaptureKey(capHandle);
658 capHandle=group.CaptureKeyUpAndDowns(protKey,0,0);
662 _LIT(KLog,"Capture Key Up & Down failed when it should of succeeded, Error=%d");
663 LOG_MESSAGE2(KLog,capHandle);
666 group.CancelCaptureKeyUpAndDowns(capHandle);
667 CleanupStack::PopAndDestroy(4,&ws);
671 void CTCaptureKey::RunTestCaseL(TInt /*aCurTestCase*/)
673 _LIT(Test0,"Normal capture with priority");
674 _LIT(TestNormalCaptureWithPriority,"Normal capture with priority");
675 _LIT(TestUpDown,"Capture ups and downs");
676 _LIT(TestUpDownWithPriority,"Capture ups and downs with priority");
677 _LIT(TestAbort,"Abort key");
678 _LIT(TestAbort2,"Abort key extended");
679 _LIT(TestErrors,"Errors");
680 _LIT(TestCaptureKey,"Capture Key");
681 _LIT(TestCapturePowerOffKey,"Capture PowerOff Key");
683 iTest->iState=iState;
684 ((CTCaptureKeyStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
688 @SYMTestCaseID GRAPHICS-WSERV-0140
693 @SYMTestCaseDesc Normal key capture test
695 @SYMTestPriority High
697 @SYMTestStatus Implemented
699 @SYMTestActions The test uses 3 wserv clients with their own window groups. The
700 clients are registered for different keys to capture. The test
701 simulates key presses.
703 @SYMTestExpectedResults Checks that the key presses are captured correctly .
705 case 0: // Dummy one to let capture key tests run
706 ((CTCaptureKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0140"));
707 iTest->LogSubTest(Test0);
712 @SYMTestCaseID GRAPHICS-WSERV-0141
716 @SYMTestCaseDesc Normal key capture test with priorities
718 @SYMTestPriority High
720 @SYMTestStatus Implemented
722 @SYMTestActions The test uses 3 wserv clients with their own window groups. The
723 clients are registered for different keys to capture and with
724 different priorities. The test simulates key presses.
726 @SYMTestExpectedResults Checks that the key presses are captured correctly .
729 ((CTCaptureKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0141"));
730 iTest->LogSubTest(TestNormalCaptureWithPriority);
731 CaptureWithPriorityTest();
736 @SYMTestCaseID GRAPHICS-WSERV-0142
740 @SYMTestCaseDesc Up-down key capture test
742 @SYMTestPriority High
744 @SYMTestStatus Implemented
746 @SYMTestActions The test uses 3 wserv clients with their own window groups. The
747 clients are registered for different keys to capture their
748 up and down events. The test simulates key presses and releases.
750 @SYMTestExpectedResults Checks that the key presses and releases are captured correctly .
753 ((CTCaptureKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0142"));
754 iTest->LogSubTest(TestUpDown);
755 CaptureUpsAndDownsTest();
760 @SYMTestCaseID GRAPHICS-WSERV-0143
764 @SYMTestCaseDesc Up-down key capture test with priorities
766 @SYMTestPriority High
768 @SYMTestStatus Implemented
770 @SYMTestActions The test uses 3 wserv clients with their own window groups. The
771 clients are registered with different priorities for different keys to capture their
772 up and down events. The test simulates key presses and releases.
774 @SYMTestExpectedResults Checks that the key presses and releases are captured correctly .
777 ((CTCaptureKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0143"));
778 iTest->LogSubTest(TestUpDownWithPriority);
779 CaptureUpsAndDownsWithPriorityTest();
784 @SYMTestCaseID GRAPHICS-WSERV-0144
788 @SYMTestCaseDesc Priority key events test
790 @SYMTestPriority High
792 @SYMTestStatus Implemented
794 @SYMTestActions The test simulates key events and make sure that the events are
795 recieved by the registered wserv client.
797 @SYMTestExpectedResults Makes sure that key code is the same as a key simulated, event modifiers comply
798 with registered priority key's modifirs and mask, and that event handle
799 is a window group of the session.
803 ((CTCaptureKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0144"));
804 if (iSubState==numCapKeyTests+numUpDownKeyWithPriorityTests+numUpDownKeyTests+numUpDownKeyWithPriorityTests)
806 iTest->LogSubTest(TestAbort);
807 SetUpPriorityKeyTest();
810 iTest->LogSubTest(TestAbort2);
813 TheClient->WaitUntilEventPending();
816 @SYMTestCaseID GRAPHICS-WSERV-0145
820 @SYMTestCaseDesc Invalid capture keys test
822 @SYMTestPriority High
824 @SYMTestStatus Implemented
826 @SYMTestActions Memorizes amount of objects that the server has allocated for that client.
827 Tries to register capture keys with invalid modifiers and
828 modifier mask pairs, using each of the RWindowGroup capture
829 functions CaptureKey(), CaptureKeyUpAndDowns() and
832 @SYMTestExpectedResults Makes sure that the number of server-side objects for the
833 session didn't change.
836 ((CTCaptureKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0145"));
837 iTest->LogSubTest(TestErrors);
839 ((CTCaptureKeyStep*)iStep)->RecordTestResultL();
841 @SYMTestCaseID GRAPHICS-WSERV-0146
845 @SYMTestCaseDesc Capture keys clean up test
847 @SYMTestPriority High
849 @SYMTestStatus Implemented
851 @SYMTestActions Memorizes amount of objects that the server has allocated for that client.
852 Creates a window group and requests two keys to be captured.
853 Cancels one key capture request and closes the window group.
855 @SYMTestExpectedResults Checks that creation of the group or registering a capture key
856 increased this amount by 1 each time.
857 Makes sure that the number of server-side objects for the
858 session in the end of the test is the same as in the beginning.
860 ((CTCaptureKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0146"));
861 iTest->LogSubTest(TestCaptureKey);
866 @SYMTestCaseID GRAPHICS-WSERV-0147
870 @SYMTestCaseDesc Capture power off key test
872 @SYMTestPriority High
874 @SYMTestStatus Implemented
876 @SYMTestActions The test creates a new session, new window group and a new window
877 in the group. After that the test gives "Hello" name to the group
878 and tries to register for key capture of FN+EKeyDevice2 and 0xF844
879 buttons. Makes sure that registration fails due to KErrPermissionDenied
881 Then the test changes the name of the window group to "SysApp"
882 and tries the registration again. Makes sure that operation
883 completed successfully.
885 @SYMTestExpectedResults See actions
888 ((CTCaptureKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0147"));
889 iTest->LogSubTest(TestCapturePowerOffKey);
894 ((CTCaptureKeyStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
897 ((CTCaptureKeyStep*)iStep)->RecordTestResultL();
902 __WS_CONSTRUCT_STEP__(CaptureKey)