windowing/windowserver/test/tauto/TPNTCAP.CPP
branchRCL_3
changeset 163 bbf46f59e123
equal deleted inserted replaced
150:57c618273d5c 163:bbf46f59e123
       
     1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Test pointer capture
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @test
       
    21  @internalComponent - Internal Symbian test code
       
    22 */
       
    23 
       
    24 #include "TPNTCAP.H"
       
    25 
       
    26 #define LOGGING on
       
    27 
       
    28 _LIT(ClickOnMe,"Click on me");
       
    29 
       
    30 //
       
    31 // CMcConnection
       
    32 
       
    33 CPcConnection::CPcConnection(CTPointerCapture *aTest) : iTest(aTest)
       
    34 	{
       
    35 	}
       
    36 
       
    37 CPcConnection::~CPcConnection()
       
    38 	{
       
    39 	}
       
    40 
       
    41 void CPcConnection::ConstructL()
       
    42 	{
       
    43 	CTClient::SetScreenNumber(iTest->TestBase()->ScreenNumber());
       
    44 	CTClient::ConstructL();
       
    45 	iGroup=new(ELeave) CTWindowGroup(this);
       
    46 	iGroup->ConstructL();
       
    47 	iGroup->GroupWin()->SetOrdinalPosition(0,1);
       
    48 	iGroup->GroupWin()->EnableReceiptOfFocus(EFalse);
       
    49 	iWs.Flush();
       
    50 	}
       
    51 
       
    52 //
       
    53 // CPcWindow, base class //
       
    54 //
       
    55 
       
    56 CPcWindowBase::CPcWindowBase(CTPointerCapture *aTest) : CTWin(), iTest(aTest)
       
    57 	{
       
    58 	}
       
    59 
       
    60 void CPcWindowBase::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc)
       
    61 	{
       
    62 	ConstructExtLD(*parent,pos,size);
       
    63 	iWin.SetBackgroundColor(iBack);
       
    64 	Activate();
       
    65 	AssignGC(aGc);
       
    66 	}
       
    67 
       
    68 void CPcWindowBase::SetUpL(TPoint pos,TSize size,CTWinBase *parent)
       
    69 	{
       
    70 	SetUpL(pos,size,parent,*iTest->Client()->iGc);
       
    71 	}
       
    72 
       
    73 void CPcWindowBase::SubStateChanged()
       
    74 	{
       
    75 	iWin.Invalidate();
       
    76 	Client()->iWs.Flush();
       
    77 	}
       
    78 
       
    79 void CPcWindowBase::Draw(TDesC &aBuf)
       
    80 	{
       
    81 	iGc->Clear();
       
    82 	iGc->SetPenColor(iBack.Gray4()>1 ? TRgb(0,0,0) : TRgb(255,255,255));
       
    83 	iGc->DrawText(aBuf, TPoint(10,20));
       
    84 	}
       
    85 
       
    86 void CPcWindowBase::PointerL(const TPointerEvent &pointer,const TTime &)
       
    87 	{
       
    88 #if defined(LOGGING)
       
    89 	_LIT(KLog1,"Pointer Event Recieved  Type=%S  State=%d  SubState=%d");
       
    90 	_LIT(KDown,"Down");
       
    91 	_LIT(KUp,"Up");
       
    92 	iTest->LOG_MESSAGE4(KLog1,&(pointer.iType?KUp():KDown()),iTest->State(),iTest->SubState());
       
    93 #endif
       
    94 	if (pointer.iType==TPointerEvent::EButton1Down && !iTest->iFailed)
       
    95 		{
       
    96 		if (iTest->SubState()==ERootWindow)	// Root window click, must not be inside this window
       
    97 			{
       
    98 			if (TRect(Size()).Contains(pointer.iPosition))
       
    99 				{
       
   100 				iTest->TestFailed();
       
   101 				return;
       
   102 				}
       
   103 			}
       
   104 		TInt ret;
       
   105 		if ((ret=PointerDown())==EFailed)
       
   106 			iTest->TestFailed();
       
   107 		else
       
   108 			iTest->IncSubStateL(ret==ENeedsDDEvent);
       
   109 		}
       
   110 #if defined(LOGGING)
       
   111 	_LIT(KLog2,"End of processing Pointer Event");
       
   112 	iTest->LOG_MESSAGE(KLog2);
       
   113 #endif
       
   114 	}
       
   115 
       
   116 void CPcWindowBase::DragDropL(const TPointerEvent &pointer,const TTime &)
       
   117 	{
       
   118 #if defined(LOGGING)
       
   119 	_LIT(KLog,"CPcWindowBase::DragDropL  Type=%d  State=%d  SubState=%d");
       
   120 	iTest->LOG_MESSAGE4(KLog,pointer.iType,iTest->State(),iTest->SubState());
       
   121 #endif
       
   122 	switch(iTest->State())
       
   123 		{
       
   124 		case ENormalCaptureWithoutFocus:
       
   125 			if (iTest->SubState()==0)
       
   126 				break;
       
   127 		case ECaptureDisabled:
       
   128 		case ENormalCapture:
       
   129 		case ECaptureAllGroups:
       
   130 			iTest->TestFailed();
       
   131 			break;
       
   132 		}
       
   133 	if (pointer.iType==TPointerEvent::EButton1Down && !iTest->iFailed)
       
   134 		{
       
   135 		if (DragDrop()==EFailed)
       
   136 			iTest->TestFailed();
       
   137 		else
       
   138 			iTest->GotDDL();
       
   139 		}
       
   140 	}
       
   141 //
       
   142 
       
   143 CPcWindowMain::CPcWindowMain(CTPointerCapture *aTest) : CPcWindowBase(aTest)
       
   144 	{
       
   145 	iBack=TRgb::Gray256(236);
       
   146 	}
       
   147 
       
   148 TPointerCheckRet CPcWindowMain::PointerDown()
       
   149 	{
       
   150 #if defined(LOGGING)
       
   151 	_LIT(KLog1,"CPcWindowMain::PointerDown  State=%d  SubState=%d");
       
   152 	iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState());
       
   153 #endif
       
   154 	switch(iTest->State())
       
   155 		{
       
   156 		case ECaptureDisabled:
       
   157 			if (iTest->SubState()==EMainWindow)
       
   158 				return(EOkay);
       
   159 			break;
       
   160 		case ENormalCapture:
       
   161 			switch(iTest->SubState())
       
   162 				{
       
   163 				case EMainWindow:
       
   164 				case ERootWindow:
       
   165 					return(EOkay);
       
   166 				default:
       
   167 					break;
       
   168 				}
       
   169 			break;
       
   170 		case ECaptureAllGroups:
       
   171 			switch(iTest->SubState())
       
   172 				{
       
   173 				case EMainWindow:
       
   174 				case EOtherGroup:
       
   175 				case EOtherSession:
       
   176 				case ERootWindow:
       
   177 					return(EOkay);
       
   178 				default:
       
   179 					break;
       
   180 				}
       
   181 			break;
       
   182 		case EDragDropCapture:
       
   183 			switch(iTest->SubState())
       
   184 				{
       
   185 				case EMainWindow:
       
   186 					return(ENeedsDDEvent);
       
   187 				case ERootWindow:
       
   188 					return(EOkay);
       
   189 				default:
       
   190 					break;
       
   191 				}
       
   192 			break;
       
   193 		case EDragDropCaptureAllGroups:
       
   194 			switch(iTest->SubState())
       
   195 				{
       
   196 				case EMainWindow:
       
   197 				case EOtherGroup:
       
   198 				case EOtherSession:
       
   199 					return(ENeedsDDEvent);
       
   200 				case ERootWindow:
       
   201 					return(EOkay);
       
   202 				default:
       
   203 					break;
       
   204 				}
       
   205 			break;
       
   206 		case ENormalCaptureWithoutFocus:
       
   207 			switch(iTest->SubState())
       
   208 				{
       
   209 				case EMainWindow:
       
   210 					return(EOkay);
       
   211 				default:
       
   212 					break;
       
   213 				}
       
   214 			break;
       
   215 		default:
       
   216 			break;
       
   217 		}
       
   218 #if defined(LOGGING)
       
   219 	_LIT(KLog2,"CPcWindowMain::PointerDown  FAILED  State=%d  SubState=%d");
       
   220 	iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState());
       
   221 #endif
       
   222 	return(EFailed);
       
   223 	}
       
   224 
       
   225 TPointerCheckRet CPcWindowMain::DragDrop()
       
   226 	{
       
   227 #if defined(LOGGING)
       
   228 	_LIT(KLog1,"CPcWindowMain::DragDrop  State=%d  SubState=%d");
       
   229 	iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState());
       
   230 #endif
       
   231 	switch(iTest->State())
       
   232 		{
       
   233 		case EDragDropCapture:
       
   234 		case EDragDropCaptureAllGroups:
       
   235 			switch(iTest->SubState())
       
   236 				{
       
   237 				case EMainWindow:
       
   238 					return(EOkay);
       
   239 				default:
       
   240 					break;
       
   241 				}
       
   242 			break;
       
   243 		default:
       
   244 			break;
       
   245 		}
       
   246 #if defined(LOGGING)
       
   247 	_LIT(KLog2,"CPcWindowMain::DragDrop  FAILED  State=%d  SubState=%d");
       
   248 	iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState());
       
   249 #endif
       
   250 	return(EFailed);
       
   251 	}
       
   252 
       
   253 void CPcWindowMain::Draw()
       
   254 	{
       
   255 	TBuf<0x40> buf;
       
   256 	if (iTest->State()==ECaptureDisabled)
       
   257 		{
       
   258 		switch(iTest->SubState())
       
   259 			{
       
   260 			case EMainWindow:
       
   261 				buf.Copy(ClickOnMe);
       
   262 				break;
       
   263 			}
       
   264 		}
       
   265 	else
       
   266 		{
       
   267 		switch(iTest->SubState())
       
   268 			{
       
   269 			case EMainWindow:
       
   270 				buf.Copy(ClickOnMe);
       
   271 				break;
       
   272 			case EChildWindow:
       
   273 			case EOtherGroup:
       
   274 			case EOtherSession:
       
   275 				break;
       
   276 			case ERootWindow:
       
   277 				{
       
   278 				_LIT(ClickOnRoot,"Click on the root window");
       
   279 				if (iTest->State()<ENormalCaptureWithoutFocus)
       
   280 					buf.Copy(ClickOnRoot);
       
   281 				else
       
   282 					{
       
   283 					_LIT(AndEscape,", then press <Escape>");
       
   284 					buf.Copy(ClickOnRoot);
       
   285 					buf.Append(AndEscape);
       
   286 					}
       
   287 				}
       
   288 				break;
       
   289 			}
       
   290 		}
       
   291 	CPcWindowBase::Draw(buf);
       
   292 	}
       
   293 
       
   294 void CPcWindowMain::WinKeyL(const TKeyEvent &aKey,const TTime &)
       
   295 	{
       
   296 	switch(aKey.iCode)
       
   297 		{
       
   298 		case EKeyEscape:
       
   299 			iTest->AbortTests();
       
   300 			break;
       
   301 		case EKeyEnter:
       
   302 			if (iTest->SubState()==ERootWindow)
       
   303 				iTest->IncSubStateL(EFalse);
       
   304 			break;
       
   305 		}
       
   306 	}
       
   307 
       
   308 //
       
   309 
       
   310 CPcWindowChild::CPcWindowChild(CTPointerCapture *aTest) : CPcWindowBase(aTest)
       
   311 	{
       
   312 	iBack=TRgb::Gray256(85);
       
   313 	}
       
   314 
       
   315 TPointerCheckRet CPcWindowChild::PointerDown()
       
   316 	{
       
   317 #if defined(LOGGING)
       
   318 	_LIT(KLog1,"CPcWindowChild::PointerDown  State=%d  SubState=%d");
       
   319 	iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState());
       
   320 #endif
       
   321 	switch(iTest->State())
       
   322 		{
       
   323 		case ECaptureDisabled:
       
   324 			break;
       
   325 		default:
       
   326 			switch(iTest->SubState())
       
   327 				{
       
   328 				case EChildWindow:
       
   329 					return(EOkay);
       
   330 				default:
       
   331 					break;
       
   332 				}
       
   333 			break;
       
   334 		}
       
   335 #if defined(LOGGING)
       
   336 	_LIT(KLog2,"CPcWindowChild::PointerDown  FAILED  State=%d  SubState=%d");
       
   337 	iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState());
       
   338 #endif
       
   339 	return(EFailed);
       
   340 	}
       
   341 
       
   342 TPointerCheckRet CPcWindowChild::DragDrop()
       
   343 	{
       
   344 #if defined(LOGGING)
       
   345 	_LIT(KLog1,"CPcWindowChild::PointerDown  State=%d  SubState=%d");
       
   346 	iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState());
       
   347 #endif
       
   348 	switch(iTest->State())
       
   349 		{
       
   350 		case EDragDropCapture:
       
   351 		case EDragDropCaptureAllGroups:
       
   352 			switch(iTest->SubState())
       
   353 				{
       
   354 				case EChildWindow:
       
   355 					return(EOkay);
       
   356 				default:
       
   357 					break;
       
   358 				}
       
   359 			break;
       
   360 		default:
       
   361 			break;
       
   362 		}
       
   363 #if defined(LOGGING)
       
   364 	_LIT(KLog2,"CPcWindowChild::PointerDown  FAILED  State=%d  SubState=%d");
       
   365 	iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState());
       
   366 #endif
       
   367 	return(EFailed);
       
   368 	}
       
   369 
       
   370 void CPcWindowChild::Draw()
       
   371 	{
       
   372 	TBuf<0x40> buf;
       
   373 	if (iTest->State()!=ECaptureDisabled)
       
   374 		{
       
   375 		switch(iTest->SubState())
       
   376 			{
       
   377 			case EChildWindow:
       
   378 				buf.Copy(ClickOnMe);
       
   379 				break;
       
   380 			default:
       
   381 				break;
       
   382 			}
       
   383 		}
       
   384 	CPcWindowBase::Draw(buf);
       
   385 	}
       
   386 
       
   387 //
       
   388 
       
   389 CPcWindowNickFocusGroup::CPcWindowNickFocusGroup(CTPointerCapture *aTest, CTClient *aClient) : CTWindowGroup(aClient), iTest(aTest)
       
   390 	{
       
   391 	}
       
   392 
       
   393 void CPcWindowNickFocusGroup::KeyL(const TKeyEvent &aKey,const TTime &)
       
   394 	{
       
   395 	if (aKey.iCode==EKeyEscape)
       
   396 		iTest->IncSubStateL(EFalse);
       
   397 	}
       
   398 
       
   399 //
       
   400 
       
   401 CPcWindowAltGroup::CPcWindowAltGroup(CTPointerCapture *aTest) : CPcWindowBase(aTest)
       
   402 	{
       
   403 	iBack=TRgb::Gray256(236);
       
   404 	}
       
   405 
       
   406 TPointerCheckRet CPcWindowAltGroup::PointerDown()
       
   407 	{
       
   408 #if defined(LOGGING)
       
   409 	_LIT(KLog1,"CPcWindowAltGroup::PointerDown  State=%d  SubState=%d");
       
   410 	iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState());
       
   411 #endif
       
   412 	switch(iTest->State())
       
   413 		{
       
   414 		case ECaptureDisabled:
       
   415 			if (iTest->SubState()==EChildWindow)
       
   416 				return(EOkay);
       
   417 			break;
       
   418 		case ENormalCapture:
       
   419 		case EDragDropCapture:
       
   420 		case ENormalCaptureWithoutFocus:
       
   421 			switch(iTest->SubState())
       
   422 				{
       
   423 				case EOtherGroup:
       
   424 					return(EOkay);
       
   425 				default:
       
   426 					break;
       
   427 				}
       
   428 			break;
       
   429 		default:
       
   430 			break;
       
   431 		}
       
   432 #if defined(LOGGING)
       
   433 	_LIT(KLog2,"CPcWindowAltGroup::PointerDown  FAILED  State=%d  SubState=%d");
       
   434 	iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState());
       
   435 #endif
       
   436 	return(EFailed);
       
   437 	}
       
   438 
       
   439 TPointerCheckRet CPcWindowAltGroup::DragDrop()
       
   440 	{
       
   441 #if defined(LOGGING)
       
   442 	_LIT(KLog1,"CPcWindowAltGroup::DragDrop  State=%d  SubState=%d");
       
   443 	iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState());
       
   444 #endif
       
   445 	switch(iTest->State())
       
   446 		{
       
   447 		case EDragDropCapture:
       
   448 		case EDragDropCaptureAllGroups:
       
   449 			switch(iTest->SubState())
       
   450 				{
       
   451 				case EOtherGroup:
       
   452 					return(EOkay);
       
   453 				default:
       
   454 					break;
       
   455 				}
       
   456 			break;
       
   457 		default:
       
   458 			break;
       
   459 		}
       
   460 #if defined(LOGGING)
       
   461 	_LIT(KLog2,"CPcWindowAltGroup::DragDrop  FAILED  State=%d  SubState=%d");
       
   462 	iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState());
       
   463 #endif
       
   464 	return(EFailed);
       
   465 	}
       
   466 
       
   467 void CPcWindowAltGroup::Draw()
       
   468 	{
       
   469 	TBuf<0x40> buf;
       
   470 	if (iTest->State()==ECaptureDisabled)
       
   471 		{
       
   472 		switch(iTest->SubState())
       
   473 			{
       
   474 			case EMainWindow:
       
   475 				break;
       
   476 			case EChildWindow:
       
   477 				buf.Copy(ClickOnMe);
       
   478 				break;
       
   479 			}
       
   480 		}
       
   481 	else
       
   482 		{
       
   483 		switch(iTest->SubState())
       
   484 			{
       
   485 			case EOtherGroup:
       
   486 				buf.Copy(ClickOnMe);
       
   487 				break;
       
   488 			default:
       
   489 				break;
       
   490 			}
       
   491 		}
       
   492 	CPcWindowBase::Draw(buf);
       
   493 	}
       
   494 
       
   495 //
       
   496 
       
   497 CPcWindowAltConnection::CPcWindowAltConnection(CTPointerCapture *aTest) : CPcWindowBase(aTest)
       
   498 	{
       
   499 	iBack=TRgb::Gray256(236);
       
   500 	}
       
   501 
       
   502 TPointerCheckRet CPcWindowAltConnection::PointerDown()
       
   503 	{
       
   504 #if defined(LOGGING)
       
   505 	_LIT(KLog1,"CPcWindowAltConnection::PointerDown  State=%d  SubState=%d");
       
   506 	iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState());
       
   507 #endif
       
   508 	switch(iTest->State())
       
   509 		{
       
   510 		case ECaptureDisabled:
       
   511 			if (iTest->SubState()==EChildWindow)
       
   512 				return(EOkay);
       
   513 			break;
       
   514 		case ENormalCapture:
       
   515 		case EDragDropCapture:
       
   516 		case ENormalCaptureWithoutFocus:
       
   517 			switch(iTest->SubState())
       
   518 				{
       
   519 				case EOtherSession:
       
   520 					return(EOkay);
       
   521 				default:
       
   522 					break;
       
   523 				}
       
   524 			break;
       
   525 		default:
       
   526 			break;
       
   527 		}
       
   528 #if defined(LOGGING)
       
   529 	_LIT(KLog2,"CPcWindowAltConnection::PointerDown  FAILED  State=%d  SubState=%d");
       
   530 	iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState());
       
   531 #endif
       
   532 	return(EFailed);
       
   533 	}
       
   534 
       
   535 TPointerCheckRet CPcWindowAltConnection::DragDrop()
       
   536 	{
       
   537 #if defined(LOGGING)
       
   538 	_LIT(KLog1,"CPcWindowAltConnection::DragDrop  State=%d  SubState=%d");
       
   539 	iTest->LOG_MESSAGE3(KLog1,iTest->State(),iTest->SubState());
       
   540 #endif
       
   541 	switch(iTest->State())
       
   542 		{
       
   543 		case EDragDropCapture:
       
   544 		case EDragDropCaptureAllGroups:
       
   545 			switch(iTest->SubState())
       
   546 				{
       
   547 				case EOtherSession:
       
   548 					return(EOkay);
       
   549 				default:
       
   550 					break;
       
   551 				}
       
   552 			break;
       
   553 		default:
       
   554 			break;
       
   555 		}
       
   556 #if defined(LOGGING)
       
   557 	_LIT(KLog2,"CPcWindowAltConnection::DragDrop  FAILED  State=%d  SubState=%d");
       
   558 	iTest->LOG_MESSAGE3(KLog2,iTest->State(),iTest->SubState());
       
   559 #endif
       
   560 	return(EFailed);
       
   561 	}
       
   562 
       
   563 void CPcWindowAltConnection::Draw()
       
   564 	{
       
   565 	TBuf<0x40> buf;
       
   566 	if (iTest->State()!=ECaptureDisabled)
       
   567 		{
       
   568 		switch(iTest->SubState())
       
   569 			{
       
   570 			case EOtherSession:
       
   571 				buf.Copy(ClickOnMe);
       
   572 				break;
       
   573 			default:
       
   574 				break;
       
   575 			}
       
   576 		}
       
   577 	CPcWindowBase::Draw(buf);
       
   578 	}
       
   579 
       
   580 //
       
   581 
       
   582 CTPointerCapture::CTPointerCapture(CTestStep* aStep) : CTWsGraphicsBase(aStep)
       
   583 	{
       
   584 	iSubState=0;
       
   585 	iFailed=EFalse;
       
   586 	}
       
   587 
       
   588 CTPointerCapture::~CTPointerCapture()
       
   589 	{
       
   590 	delete iNickFocusBlankWin;
       
   591 	delete iNickFocusGroup;
       
   592 	delete iAltConnectionWin;
       
   593 	delete iAltConnection;
       
   594 	delete iChildWin;
       
   595 	delete iMainWin;
       
   596 	delete iMainGroup;
       
   597 	delete iAltGroupWin;
       
   598 	delete iAltGroup;
       
   599 	}
       
   600 
       
   601 void CTPointerCapture::TestFailed()
       
   602 	{
       
   603 	if (iFailed)
       
   604 		{
       
   605 		_LIT(KLog,"Test Failed  State=%d  SubState=%d");
       
   606 		LOG_MESSAGE3(KLog,iTest->iState,iSubState);
       
   607 		}
       
   608 	__ASSERT_DEBUG(iFailed==EFalse,AutoPanic(ETManPanicPcFailed));
       
   609 	TInt dRet=1;
       
   610 #if !defined(DISABLE_FAIL_DIALOG)
       
   611 	Client()->iGroup->GroupWin()->SetOrdinalPosition(0,10);	// Put error dialog on top of test windows
       
   612 	TRAPD(err,dRet=doTestFailedL());
       
   613 	Client()->iGroup->GroupWin()->SetOrdinalPosition(0,0);
       
   614 #endif
       
   615 	switch(dRet)
       
   616 		{
       
   617 		case 0:
       
   618 			break;
       
   619 		case 1:
       
   620 			iFailed=ETrue;
       
   621 			NextTest();
       
   622 			break;
       
   623 		}
       
   624 	}
       
   625 
       
   626 TInt CTPointerCapture::doTestFailedL()
       
   627 	{
       
   628 	CTDialog *dialog=new(ELeave) CTDialog();
       
   629 	dialog->SetTitle(_L("Pointer capture test failed"));
       
   630 	dialog->SetNumButtons(2);
       
   631 	dialog->SetButtonText(0,_L("Retest"));
       
   632 	dialog->SetButtonText(1,_L("Fail"));
       
   633 	dialog->ConstructLD(*Client()->iGroup,*Client()->iGc);
       
   634 	return dialog->Display();
       
   635 	}
       
   636 
       
   637 TInt CTPointerCapture::State() const
       
   638 	{
       
   639 	return(iTest->iState);
       
   640 	}
       
   641 
       
   642 TInt CTPointerCapture::SubState() const
       
   643 	{
       
   644 	return(iSubState);
       
   645 	}
       
   646 
       
   647 void CTPointerCapture::doIncSubStateL()
       
   648 	{
       
   649 	iSubState++;
       
   650 	TInt max=0;
       
   651 	switch(iTest->iState)
       
   652 		{
       
   653 		case ECaptureDisabled:
       
   654 			max=ESubStates1;
       
   655 			break;
       
   656 		case ENormalCapture:
       
   657 			max=ESubStates2;
       
   658 			break;
       
   659 		case ECaptureAllGroups:
       
   660 			max=ESubStates3;
       
   661 			break;
       
   662 		case EDragDropCapture:
       
   663 			max=ESubStates4;
       
   664 			break;
       
   665 		case EDragDropCaptureAllGroups:
       
   666 			max=ESubStates5;
       
   667 			break;
       
   668 		case ENormalCaptureWithoutFocus:
       
   669 			max=ESubStates6;
       
   670 			break;
       
   671 		}
       
   672 	//SubState 4 has been broken by something in the framework
       
   673 	if (iSubState==max || iSubState==4)
       
   674 		{
       
   675 	#if defined(LOGGING)
       
   676 		_LIT(KLog,"IncState  OldState=%d  SubState=%d");
       
   677 		LOG_MESSAGE3(KLog,iTest->iState,iSubState);
       
   678 	#endif
       
   679 		NextTest();
       
   680 		}
       
   681 	StateChanged();
       
   682 	TheClient->WaitForRedrawsToFinish();
       
   683 	if (iSubState>0)
       
   684 		SendEventsL();
       
   685 	}
       
   686 
       
   687 void CTPointerCapture::GotDDL()
       
   688 	{
       
   689 	if (iDDState==DDStateWaiting)
       
   690 		doIncSubStateL();
       
   691 	else
       
   692 		iDDState=DDStateGot;
       
   693 	}
       
   694 
       
   695 void CTPointerCapture::IncSubStateL(TBool aNeedsDD)
       
   696 	{
       
   697 	if (!aNeedsDD)
       
   698 		{
       
   699 		if (iDDState!=DDStateNull)
       
   700 			TestFailed();
       
   701 		else
       
   702 			doIncSubStateL();
       
   703 		}
       
   704 	else if (iDDState==DDStateGot)
       
   705 		doIncSubStateL();
       
   706 	else
       
   707 		iDDState=DDStateWaiting;
       
   708 	}
       
   709 
       
   710 void CTPointerCapture::StateChanged()
       
   711 	{
       
   712 	iDDState=DDStateNull;
       
   713 	iChildWin->SubStateChanged();
       
   714 	iMainWin->SubStateChanged();
       
   715 	iAltGroupWin->SubStateChanged();
       
   716 	iAltConnectionWin->SubStateChanged();
       
   717 	}
       
   718 
       
   719 void CTPointerCapture::AbortTests()
       
   720 	{
       
   721 	iTest->iState=99;
       
   722 	}
       
   723 
       
   724 void CTPointerCapture::NextTest()
       
   725 	{
       
   726 	TEST(!iFailed);
       
   727 	if (iFailed)
       
   728 		{
       
   729 		_LIT(KLog,"SubTest %d failed");
       
   730 		LOG_MESSAGE2(KLog,iTest->iState);
       
   731 		}
       
   732 	++iTest->iState;
       
   733 	iSubState=0;
       
   734 	iFailed=EFalse;
       
   735 	CaseComplete();
       
   736 	_LIT(KLog,"Done NextTest  NewSubTest %d");
       
   737 	LOG_MESSAGE2(KLog,iTest->iState);
       
   738 	}
       
   739 
       
   740 void CTPointerCapture::ConstructL()
       
   741 	{
       
   742 	TheClient->iWs.SetPointerCursorArea(iTest->iNormalPointerCursorArea);
       
   743 	iScreenSize=TSize(TheClient->iScreen->SizeInPixels());
       
   744 	TInt winWidth2=iScreenSize.iWidth/2-EWinBorderSize*2;
       
   745 	TInt winWidth4=iScreenSize.iWidth/4-EWinBorderSize*2;
       
   746 	TInt winHeight=iScreenSize.iHeight/2-EWinBorderSize*2;
       
   747 //
       
   748 	iMainGroup=new(ELeave) CTWindowGroup(Client());
       
   749 	iMainGroup->ConstructL();
       
   750 	iMainGroup->GroupWin()->SetOrdinalPosition(0,1);
       
   751 	iMainWin=new(ELeave) CPcWindowMain(this);
       
   752 	iMainWin->SetUpL(TPoint(EWinBorderSize,EWinBorderSize) ,TSize(winWidth2,winHeight) ,iMainGroup);
       
   753 	iMainGroup->SetCurrentWindow(iMainWin);
       
   754 	iChildWin=new(ELeave) CPcWindowChild(this);
       
   755 	iChildWin->SetUpL(TPoint(0,winHeight/2) ,TSize(winWidth2,winHeight/2) ,iMainWin);
       
   756 //
       
   757 	iAltGroup=new(ELeave) CTWindowGroup(Client());
       
   758 	iAltGroup->ConstructL();
       
   759 	iAltGroup->GroupWin()->SetOrdinalPosition(0,1);
       
   760 	iAltGroup->GroupWin()->EnableReceiptOfFocus(EFalse);
       
   761 	iAltGroupWin=new(ELeave) CPcWindowAltGroup(this);
       
   762 	iAltGroupWin->SetUpL(TPoint(iScreenSize.iWidth/2+EWinBorderSize,EWinBorderSize) ,TSize(winWidth4,winHeight) ,iAltGroup);
       
   763 //
       
   764 	iAltConnection=new(ELeave) CPcConnection(this);
       
   765 	iAltConnection->ConstructL();
       
   766 	iAltConnectionWin=new(ELeave) CPcWindowAltConnection(this);
       
   767 	iAltConnectionWin->SetUpL(TPoint(iScreenSize.iWidth/4*3+EWinBorderSize,EWinBorderSize) ,TSize(winWidth4,winHeight),iAltConnection->iGroup,*iAltConnection->iGc);
       
   768 	iTest->DelayIfFullRomL();
       
   769 	SetSelfDrive(ETrue);
       
   770 	}
       
   771 
       
   772 void CTPointerCapture::NickFocusL()
       
   773 	{
       
   774 	iNickFocusGroup=new(ELeave) CPcWindowNickFocusGroup(this,Client());
       
   775 	iNickFocusGroup->ConstructL();
       
   776 	iNickFocusGroup->GroupWin()->SetOrdinalPosition(0,2);
       
   777 	iNickFocusBlankWin=new(ELeave) CTBlankWindow();
       
   778 	iNickFocusBlankWin->ConstructL(*iNickFocusGroup);
       
   779 	iNickFocusBlankWin->SetSize(TSize(1,1));
       
   780 	iNickFocusBlankWin->Activate();
       
   781 	}
       
   782 
       
   783 void CTPointerCapture::SetCapture(TInt aCaptureFlags)
       
   784 	{
       
   785 #if defined(LOGGING)
       
   786 	_LIT(KLog,"Change Capture  State=%d  CaptureFlags=0x%x");
       
   787 	LOG_MESSAGE3(KLog,iTest->iState,aCaptureFlags);
       
   788 #endif
       
   789 	iMainWin->Win()->SetPointerCapture(aCaptureFlags);
       
   790 	}
       
   791 
       
   792 void CTPointerCapture::SendEventsL()
       
   793 	{
       
   794 #if defined(LOGGING)
       
   795 	_LIT(KLog,"SendEvent  State=%d  SubState=%d");
       
   796 	LOG_MESSAGE3(KLog,iTest->iState,iSubState);
       
   797 #endif
       
   798 	switch (iSubState)
       
   799 		{
       
   800 	case 0:
       
   801 		iTest->SimulatePointerDownUp(iScreenSize.iWidth/4,iScreenSize.iHeight/8+EWinBorderSize/2);
       
   802 		break;
       
   803 	case 1:
       
   804 		if (iTest->iState>ECaptureDisabled)
       
   805 			{
       
   806 			iTest->SimulatePointerDownUp(iScreenSize.iWidth/4,3*iScreenSize.iHeight/8-EWinBorderSize/2);
       
   807 			break;
       
   808 			}
       
   809 	case 2:
       
   810 		iTest->SimulatePointerDownUp(5*iScreenSize.iWidth/8,iScreenSize.iHeight/4);
       
   811 		break;
       
   812 	case 3:
       
   813 		iTest->SimulatePointerDownUp(7*iScreenSize.iWidth/8,iScreenSize.iHeight/4);
       
   814 		break;
       
   815 	case 4:
       
   816 		if (iTest->IsFullRomL())
       
   817 			iTest->SimulateKeyDownUp(EStdKeyEnter);
       
   818 		else
       
   819 			iTest->SimulatePointerDownUp(0,0);
       
   820 		if (iTest->iState==ENormalCaptureWithoutFocus)
       
   821 			{
       
   822 			iTest->SimulateKeyDownUp(EStdKeyEscape);
       
   823 			break;
       
   824 			}
       
   825 		break;
       
   826 	default:
       
   827 		TEST(EFalse);
       
   828 		}
       
   829 	TheClient->iWs.Flush();
       
   830 	}
       
   831 
       
   832 void CTPointerCapture::RunTestCaseL(TInt /*aCurTestCase*/)
       
   833 	{
       
   834 	_LIT(TestNoCapture,"No capture");
       
   835 	_LIT(TestNormalCapture,"Normal capture");
       
   836 	_LIT(TestAllGroups,"All groups");
       
   837 	_LIT(TestDragDrop,"Drag & Drop");
       
   838 	_LIT(TestDragDropAllGroups,"Drag & Drop All groups");
       
   839 	_LIT(TestWithoutFocus,"Without focus");
       
   840 	StateChanged();
       
   841 	
       
   842 	if (!TestBase()->ConfigurationSupportsPointerEventTesting())
       
   843 	    {
       
   844 	    INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing"));
       
   845 	    TestComplete();
       
   846 	    return;
       
   847 	    }
       
   848 	
       
   849 	((CTPointerCaptureStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
       
   850 	switch(iTest->iState)
       
   851 		{
       
   852 /**
       
   853 
       
   854   @SYMTestCaseID GRAPHICS-WSERV-0290
       
   855   
       
   856   @SYMDEF             DEF081259
       
   857  
       
   858   @SYMTestCaseDesc Test pointer capture can be disabled
       
   859     
       
   860   @SYMTestPriority High
       
   861  
       
   862   @SYMTestStatus Implemented
       
   863  
       
   864   @SYMTestActions Disable the pointer capture to the screen and simulate
       
   865   					capture with the pointer
       
   866   
       
   867   @SYMTestExpectedResults The pointer capture has been disabled
       
   868  
       
   869 */
       
   870 		case ECaptureDisabled:
       
   871 			((CTPointerCaptureStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0290"));
       
   872 			if (TheClient->iScreen->GetScreenNumber()>0)
       
   873 				{
       
   874 				_LIT(KLog,"Cannot run this test on the 2nd screen - all pointer events goto the 1st screen");
       
   875 				LOG_MESSAGE(KLog);
       
   876 				TestComplete();
       
   877 				}
       
   878 			iTest->LogSubTest(TestNoCapture);
       
   879 			SetCapture(RWindowBase::TCaptureDisabled);
       
   880 			break;
       
   881 /**
       
   882 
       
   883   @SYMTestCaseID GRAPHICS-WSERV-0291
       
   884   
       
   885   @SYMDEF             DEF081259
       
   886  
       
   887   @SYMTestCaseDesc Test pointer capture can be enabled
       
   888     
       
   889   @SYMTestPriority High
       
   890  
       
   891   @SYMTestStatus Implemented
       
   892  
       
   893   @SYMTestActions Enable the pointer capture to the screen and simulate
       
   894   					capture with the pointer
       
   895   
       
   896   @SYMTestExpectedResults The pointer capture has been enabled and works
       
   897   							correctly
       
   898  
       
   899 */
       
   900 		case ENormalCapture:
       
   901 			((CTPointerCaptureStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0291"));
       
   902 			iTest->LogSubTest(TestNormalCapture);
       
   903 			SetCapture(RWindowBase::TCaptureEnabled);
       
   904 			break;
       
   905 /**
       
   906 
       
   907   @SYMTestCaseID GRAPHICS-WSERV-0292
       
   908   
       
   909   @SYMDEF             DEF081259
       
   910  
       
   911   @SYMTestCaseDesc Test pointer capture can be enabled for 
       
   912   					windows belonging to any group
       
   913     
       
   914   @SYMTestPriority High
       
   915  
       
   916   @SYMTestStatus Implemented
       
   917  
       
   918   @SYMTestActions Enable the pointer capture to all windows and simulate
       
   919   					capture with the pointer
       
   920   
       
   921   @SYMTestExpectedResults The pointer capture has been enabled and works
       
   922   							correctly
       
   923  
       
   924 */
       
   925 		case ECaptureAllGroups:
       
   926 			((CTPointerCaptureStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0292"));
       
   927 			iTest->LogSubTest(TestAllGroups);
       
   928 			SetCapture(RWindowBase::TCaptureEnabled|RWindowBase::TCaptureFlagAllGroups);
       
   929 			break;
       
   930 /**
       
   931 
       
   932   @SYMTestCaseID GRAPHICS-WSERV-0293
       
   933   
       
   934   @SYMDEF             DEF081259
       
   935  
       
   936   @SYMTestCaseDesc Test drag and drop pointer capture can be enabled for 
       
   937   					windows belonging to any group
       
   938     
       
   939   @SYMTestPriority High
       
   940  
       
   941   @SYMTestStatus Implemented
       
   942  
       
   943   @SYMTestActions Enable drag and drop  pointer capture to all windows and simulate
       
   944   					capture with the pointer
       
   945   
       
   946   @SYMTestExpectedResults The pointer capture has been enabled and works
       
   947   							correctly
       
   948  
       
   949 */
       
   950 		case EDragDropCapture:
       
   951 			((CTPointerCaptureStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0293"));
       
   952 			iTest->LogSubTest(TestDragDrop);
       
   953 			SetCapture(RWindowBase::TCaptureDragDrop&~RWindowBase::TCaptureFlagAllGroups);
       
   954 			break;
       
   955 /**
       
   956 
       
   957   @SYMTestCaseID GRAPHICS-WSERV-0294
       
   958   
       
   959   @SYMDEF             DEF081259
       
   960  
       
   961   @SYMTestCaseDesc Test drag and drop pointer capture can be enabled
       
   962     
       
   963   @SYMTestPriority High
       
   964  
       
   965   @SYMTestStatus Implemented
       
   966  
       
   967   @SYMTestActions Enable drag and drop  pointer capture and simulate
       
   968   					capture with the pointer
       
   969   
       
   970   @SYMTestExpectedResults The pointer capture has been enabled and works
       
   971   							correctly
       
   972  
       
   973 */
       
   974 		case EDragDropCaptureAllGroups:
       
   975 			((CTPointerCaptureStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0294"));
       
   976 			iTest->LogSubTest(TestDragDropAllGroups);
       
   977 			SetCapture(RWindowBase::TCaptureDragDrop);
       
   978 			break;
       
   979 /**
       
   980 
       
   981   @SYMTestCaseID GRAPHICS-WSERV-0295
       
   982   
       
   983   @SYMDEF             DEF081259
       
   984  
       
   985   @SYMTestCaseDesc Test pointer capture can be enabled
       
   986     
       
   987   @SYMTestPriority High
       
   988  
       
   989   @SYMTestStatus Implemented
       
   990  
       
   991   @SYMTestActions Enable the pointer capture to the screen and simulate capture
       
   992   					with the pointer when the screen does not have the focus
       
   993   
       
   994   @SYMTestExpectedResults The pointer capture has been enabled and works
       
   995   							correctly
       
   996  
       
   997 */
       
   998 		case ENormalCaptureWithoutFocus:
       
   999 			((CTPointerCaptureStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0295"));
       
  1000 			iTest->LogSubTest(TestWithoutFocus);
       
  1001 			NickFocusL();
       
  1002 			SetCapture(RWindowBase::TCaptureEnabled);
       
  1003 			break;
       
  1004 		default:
       
  1005 			((CTPointerCaptureStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
       
  1006 			((CTPointerCaptureStep*)iStep)->CloseTMSGraphicsStep();
       
  1007 			TestComplete();
       
  1008 			return;
       
  1009 		}
       
  1010 	((CTPointerCaptureStep*)iStep)->RecordTestResultL();
       
  1011 	SendEventsL();
       
  1012 	}
       
  1013 
       
  1014 __WS_CONSTRUCT_STEP__(PointerCapture)