os/graphics/windowing/windowserver/test/tauto/TCapKey.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/windowing/windowserver/test/tauto/TCapKey.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,902 @@
     1.4 +// Copyright (c) 1996-2010 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// Test capture key
    1.18 +// Coverted from TMan test code (TMCAPKEY.CPP) October 2000
    1.19 +// 
    1.20 +//
    1.21 +
    1.22 +/**
    1.23 + @file
    1.24 + @test
    1.25 + @internalComponent - Internal Symbian test code
    1.26 +*/
    1.27 +
    1.28 +
    1.29 +#include "TCapKey.H"
    1.30 +
    1.31 +#define LOGGING on
    1.32 +
    1.33 +//
    1.34 +// CAbortHandler
    1.35 +
    1.36 +CAbortHandler::CAbortHandler(RWsSession *aWs, CCKAbortConnection *aConnection) : CTEventBase(aWs, 10), iConnection(aConnection)
    1.37 +	{
    1.38 +	}
    1.39 +
    1.40 +CAbortHandler::~CAbortHandler()
    1.41 +	{
    1.42 +	Cancel();
    1.43 +	}
    1.44 +
    1.45 +void CAbortHandler::Request()
    1.46 +	{
    1.47 +	iWs->PriorityKeyReady(&iStatus);
    1.48 +	SetActive();
    1.49 +	}
    1.50 +
    1.51 +void CAbortHandler::DoCancel()
    1.52 +	{
    1.53 +	iWs->PriorityKeyReadyCancel();
    1.54 +	}
    1.55 +
    1.56 +void CAbortHandler::doRunL()
    1.57 +	{
    1.58 +	TWsPriorityKeyEvent abortEvent;
    1.59 +	iWs->GetPriorityKey(abortEvent);
    1.60 +	iConnection->ReceivedAbortEvent(abortEvent.Handle(),abortEvent.Key());
    1.61 +	}
    1.62 +
    1.63 +//
    1.64 +// CCKConnection
    1.65 +
    1.66 +CCKConnectionBase::CCKConnectionBase(CTCaptureKey *aTest) : iTest(aTest)
    1.67 +	{
    1.68 +	}
    1.69 +
    1.70 +void CCKConnectionBase::ConstructL()
    1.71 +	{
    1.72 +	CTClient::SetScreenNumber(iTest->ScreenNumber());
    1.73 +	CTClient::ConstructL();
    1.74 +	iGroup=new(ELeave) CCKWindowGroup(this, iTest);
    1.75 +	iGroup->ConstructL();
    1.76 +	}
    1.77 +
    1.78 +CCKConnection::CCKConnection(CTCaptureKey *aTest, TInt aConnIndex) : CCKConnectionBase(aTest), iConnIndex(aConnIndex)
    1.79 +	{
    1.80 +	}
    1.81 +
    1.82 +CCKConnection::~CCKConnection()
    1.83 +	{
    1.84 +	for(TInt index=0;index<numCapKeys;index++)
    1.85 +		if (capKeys[index].connIndex==iConnIndex)
    1.86 +			iGroup->GroupWin()->CancelCaptureKey(capKeyHandle[index]);
    1.87 +	for(TInt index1=0;index1<numCapKeysWithPriority;index1++)
    1.88 +		if (capKeysWithPriority[index1].connIndex==iConnIndex)
    1.89 +			iGroup->GroupWin()->CancelCaptureKey(capKeyWithPriorityHandle[index1]);
    1.90 +	for(TInt index2=0;index2<numUpDownKeys;index2++)
    1.91 +		if (capUpAndDownKeys[index2].connIndex==iConnIndex)
    1.92 +			iGroup->GroupWin()->CancelCaptureKeyUpAndDowns(capUpDownKeyHandle[index2]);
    1.93 +	for(TInt index3=0;index3<numUpDownKeysWithPriority;index3++)
    1.94 +		if (capUpAndDownKeysWithPriority[index3].connIndex==iConnIndex)
    1.95 +			iGroup->GroupWin()->CancelCaptureKeyUpAndDowns(capUpDownKeyWithPriorityHandle[index3]);
    1.96 +	CTWin::Delete(iWin);
    1.97 +	}
    1.98 +
    1.99 +void CCKConnection::SubStateChanged()
   1.100 +	{
   1.101 +	iWin->Invalidate();
   1.102 +	iWs.Flush();
   1.103 +	}
   1.104 +
   1.105 +void CCKConnection::ConstructL()
   1.106 +	{
   1.107 +	CCKConnectionBase::ConstructL();
   1.108 +	for(TInt index=0;index<numCapKeys;index++)
   1.109 +		if (capKeys[index].connIndex==iConnIndex)
   1.110 +			capKeyHandle[index]=User::LeaveIfError(iGroup->GroupWin()->CaptureKey(capKeys[index].keyCode,capKeys[index].modifier_mask,capKeys[index].modifiers));
   1.111 +	for(TInt index1=0;index1<numCapKeysWithPriority;index1++)
   1.112 +		if (capKeysWithPriority[index1].connIndex==iConnIndex)
   1.113 +			capKeyWithPriorityHandle[index1]=User::LeaveIfError(iGroup->GroupWin()->CaptureKey(capKeysWithPriority[index1].keyCode,capKeysWithPriority[index1].modifier_mask,capKeysWithPriority[index1].modifiers,capKeysWithPriority[index1].priority));
   1.114 +	for(TInt index2=0;index2<numUpDownKeys;index2++)
   1.115 +		if (capUpAndDownKeys[index2].connIndex==iConnIndex)
   1.116 +			capUpDownKeyHandle[index2]=User::LeaveIfError(iGroup->GroupWin()->CaptureKeyUpAndDowns(capUpAndDownKeys[index2].keyCode,
   1.117 +								capUpAndDownKeys[index2].modifier_mask,capUpAndDownKeys[index2].modifiers));
   1.118 +	for(TInt index3=0;index3<numUpDownKeysWithPriority;index3++)
   1.119 +		if (capUpAndDownKeysWithPriority[index3].connIndex==iConnIndex)
   1.120 +			capUpDownKeyWithPriorityHandle[index3]=User::LeaveIfError(iGroup->GroupWin()->CaptureKeyUpAndDowns(capUpAndDownKeysWithPriority[index3].keyCode,
   1.121 +								capUpAndDownKeysWithPriority[index3].modifier_mask,capUpAndDownKeysWithPriority[index3].modifiers,capUpAndDownKeysWithPriority[index3].priority));
   1.122 +	TSize screenSize=iGroup->Size();
   1.123 +	TInt winWidth=screenSize.iWidth/2;
   1.124 +	TInt winHeight=screenSize.iHeight-10;
   1.125 +	iGroup->GroupWin()->AutoForeground(EFalse);		// Don't allow clicking to cause foreground, might mess up test
   1.126 +	CCKWindow *win=new(ELeave) CCKWindow(iTest, iConnIndex);
   1.127 +	win->SetUpL(TPoint(5,5),TSize(winWidth,winHeight),iGroup,*iGc);
   1.128 +	iWin=win;
   1.129 +	}
   1.130 +
   1.131 +void CCKConnection::KeyTestL(TInt aBool)
   1.132 +	{
   1.133 +	if (!aBool)
   1.134 +		{
   1.135 +		CTDialog *dialog= new(ELeave) CTDialog();
   1.136 +		TInt ret=0;
   1.137 +		if (dialog)
   1.138 +			{
   1.139 +			dialog->ConstructLD(*iGroup,*iGc);
   1.140 +			dialog->SetTitle(_L("Invalid key press"));
   1.141 +			dialog->SetLine1(_L("Try again?"));
   1.142 +			dialog->SetNumButtons(2);
   1.143 +			dialog->SetButtonText(0,_L("Fail"));
   1.144 +			dialog->SetButtonText(1,_L("Retry"));
   1.145 +			ret=dialog->Display();
   1.146 +			}
   1.147 +		User::Leave(ret==1 ? ECapKeyRetry : ECapKeyFail);
   1.148 +		}
   1.149 +	}
   1.150 +
   1.151 +void CCKConnection::CheckKeyL(const SCapKeyTestParams &aKeyTest, const TKeyEvent &aKey)
   1.152 +	{
   1.153 +	KeyTestL(aKeyTest.keyCode==aKey.iCode);
   1.154 +	KeyTestL(aKeyTest.modifiers==(aKey.iModifiers&aKeyTest.modifier_mask));
   1.155 +	}
   1.156 +
   1.157 +void CCKConnection::CheckUpDownL(const SCapKeyTestParams &aKeyTest, const TKeyEvent &aKey)
   1.158 +	{
   1.159 +	if(iTest->Mode()==EModeKeyUpsAndDownsWithPriority)
   1.160 +		KeyTestL(aKeyTest.connIndex==iTest->SubState()-15);
   1.161 +	KeyTestL(aKeyTest.connIndex==iConnIndex);
   1.162 +	KeyTestL(aKeyTest.keyCode==(TUint)aKey.iScanCode);
   1.163 +	KeyTestL(aKeyTest.modifiers==(aKey.iModifiers&aKeyTest.modifier_mask));
   1.164 +	}
   1.165 +
   1.166 +void CCKConnection::KeyL(const TKeyEvent &aKey,const TTime &)
   1.167 +	{
   1.168 +#if defined(LOGGING)
   1.169 +	_LIT(KLog,"CCKConnection::KeyL  State=%d  SubState=%d  Mode=%d  KeyCode=%d  ScanCode=%d  Mod=0x%x");
   1.170 +	iTest->LOG_MESSAGE7(KLog,iTest->State(),iTest->SubState(),iTest->Mode(),aKey.iCode,aKey.iScanCode,aKey.iModifiers);
   1.171 +#endif
   1.172 +	if (iTest->Mode()==EModeNormalCapture || iTest->Mode()==EModeNormalCaptureWithPriority)
   1.173 +		{
   1.174 +		//if (aKey.iCode==EKeyEscape)
   1.175 +		//	iTest->Abort();
   1.176 +		if(iTest->Mode()==EModeNormalCaptureWithPriority)
   1.177 +			{
   1.178 +			SCapKeyTestParams tmpCapKeyTest=capKeyTests[iTest->SubState()];
   1.179 +			KeyTestL(tmpCapKeyTest.connIndex==iTest->SubState()-8);
   1.180 +			}
   1.181 +		TRAPD(ret,CheckKeyL(capKeyTests[iTest->SubState()],aKey));
   1.182 +		if (ret==ECapKeyOkay)
   1.183 +			iTest->IncSubState();
   1.184 +		else
   1.185 +			{
   1.186 +			iTest->TEST(ret==ECapKeyRetry);
   1.187 +			if (ret!=ECapKeyRetry)
   1.188 +				iTest->INFO_PRINTF3(_L("CheckKeyL(capKeyTests[iTest->SubState()],aKey) return value - Expected: %d, Actual: %d"), ECapKeyRetry, ret);		
   1.189 +			}
   1.190 +			
   1.191 +		}
   1.192 +	}
   1.193 +
   1.194 +void CCKConnection::CheckUpDownL(const TKeyEvent &aKey)
   1.195 +	{
   1.196 +	CheckUpDownL(capKeyTests[iTest->SubState()],aKey);
   1.197 +	}
   1.198 +
   1.199 +CCKAbortConnection::CCKAbortConnection(CTCaptureKey *aTest) : CCKConnectionBase(aTest)
   1.200 +	{
   1.201 +	}
   1.202 +
   1.203 +CCKAbortConnection::~CCKAbortConnection()
   1.204 +	{
   1.205 +	iGroup->GroupWin()->RemovePriorityKey(3,EModifierCtrl,EModifierCtrl);
   1.206 +	delete iAbortHandler;
   1.207 +	}
   1.208 +
   1.209 +void CCKAbortConnection::ConstructL()
   1.210 +	{
   1.211 +	CCKConnectionBase::ConstructL();
   1.212 +	User::LeaveIfError(iGroup->GroupWin()->AddPriorityKey(abortKeyTests[0].keyCode,abortKeyTests[0].modifier_mask,abortKeyTests[0].modifiers));
   1.213 +	User::LeaveIfError(iGroup->GroupWin()->AddPriorityKey(abortKeyTests[1].keyCode,abortKeyTests[1].modifier_mask,abortKeyTests[1].modifiers));
   1.214 +	User::LeaveIfError(iGroup->GroupWin()->AddPriorityKey(abortKeyTests[2].keyCode,abortKeyTests[2].modifier_mask,abortKeyTests[2].modifiers));
   1.215 +	iAbortHandler=new(ELeave) CAbortHandler(&iWs, this);
   1.216 +	iAbortHandler->Construct();
   1.217 +	iWs.Flush();
   1.218 +	}
   1.219 +
   1.220 +void CCKAbortConnection::ReceivedAbortEvent(TInt aHandle,TKeyEvent* aKey)
   1.221 +	{
   1.222 +#if defined(LOGGING)
   1.223 +	_LIT(KLog,"CCKAbortConnection::ReceivedAbortEvent  State=%d  SubState=%d  Mode=%d  KeyCode=%d  ScanCode=%d  Mod=0x%x");
   1.224 +	iTest->LOG_MESSAGE7(KLog,iTest->State(),iTest->SubState(),iTest->Mode(),aKey->iCode,aKey->iScanCode,aKey->iModifiers);
   1.225 +#endif
   1.226 +	TInt group=reinterpret_cast<TInt>(iGroup);
   1.227 +	iTest->TEST(aHandle==group);
   1.228 +	if (aHandle!=group)
   1.229 +		{
   1.230 +		_LIT(KLog,"Event Handle is not for the right group, expected=%d actual=%d");
   1.231 +		iTest->LOG_MESSAGE3(KLog,group,aHandle);
   1.232 +		}
   1.233 +
   1.234 +	iTest->TEST(aKey->iCode==abortKeyTests[iAbortKeyIndex].keyCode);
   1.235 +	if (aKey->iCode!=abortKeyTests[iAbortKeyIndex].keyCode)
   1.236 +		{
   1.237 +		_LIT(KLog,"The event KeyCode is not right, expected=%d actual=%d");
   1.238 +		iTest->LOG_MESSAGE3(KLog,abortKeyTests[iAbortKeyIndex].keyCode,aKey->iCode);
   1.239 +		}
   1.240 +
   1.241 +	iTest->TEST((aKey->iModifiers&abortKeyTests[iAbortKeyIndex].modifier_mask)==abortKeyTests[iAbortKeyIndex].modifiers);
   1.242 +	if ((aKey->iModifiers&abortKeyTests[iAbortKeyIndex].modifier_mask)!=abortKeyTests[iAbortKeyIndex].modifiers)
   1.243 +		{
   1.244 +		_LIT(KLog,"The event modifiers are not right, expected=0x%x actual=0x%x (0x%x) mask=0x%x");
   1.245 +		iTest->LOG_MESSAGE5(KLog,abortKeyTests[iAbortKeyIndex].modifiers,aKey->iModifiers&abortKeyTests[iAbortKeyIndex].modifier_mask
   1.246 +									,aKey->iModifiers,abortKeyTests[iAbortKeyIndex].modifier_mask);
   1.247 +		}
   1.248 +	iAbortKeyIndex++;
   1.249 +	iTest->IncSubState();
   1.250 +	}
   1.251 +
   1.252 +void CCKAbortConnection::Foreground()
   1.253 +	{
   1.254 +	iGroup->GroupWin()->SetOrdinalPosition(0);
   1.255 +	iWs.Flush();
   1.256 +	}
   1.257 +
   1.258 +//
   1.259 +// CCKWindowGroup class //
   1.260 +//
   1.261 +
   1.262 +CCKWindowGroup::CCKWindowGroup(CTClient *aClient, CTCaptureKey *aTest) : CTWindowGroup(aClient), iTest(aTest)
   1.263 +	{}
   1.264 +
   1.265 +void CCKWindowGroup::KeyL(const TKeyEvent &aKey,const TTime &time)
   1.266 +	{
   1.267 +#if defined(LOGGING)
   1.268 +	_LIT(KLog,"CCKWindowGroup::KeyL  State=%d  SubState=%d  Mode=%d  KeyCode=%d  ScanCode=%d  Mod=0x%x");
   1.269 +	iTest->LOG_MESSAGE7(KLog,iTest->State(),iTest->SubState(),iTest->Mode(),aKey.iCode,aKey.iScanCode,aKey.iModifiers);
   1.270 +#endif
   1.271 +	if (iTest->Mode()==EModeWaitingForFirstNormalCapWithPriority)
   1.272 +		iTest->SetMode(EModeNormalCaptureWithPriority);
   1.273 +	if (iCurWin)
   1.274 +		iCurWin->WinKeyL(aKey,time);
   1.275 +	else
   1.276 +		((CCKConnection *)iClient)->KeyL(aKey,time);
   1.277 +	}
   1.278 +
   1.279 +void CCKWindowGroup::KeyDownL(const TKeyEvent &aKey,const TTime &)
   1.280 +	{
   1.281 +#if defined(LOGGING)
   1.282 +	_LIT(KLog,"CCKWindowGroup::KeyDownL  State=%d  SubState=%d  Mode=%d  KeyCode=%d  ScanCode=%d  Mod=0x%x");
   1.283 +	iTest->LOG_MESSAGE7(KLog,iTest->State(),iTest->SubState(),iTest->Mode(),aKey.iCode,aKey.iScanCode,aKey.iModifiers);
   1.284 +#endif
   1.285 +	if (aKey.iScanCode!=EStdKeyLeftShift && aKey.iScanCode!=EStdKeyRightShift)
   1.286 +		{
   1.287 +		if (iTest->Mode()==EModeWaitingForFirstDown)
   1.288 +			iTest->SetMode(EModeKeyUpsAndDowns);
   1.289 +		if (iTest->Mode()==EModeWaitingForFirstDownWithPriority)
   1.290 +			iTest->SetMode(EModeKeyUpsAndDownsWithPriority);
   1.291 +		if (iTest->Mode()==EModeKeyUpsAndDowns || iTest->Mode()==EModeKeyUpsAndDownsWithPriority)
   1.292 +			((CCKConnection *)iClient)->CheckUpDownL(aKey);
   1.293 +		}
   1.294 +	}
   1.295 +
   1.296 +void CCKWindowGroup::KeyUpL(const TKeyEvent &aKey,const TTime &)
   1.297 +	{
   1.298 +#if defined(LOGGING)
   1.299 +	_LIT(KLog,"CCKWindowGroup::KeyUpL  State=%d  SubState=%d  Mode=%d  KeyCode=%d  ScanCode=%d  Mod=0x%x");
   1.300 +	iTest->LOG_MESSAGE7(KLog,iTest->State(),iTest->SubState(),iTest->Mode(),aKey.iCode,aKey.iScanCode,aKey.iModifiers);
   1.301 +#endif
   1.302 +	if (aKey.iScanCode!=EStdKeyLeftShift && aKey.iScanCode!=EStdKeyRightShift)
   1.303 +		{
   1.304 +		if (iTest->Mode()==EModeKeyUpsAndDowns || iTest->Mode()==EModeKeyUpsAndDownsWithPriority)
   1.305 +			{
   1.306 +			((CCKConnection *)iClient)->CheckUpDownL(aKey);
   1.307 +			iTest->IncSubState();
   1.308 +			}
   1.309 +		}
   1.310 +	}
   1.311 +
   1.312 +//
   1.313 +// CCKWindow, class //
   1.314 +//
   1.315 +
   1.316 +CCKWindow::CCKWindow(CTCaptureKey *aTest, TInt aConnIndex) : CTWin(), iConnIndex(aConnIndex), iTest(aTest)
   1.317 +	{
   1.318 +	iBack=TRgb::Gray256(230);
   1.319 +	}
   1.320 +
   1.321 +void CCKWindow::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc)
   1.322 +	{
   1.323 +	ConstructExtLD(*parent,pos,size);
   1.324 +	iWin.SetBackgroundColor(iBack);
   1.325 +	Activate();
   1.326 +	AssignGC(aGc);
   1.327 +	}
   1.328 +
   1.329 +void CCKWindow::Draw()
   1.330 +	{
   1.331 +	iGc->Clear();
   1.332 +	if (iConnIndex==0)
   1.333 +		{
   1.334 +		TInt test=iTest->SubState();
   1.335 +		if (test<numTests)
   1.336 +			iGc->DrawText(TPtrC(capKeyTests[test].txt), TPoint(10,20));
   1.337 +		}
   1.338 +	}
   1.339 +
   1.340 +//
   1.341 +
   1.342 +CTCaptureKey::CTCaptureKey(CTestStep* aStep) : CTWsGraphicsBase(aStep)
   1.343 +	{
   1.344 +	}
   1.345 +	
   1.346 +CTCaptureKey::~CTCaptureKey()
   1.347 +	{
   1.348 +	((CTCaptureKeyStep*)iStep)->CloseTMSGraphicsStep();
   1.349 +	delete iConn1;
   1.350 +	delete iConn2;
   1.351 +	delete iConn3;
   1.352 +	delete iAbortConn;
   1.353 +	}
   1.354 +
   1.355 +void CTCaptureKey::ConstructL()
   1.356 +	{
   1.357 +	iAbortConn=new(ELeave) CCKAbortConnection(this);
   1.358 +	iAbortConn->ConstructL();
   1.359 +	iConn3=new(ELeave) CCKConnection(this,2);
   1.360 +	iConn3->ConstructL();
   1.361 +	iConn2=new(ELeave) CCKConnection(this,1);
   1.362 +	iConn2->ConstructL();
   1.363 +	iConn1=new(ELeave) CCKConnection(this,0);
   1.364 +	iConn1->ConstructL();
   1.365 +	iMode=EModeNormalCapture;
   1.366 +	SetSelfDrive(ETrue);
   1.367 +	TUint mods=TheClient->iWs.GetModifierState();
   1.368 +	_LIT(KLog,"Initial Modifiers state 0x%x (ideally should be zero)");
   1.369 +	LOG_MESSAGE2(KLog,mods);
   1.370 +	}
   1.371 +
   1.372 +TInt CTCaptureKey::SubState() const
   1.373 +	{
   1.374 +	return(iSubState);
   1.375 +	}
   1.376 +
   1.377 +void CTCaptureKey::IncSubState()
   1.378 +	{
   1.379 +	iSubState++;
   1.380 +#if defined(LOGGING)
   1.381 +	_LIT(KLog,"IncSubState  State=%d  SubState=%d  Mode=%d");
   1.382 +	LOG_MESSAGE4(KLog,iState,iSubState,iMode);
   1.383 +#endif
   1.384 +	iConn1->SubStateChanged();
   1.385 +	iConn2->SubStateChanged();
   1.386 +	iConn3->SubStateChanged();
   1.387 +	switch(iMode)
   1.388 +		{
   1.389 +		case EModeNormalCapture:
   1.390 +			if (iSubState==numCapKeyTests)
   1.391 +				{
   1.392 +				CaseComplete();
   1.393 +				return;
   1.394 +				}
   1.395 +			break;
   1.396 +		case EModeNormalCaptureWithPriority:
   1.397 +			if (iSubState==numCapKeyTests+numCapKeyWithPriorityTests)
   1.398 +				{
   1.399 +				CaseComplete();
   1.400 +				return;
   1.401 +				}
   1.402 +			break;
   1.403 +		case EModeKeyUpsAndDowns:
   1.404 +			if (iSubState==(numCapKeyTests+numCapKeyWithPriorityTests+numUpDownKeyTests))
   1.405 +				{
   1.406 +				CaseComplete();
   1.407 +				return;
   1.408 +				}
   1.409 +			break;
   1.410 +		case EModeKeyUpsAndDownsWithPriority:
   1.411 +			if (iSubState==(numCapKeyTests+numCapKeyWithPriorityTests+numUpDownKeyTests+numUpDownKeyWithPriorityTests))
   1.412 +				{
   1.413 +				SetSelfDrive(EFalse);
   1.414 +				return;
   1.415 +				}
   1.416 +			break;
   1.417 +		case EModeAbortKeys:
   1.418 +			if (iSubState==(numCapKeyTests+numCapKeyWithPriorityTests+numUpDownKeyTests+numUpDownKeyWithPriorityTests+numAbortKeyTests))
   1.419 +				++iState;
   1.420 +			TheClient->WaitForRedrawsToFinish();
   1.421 +			return;
   1.422 +		default:
   1.423 +			break;
   1.424 +		}
   1.425 +	TheClient->WaitForRedrawsToFinish();
   1.426 +	SendEvents();
   1.427 +	}
   1.428 +
   1.429 +void CTCaptureKey::CapKeyPurgingL()
   1.430 +	{
   1.431 +	TInt base=Client()->iWs.ResourceCount();
   1.432 +	RWindowGroup groupWin(Client()->iWs);
   1.433 +	User::LeaveIfError(groupWin.Construct(ENullWsHandle));
   1.434 +	TInt capHandle=User::LeaveIfError(groupWin.CaptureKey('a',EModifierFunc,EModifierFunc));
   1.435 +	User::LeaveIfError(groupWin.CaptureKey('b',EModifierFunc,EModifierFunc));
   1.436 +	TInt retVal = Client()->iWs.ResourceCount();
   1.437 +	TEST(retVal==(base+3));
   1.438 +	if (retVal!=(base+3))
   1.439 +		INFO_PRINTF3(_L("Client()->iWs.ResourceCount() return value - Expected: %d, Actual: %d"), retVal, (base+3));		
   1.440 +
   1.441 +	groupWin.CancelCaptureKey(capHandle);
   1.442 +	retVal = Client()->iWs.ResourceCount();
   1.443 +	TEST(retVal==(base+2));
   1.444 +	if (retVal!=(base+2))
   1.445 +		INFO_PRINTF3(_L("Client()->iWs.ResourceCount() return value - Expected: %d, Actual: %d"), retVal, (base+2));		
   1.446 +
   1.447 +	groupWin.Close();
   1.448 +	// Check it also freed the extra capture key
   1.449 +	retVal = Client()->iWs.ResourceCount();
   1.450 +	TEST(retVal==base);
   1.451 +	if (retVal!=base)
   1.452 +		INFO_PRINTF3(_L("Client()->iWs.ResourceCount() return value - Expected: %d, Actual: %d"), retVal, base);		
   1.453 +
   1.454 +	}
   1.455 +
   1.456 +void CTCaptureKey::BadParams()
   1.457 +	{
   1.458 +	TInt retVal;
   1.459 +	TInt resCount=Client()->iWs.ResourceCount();
   1.460 +	for(TInt index=0;index<numErrorKeys;index++)
   1.461 +		{
   1.462 +		retVal = Client()->iGroup->GroupWin()->CaptureKey(errorKeys[index].keyCode,errorKeys[index].modifier_mask,errorKeys[index].modifiers, errorKeys[index].priority);
   1.463 +		TEST(retVal==KErrArgument);
   1.464 +		if (retVal!=KErrArgument)
   1.465 +			{
   1.466 +			_LIT(KMsg, "CaptureKey() with bad parameter set %d returned %d - expected KErrArgument (%d)");
   1.467 +			LOG_MESSAGE4(KMsg, index, retVal, KErrArgument);	
   1.468 +			}
   1.469 +
   1.470 +		retVal = Client()->iGroup->GroupWin()->CaptureKeyUpAndDowns(errorKeys[index].keyCode, errorKeys[index].modifier_mask, errorKeys[index].modifiers, errorKeys[index].priority);
   1.471 +		TEST(retVal == KErrArgument);
   1.472 +		if (retVal != KErrArgument)
   1.473 +			{
   1.474 +			_LIT(KMsg, "CaptureKeyUpAndDowns() with bad parameter set %d returned %d - expected KErrArgument (%d)");
   1.475 +			LOG_MESSAGE4(KMsg, index, retVal, KErrArgument);	
   1.476 +			}
   1.477 +
   1.478 +		retVal = Client()->iGroup->GroupWin()->CaptureLongKey(errorKeys[index].keyCode, errorKeys[index].keyCode, errorKeys[index].modifier_mask, errorKeys[index].modifiers, errorKeys[index].priority, ELongCaptureNormal);
   1.479 +		TEST(retVal == KErrArgument);
   1.480 +		if (retVal != KErrArgument)
   1.481 +			{
   1.482 +			_LIT(KMsg, "CaptureLongKey() with bad parameter set %d returned %d - expected KErrArgument (%d)");
   1.483 +			LOG_MESSAGE4(KMsg, index, retVal, KErrArgument);	
   1.484 +			}
   1.485 +		}
   1.486 +
   1.487 +	retVal = Client()->iWs.ResourceCount();
   1.488 +	TEST(retVal==resCount);
   1.489 +	if (retVal!=resCount)
   1.490 +		{
   1.491 +		_LIT(KMsg, "Resource count %d - expected %d");
   1.492 +		LOG_MESSAGE3(KMsg, retVal, resCount);	
   1.493 +		}
   1.494 +	}
   1.495 +
   1.496 +void CTCaptureKey::SetMode(TTestMode aMode)
   1.497 +	{
   1.498 +#if defined(LOGGING)
   1.499 +	_LIT(KLog,"SetMode  State=%d  SubState=%d  OldMode=%d  NewMode=%d");
   1.500 +	LOG_MESSAGE5(KLog,State(),SubState(),iMode,aMode);
   1.501 +#endif
   1.502 +	iMode=aMode;
   1.503 +	}
   1.504 +
   1.505 +TTestMode CTCaptureKey::Mode()
   1.506 +	{
   1.507 +	return(iMode);
   1.508 +	}
   1.509 +
   1.510 +void CTCaptureKey::SetUpPriorityKeyTest()
   1.511 +	{
   1.512 +	iMode=EModeAbortKeys;
   1.513 +	iAbortConn->Foreground();
   1.514 +	}
   1.515 +
   1.516 +void CTCaptureKey::CaptureWithPriorityTest() //normal key capture but with priority
   1.517 +	{
   1.518 +	iMode=EModeWaitingForFirstNormalCapWithPriority;
   1.519 +	}
   1.520 +
   1.521 +void CTCaptureKey::CaptureUpsAndDownsTest()
   1.522 +	{
   1.523 +	iMode=EModeWaitingForFirstDown;
   1.524 +	}
   1.525 +
   1.526 +void CTCaptureKey::CaptureUpsAndDownsWithPriorityTest()
   1.527 +	{
   1.528 +	iMode=EModeWaitingForFirstDownWithPriority;
   1.529 +	}
   1.530 +
   1.531 +void CTCaptureKey::SendEvents()
   1.532 +	{
   1.533 +#if defined(LOGGING)
   1.534 +	_LIT(KLog,"SendEvents  State=%d  SubState=%d");
   1.535 +	LOG_MESSAGE3(KLog,iState,iSubState);
   1.536 +#endif
   1.537 +	switch (iSubState)
   1.538 +		{
   1.539 +	case 0:
   1.540 +		iTest->SimulateKeyDownUp('Q');
   1.541 +		break;
   1.542 +	case 1:
   1.543 +		iTest->SimulateKeyDownUpWithModifiers('W',EModifierAlt);
   1.544 +		break;
   1.545 +	case 2:
   1.546 +		iTest->SimulateKeyDownUp('A');
   1.547 +		break;
   1.548 +	case 3:
   1.549 +		iTest->SimulateKeyDownUpWithModifiers('S',EModifierAlt|EModifierCtrl);
   1.550 +		break;
   1.551 +	case 4:
   1.552 +		iTest->SimulateKeyDownUpWithModifiers('N',EModifierAlt);
   1.553 +		break;
   1.554 +	case 5:
   1.555 +		iTest->SimulateKeyDownUpWithModifiers('B',EModifierAlt|EModifierCtrl);
   1.556 +		break;
   1.557 +	case 6:
   1.558 +		iTest->SimulateKeyDownUpWithModifiers('D',EModifierAlt);
   1.559 +		break;
   1.560 +	case 7:
   1.561 +		iTest->SimulateKeyDownUpWithModifiers('C',EModifierAlt|EModifierCtrl);
   1.562 +		break;
   1.563 +	case 8:
   1.564 +		iTest->SimulateKeyDownUp('H');//state EModeNormalCaptureWithPriority
   1.565 +		break;
   1.566 +	case 9:
   1.567 +		iTest->SimulateKeyDownUp('J');
   1.568 +		break;
   1.569 +	case 10:
   1.570 +		iTest->SimulateKeyDownUp('K');
   1.571 +		break;
   1.572 +	case 11:
   1.573 +		iTest->SimulateKeyDownUp(EStdKeySpace);
   1.574 +		break;
   1.575 +	case 12:
   1.576 +		iTest->SimulateKeyDownUp(EStdKeyEnter);
   1.577 +		break;
   1.578 +	case 13:
   1.579 +		iTest->SimulateKeyDownUpWithModifiers(EStdKeySpace,EModifierShift);
   1.580 +		break;
   1.581 +	case 14:
   1.582 +		iTest->SimulateKeyDownUpWithModifiers(EStdKeyEnter,EModifierShift);
   1.583 +		break;
   1.584 +	case 15:
   1.585 +		iTest->SimulateKeyDownUp('H');//state EModeKeyUpsAndDownsWithPriority
   1.586 +		break;
   1.587 +	case 16:
   1.588 +		iTest->SimulateKeyDownUp('J');
   1.589 +		break;
   1.590 +	case 17:
   1.591 +		iTest->SimulateKeyDownUp('K');
   1.592 +		break;
   1.593 +	case 18:
   1.594 +		iTest->SimulateKeyDownUpWithModifiers('C',EModifierCtrl);
   1.595 +		break;
   1.596 +	case 19:
   1.597 +		iTest->SimulateKeyDownUpWithModifiers('D',EModifierCtrl);
   1.598 +		break;
   1.599 +	case 20:
   1.600 +		iTest->SimulateKeyDownUp('Z');
   1.601 +		break;
   1.602 +	default:
   1.603 +		TEST(EFalse);
   1.604 +		}
   1.605 +	TheClient->iWs.Flush();
   1.606 +	}
   1.607 +
   1.608 +void CTCaptureKey::CapKeyPowerOffL()
   1.609 +	{
   1.610 +	const TUint protKey=0xF844;		//This value needs to be defined in the WSINI.INI file as a key only capturable by a certain application
   1.611 +	RWsSession ws;
   1.612 +	User::LeaveIfError(ws.Connect());
   1.613 +	CleanupClosePushL(ws);
   1.614 +	
   1.615 +	// assign to the correct screen
   1.616 +	CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
   1.617 +	CleanupStack::PushL(screen);
   1.618 +	User::LeaveIfError(screen->Construct(iTest->iScreenNumber));
   1.619 +	
   1.620 +	RWindowGroup group(ws);
   1.621 +	group.Construct(ENullWsHandle);
   1.622 +	CleanupClosePushL(group);
   1.623 +	group.EnableReceiptOfFocus(EFalse);
   1.624 +	group.SetOrdinalPosition(0,5);
   1.625 +	RBlankWindow blank(ws);
   1.626 +	blank.Construct(group,ENullWsHandle);
   1.627 +	CleanupClosePushL(blank);
   1.628 +	blank.EnableBackup();
   1.629 +	blank.Activate();
   1.630 +	_LIT(kGroupName1,"Hello");
   1.631 +	group.SetName(kGroupName1);
   1.632 +	TInt capHandle = group.CaptureKey(EKeyDevice2,EModifierFunc,EModifierFunc);
   1.633 +	TEST(capHandle==KErrPermissionDenied);
   1.634 +	if (capHandle!=KErrPermissionDenied)
   1.635 +		{
   1.636 +		_LIT(KLog1,"Capture Key suceeded when it should of failed, Error/Handle=%d (expected: %d)");
   1.637 +		LOG_MESSAGE3(KLog1,capHandle,KErrPermissionDenied);
   1.638 +		_LIT(KLog2,"This is indicative of a bad WSINI file");
   1.639 +		LOG_MESSAGE(KLog2);
   1.640 +		}
   1.641 +
   1.642 +	capHandle=group.CaptureKeyUpAndDowns(protKey,0,0);
   1.643 +	TEST(capHandle==KErrPermissionDenied);
   1.644 +	if (capHandle!=KErrPermissionDenied)
   1.645 +		{
   1.646 +		_LIT(KLog,"Capture Key Up & Down suceeded when it should of failed, Error/Handle=%d (expected: %d)");
   1.647 +		LOG_MESSAGE3(KLog,capHandle,KErrPermissionDenied);
   1.648 +		}
   1.649 +	
   1.650 +	_LIT(kGroupName2,"SysApp");
   1.651 +	group.SetName(kGroupName2);
   1.652 +	capHandle = group.CaptureKey(EKeyDevice2,EModifierFunc,EModifierFunc);
   1.653 +	TEST(capHandle > 0);
   1.654 +	if (capHandle<=0)
   1.655 +		{
   1.656 +		_LIT(KLog,"Capture Key failed when it should of succeeded, Error=%d");
   1.657 +		LOG_MESSAGE2(KLog,capHandle);
   1.658 +		}
   1.659 +
   1.660 +	group.CancelCaptureKey(capHandle);
   1.661 +	capHandle=group.CaptureKeyUpAndDowns(protKey,0,0);
   1.662 +	TEST(capHandle > 0);
   1.663 +	if (capHandle<=0)
   1.664 +		{
   1.665 +		_LIT(KLog,"Capture Key Up & Down failed when it should of succeeded, Error=%d");
   1.666 +		LOG_MESSAGE2(KLog,capHandle);
   1.667 +		}
   1.668 +
   1.669 +	group.CancelCaptureKeyUpAndDowns(capHandle);
   1.670 +	CleanupStack::PopAndDestroy(4,&ws);
   1.671 +	}
   1.672 +
   1.673 +
   1.674 +void CTCaptureKey::RunTestCaseL(TInt /*aCurTestCase*/)
   1.675 +	{
   1.676 +	_LIT(Test0,"Normal capture with priority");
   1.677 +	_LIT(TestNormalCaptureWithPriority,"Normal capture with priority");
   1.678 +	_LIT(TestUpDown,"Capture ups and downs");
   1.679 +	_LIT(TestUpDownWithPriority,"Capture ups and downs with priority");
   1.680 +	_LIT(TestAbort,"Abort key");
   1.681 +	_LIT(TestAbort2,"Abort key extended");
   1.682 +	_LIT(TestErrors,"Errors");
   1.683 +	_LIT(TestCaptureKey,"Capture Key");
   1.684 +	_LIT(TestCapturePowerOffKey,"Capture PowerOff Key");
   1.685 +
   1.686 +	iTest->iState=iState;
   1.687 +	((CTCaptureKeyStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
   1.688 +	switch(iState)
   1.689 +		{
   1.690 +/**
   1.691 +@SYMTestCaseID		GRAPHICS-WSERV-0140
   1.692 +
   1.693 +
   1.694 +@SYMDEF             DEF081259
   1.695 +
   1.696 +@SYMTestCaseDesc    Normal key capture test
   1.697 +
   1.698 +@SYMTestPriority    High
   1.699 +
   1.700 +@SYMTestStatus      Implemented
   1.701 +
   1.702 +@SYMTestActions     The test uses 3 wserv clients with their own window groups. The 
   1.703 +					clients are registered for different keys to capture. The test 
   1.704 +					simulates key presses.
   1.705 +
   1.706 +@SYMTestExpectedResults Checks that the key presses are captured correctly .
   1.707 +*/
   1.708 +		case 0:	// Dummy one to let capture key tests run
   1.709 +			((CTCaptureKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0140"));
   1.710 +			iTest->LogSubTest(Test0);
   1.711 +			iState++;
   1.712 +			SendEvents();
   1.713 +			break;
   1.714 +/**
   1.715 +@SYMTestCaseID		GRAPHICS-WSERV-0141
   1.716 +
   1.717 +@SYMDEF             DEF081259
   1.718 +
   1.719 +@SYMTestCaseDesc    Normal key capture test with priorities
   1.720 +
   1.721 +@SYMTestPriority    High
   1.722 +
   1.723 +@SYMTestStatus      Implemented
   1.724 +
   1.725 +@SYMTestActions     The test uses 3 wserv clients with their own window groups. The 
   1.726 +					clients are registered for different keys to capture and with
   1.727 +					different priorities. The test simulates key presses.
   1.728 +
   1.729 +@SYMTestExpectedResults Checks that the key presses are captured correctly .
   1.730 +*/
   1.731 +		case 1:
   1.732 +			((CTCaptureKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0141"));
   1.733 +			iTest->LogSubTest(TestNormalCaptureWithPriority);
   1.734 +			CaptureWithPriorityTest();
   1.735 +			iState++;
   1.736 +			SendEvents();
   1.737 +			break;
   1.738 +/**
   1.739 +@SYMTestCaseID		GRAPHICS-WSERV-0142
   1.740 +
   1.741 +@SYMDEF             DEF081259
   1.742 +
   1.743 +@SYMTestCaseDesc    Up-down key capture test
   1.744 +
   1.745 +@SYMTestPriority    High
   1.746 +
   1.747 +@SYMTestStatus      Implemented
   1.748 +
   1.749 +@SYMTestActions     The test uses 3 wserv clients with their own window groups. The 
   1.750 +					clients are registered for different keys to capture their
   1.751 +					up and down events. The test simulates key presses and releases.
   1.752 +
   1.753 +@SYMTestExpectedResults Checks that the key presses and releases are captured correctly .
   1.754 +*/
   1.755 +		case 2:
   1.756 +			((CTCaptureKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0142"));
   1.757 +			iTest->LogSubTest(TestUpDown);
   1.758 +			CaptureUpsAndDownsTest();
   1.759 +			iState++;
   1.760 +			SendEvents();
   1.761 +			break;
   1.762 +/**
   1.763 +@SYMTestCaseID		GRAPHICS-WSERV-0143
   1.764 +
   1.765 +@SYMDEF             DEF081259
   1.766 +
   1.767 +@SYMTestCaseDesc    Up-down key capture test with priorities
   1.768 +
   1.769 +@SYMTestPriority    High
   1.770 +
   1.771 +@SYMTestStatus      Implemented
   1.772 +
   1.773 +@SYMTestActions     The test uses 3 wserv clients with their own window groups. The 
   1.774 +					clients are registered with different priorities for different keys to capture their
   1.775 +					up and down events. The test simulates key presses and releases.
   1.776 +
   1.777 +@SYMTestExpectedResults Checks that the key presses and releases are captured correctly .
   1.778 +*/
   1.779 +		case 3:
   1.780 +			((CTCaptureKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0143"));
   1.781 +			iTest->LogSubTest(TestUpDownWithPriority);
   1.782 +			CaptureUpsAndDownsWithPriorityTest();
   1.783 +			iState++;
   1.784 +			SendEvents();
   1.785 +			break;
   1.786 +/**
   1.787 +@SYMTestCaseID		GRAPHICS-WSERV-0144
   1.788 +
   1.789 +@SYMDEF             DEF081259
   1.790 +
   1.791 +@SYMTestCaseDesc    Priority key events test
   1.792 +
   1.793 +@SYMTestPriority    High
   1.794 +
   1.795 +@SYMTestStatus      Implemented
   1.796 +
   1.797 +@SYMTestActions     The test simulates key events and make sure that the events are 
   1.798 +					recieved by the registered wserv client.
   1.799 +
   1.800 +@SYMTestExpectedResults Makes sure that key code is the same as a key simulated, event modifiers comply
   1.801 +					with registered priority key's modifirs and mask, and that event handle 
   1.802 +					is a window group of the session.
   1.803 +					
   1.804 +*/
   1.805 +		case 4:
   1.806 +			((CTCaptureKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0144"));
   1.807 +			if (iSubState==numCapKeyTests+numUpDownKeyWithPriorityTests+numUpDownKeyTests+numUpDownKeyWithPriorityTests)
   1.808 +				{
   1.809 +				iTest->LogSubTest(TestAbort);
   1.810 +				SetUpPriorityKeyTest();
   1.811 +				}
   1.812 +			else
   1.813 +				iTest->LogSubTest(TestAbort2);
   1.814 +			//iState++;
   1.815 +			SendEvents();
   1.816 +			TheClient->WaitUntilEventPending();
   1.817 +			break;
   1.818 +/**
   1.819 +@SYMTestCaseID		GRAPHICS-WSERV-0145
   1.820 +
   1.821 +@SYMDEF             DEF081259
   1.822 +
   1.823 +@SYMTestCaseDesc    Invalid capture keys test
   1.824 +
   1.825 +@SYMTestPriority    High
   1.826 +
   1.827 +@SYMTestStatus      Implemented
   1.828 +
   1.829 +@SYMTestActions     Memorizes amount of objects that the server has allocated for that client.
   1.830 +					Tries to register capture keys with invalid modifiers and
   1.831 +					modifier mask pairs, using each of the RWindowGroup capture
   1.832 +					functions CaptureKey(), CaptureKeyUpAndDowns() and
   1.833 +					CaptureLongKey().
   1.834 +
   1.835 +@SYMTestExpectedResults Makes sure that the number of server-side objects for the 
   1.836 +					session didn't change.
   1.837 +*/
   1.838 +		case 5:
   1.839 +			((CTCaptureKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0145"));
   1.840 +			iTest->LogSubTest(TestErrors);
   1.841 +			BadParams();
   1.842 +			((CTCaptureKeyStep*)iStep)->RecordTestResultL();
   1.843 +/**
   1.844 +@SYMTestCaseID		GRAPHICS-WSERV-0146
   1.845 +
   1.846 +@SYMDEF             DEF081259
   1.847 +
   1.848 +@SYMTestCaseDesc    Capture keys clean up test
   1.849 +
   1.850 +@SYMTestPriority    High
   1.851 +
   1.852 +@SYMTestStatus      Implemented
   1.853 +
   1.854 +@SYMTestActions     Memorizes amount of objects that the server has allocated for that client.
   1.855 +					Creates a window group and requests two keys to be captured.
   1.856 +					Cancels one key capture request and closes the window group.
   1.857 +
   1.858 +@SYMTestExpectedResults Checks that creation of the group or registering a capture key
   1.859 +					increased this amount by 1 each time.
   1.860 +					Makes sure that the number of server-side objects for the 
   1.861 +					session in the end of the test is the same as in the beginning.
   1.862 +*/
   1.863 +			((CTCaptureKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0146"));
   1.864 +			iTest->LogSubTest(TestCaptureKey);
   1.865 +			CapKeyPurgingL();
   1.866 +			iState++;
   1.867 +			break;
   1.868 +/**
   1.869 +@SYMTestCaseID		GRAPHICS-WSERV-0147
   1.870 +
   1.871 +@SYMDEF             DEF081259
   1.872 +
   1.873 +@SYMTestCaseDesc    Capture power off key test
   1.874 +
   1.875 +@SYMTestPriority    High
   1.876 +
   1.877 +@SYMTestStatus      Implemented
   1.878 +
   1.879 +@SYMTestActions     The test creates a new session, new window group and a new window
   1.880 +					in the group. After that the test gives "Hello" name to the group
   1.881 +					and tries to register for key capture of FN+EKeyDevice2 and 0xF844
   1.882 +					buttons. Makes sure that registration fails due to KErrPermissionDenied
   1.883 +					error.
   1.884 +					Then the test changes the name of the window group to "SysApp"
   1.885 +					and tries the registration again. Makes sure that operation 
   1.886 +					completed successfully.
   1.887 +
   1.888 +@SYMTestExpectedResults See actions
   1.889 +*/
   1.890 +		case 6:
   1.891 +			((CTCaptureKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0147"));
   1.892 +			iTest->LogSubTest(TestCapturePowerOffKey);
   1.893 +			CapKeyPowerOffL();
   1.894 +			iState++;
   1.895 +			break;
   1.896 +		default:
   1.897 +			((CTCaptureKeyStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
   1.898 +			TestComplete();
   1.899 +		}
   1.900 +	((CTCaptureKeyStep*)iStep)->RecordTestResultL();
   1.901 +
   1.902 +	}
   1.903 +
   1.904 +
   1.905 +__WS_CONSTRUCT_STEP__(CaptureKey)