1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/windowing/windowserver/test/tman/TMPNTCAP.CPP Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,856 @@
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 +#include <e32std.h>
1.22 +#include <e32svr.h>
1.23 +#include "W32STD.H"
1.24 +#include "../tlib/testbase.h"
1.25 +#include "TMAN.H"
1.26 +
1.27 +enum TTestState
1.28 + {
1.29 + ECaptureDisabled,
1.30 + ENormalCapture,
1.31 + ECaptureAllGroups,
1.32 + EDragDropCapture,
1.33 + EDragDropCaptureAllGroups,
1.34 + ENormalCaptureWithoutFocus,
1.35 + };
1.36 +
1.37 +enum TTestSubState
1.38 + {
1.39 + EMainWindow,
1.40 + EChildWindow,
1.41 + EOtherGroup,
1.42 + EOtherSession,
1.43 + ERootWindow,
1.44 + };
1.45 +
1.46 +enum TPointerCheckRet
1.47 + {
1.48 + EFailed,
1.49 + EOkay,
1.50 + ENeedsDDEvent,
1.51 + };
1.52 +
1.53 +const TInt ESubStates1=2;
1.54 +const TInt ESubStates2=5;
1.55 +const TInt ESubStates3=5;
1.56 +const TInt ESubStates4=5;
1.57 +const TInt ESubStates5=5;
1.58 +const TInt ESubStates6=5;
1.59 +
1.60 +const TInt EWinBorderSize=10;
1.61 +
1.62 +class CPcWindowBase;
1.63 +class TPointerCaptureTest;
1.64 +
1.65 +class CPcConnection : public CTClient
1.66 + {
1.67 +public:
1.68 + CPcConnection(TPointerCaptureTest *aTest);
1.69 + ~CPcConnection();
1.70 + virtual void ConstructL();
1.71 +protected:
1.72 + TPointerCaptureTest *iTest;
1.73 + };
1.74 +
1.75 +class CPcWindowBase : public CTWin
1.76 + {
1.77 +public:
1.78 + CPcWindowBase(TPointerCaptureTest *aTest);
1.79 + void SetUpL(TPoint pos,TSize size,CTWinBase *parent);
1.80 + void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc);
1.81 + void Draw(TDesC &aBuf);
1.82 + void PointerL(const TPointerEvent &pointer,const TTime &);
1.83 + void DragDropL(const TPointerEvent &pointer,const TTime &);
1.84 + virtual TPointerCheckRet PointerDown()=0;
1.85 + virtual TPointerCheckRet DragDrop()=0;
1.86 + virtual void SubStateChanged();
1.87 +protected:
1.88 + TPointerCaptureTest *iTest;
1.89 + TRgb iBack;
1.90 + };
1.91 +
1.92 +class CPcWindowChild : public CPcWindowBase
1.93 + {
1.94 +public:
1.95 + CPcWindowChild(TPointerCaptureTest *aTest);
1.96 + void Draw();
1.97 + TPointerCheckRet PointerDown();
1.98 + TPointerCheckRet DragDrop();
1.99 + };
1.100 +
1.101 +class CPcWindowMain : public CPcWindowBase
1.102 + {
1.103 +public:
1.104 + CPcWindowMain(TPointerCaptureTest *aTest);
1.105 + void Draw();
1.106 + TPointerCheckRet PointerDown();
1.107 + TPointerCheckRet DragDrop();
1.108 + void WinKeyL(const TKeyEvent &aKey,const TTime &aTime);
1.109 + };
1.110 +
1.111 +class CPcWindowAltGroup : public CPcWindowBase
1.112 + {
1.113 +public:
1.114 + CPcWindowAltGroup(TPointerCaptureTest *aTest);
1.115 + void Draw();
1.116 + TPointerCheckRet PointerDown();
1.117 + TPointerCheckRet DragDrop();
1.118 + };
1.119 +
1.120 +class CPcWindowNickFocusGroup : public CTWindowGroup
1.121 + {
1.122 +public:
1.123 + CPcWindowNickFocusGroup(TPointerCaptureTest *aTest, CTClient *aClient);
1.124 + void KeyL(const TKeyEvent &aKey,const TTime &aTime);
1.125 +private:
1.126 + TPointerCaptureTest *iTest;
1.127 + };
1.128 +
1.129 +class CPcWindowAltConnection : public CPcWindowBase
1.130 + {
1.131 +public:
1.132 + CPcWindowAltConnection(TPointerCaptureTest *aTest);
1.133 + void Draw();
1.134 + TPointerCheckRet PointerDown();
1.135 + TPointerCheckRet DragDrop();
1.136 + };
1.137 +
1.138 +class TPointerCaptureTest : public CTestBase
1.139 + {
1.140 +private:
1.141 + enum TDState {DDStateNull, DDStateGot, DDStateWaiting};
1.142 +public:
1.143 + TPointerCaptureTest();
1.144 + ~TPointerCaptureTest();
1.145 + TestState DoTestL();
1.146 + void ConstructL();
1.147 + void NextTest();
1.148 + void AbortTests();
1.149 + TInt State() const;
1.150 + TInt SubState() const;
1.151 + void doIncSubState();
1.152 + void IncSubState(TBool aNeedsDD=EFalse);
1.153 + void GotDD();
1.154 + void StateChanged();
1.155 + void TestFailed();
1.156 + void NickFocusL();
1.157 + void SetCapture(TInt aCaptureFlags);
1.158 + void RestartTest();
1.159 +private:
1.160 + TInt doTestFailedL();
1.161 +private:
1.162 + CPcConnection *iAltConnection;
1.163 + CTWindowGroup *iMainGroup;
1.164 + CTWindowGroup *iAltGroup;
1.165 + CPcWindowChild *iChildWin;
1.166 + CPcWindowMain *iMainWin;
1.167 + CPcWindowAltGroup *iAltGroupWin;
1.168 + CPcWindowAltConnection *iAltConnectionWin;
1.169 + CPcWindowNickFocusGroup *iNickFocusGroup;
1.170 + CTBlankWindow *iNickFocusBlankWin;
1.171 + TInt iState;
1.172 + TInt iSubState;
1.173 + TDState iDDState;
1.174 +public:
1.175 + TBool iFailed;
1.176 + };
1.177 +
1.178 +GLDEF_C CTestBase *CreatePointerCaptureTest()
1.179 + {
1.180 + return(new(ELeave) TPointerCaptureTest());
1.181 + }
1.182 +
1.183 +//
1.184 +// CMcConnection
1.185 +
1.186 +CPcConnection::CPcConnection(TPointerCaptureTest *aTest) : iTest(aTest)
1.187 + {
1.188 + }
1.189 +
1.190 +CPcConnection::~CPcConnection()
1.191 + {
1.192 + }
1.193 +
1.194 +void CPcConnection::ConstructL()
1.195 + {
1.196 + CTClient::ConstructL();
1.197 + iGroup=new(ELeave) CTWindowGroup(this);
1.198 + iGroup->ConstructL();
1.199 + iGroup->GroupWin()->SetOrdinalPosition(0,1);
1.200 + iGroup->GroupWin()->EnableReceiptOfFocus(EFalse);
1.201 + iWs.Flush();
1.202 + }
1.203 +
1.204 +//
1.205 +// CPcWindow, base class //
1.206 +//
1.207 +
1.208 +CPcWindowBase::CPcWindowBase(TPointerCaptureTest *aTest) : CTWin(), iTest(aTest)
1.209 + {
1.210 + }
1.211 +
1.212 +void CPcWindowBase::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc)
1.213 + {
1.214 + ConstructExtLD(*parent,pos,size);
1.215 + iWin.SetBackgroundColor(iBack);
1.216 + Activate();
1.217 + AssignGC(aGc);
1.218 + }
1.219 +
1.220 +void CPcWindowBase::SetUpL(TPoint pos,TSize size,CTWinBase *parent)
1.221 + {
1.222 + SetUpL(pos,size,parent,*iTest->Client()->iGc);
1.223 + }
1.224 +
1.225 +void CPcWindowBase::SubStateChanged()
1.226 + {
1.227 + iWin.Invalidate();
1.228 + Client()->iWs.Flush();
1.229 + }
1.230 +
1.231 +void CPcWindowBase::Draw(TDesC &aBuf)
1.232 + {
1.233 + iGc->Clear();
1.234 + iGc->SetPenColor(iBack.Gray4()>1 ? TRgb(0,0,0) : TRgb(255,255,255));
1.235 + iGc->DrawText(aBuf, TPoint(10,20));
1.236 + }
1.237 +
1.238 +void CPcWindowBase::PointerL(const TPointerEvent &pointer,const TTime &)
1.239 + {
1.240 + if (pointer.iType==TPointerEvent::EButton1Down && !iTest->iFailed)
1.241 + {
1.242 + if (iTest->SubState()==ERootWindow) // Root window click, must not be inside this window
1.243 + {
1.244 + if (TRect(Size()).Contains(pointer.iPosition))
1.245 + {
1.246 + iTest->TestFailed();
1.247 + return;
1.248 + }
1.249 + }
1.250 + TInt ret;
1.251 + if ((ret=PointerDown())==EFailed)
1.252 + iTest->TestFailed();
1.253 + else
1.254 + iTest->IncSubState(ret==ENeedsDDEvent);
1.255 + }
1.256 + }
1.257 +
1.258 +void CPcWindowBase::DragDropL(const TPointerEvent &pointer,const TTime &)
1.259 + {
1.260 + switch(iTest->State())
1.261 + {
1.262 + case ECaptureDisabled:
1.263 + case ENormalCapture:
1.264 + case ECaptureAllGroups:
1.265 + case ENormalCaptureWithoutFocus:
1.266 + iTest->TestFailed();
1.267 + break;
1.268 + }
1.269 + if (pointer.iType==TPointerEvent::EButton1Down && !iTest->iFailed)
1.270 + {
1.271 + if (DragDrop()==EFailed)
1.272 + iTest->TestFailed();
1.273 + else
1.274 + iTest->GotDD();
1.275 + }
1.276 + }
1.277 +//
1.278 +
1.279 +CPcWindowMain::CPcWindowMain(TPointerCaptureTest *aTest) : CPcWindowBase(aTest)
1.280 + {
1.281 + iBack=TRgb::Gray256(236);
1.282 + }
1.283 +
1.284 +TPointerCheckRet CPcWindowMain::PointerDown()
1.285 + {
1.286 + switch(iTest->State())
1.287 + {
1.288 + case ECaptureDisabled:
1.289 + if (iTest->SubState()==EMainWindow)
1.290 + return(EOkay);
1.291 + break;
1.292 + case ENormalCapture:
1.293 + switch(iTest->SubState())
1.294 + {
1.295 + case EMainWindow:
1.296 + case ERootWindow:
1.297 + return(EOkay);
1.298 + default:
1.299 + break;
1.300 + }
1.301 + break;
1.302 + case ECaptureAllGroups:
1.303 + switch(iTest->SubState())
1.304 + {
1.305 + case EMainWindow:
1.306 + case EOtherGroup:
1.307 + case EOtherSession:
1.308 + case ERootWindow:
1.309 + return(EOkay);
1.310 + default:
1.311 + break;
1.312 + }
1.313 + break;
1.314 + case EDragDropCapture:
1.315 + switch(iTest->SubState())
1.316 + {
1.317 + case EMainWindow:
1.318 + return(ENeedsDDEvent);
1.319 + case ERootWindow:
1.320 + return(EOkay);
1.321 + default:
1.322 + break;
1.323 + }
1.324 + break;
1.325 + case EDragDropCaptureAllGroups:
1.326 + switch(iTest->SubState())
1.327 + {
1.328 + case EMainWindow:
1.329 + case EOtherGroup:
1.330 + case EOtherSession:
1.331 + return(ENeedsDDEvent);
1.332 + case ERootWindow:
1.333 + return(EOkay);
1.334 + default:
1.335 + break;
1.336 + }
1.337 + break;
1.338 + case ENormalCaptureWithoutFocus:
1.339 + switch(iTest->SubState())
1.340 + {
1.341 + case EMainWindow:
1.342 + return(EOkay);
1.343 + default:
1.344 + break;
1.345 + }
1.346 + break;
1.347 + default:
1.348 + break;
1.349 + }
1.350 + return(EFailed);
1.351 + }
1.352 +
1.353 +TPointerCheckRet CPcWindowMain::DragDrop()
1.354 + {
1.355 + switch(iTest->State())
1.356 + {
1.357 + case EDragDropCapture:
1.358 + case EDragDropCaptureAllGroups:
1.359 + switch(iTest->SubState())
1.360 + {
1.361 + case EMainWindow:
1.362 + return(EOkay);
1.363 + default:
1.364 + break;
1.365 + }
1.366 + break;
1.367 + default:
1.368 + break;
1.369 + }
1.370 + return(EFailed);
1.371 + }
1.372 +
1.373 +void CPcWindowMain::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 EMainWindow:
1.381 + buf.Copy(_L("Click on me"));
1.382 + break;
1.383 + }
1.384 + }
1.385 + else
1.386 + {
1.387 + switch(iTest->SubState())
1.388 + {
1.389 + case EMainWindow:
1.390 + buf.Copy(_L("Click on me"));
1.391 + break;
1.392 + case EChildWindow:
1.393 + case EOtherGroup:
1.394 + case EOtherSession:
1.395 + break;
1.396 + case ERootWindow:
1.397 + if (iTest->State()==ENormalCaptureWithoutFocus)
1.398 + buf.Copy(_L("Click on the root window, then press <Escape>"));
1.399 + else
1.400 + buf.Copy(_L("Click on the root window"));
1.401 + break;
1.402 + }
1.403 + }
1.404 + CPcWindowBase::Draw(buf);
1.405 + }
1.406 +
1.407 +void CPcWindowMain::WinKeyL(const TKeyEvent &aKey,const TTime &)
1.408 + {
1.409 + switch(aKey.iCode)
1.410 + {
1.411 + case EKeyEscape:
1.412 + iTest->AbortTests();
1.413 + break;
1.414 + }
1.415 + }
1.416 +
1.417 +//
1.418 +
1.419 +CPcWindowChild::CPcWindowChild(TPointerCaptureTest *aTest) : CPcWindowBase(aTest)
1.420 + {
1.421 + iBack=TRgb::Gray256(85);
1.422 + }
1.423 +
1.424 +TPointerCheckRet CPcWindowChild::PointerDown()
1.425 + {
1.426 + switch(iTest->State())
1.427 + {
1.428 + case ECaptureDisabled:
1.429 + break;
1.430 + default:
1.431 + switch(iTest->SubState())
1.432 + {
1.433 + case EChildWindow:
1.434 + return(EOkay);
1.435 + default:
1.436 + break;
1.437 + }
1.438 + break;
1.439 + }
1.440 + return(EFailed);
1.441 + }
1.442 +
1.443 +TPointerCheckRet CPcWindowChild::DragDrop()
1.444 + {
1.445 + switch(iTest->State())
1.446 + {
1.447 + case EDragDropCapture:
1.448 + case EDragDropCaptureAllGroups:
1.449 + switch(iTest->SubState())
1.450 + {
1.451 + case EChildWindow:
1.452 + return(EOkay);
1.453 + default:
1.454 + break;
1.455 + }
1.456 + break;
1.457 + default:
1.458 + break;
1.459 + }
1.460 + return(EFailed);
1.461 + }
1.462 +
1.463 +void CPcWindowChild::Draw()
1.464 + {
1.465 + TBuf<0x40> buf;
1.466 + if (iTest->State()!=ECaptureDisabled)
1.467 + {
1.468 + switch(iTest->SubState())
1.469 + {
1.470 + case EChildWindow:
1.471 + buf.Copy(_L("Click on me"));
1.472 + break;
1.473 + default:
1.474 + break;
1.475 + }
1.476 + }
1.477 + CPcWindowBase::Draw(buf);
1.478 + }
1.479 +
1.480 +//
1.481 +
1.482 +CPcWindowNickFocusGroup::CPcWindowNickFocusGroup(TPointerCaptureTest *aTest, CTClient *aClient) : CTWindowGroup(aClient), iTest(aTest)
1.483 + {
1.484 + }
1.485 +
1.486 +void CPcWindowNickFocusGroup::KeyL(const TKeyEvent &aKey,const TTime &)
1.487 + {
1.488 + if (aKey.iCode==EKeyEscape)
1.489 + iTest->IncSubState(EFalse);
1.490 + }
1.491 +
1.492 +//
1.493 +
1.494 +CPcWindowAltGroup::CPcWindowAltGroup(TPointerCaptureTest *aTest) : CPcWindowBase(aTest)
1.495 + {
1.496 + iBack=TRgb::Gray256(236);
1.497 + }
1.498 +
1.499 +TPointerCheckRet CPcWindowAltGroup::PointerDown()
1.500 + {
1.501 + switch(iTest->State())
1.502 + {
1.503 + case ECaptureDisabled:
1.504 + if (iTest->SubState()==EChildWindow)
1.505 + return(EOkay);
1.506 + break;
1.507 + case ENormalCapture:
1.508 + case EDragDropCapture:
1.509 + case ENormalCaptureWithoutFocus:
1.510 + switch(iTest->SubState())
1.511 + {
1.512 + case EOtherGroup:
1.513 + return(EOkay);
1.514 + default:
1.515 + break;
1.516 + }
1.517 + break;
1.518 + default:
1.519 + break;
1.520 + }
1.521 + return(EFailed);
1.522 + }
1.523 +
1.524 +TPointerCheckRet CPcWindowAltGroup::DragDrop()
1.525 + {
1.526 + switch(iTest->State())
1.527 + {
1.528 + case EDragDropCapture:
1.529 + case EDragDropCaptureAllGroups:
1.530 + switch(iTest->SubState())
1.531 + {
1.532 + case EOtherGroup:
1.533 + return(EOkay);
1.534 + default:
1.535 + break;
1.536 + }
1.537 + break;
1.538 + default:
1.539 + break;
1.540 + }
1.541 + return(EFailed);
1.542 + }
1.543 +
1.544 +void CPcWindowAltGroup::Draw()
1.545 + {
1.546 + TBuf<0x40> buf;
1.547 + if (iTest->State()==ECaptureDisabled)
1.548 + {
1.549 + switch(iTest->SubState())
1.550 + {
1.551 + case EMainWindow:
1.552 + break;
1.553 + case EChildWindow:
1.554 + buf.Copy(_L("Click on me"));
1.555 + break;
1.556 + }
1.557 + }
1.558 + else
1.559 + {
1.560 + switch(iTest->SubState())
1.561 + {
1.562 + case EOtherGroup:
1.563 + buf.Copy(_L("Click on me"));
1.564 + break;
1.565 + default:
1.566 + break;
1.567 + }
1.568 + }
1.569 + CPcWindowBase::Draw(buf);
1.570 + }
1.571 +
1.572 +//
1.573 +
1.574 +CPcWindowAltConnection::CPcWindowAltConnection(TPointerCaptureTest *aTest) : CPcWindowBase(aTest)
1.575 + {
1.576 + iBack=TRgb::Gray256(236);
1.577 + }
1.578 +
1.579 +TPointerCheckRet CPcWindowAltConnection::PointerDown()
1.580 + {
1.581 + switch(iTest->State())
1.582 + {
1.583 + case ECaptureDisabled:
1.584 + if (iTest->SubState()==EChildWindow)
1.585 + return(EOkay);
1.586 + break;
1.587 + case ENormalCapture:
1.588 + case EDragDropCapture:
1.589 + case ENormalCaptureWithoutFocus:
1.590 + switch(iTest->SubState())
1.591 + {
1.592 + case EOtherSession:
1.593 + return(EOkay);
1.594 + default:
1.595 + break;
1.596 + }
1.597 + break;
1.598 + default:
1.599 + break;
1.600 + }
1.601 + return(EFailed);
1.602 + }
1.603 +
1.604 +TPointerCheckRet CPcWindowAltConnection::DragDrop()
1.605 + {
1.606 + switch(iTest->State())
1.607 + {
1.608 + case EDragDropCapture:
1.609 + case EDragDropCaptureAllGroups:
1.610 + switch(iTest->SubState())
1.611 + {
1.612 + case EOtherSession:
1.613 + return(EOkay);
1.614 + default:
1.615 + break;
1.616 + }
1.617 + break;
1.618 + default:
1.619 + break;
1.620 + }
1.621 + return(EFailed);
1.622 + }
1.623 +
1.624 +void CPcWindowAltConnection::Draw()
1.625 + {
1.626 + TBuf<0x40> buf;
1.627 + if (iTest->State()!=ECaptureDisabled)
1.628 + {
1.629 + switch(iTest->SubState())
1.630 + {
1.631 + case EOtherSession:
1.632 + buf.Copy(_L("Click on me"));
1.633 + break;
1.634 + default:
1.635 + break;
1.636 + }
1.637 + }
1.638 + CPcWindowBase::Draw(buf);
1.639 + }
1.640 +
1.641 +//
1.642 +
1.643 +TPointerCaptureTest::TPointerCaptureTest() : CTestBase(_L("Pointer Capture"))
1.644 + {}
1.645 +
1.646 +TPointerCaptureTest::~TPointerCaptureTest()
1.647 + {
1.648 + delete iNickFocusBlankWin;
1.649 + delete iNickFocusGroup;
1.650 + delete iAltConnectionWin;
1.651 + delete iAltConnection;
1.652 + delete iChildWin;
1.653 + delete iMainWin;
1.654 + delete iMainGroup;
1.655 + delete iAltGroupWin;
1.656 + delete iAltGroup;
1.657 + }
1.658 +
1.659 +void TPointerCaptureTest::TestFailed()
1.660 + {
1.661 + __ASSERT_DEBUG(iFailed==EFalse,TManPanic(ETManPanicPcFailed));
1.662 + iFailed=ETrue;
1.663 + Client()->iGroup->GroupWin()->SetOrdinalPosition(0,10); // Put error dialog on top of test windows
1.664 + TInt dRet=1;
1.665 + TRAPD(err,dRet=doTestFailedL());
1.666 + Client()->iGroup->GroupWin()->SetOrdinalPosition(0,0);
1.667 + switch(dRet)
1.668 + {
1.669 + case 0:
1.670 + RestartTest();
1.671 + break;
1.672 + case 1:
1.673 + TRAP(err,TestL(EFalse));
1.674 + break;
1.675 + }
1.676 + }
1.677 +
1.678 +TInt TPointerCaptureTest::doTestFailedL()
1.679 + {
1.680 + CTDialog *dialog=new(ELeave) CTDialog();
1.681 + dialog->SetTitle(_L("Pointer capture test failed"));
1.682 + dialog->SetNumButtons(2);
1.683 + dialog->SetButtonText(0,_L("Retest"));
1.684 + dialog->SetButtonText(1,_L("Fail"));
1.685 + dialog->ConstructLD(*Client()->iGroup,*Client()->iGc);
1.686 + return dialog->Display();
1.687 + }
1.688 +
1.689 +TInt TPointerCaptureTest::State() const
1.690 + {
1.691 + return(iState);
1.692 + }
1.693 +
1.694 +TInt TPointerCaptureTest::SubState() const
1.695 + {
1.696 + return(iSubState);
1.697 + }
1.698 +
1.699 +void TPointerCaptureTest::doIncSubState()
1.700 + {
1.701 + iSubState++;
1.702 + TInt max=0;
1.703 + switch(iState)
1.704 + {
1.705 + case ECaptureDisabled:
1.706 + max=ESubStates1;
1.707 + break;
1.708 + case ENormalCapture:
1.709 + max=ESubStates2;
1.710 + break;
1.711 + case ECaptureAllGroups:
1.712 + max=ESubStates3;
1.713 + break;
1.714 + case EDragDropCapture:
1.715 + max=ESubStates4;
1.716 + break;
1.717 + case EDragDropCaptureAllGroups:
1.718 + max=ESubStates5;
1.719 + break;
1.720 + case ENormalCaptureWithoutFocus:
1.721 + max=ESubStates6;
1.722 + break;
1.723 + }
1.724 + if (iSubState==max)
1.725 + NextTest();
1.726 + StateChanged();
1.727 + }
1.728 +
1.729 +void TPointerCaptureTest::GotDD()
1.730 + {
1.731 + if (iDDState==DDStateWaiting)
1.732 + doIncSubState();
1.733 + else
1.734 + iDDState=DDStateGot;
1.735 + }
1.736 +
1.737 +void TPointerCaptureTest::IncSubState(TBool aNeedsDD)
1.738 + {
1.739 + if (!aNeedsDD)
1.740 + {
1.741 + if (iDDState!=DDStateNull)
1.742 + TestFailed();
1.743 + else
1.744 + doIncSubState();
1.745 + }
1.746 + else if (iDDState==DDStateGot)
1.747 + doIncSubState();
1.748 + else
1.749 + iDDState=DDStateWaiting;
1.750 + }
1.751 +
1.752 +void TPointerCaptureTest::StateChanged()
1.753 + {
1.754 + iDDState=DDStateNull;
1.755 + iChildWin->SubStateChanged();
1.756 + iMainWin->SubStateChanged();
1.757 + iAltGroupWin->SubStateChanged();
1.758 + iAltConnectionWin->SubStateChanged();
1.759 + }
1.760 +
1.761 +void TPointerCaptureTest::AbortTests()
1.762 + {
1.763 + iState=99;
1.764 + Request();
1.765 + }
1.766 +
1.767 +void TPointerCaptureTest::NextTest()
1.768 + {
1.769 + iState++;
1.770 + Request();
1.771 + }
1.772 +
1.773 +void TPointerCaptureTest::RestartTest()
1.774 + {
1.775 + Request();
1.776 + }
1.777 +
1.778 +void TPointerCaptureTest::ConstructL()
1.779 + {
1.780 + TSize size(Client()->iGroup->Size());
1.781 + TInt winWidth2=size.iWidth/2-EWinBorderSize*2;
1.782 + TInt winWidth4=size.iWidth/4-EWinBorderSize*2;
1.783 + TInt winHeight=size.iHeight/2-EWinBorderSize*2;
1.784 +//
1.785 + iMainGroup=new(ELeave) CTWindowGroup(Client());
1.786 + iMainGroup->ConstructL();
1.787 + iMainGroup->GroupWin()->SetOrdinalPosition(0,1);
1.788 + iMainWin=new(ELeave) CPcWindowMain(this);
1.789 + iMainWin->SetUpL(TPoint(EWinBorderSize,EWinBorderSize) ,TSize(winWidth2,winHeight) ,iMainGroup);
1.790 + iMainGroup->SetCurrentWindow(iMainWin);
1.791 + iChildWin=new(ELeave) CPcWindowChild(this);
1.792 + iChildWin->SetUpL(TPoint(0,winHeight/2) ,TSize(winWidth2,winHeight/2) ,iMainWin);
1.793 +//
1.794 + iAltGroup=new(ELeave) CTWindowGroup(Client());
1.795 + iAltGroup->ConstructL();
1.796 + iAltGroup->GroupWin()->SetOrdinalPosition(0,1);
1.797 + iAltGroup->GroupWin()->EnableReceiptOfFocus(EFalse);
1.798 + iAltGroupWin=new(ELeave) CPcWindowAltGroup(this);
1.799 + iAltGroupWin->SetUpL(TPoint(size.iWidth/2+EWinBorderSize,EWinBorderSize) ,TSize(winWidth4,winHeight) ,iAltGroup);
1.800 +//
1.801 + iAltConnection=new(ELeave) CPcConnection(this);
1.802 + iAltConnection->ConstructL();
1.803 + iAltConnectionWin=new(ELeave) CPcWindowAltConnection(this);
1.804 + iAltConnectionWin->SetUpL(TPoint(size.iWidth/4*3+EWinBorderSize,EWinBorderSize) ,TSize(winWidth4,winHeight),iAltConnection->iGroup,*iAltConnection->iGc);
1.805 + }
1.806 +
1.807 +void TPointerCaptureTest::NickFocusL()
1.808 + {
1.809 + iNickFocusGroup=new(ELeave) CPcWindowNickFocusGroup(this,Client());
1.810 + iNickFocusGroup->ConstructL();
1.811 + iNickFocusGroup->GroupWin()->SetOrdinalPosition(0,2);
1.812 + iNickFocusBlankWin=new(ELeave) CTBlankWindow();
1.813 + iNickFocusBlankWin->ConstructL(*iNickFocusGroup);
1.814 + iNickFocusBlankWin->SetSize(TSize(1,1));
1.815 + iNickFocusBlankWin->Activate();
1.816 + }
1.817 +
1.818 +void TPointerCaptureTest::SetCapture(TInt aCaptureFlags)
1.819 + {
1.820 + iMainWin->Win()->SetPointerCapture(aCaptureFlags);
1.821 + }
1.822 +
1.823 +TestState TPointerCaptureTest::DoTestL()
1.824 + {
1.825 + iSubState=0;
1.826 + iFailed=EFalse;
1.827 + StateChanged();
1.828 + switch(iState)
1.829 + {
1.830 + case ECaptureDisabled:
1.831 + LogSubTest(_L("No capture"),1);
1.832 + SetCapture(RWindowBase::TCaptureDisabled);
1.833 + break;
1.834 + case ENormalCapture:
1.835 + LogSubTest(_L("Normal capture"),1);
1.836 + SetCapture(RWindowBase::TCaptureEnabled);
1.837 + break;
1.838 + case ECaptureAllGroups:
1.839 + LogSubTest(_L("All groups"),1);
1.840 + SetCapture(RWindowBase::TCaptureEnabled|RWindowBase::TCaptureFlagAllGroups);
1.841 + break;
1.842 + case EDragDropCapture:
1.843 + LogSubTest(_L("Drag & Drop"),1);
1.844 + SetCapture(RWindowBase::TCaptureDragDrop&~RWindowBase::TCaptureFlagAllGroups);
1.845 + break;
1.846 + case EDragDropCaptureAllGroups:
1.847 + LogSubTest(_L("Drag & Drop All groups"),1);
1.848 + SetCapture(RWindowBase::TCaptureDragDrop);
1.849 + break;
1.850 + case ENormalCaptureWithoutFocus:
1.851 + LogSubTest(_L("Without focus"),1);
1.852 + NickFocusL();
1.853 + SetCapture(RWindowBase::TCaptureEnabled);
1.854 + break;
1.855 + default:
1.856 + return(EFinished);
1.857 + }
1.858 + return(EContinue);
1.859 + }