os/graphics/windowing/windowserver/test/tauto/TPNTCAP.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/TPNTCAP.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1014 @@
     1.4 +// Copyright (c) 1996-2009 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 pointer capture
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +/**
    1.22 + @file
    1.23 + @test
    1.24 + @internalComponent - Internal Symbian test code
    1.25 +*/
    1.26 +
    1.27 +#include "TPNTCAP.H"
    1.28 +
    1.29 +#define LOGGING on
    1.30 +
    1.31 +_LIT(ClickOnMe,"Click on me");
    1.32 +
    1.33 +//
    1.34 +// CMcConnection
    1.35 +
    1.36 +CPcConnection::CPcConnection(CTPointerCapture *aTest) : iTest(aTest)
    1.37 +	{
    1.38 +	}
    1.39 +
    1.40 +CPcConnection::~CPcConnection()
    1.41 +	{
    1.42 +	}
    1.43 +
    1.44 +void CPcConnection::ConstructL()
    1.45 +	{
    1.46 +	CTClient::SetScreenNumber(iTest->TestBase()->ScreenNumber());
    1.47 +	CTClient::ConstructL();
    1.48 +	iGroup=new(ELeave) CTWindowGroup(this);
    1.49 +	iGroup->ConstructL();
    1.50 +	iGroup->GroupWin()->SetOrdinalPosition(0,1);
    1.51 +	iGroup->GroupWin()->EnableReceiptOfFocus(EFalse);
    1.52 +	iWs.Flush();
    1.53 +	}
    1.54 +
    1.55 +//
    1.56 +// CPcWindow, base class //
    1.57 +//
    1.58 +
    1.59 +CPcWindowBase::CPcWindowBase(CTPointerCapture *aTest) : CTWin(), iTest(aTest)
    1.60 +	{
    1.61 +	}
    1.62 +
    1.63 +void CPcWindowBase::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc)
    1.64 +	{
    1.65 +	ConstructExtLD(*parent,pos,size);
    1.66 +	iWin.SetBackgroundColor(iBack);
    1.67 +	Activate();
    1.68 +	AssignGC(aGc);
    1.69 +	}
    1.70 +
    1.71 +void CPcWindowBase::SetUpL(TPoint pos,TSize size,CTWinBase *parent)
    1.72 +	{
    1.73 +	SetUpL(pos,size,parent,*iTest->Client()->iGc);
    1.74 +	}
    1.75 +
    1.76 +void CPcWindowBase::SubStateChanged()
    1.77 +	{
    1.78 +	iWin.Invalidate();
    1.79 +	Client()->iWs.Flush();
    1.80 +	}
    1.81 +
    1.82 +void CPcWindowBase::Draw(TDesC &aBuf)
    1.83 +	{
    1.84 +	iGc->Clear();
    1.85 +	iGc->SetPenColor(iBack.Gray4()>1 ? TRgb(0,0,0) : TRgb(255,255,255));
    1.86 +	iGc->DrawText(aBuf, TPoint(10,20));
    1.87 +	}
    1.88 +
    1.89 +void CPcWindowBase::PointerL(const TPointerEvent &pointer,const TTime &)
    1.90 +	{
    1.91 +#if defined(LOGGING)
    1.92 +	_LIT(KLog1,"Pointer Event Recieved  Type=%S  State=%d  SubState=%d");
    1.93 +	_LIT(KDown,"Down");
    1.94 +	_LIT(KUp,"Up");
    1.95 +	iTest->LOG_MESSAGE4(KLog1,&(pointer.iType?KUp():KDown()),iTest->State(),iTest->SubState());
    1.96 +#endif
    1.97 +	if (pointer.iType==TPointerEvent::EButton1Down && !iTest->iFailed)
    1.98 +		{
    1.99 +		if (iTest->SubState()==ERootWindow)	// Root window click, must not be inside this window
   1.100 +			{
   1.101 +			if (TRect(Size()).Contains(pointer.iPosition))
   1.102 +				{
   1.103 +				iTest->TestFailed();
   1.104 +				return;
   1.105 +				}
   1.106 +			}
   1.107 +		TInt ret;
   1.108 +		if ((ret=PointerDown())==EFailed)
   1.109 +			iTest->TestFailed();
   1.110 +		else
   1.111 +			iTest->IncSubStateL(ret==ENeedsDDEvent);
   1.112 +		}
   1.113 +#if defined(LOGGING)
   1.114 +	_LIT(KLog2,"End of processing Pointer Event");
   1.115 +	iTest->LOG_MESSAGE(KLog2);
   1.116 +#endif
   1.117 +	}
   1.118 +
   1.119 +void CPcWindowBase::DragDropL(const TPointerEvent &pointer,const TTime &)
   1.120 +	{
   1.121 +#if defined(LOGGING)
   1.122 +	_LIT(KLog,"CPcWindowBase::DragDropL  Type=%d  State=%d  SubState=%d");
   1.123 +	iTest->LOG_MESSAGE4(KLog,pointer.iType,iTest->State(),iTest->SubState());
   1.124 +#endif
   1.125 +	switch(iTest->State())
   1.126 +		{
   1.127 +		case ENormalCaptureWithoutFocus:
   1.128 +			if (iTest->SubState()==0)
   1.129 +				break;
   1.130 +		case ECaptureDisabled:
   1.131 +		case ENormalCapture:
   1.132 +		case ECaptureAllGroups:
   1.133 +			iTest->TestFailed();
   1.134 +			break;
   1.135 +		}
   1.136 +	if (pointer.iType==TPointerEvent::EButton1Down && !iTest->iFailed)
   1.137 +		{
   1.138 +		if (DragDrop()==EFailed)
   1.139 +			iTest->TestFailed();
   1.140 +		else
   1.141 +			iTest->GotDDL();
   1.142 +		}
   1.143 +	}
   1.144 +//
   1.145 +
   1.146 +CPcWindowMain::CPcWindowMain(CTPointerCapture *aTest) : CPcWindowBase(aTest)
   1.147 +	{
   1.148 +	iBack=TRgb::Gray256(236);
   1.149 +	}
   1.150 +
   1.151 +TPointerCheckRet CPcWindowMain::PointerDown()
   1.152 +	{
   1.153 +#if defined(LOGGING)
   1.154 +	_LIT(KLog1,"CPcWindowMain::PointerDown  State=%d  SubState=%d");
   1.155 +	iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState());
   1.156 +#endif
   1.157 +	switch(iTest->State())
   1.158 +		{
   1.159 +		case ECaptureDisabled:
   1.160 +			if (iTest->SubState()==EMainWindow)
   1.161 +				return(EOkay);
   1.162 +			break;
   1.163 +		case ENormalCapture:
   1.164 +			switch(iTest->SubState())
   1.165 +				{
   1.166 +				case EMainWindow:
   1.167 +				case ERootWindow:
   1.168 +					return(EOkay);
   1.169 +				default:
   1.170 +					break;
   1.171 +				}
   1.172 +			break;
   1.173 +		case ECaptureAllGroups:
   1.174 +			switch(iTest->SubState())
   1.175 +				{
   1.176 +				case EMainWindow:
   1.177 +				case EOtherGroup:
   1.178 +				case EOtherSession:
   1.179 +				case ERootWindow:
   1.180 +					return(EOkay);
   1.181 +				default:
   1.182 +					break;
   1.183 +				}
   1.184 +			break;
   1.185 +		case EDragDropCapture:
   1.186 +			switch(iTest->SubState())
   1.187 +				{
   1.188 +				case EMainWindow:
   1.189 +					return(ENeedsDDEvent);
   1.190 +				case ERootWindow:
   1.191 +					return(EOkay);
   1.192 +				default:
   1.193 +					break;
   1.194 +				}
   1.195 +			break;
   1.196 +		case EDragDropCaptureAllGroups:
   1.197 +			switch(iTest->SubState())
   1.198 +				{
   1.199 +				case EMainWindow:
   1.200 +				case EOtherGroup:
   1.201 +				case EOtherSession:
   1.202 +					return(ENeedsDDEvent);
   1.203 +				case ERootWindow:
   1.204 +					return(EOkay);
   1.205 +				default:
   1.206 +					break;
   1.207 +				}
   1.208 +			break;
   1.209 +		case ENormalCaptureWithoutFocus:
   1.210 +			switch(iTest->SubState())
   1.211 +				{
   1.212 +				case EMainWindow:
   1.213 +					return(EOkay);
   1.214 +				default:
   1.215 +					break;
   1.216 +				}
   1.217 +			break;
   1.218 +		default:
   1.219 +			break;
   1.220 +		}
   1.221 +#if defined(LOGGING)
   1.222 +	_LIT(KLog2,"CPcWindowMain::PointerDown  FAILED  State=%d  SubState=%d");
   1.223 +	iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState());
   1.224 +#endif
   1.225 +	return(EFailed);
   1.226 +	}
   1.227 +
   1.228 +TPointerCheckRet CPcWindowMain::DragDrop()
   1.229 +	{
   1.230 +#if defined(LOGGING)
   1.231 +	_LIT(KLog1,"CPcWindowMain::DragDrop  State=%d  SubState=%d");
   1.232 +	iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState());
   1.233 +#endif
   1.234 +	switch(iTest->State())
   1.235 +		{
   1.236 +		case EDragDropCapture:
   1.237 +		case EDragDropCaptureAllGroups:
   1.238 +			switch(iTest->SubState())
   1.239 +				{
   1.240 +				case EMainWindow:
   1.241 +					return(EOkay);
   1.242 +				default:
   1.243 +					break;
   1.244 +				}
   1.245 +			break;
   1.246 +		default:
   1.247 +			break;
   1.248 +		}
   1.249 +#if defined(LOGGING)
   1.250 +	_LIT(KLog2,"CPcWindowMain::DragDrop  FAILED  State=%d  SubState=%d");
   1.251 +	iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState());
   1.252 +#endif
   1.253 +	return(EFailed);
   1.254 +	}
   1.255 +
   1.256 +void CPcWindowMain::Draw()
   1.257 +	{
   1.258 +	TBuf<0x40> buf;
   1.259 +	if (iTest->State()==ECaptureDisabled)
   1.260 +		{
   1.261 +		switch(iTest->SubState())
   1.262 +			{
   1.263 +			case EMainWindow:
   1.264 +				buf.Copy(ClickOnMe);
   1.265 +				break;
   1.266 +			}
   1.267 +		}
   1.268 +	else
   1.269 +		{
   1.270 +		switch(iTest->SubState())
   1.271 +			{
   1.272 +			case EMainWindow:
   1.273 +				buf.Copy(ClickOnMe);
   1.274 +				break;
   1.275 +			case EChildWindow:
   1.276 +			case EOtherGroup:
   1.277 +			case EOtherSession:
   1.278 +				break;
   1.279 +			case ERootWindow:
   1.280 +				{
   1.281 +				_LIT(ClickOnRoot,"Click on the root window");
   1.282 +				if (iTest->State()<ENormalCaptureWithoutFocus)
   1.283 +					buf.Copy(ClickOnRoot);
   1.284 +				else
   1.285 +					{
   1.286 +					_LIT(AndEscape,", then press <Escape>");
   1.287 +					buf.Copy(ClickOnRoot);
   1.288 +					buf.Append(AndEscape);
   1.289 +					}
   1.290 +				}
   1.291 +				break;
   1.292 +			}
   1.293 +		}
   1.294 +	CPcWindowBase::Draw(buf);
   1.295 +	}
   1.296 +
   1.297 +void CPcWindowMain::WinKeyL(const TKeyEvent &aKey,const TTime &)
   1.298 +	{
   1.299 +	switch(aKey.iCode)
   1.300 +		{
   1.301 +		case EKeyEscape:
   1.302 +			iTest->AbortTests();
   1.303 +			break;
   1.304 +		case EKeyEnter:
   1.305 +			if (iTest->SubState()==ERootWindow)
   1.306 +				iTest->IncSubStateL(EFalse);
   1.307 +			break;
   1.308 +		}
   1.309 +	}
   1.310 +
   1.311 +//
   1.312 +
   1.313 +CPcWindowChild::CPcWindowChild(CTPointerCapture *aTest) : CPcWindowBase(aTest)
   1.314 +	{
   1.315 +	iBack=TRgb::Gray256(85);
   1.316 +	}
   1.317 +
   1.318 +TPointerCheckRet CPcWindowChild::PointerDown()
   1.319 +	{
   1.320 +#if defined(LOGGING)
   1.321 +	_LIT(KLog1,"CPcWindowChild::PointerDown  State=%d  SubState=%d");
   1.322 +	iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState());
   1.323 +#endif
   1.324 +	switch(iTest->State())
   1.325 +		{
   1.326 +		case ECaptureDisabled:
   1.327 +			break;
   1.328 +		default:
   1.329 +			switch(iTest->SubState())
   1.330 +				{
   1.331 +				case EChildWindow:
   1.332 +					return(EOkay);
   1.333 +				default:
   1.334 +					break;
   1.335 +				}
   1.336 +			break;
   1.337 +		}
   1.338 +#if defined(LOGGING)
   1.339 +	_LIT(KLog2,"CPcWindowChild::PointerDown  FAILED  State=%d  SubState=%d");
   1.340 +	iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState());
   1.341 +#endif
   1.342 +	return(EFailed);
   1.343 +	}
   1.344 +
   1.345 +TPointerCheckRet CPcWindowChild::DragDrop()
   1.346 +	{
   1.347 +#if defined(LOGGING)
   1.348 +	_LIT(KLog1,"CPcWindowChild::PointerDown  State=%d  SubState=%d");
   1.349 +	iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState());
   1.350 +#endif
   1.351 +	switch(iTest->State())
   1.352 +		{
   1.353 +		case EDragDropCapture:
   1.354 +		case EDragDropCaptureAllGroups:
   1.355 +			switch(iTest->SubState())
   1.356 +				{
   1.357 +				case EChildWindow:
   1.358 +					return(EOkay);
   1.359 +				default:
   1.360 +					break;
   1.361 +				}
   1.362 +			break;
   1.363 +		default:
   1.364 +			break;
   1.365 +		}
   1.366 +#if defined(LOGGING)
   1.367 +	_LIT(KLog2,"CPcWindowChild::PointerDown  FAILED  State=%d  SubState=%d");
   1.368 +	iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState());
   1.369 +#endif
   1.370 +	return(EFailed);
   1.371 +	}
   1.372 +
   1.373 +void CPcWindowChild::Draw()
   1.374 +	{
   1.375 +	TBuf<0x40> buf;
   1.376 +	if (iTest->State()!=ECaptureDisabled)
   1.377 +		{
   1.378 +		switch(iTest->SubState())
   1.379 +			{
   1.380 +			case EChildWindow:
   1.381 +				buf.Copy(ClickOnMe);
   1.382 +				break;
   1.383 +			default:
   1.384 +				break;
   1.385 +			}
   1.386 +		}
   1.387 +	CPcWindowBase::Draw(buf);
   1.388 +	}
   1.389 +
   1.390 +//
   1.391 +
   1.392 +CPcWindowNickFocusGroup::CPcWindowNickFocusGroup(CTPointerCapture *aTest, CTClient *aClient) : CTWindowGroup(aClient), iTest(aTest)
   1.393 +	{
   1.394 +	}
   1.395 +
   1.396 +void CPcWindowNickFocusGroup::KeyL(const TKeyEvent &aKey,const TTime &)
   1.397 +	{
   1.398 +	if (aKey.iCode==EKeyEscape)
   1.399 +		iTest->IncSubStateL(EFalse);
   1.400 +	}
   1.401 +
   1.402 +//
   1.403 +
   1.404 +CPcWindowAltGroup::CPcWindowAltGroup(CTPointerCapture *aTest) : CPcWindowBase(aTest)
   1.405 +	{
   1.406 +	iBack=TRgb::Gray256(236);
   1.407 +	}
   1.408 +
   1.409 +TPointerCheckRet CPcWindowAltGroup::PointerDown()
   1.410 +	{
   1.411 +#if defined(LOGGING)
   1.412 +	_LIT(KLog1,"CPcWindowAltGroup::PointerDown  State=%d  SubState=%d");
   1.413 +	iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState());
   1.414 +#endif
   1.415 +	switch(iTest->State())
   1.416 +		{
   1.417 +		case ECaptureDisabled:
   1.418 +			if (iTest->SubState()==EChildWindow)
   1.419 +				return(EOkay);
   1.420 +			break;
   1.421 +		case ENormalCapture:
   1.422 +		case EDragDropCapture:
   1.423 +		case ENormalCaptureWithoutFocus:
   1.424 +			switch(iTest->SubState())
   1.425 +				{
   1.426 +				case EOtherGroup:
   1.427 +					return(EOkay);
   1.428 +				default:
   1.429 +					break;
   1.430 +				}
   1.431 +			break;
   1.432 +		default:
   1.433 +			break;
   1.434 +		}
   1.435 +#if defined(LOGGING)
   1.436 +	_LIT(KLog2,"CPcWindowAltGroup::PointerDown  FAILED  State=%d  SubState=%d");
   1.437 +	iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState());
   1.438 +#endif
   1.439 +	return(EFailed);
   1.440 +	}
   1.441 +
   1.442 +TPointerCheckRet CPcWindowAltGroup::DragDrop()
   1.443 +	{
   1.444 +#if defined(LOGGING)
   1.445 +	_LIT(KLog1,"CPcWindowAltGroup::DragDrop  State=%d  SubState=%d");
   1.446 +	iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState());
   1.447 +#endif
   1.448 +	switch(iTest->State())
   1.449 +		{
   1.450 +		case EDragDropCapture:
   1.451 +		case EDragDropCaptureAllGroups:
   1.452 +			switch(iTest->SubState())
   1.453 +				{
   1.454 +				case EOtherGroup:
   1.455 +					return(EOkay);
   1.456 +				default:
   1.457 +					break;
   1.458 +				}
   1.459 +			break;
   1.460 +		default:
   1.461 +			break;
   1.462 +		}
   1.463 +#if defined(LOGGING)
   1.464 +	_LIT(KLog2,"CPcWindowAltGroup::DragDrop  FAILED  State=%d  SubState=%d");
   1.465 +	iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState());
   1.466 +#endif
   1.467 +	return(EFailed);
   1.468 +	}
   1.469 +
   1.470 +void CPcWindowAltGroup::Draw()
   1.471 +	{
   1.472 +	TBuf<0x40> buf;
   1.473 +	if (iTest->State()==ECaptureDisabled)
   1.474 +		{
   1.475 +		switch(iTest->SubState())
   1.476 +			{
   1.477 +			case EMainWindow:
   1.478 +				break;
   1.479 +			case EChildWindow:
   1.480 +				buf.Copy(ClickOnMe);
   1.481 +				break;
   1.482 +			}
   1.483 +		}
   1.484 +	else
   1.485 +		{
   1.486 +		switch(iTest->SubState())
   1.487 +			{
   1.488 +			case EOtherGroup:
   1.489 +				buf.Copy(ClickOnMe);
   1.490 +				break;
   1.491 +			default:
   1.492 +				break;
   1.493 +			}
   1.494 +		}
   1.495 +	CPcWindowBase::Draw(buf);
   1.496 +	}
   1.497 +
   1.498 +//
   1.499 +
   1.500 +CPcWindowAltConnection::CPcWindowAltConnection(CTPointerCapture *aTest) : CPcWindowBase(aTest)
   1.501 +	{
   1.502 +	iBack=TRgb::Gray256(236);
   1.503 +	}
   1.504 +
   1.505 +TPointerCheckRet CPcWindowAltConnection::PointerDown()
   1.506 +	{
   1.507 +#if defined(LOGGING)
   1.508 +	_LIT(KLog1,"CPcWindowAltConnection::PointerDown  State=%d  SubState=%d");
   1.509 +	iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState());
   1.510 +#endif
   1.511 +	switch(iTest->State())
   1.512 +		{
   1.513 +		case ECaptureDisabled:
   1.514 +			if (iTest->SubState()==EChildWindow)
   1.515 +				return(EOkay);
   1.516 +			break;
   1.517 +		case ENormalCapture:
   1.518 +		case EDragDropCapture:
   1.519 +		case ENormalCaptureWithoutFocus:
   1.520 +			switch(iTest->SubState())
   1.521 +				{
   1.522 +				case EOtherSession:
   1.523 +					return(EOkay);
   1.524 +				default:
   1.525 +					break;
   1.526 +				}
   1.527 +			break;
   1.528 +		default:
   1.529 +			break;
   1.530 +		}
   1.531 +#if defined(LOGGING)
   1.532 +	_LIT(KLog2,"CPcWindowAltConnection::PointerDown  FAILED  State=%d  SubState=%d");
   1.533 +	iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState());
   1.534 +#endif
   1.535 +	return(EFailed);
   1.536 +	}
   1.537 +
   1.538 +TPointerCheckRet CPcWindowAltConnection::DragDrop()
   1.539 +	{
   1.540 +#if defined(LOGGING)
   1.541 +	_LIT(KLog1,"CPcWindowAltConnection::DragDrop  State=%d  SubState=%d");
   1.542 +	iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState());
   1.543 +#endif
   1.544 +	switch(iTest->State())
   1.545 +		{
   1.546 +		case EDragDropCapture:
   1.547 +		case EDragDropCaptureAllGroups:
   1.548 +			switch(iTest->SubState())
   1.549 +				{
   1.550 +				case EOtherSession:
   1.551 +					return(EOkay);
   1.552 +				default:
   1.553 +					break;
   1.554 +				}
   1.555 +			break;
   1.556 +		default:
   1.557 +			break;
   1.558 +		}
   1.559 +#if defined(LOGGING)
   1.560 +	_LIT(KLog2,"CPcWindowAltConnection::DragDrop  FAILED  State=%d  SubState=%d");
   1.561 +	iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState());
   1.562 +#endif
   1.563 +	return(EFailed);
   1.564 +	}
   1.565 +
   1.566 +void CPcWindowAltConnection::Draw()
   1.567 +	{
   1.568 +	TBuf<0x40> buf;
   1.569 +	if (iTest->State()!=ECaptureDisabled)
   1.570 +		{
   1.571 +		switch(iTest->SubState())
   1.572 +			{
   1.573 +			case EOtherSession:
   1.574 +				buf.Copy(ClickOnMe);
   1.575 +				break;
   1.576 +			default:
   1.577 +				break;
   1.578 +			}
   1.579 +		}
   1.580 +	CPcWindowBase::Draw(buf);
   1.581 +	}
   1.582 +
   1.583 +//
   1.584 +
   1.585 +CTPointerCapture::CTPointerCapture(CTestStep* aStep) : CTWsGraphicsBase(aStep)
   1.586 +	{
   1.587 +	iSubState=0;
   1.588 +	iFailed=EFalse;
   1.589 +	}
   1.590 +
   1.591 +CTPointerCapture::~CTPointerCapture()
   1.592 +	{
   1.593 +	delete iNickFocusBlankWin;
   1.594 +	delete iNickFocusGroup;
   1.595 +	delete iAltConnectionWin;
   1.596 +	delete iAltConnection;
   1.597 +	delete iChildWin;
   1.598 +	delete iMainWin;
   1.599 +	delete iMainGroup;
   1.600 +	delete iAltGroupWin;
   1.601 +	delete iAltGroup;
   1.602 +	}
   1.603 +
   1.604 +void CTPointerCapture::TestFailed()
   1.605 +	{
   1.606 +	if (iFailed)
   1.607 +		{
   1.608 +		_LIT(KLog,"Test Failed  State=%d  SubState=%d");
   1.609 +		LOG_MESSAGE3(KLog,iTest->iState,iSubState);
   1.610 +		}
   1.611 +	__ASSERT_DEBUG(iFailed==EFalse,AutoPanic(ETManPanicPcFailed));
   1.612 +	TInt dRet=1;
   1.613 +#if !defined(DISABLE_FAIL_DIALOG)
   1.614 +	Client()->iGroup->GroupWin()->SetOrdinalPosition(0,10);	// Put error dialog on top of test windows
   1.615 +	TRAPD(err,dRet=doTestFailedL());
   1.616 +	Client()->iGroup->GroupWin()->SetOrdinalPosition(0,0);
   1.617 +#endif
   1.618 +	switch(dRet)
   1.619 +		{
   1.620 +		case 0:
   1.621 +			break;
   1.622 +		case 1:
   1.623 +			iFailed=ETrue;
   1.624 +			NextTest();
   1.625 +			break;
   1.626 +		}
   1.627 +	}
   1.628 +
   1.629 +TInt CTPointerCapture::doTestFailedL()
   1.630 +	{
   1.631 +	CTDialog *dialog=new(ELeave) CTDialog();
   1.632 +	dialog->SetTitle(_L("Pointer capture test failed"));
   1.633 +	dialog->SetNumButtons(2);
   1.634 +	dialog->SetButtonText(0,_L("Retest"));
   1.635 +	dialog->SetButtonText(1,_L("Fail"));
   1.636 +	dialog->ConstructLD(*Client()->iGroup,*Client()->iGc);
   1.637 +	return dialog->Display();
   1.638 +	}
   1.639 +
   1.640 +TInt CTPointerCapture::State() const
   1.641 +	{
   1.642 +	return(iTest->iState);
   1.643 +	}
   1.644 +
   1.645 +TInt CTPointerCapture::SubState() const
   1.646 +	{
   1.647 +	return(iSubState);
   1.648 +	}
   1.649 +
   1.650 +void CTPointerCapture::doIncSubStateL()
   1.651 +	{
   1.652 +	iSubState++;
   1.653 +	TInt max=0;
   1.654 +	switch(iTest->iState)
   1.655 +		{
   1.656 +		case ECaptureDisabled:
   1.657 +			max=ESubStates1;
   1.658 +			break;
   1.659 +		case ENormalCapture:
   1.660 +			max=ESubStates2;
   1.661 +			break;
   1.662 +		case ECaptureAllGroups:
   1.663 +			max=ESubStates3;
   1.664 +			break;
   1.665 +		case EDragDropCapture:
   1.666 +			max=ESubStates4;
   1.667 +			break;
   1.668 +		case EDragDropCaptureAllGroups:
   1.669 +			max=ESubStates5;
   1.670 +			break;
   1.671 +		case ENormalCaptureWithoutFocus:
   1.672 +			max=ESubStates6;
   1.673 +			break;
   1.674 +		}
   1.675 +	//SubState 4 has been broken by something in the framework
   1.676 +	if (iSubState==max || iSubState==4)
   1.677 +		{
   1.678 +	#if defined(LOGGING)
   1.679 +		_LIT(KLog,"IncState  OldState=%d  SubState=%d");
   1.680 +		LOG_MESSAGE3(KLog,iTest->iState,iSubState);
   1.681 +	#endif
   1.682 +		NextTest();
   1.683 +		}
   1.684 +	StateChanged();
   1.685 +	TheClient->WaitForRedrawsToFinish();
   1.686 +	if (iSubState>0)
   1.687 +		SendEventsL();
   1.688 +	}
   1.689 +
   1.690 +void CTPointerCapture::GotDDL()
   1.691 +	{
   1.692 +	if (iDDState==DDStateWaiting)
   1.693 +		doIncSubStateL();
   1.694 +	else
   1.695 +		iDDState=DDStateGot;
   1.696 +	}
   1.697 +
   1.698 +void CTPointerCapture::IncSubStateL(TBool aNeedsDD)
   1.699 +	{
   1.700 +	if (!aNeedsDD)
   1.701 +		{
   1.702 +		if (iDDState!=DDStateNull)
   1.703 +			TestFailed();
   1.704 +		else
   1.705 +			doIncSubStateL();
   1.706 +		}
   1.707 +	else if (iDDState==DDStateGot)
   1.708 +		doIncSubStateL();
   1.709 +	else
   1.710 +		iDDState=DDStateWaiting;
   1.711 +	}
   1.712 +
   1.713 +void CTPointerCapture::StateChanged()
   1.714 +	{
   1.715 +	iDDState=DDStateNull;
   1.716 +	iChildWin->SubStateChanged();
   1.717 +	iMainWin->SubStateChanged();
   1.718 +	iAltGroupWin->SubStateChanged();
   1.719 +	iAltConnectionWin->SubStateChanged();
   1.720 +	}
   1.721 +
   1.722 +void CTPointerCapture::AbortTests()
   1.723 +	{
   1.724 +	iTest->iState=99;
   1.725 +	}
   1.726 +
   1.727 +void CTPointerCapture::NextTest()
   1.728 +	{
   1.729 +	TEST(!iFailed);
   1.730 +	if (iFailed)
   1.731 +		{
   1.732 +		_LIT(KLog,"SubTest %d failed");
   1.733 +		LOG_MESSAGE2(KLog,iTest->iState);
   1.734 +		}
   1.735 +	++iTest->iState;
   1.736 +	iSubState=0;
   1.737 +	iFailed=EFalse;
   1.738 +	CaseComplete();
   1.739 +	_LIT(KLog,"Done NextTest  NewSubTest %d");
   1.740 +	LOG_MESSAGE2(KLog,iTest->iState);
   1.741 +	}
   1.742 +
   1.743 +void CTPointerCapture::ConstructL()
   1.744 +	{
   1.745 +	TheClient->iWs.SetPointerCursorArea(iTest->iNormalPointerCursorArea);
   1.746 +	iScreenSize=TSize(TheClient->iScreen->SizeInPixels());
   1.747 +	TInt winWidth2=iScreenSize.iWidth/2-EWinBorderSize*2;
   1.748 +	TInt winWidth4=iScreenSize.iWidth/4-EWinBorderSize*2;
   1.749 +	TInt winHeight=iScreenSize.iHeight/2-EWinBorderSize*2;
   1.750 +//
   1.751 +	iMainGroup=new(ELeave) CTWindowGroup(Client());
   1.752 +	iMainGroup->ConstructL();
   1.753 +	iMainGroup->GroupWin()->SetOrdinalPosition(0,1);
   1.754 +	iMainWin=new(ELeave) CPcWindowMain(this);
   1.755 +	iMainWin->SetUpL(TPoint(EWinBorderSize,EWinBorderSize) ,TSize(winWidth2,winHeight) ,iMainGroup);
   1.756 +	iMainGroup->SetCurrentWindow(iMainWin);
   1.757 +	iChildWin=new(ELeave) CPcWindowChild(this);
   1.758 +	iChildWin->SetUpL(TPoint(0,winHeight/2) ,TSize(winWidth2,winHeight/2) ,iMainWin);
   1.759 +//
   1.760 +	iAltGroup=new(ELeave) CTWindowGroup(Client());
   1.761 +	iAltGroup->ConstructL();
   1.762 +	iAltGroup->GroupWin()->SetOrdinalPosition(0,1);
   1.763 +	iAltGroup->GroupWin()->EnableReceiptOfFocus(EFalse);
   1.764 +	iAltGroupWin=new(ELeave) CPcWindowAltGroup(this);
   1.765 +	iAltGroupWin->SetUpL(TPoint(iScreenSize.iWidth/2+EWinBorderSize,EWinBorderSize) ,TSize(winWidth4,winHeight) ,iAltGroup);
   1.766 +//
   1.767 +	iAltConnection=new(ELeave) CPcConnection(this);
   1.768 +	iAltConnection->ConstructL();
   1.769 +	iAltConnectionWin=new(ELeave) CPcWindowAltConnection(this);
   1.770 +	iAltConnectionWin->SetUpL(TPoint(iScreenSize.iWidth/4*3+EWinBorderSize,EWinBorderSize) ,TSize(winWidth4,winHeight),iAltConnection->iGroup,*iAltConnection->iGc);
   1.771 +	iTest->DelayIfFullRomL();
   1.772 +	SetSelfDrive(ETrue);
   1.773 +	}
   1.774 +
   1.775 +void CTPointerCapture::NickFocusL()
   1.776 +	{
   1.777 +	iNickFocusGroup=new(ELeave) CPcWindowNickFocusGroup(this,Client());
   1.778 +	iNickFocusGroup->ConstructL();
   1.779 +	iNickFocusGroup->GroupWin()->SetOrdinalPosition(0,2);
   1.780 +	iNickFocusBlankWin=new(ELeave) CTBlankWindow();
   1.781 +	iNickFocusBlankWin->ConstructL(*iNickFocusGroup);
   1.782 +	iNickFocusBlankWin->SetSize(TSize(1,1));
   1.783 +	iNickFocusBlankWin->Activate();
   1.784 +	}
   1.785 +
   1.786 +void CTPointerCapture::SetCapture(TInt aCaptureFlags)
   1.787 +	{
   1.788 +#if defined(LOGGING)
   1.789 +	_LIT(KLog,"Change Capture  State=%d  CaptureFlags=0x%x");
   1.790 +	LOG_MESSAGE3(KLog,iTest->iState,aCaptureFlags);
   1.791 +#endif
   1.792 +	iMainWin->Win()->SetPointerCapture(aCaptureFlags);
   1.793 +	}
   1.794 +
   1.795 +void CTPointerCapture::SendEventsL()
   1.796 +	{
   1.797 +#if defined(LOGGING)
   1.798 +	_LIT(KLog,"SendEvent  State=%d  SubState=%d");
   1.799 +	LOG_MESSAGE3(KLog,iTest->iState,iSubState);
   1.800 +#endif
   1.801 +	switch (iSubState)
   1.802 +		{
   1.803 +	case 0:
   1.804 +		iTest->SimulatePointerDownUp(iScreenSize.iWidth/4,iScreenSize.iHeight/8+EWinBorderSize/2);
   1.805 +		break;
   1.806 +	case 1:
   1.807 +		if (iTest->iState>ECaptureDisabled)
   1.808 +			{
   1.809 +			iTest->SimulatePointerDownUp(iScreenSize.iWidth/4,3*iScreenSize.iHeight/8-EWinBorderSize/2);
   1.810 +			break;
   1.811 +			}
   1.812 +	case 2:
   1.813 +		iTest->SimulatePointerDownUp(5*iScreenSize.iWidth/8,iScreenSize.iHeight/4);
   1.814 +		break;
   1.815 +	case 3:
   1.816 +		iTest->SimulatePointerDownUp(7*iScreenSize.iWidth/8,iScreenSize.iHeight/4);
   1.817 +		break;
   1.818 +	case 4:
   1.819 +		if (iTest->IsFullRomL())
   1.820 +			iTest->SimulateKeyDownUp(EStdKeyEnter);
   1.821 +		else
   1.822 +			iTest->SimulatePointerDownUp(0,0);
   1.823 +		if (iTest->iState==ENormalCaptureWithoutFocus)
   1.824 +			{
   1.825 +			iTest->SimulateKeyDownUp(EStdKeyEscape);
   1.826 +			break;
   1.827 +			}
   1.828 +		break;
   1.829 +	default:
   1.830 +		TEST(EFalse);
   1.831 +		}
   1.832 +	TheClient->iWs.Flush();
   1.833 +	}
   1.834 +
   1.835 +void CTPointerCapture::RunTestCaseL(TInt /*aCurTestCase*/)
   1.836 +	{
   1.837 +	_LIT(TestNoCapture,"No capture");
   1.838 +	_LIT(TestNormalCapture,"Normal capture");
   1.839 +	_LIT(TestAllGroups,"All groups");
   1.840 +	_LIT(TestDragDrop,"Drag & Drop");
   1.841 +	_LIT(TestDragDropAllGroups,"Drag & Drop All groups");
   1.842 +	_LIT(TestWithoutFocus,"Without focus");
   1.843 +	StateChanged();
   1.844 +	
   1.845 +	if (!TestBase()->ConfigurationSupportsPointerEventTesting())
   1.846 +	    {
   1.847 +	    INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing"));
   1.848 +	    TestComplete();
   1.849 +	    return;
   1.850 +	    }
   1.851 +	
   1.852 +	((CTPointerCaptureStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
   1.853 +	switch(iTest->iState)
   1.854 +		{
   1.855 +/**
   1.856 +
   1.857 +  @SYMTestCaseID GRAPHICS-WSERV-0290
   1.858 +  
   1.859 +  @SYMDEF             DEF081259
   1.860 + 
   1.861 +  @SYMTestCaseDesc Test pointer capture can be disabled
   1.862 +    
   1.863 +  @SYMTestPriority High
   1.864 + 
   1.865 +  @SYMTestStatus Implemented
   1.866 + 
   1.867 +  @SYMTestActions Disable the pointer capture to the screen and simulate
   1.868 +  					capture with the pointer
   1.869 +  
   1.870 +  @SYMTestExpectedResults The pointer capture has been disabled
   1.871 + 
   1.872 +*/
   1.873 +		case ECaptureDisabled:
   1.874 +			((CTPointerCaptureStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0290"));
   1.875 +			if (TheClient->iScreen->GetScreenNumber()>0)
   1.876 +				{
   1.877 +				_LIT(KLog,"Cannot run this test on the 2nd screen - all pointer events goto the 1st screen");
   1.878 +				LOG_MESSAGE(KLog);
   1.879 +				TestComplete();
   1.880 +				}
   1.881 +			iTest->LogSubTest(TestNoCapture);
   1.882 +			SetCapture(RWindowBase::TCaptureDisabled);
   1.883 +			break;
   1.884 +/**
   1.885 +
   1.886 +  @SYMTestCaseID GRAPHICS-WSERV-0291
   1.887 +  
   1.888 +  @SYMDEF             DEF081259
   1.889 + 
   1.890 +  @SYMTestCaseDesc Test pointer capture can be enabled
   1.891 +    
   1.892 +  @SYMTestPriority High
   1.893 + 
   1.894 +  @SYMTestStatus Implemented
   1.895 + 
   1.896 +  @SYMTestActions Enable the pointer capture to the screen and simulate
   1.897 +  					capture with the pointer
   1.898 +  
   1.899 +  @SYMTestExpectedResults The pointer capture has been enabled and works
   1.900 +  							correctly
   1.901 + 
   1.902 +*/
   1.903 +		case ENormalCapture:
   1.904 +			((CTPointerCaptureStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0291"));
   1.905 +			iTest->LogSubTest(TestNormalCapture);
   1.906 +			SetCapture(RWindowBase::TCaptureEnabled);
   1.907 +			break;
   1.908 +/**
   1.909 +
   1.910 +  @SYMTestCaseID GRAPHICS-WSERV-0292
   1.911 +  
   1.912 +  @SYMDEF             DEF081259
   1.913 + 
   1.914 +  @SYMTestCaseDesc Test pointer capture can be enabled for 
   1.915 +  					windows belonging to any group
   1.916 +    
   1.917 +  @SYMTestPriority High
   1.918 + 
   1.919 +  @SYMTestStatus Implemented
   1.920 + 
   1.921 +  @SYMTestActions Enable the pointer capture to all windows and simulate
   1.922 +  					capture with the pointer
   1.923 +  
   1.924 +  @SYMTestExpectedResults The pointer capture has been enabled and works
   1.925 +  							correctly
   1.926 + 
   1.927 +*/
   1.928 +		case ECaptureAllGroups:
   1.929 +			((CTPointerCaptureStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0292"));
   1.930 +			iTest->LogSubTest(TestAllGroups);
   1.931 +			SetCapture(RWindowBase::TCaptureEnabled|RWindowBase::TCaptureFlagAllGroups);
   1.932 +			break;
   1.933 +/**
   1.934 +
   1.935 +  @SYMTestCaseID GRAPHICS-WSERV-0293
   1.936 +  
   1.937 +  @SYMDEF             DEF081259
   1.938 + 
   1.939 +  @SYMTestCaseDesc Test drag and drop pointer capture can be enabled for 
   1.940 +  					windows belonging to any group
   1.941 +    
   1.942 +  @SYMTestPriority High
   1.943 + 
   1.944 +  @SYMTestStatus Implemented
   1.945 + 
   1.946 +  @SYMTestActions Enable drag and drop  pointer capture to all windows and simulate
   1.947 +  					capture with the pointer
   1.948 +  
   1.949 +  @SYMTestExpectedResults The pointer capture has been enabled and works
   1.950 +  							correctly
   1.951 + 
   1.952 +*/
   1.953 +		case EDragDropCapture:
   1.954 +			((CTPointerCaptureStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0293"));
   1.955 +			iTest->LogSubTest(TestDragDrop);
   1.956 +			SetCapture(RWindowBase::TCaptureDragDrop&~RWindowBase::TCaptureFlagAllGroups);
   1.957 +			break;
   1.958 +/**
   1.959 +
   1.960 +  @SYMTestCaseID GRAPHICS-WSERV-0294
   1.961 +  
   1.962 +  @SYMDEF             DEF081259
   1.963 + 
   1.964 +  @SYMTestCaseDesc Test drag and drop pointer capture can be enabled
   1.965 +    
   1.966 +  @SYMTestPriority High
   1.967 + 
   1.968 +  @SYMTestStatus Implemented
   1.969 + 
   1.970 +  @SYMTestActions Enable drag and drop  pointer capture and simulate
   1.971 +  					capture with the pointer
   1.972 +  
   1.973 +  @SYMTestExpectedResults The pointer capture has been enabled and works
   1.974 +  							correctly
   1.975 + 
   1.976 +*/
   1.977 +		case EDragDropCaptureAllGroups:
   1.978 +			((CTPointerCaptureStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0294"));
   1.979 +			iTest->LogSubTest(TestDragDropAllGroups);
   1.980 +			SetCapture(RWindowBase::TCaptureDragDrop);
   1.981 +			break;
   1.982 +/**
   1.983 +
   1.984 +  @SYMTestCaseID GRAPHICS-WSERV-0295
   1.985 +  
   1.986 +  @SYMDEF             DEF081259
   1.987 + 
   1.988 +  @SYMTestCaseDesc Test pointer capture can be enabled
   1.989 +    
   1.990 +  @SYMTestPriority High
   1.991 + 
   1.992 +  @SYMTestStatus Implemented
   1.993 + 
   1.994 +  @SYMTestActions Enable the pointer capture to the screen and simulate capture
   1.995 +  					with the pointer when the screen does not have the focus
   1.996 +  
   1.997 +  @SYMTestExpectedResults The pointer capture has been enabled and works
   1.998 +  							correctly
   1.999 + 
  1.1000 +*/
  1.1001 +		case ENormalCaptureWithoutFocus:
  1.1002 +			((CTPointerCaptureStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0295"));
  1.1003 +			iTest->LogSubTest(TestWithoutFocus);
  1.1004 +			NickFocusL();
  1.1005 +			SetCapture(RWindowBase::TCaptureEnabled);
  1.1006 +			break;
  1.1007 +		default:
  1.1008 +			((CTPointerCaptureStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
  1.1009 +			((CTPointerCaptureStep*)iStep)->CloseTMSGraphicsStep();
  1.1010 +			TestComplete();
  1.1011 +			return;
  1.1012 +		}
  1.1013 +	((CTPointerCaptureStep*)iStep)->RecordTestResultL();
  1.1014 +	SendEventsL();
  1.1015 +	}
  1.1016 +
  1.1017 +__WS_CONSTRUCT_STEP__(PointerCapture)