os/graphics/windowing/windowserver/test/tman/TMPNTCAP.CPP
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// Test pointer capture
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include <e32std.h>
sl@0
    19
#include <e32svr.h>
sl@0
    20
#include "W32STD.H"
sl@0
    21
#include "../tlib/testbase.h"
sl@0
    22
#include "TMAN.H"
sl@0
    23
sl@0
    24
enum TTestState
sl@0
    25
	{
sl@0
    26
	ECaptureDisabled,
sl@0
    27
	ENormalCapture,
sl@0
    28
	ECaptureAllGroups,
sl@0
    29
	EDragDropCapture,
sl@0
    30
	EDragDropCaptureAllGroups,
sl@0
    31
	ENormalCaptureWithoutFocus,
sl@0
    32
	};
sl@0
    33
sl@0
    34
enum TTestSubState
sl@0
    35
	{
sl@0
    36
	EMainWindow,
sl@0
    37
	EChildWindow,
sl@0
    38
	EOtherGroup,
sl@0
    39
	EOtherSession,
sl@0
    40
	ERootWindow,
sl@0
    41
	};
sl@0
    42
sl@0
    43
enum TPointerCheckRet
sl@0
    44
	{
sl@0
    45
	EFailed,
sl@0
    46
	EOkay,
sl@0
    47
	ENeedsDDEvent,
sl@0
    48
	};
sl@0
    49
sl@0
    50
const TInt ESubStates1=2;
sl@0
    51
const TInt ESubStates2=5;
sl@0
    52
const TInt ESubStates3=5;
sl@0
    53
const TInt ESubStates4=5;
sl@0
    54
const TInt ESubStates5=5;
sl@0
    55
const TInt ESubStates6=5;
sl@0
    56
sl@0
    57
const TInt EWinBorderSize=10;
sl@0
    58
sl@0
    59
class CPcWindowBase;
sl@0
    60
class TPointerCaptureTest;
sl@0
    61
sl@0
    62
class CPcConnection : public CTClient
sl@0
    63
	{
sl@0
    64
public:
sl@0
    65
	CPcConnection(TPointerCaptureTest *aTest);
sl@0
    66
	~CPcConnection();
sl@0
    67
	virtual void ConstructL();
sl@0
    68
protected:
sl@0
    69
	TPointerCaptureTest *iTest;
sl@0
    70
	};
sl@0
    71
sl@0
    72
class CPcWindowBase : public CTWin
sl@0
    73
	{
sl@0
    74
public:
sl@0
    75
	CPcWindowBase(TPointerCaptureTest *aTest);
sl@0
    76
	void SetUpL(TPoint pos,TSize size,CTWinBase *parent);
sl@0
    77
	void SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc);
sl@0
    78
	void Draw(TDesC &aBuf);
sl@0
    79
	void PointerL(const TPointerEvent &pointer,const TTime &);
sl@0
    80
	void DragDropL(const TPointerEvent &pointer,const TTime &);
sl@0
    81
	virtual TPointerCheckRet PointerDown()=0;
sl@0
    82
	virtual TPointerCheckRet DragDrop()=0;
sl@0
    83
	virtual void SubStateChanged();
sl@0
    84
protected:
sl@0
    85
	TPointerCaptureTest *iTest;
sl@0
    86
	TRgb iBack;
sl@0
    87
	};
sl@0
    88
sl@0
    89
class CPcWindowChild : public CPcWindowBase
sl@0
    90
	{
sl@0
    91
public:
sl@0
    92
	CPcWindowChild(TPointerCaptureTest *aTest);
sl@0
    93
	void Draw();
sl@0
    94
	TPointerCheckRet PointerDown();
sl@0
    95
	TPointerCheckRet DragDrop();
sl@0
    96
	};
sl@0
    97
sl@0
    98
class CPcWindowMain : public CPcWindowBase
sl@0
    99
	{
sl@0
   100
public:
sl@0
   101
	CPcWindowMain(TPointerCaptureTest *aTest);
sl@0
   102
	void Draw();
sl@0
   103
	TPointerCheckRet PointerDown();
sl@0
   104
	TPointerCheckRet DragDrop();
sl@0
   105
	void WinKeyL(const TKeyEvent &aKey,const TTime &aTime);
sl@0
   106
	};
sl@0
   107
sl@0
   108
class CPcWindowAltGroup : public CPcWindowBase
sl@0
   109
	{
sl@0
   110
public:
sl@0
   111
	CPcWindowAltGroup(TPointerCaptureTest *aTest);
sl@0
   112
	void Draw();
sl@0
   113
	TPointerCheckRet PointerDown();
sl@0
   114
	TPointerCheckRet DragDrop();
sl@0
   115
	};
sl@0
   116
sl@0
   117
class CPcWindowNickFocusGroup : public CTWindowGroup
sl@0
   118
	{
sl@0
   119
public:
sl@0
   120
	CPcWindowNickFocusGroup(TPointerCaptureTest *aTest, CTClient *aClient);
sl@0
   121
	void KeyL(const TKeyEvent &aKey,const TTime &aTime);
sl@0
   122
private:
sl@0
   123
	TPointerCaptureTest *iTest;
sl@0
   124
	};
sl@0
   125
sl@0
   126
class CPcWindowAltConnection : public CPcWindowBase
sl@0
   127
	{
sl@0
   128
public:
sl@0
   129
	CPcWindowAltConnection(TPointerCaptureTest *aTest);
sl@0
   130
	void Draw();
sl@0
   131
	TPointerCheckRet PointerDown();
sl@0
   132
	TPointerCheckRet DragDrop();
sl@0
   133
	};
sl@0
   134
sl@0
   135
class TPointerCaptureTest : public CTestBase
sl@0
   136
	{
sl@0
   137
private:
sl@0
   138
	enum TDState {DDStateNull, DDStateGot, DDStateWaiting};
sl@0
   139
public:
sl@0
   140
	TPointerCaptureTest();
sl@0
   141
	~TPointerCaptureTest();
sl@0
   142
	TestState DoTestL();
sl@0
   143
	void ConstructL();
sl@0
   144
	void NextTest();
sl@0
   145
	void AbortTests();
sl@0
   146
	TInt State() const;
sl@0
   147
	TInt SubState() const;
sl@0
   148
	void doIncSubState();
sl@0
   149
	void IncSubState(TBool aNeedsDD=EFalse);
sl@0
   150
	void GotDD();
sl@0
   151
	void StateChanged();
sl@0
   152
	void TestFailed();
sl@0
   153
	void NickFocusL();
sl@0
   154
	void SetCapture(TInt aCaptureFlags);
sl@0
   155
	void RestartTest();
sl@0
   156
private:
sl@0
   157
	TInt doTestFailedL();
sl@0
   158
private:
sl@0
   159
	CPcConnection *iAltConnection;
sl@0
   160
	CTWindowGroup *iMainGroup;
sl@0
   161
	CTWindowGroup *iAltGroup;
sl@0
   162
	CPcWindowChild *iChildWin;
sl@0
   163
	CPcWindowMain *iMainWin;
sl@0
   164
	CPcWindowAltGroup *iAltGroupWin;
sl@0
   165
	CPcWindowAltConnection *iAltConnectionWin;
sl@0
   166
	CPcWindowNickFocusGroup *iNickFocusGroup;
sl@0
   167
	CTBlankWindow *iNickFocusBlankWin;
sl@0
   168
	TInt iState;
sl@0
   169
	TInt iSubState;
sl@0
   170
	TDState iDDState;
sl@0
   171
public:
sl@0
   172
	TBool iFailed;
sl@0
   173
	};
sl@0
   174
sl@0
   175
GLDEF_C CTestBase *CreatePointerCaptureTest()
sl@0
   176
	{
sl@0
   177
	return(new(ELeave) TPointerCaptureTest());
sl@0
   178
	}
sl@0
   179
sl@0
   180
//
sl@0
   181
// CMcConnection
sl@0
   182
sl@0
   183
CPcConnection::CPcConnection(TPointerCaptureTest *aTest) : iTest(aTest)
sl@0
   184
	{
sl@0
   185
	}
sl@0
   186
sl@0
   187
CPcConnection::~CPcConnection()
sl@0
   188
	{
sl@0
   189
	}
sl@0
   190
sl@0
   191
void CPcConnection::ConstructL()
sl@0
   192
	{
sl@0
   193
	CTClient::ConstructL();
sl@0
   194
	iGroup=new(ELeave) CTWindowGroup(this);
sl@0
   195
	iGroup->ConstructL();
sl@0
   196
	iGroup->GroupWin()->SetOrdinalPosition(0,1);
sl@0
   197
	iGroup->GroupWin()->EnableReceiptOfFocus(EFalse);
sl@0
   198
	iWs.Flush();
sl@0
   199
	}
sl@0
   200
sl@0
   201
//
sl@0
   202
// CPcWindow, base class //
sl@0
   203
//
sl@0
   204
sl@0
   205
CPcWindowBase::CPcWindowBase(TPointerCaptureTest *aTest) : CTWin(), iTest(aTest)
sl@0
   206
	{
sl@0
   207
	}
sl@0
   208
sl@0
   209
void CPcWindowBase::SetUpL(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc)
sl@0
   210
	{
sl@0
   211
	ConstructExtLD(*parent,pos,size);
sl@0
   212
	iWin.SetBackgroundColor(iBack);
sl@0
   213
	Activate();
sl@0
   214
	AssignGC(aGc);
sl@0
   215
	}
sl@0
   216
sl@0
   217
void CPcWindowBase::SetUpL(TPoint pos,TSize size,CTWinBase *parent)
sl@0
   218
	{
sl@0
   219
	SetUpL(pos,size,parent,*iTest->Client()->iGc);
sl@0
   220
	}
sl@0
   221
sl@0
   222
void CPcWindowBase::SubStateChanged()
sl@0
   223
	{
sl@0
   224
	iWin.Invalidate();
sl@0
   225
	Client()->iWs.Flush();
sl@0
   226
	}
sl@0
   227
sl@0
   228
void CPcWindowBase::Draw(TDesC &aBuf)
sl@0
   229
	{
sl@0
   230
	iGc->Clear();
sl@0
   231
	iGc->SetPenColor(iBack.Gray4()>1 ? TRgb(0,0,0) : TRgb(255,255,255));
sl@0
   232
	iGc->DrawText(aBuf, TPoint(10,20));
sl@0
   233
	}
sl@0
   234
sl@0
   235
void CPcWindowBase::PointerL(const TPointerEvent &pointer,const TTime &)
sl@0
   236
	{
sl@0
   237
	if (pointer.iType==TPointerEvent::EButton1Down && !iTest->iFailed)
sl@0
   238
		{
sl@0
   239
		if (iTest->SubState()==ERootWindow)	// Root window click, must not be inside this window
sl@0
   240
			{
sl@0
   241
			if (TRect(Size()).Contains(pointer.iPosition))
sl@0
   242
				{
sl@0
   243
				iTest->TestFailed();
sl@0
   244
				return;
sl@0
   245
				}
sl@0
   246
			}
sl@0
   247
		TInt ret;
sl@0
   248
		if ((ret=PointerDown())==EFailed)
sl@0
   249
			iTest->TestFailed();
sl@0
   250
		else
sl@0
   251
			iTest->IncSubState(ret==ENeedsDDEvent);
sl@0
   252
		}
sl@0
   253
	}
sl@0
   254
sl@0
   255
void CPcWindowBase::DragDropL(const TPointerEvent &pointer,const TTime &)
sl@0
   256
	{
sl@0
   257
	switch(iTest->State())
sl@0
   258
		{
sl@0
   259
		case ECaptureDisabled:
sl@0
   260
		case ENormalCapture:
sl@0
   261
		case ECaptureAllGroups:
sl@0
   262
		case ENormalCaptureWithoutFocus:
sl@0
   263
			iTest->TestFailed();
sl@0
   264
			break;
sl@0
   265
		}
sl@0
   266
	if (pointer.iType==TPointerEvent::EButton1Down && !iTest->iFailed)
sl@0
   267
		{
sl@0
   268
		if (DragDrop()==EFailed)
sl@0
   269
			iTest->TestFailed();
sl@0
   270
		else
sl@0
   271
			iTest->GotDD();
sl@0
   272
		}
sl@0
   273
	}
sl@0
   274
//
sl@0
   275
sl@0
   276
CPcWindowMain::CPcWindowMain(TPointerCaptureTest *aTest) : CPcWindowBase(aTest)
sl@0
   277
	{
sl@0
   278
	iBack=TRgb::Gray256(236);
sl@0
   279
	}
sl@0
   280
sl@0
   281
TPointerCheckRet CPcWindowMain::PointerDown()
sl@0
   282
	{
sl@0
   283
	switch(iTest->State())
sl@0
   284
		{
sl@0
   285
		case ECaptureDisabled:
sl@0
   286
			if (iTest->SubState()==EMainWindow)
sl@0
   287
				return(EOkay);
sl@0
   288
			break;
sl@0
   289
		case ENormalCapture:
sl@0
   290
			switch(iTest->SubState())
sl@0
   291
				{
sl@0
   292
				case EMainWindow:
sl@0
   293
				case ERootWindow:
sl@0
   294
					return(EOkay);
sl@0
   295
				default:
sl@0
   296
					break;
sl@0
   297
				}
sl@0
   298
			break;
sl@0
   299
		case ECaptureAllGroups:
sl@0
   300
			switch(iTest->SubState())
sl@0
   301
				{
sl@0
   302
				case EMainWindow:
sl@0
   303
				case EOtherGroup:
sl@0
   304
				case EOtherSession:
sl@0
   305
				case ERootWindow:
sl@0
   306
					return(EOkay);
sl@0
   307
				default:
sl@0
   308
					break;
sl@0
   309
				}
sl@0
   310
			break;
sl@0
   311
		case EDragDropCapture:
sl@0
   312
			switch(iTest->SubState())
sl@0
   313
				{
sl@0
   314
				case EMainWindow:
sl@0
   315
					return(ENeedsDDEvent);
sl@0
   316
				case ERootWindow:
sl@0
   317
					return(EOkay);
sl@0
   318
				default:
sl@0
   319
					break;
sl@0
   320
				}
sl@0
   321
			break;
sl@0
   322
		case EDragDropCaptureAllGroups:
sl@0
   323
			switch(iTest->SubState())
sl@0
   324
				{
sl@0
   325
				case EMainWindow:
sl@0
   326
				case EOtherGroup:
sl@0
   327
				case EOtherSession:
sl@0
   328
					return(ENeedsDDEvent);
sl@0
   329
				case ERootWindow:
sl@0
   330
					return(EOkay);
sl@0
   331
				default:
sl@0
   332
					break;
sl@0
   333
				}
sl@0
   334
			break;
sl@0
   335
		case ENormalCaptureWithoutFocus:
sl@0
   336
			switch(iTest->SubState())
sl@0
   337
				{
sl@0
   338
				case EMainWindow:
sl@0
   339
					return(EOkay);
sl@0
   340
				default:
sl@0
   341
					break;
sl@0
   342
				}
sl@0
   343
			break;
sl@0
   344
		default:
sl@0
   345
			break;
sl@0
   346
		}
sl@0
   347
	return(EFailed);
sl@0
   348
	}
sl@0
   349
sl@0
   350
TPointerCheckRet CPcWindowMain::DragDrop()
sl@0
   351
	{
sl@0
   352
	switch(iTest->State())
sl@0
   353
		{
sl@0
   354
		case EDragDropCapture:
sl@0
   355
		case EDragDropCaptureAllGroups:
sl@0
   356
			switch(iTest->SubState())
sl@0
   357
				{
sl@0
   358
				case EMainWindow:
sl@0
   359
					return(EOkay);
sl@0
   360
				default:
sl@0
   361
					break;
sl@0
   362
				}
sl@0
   363
			break;
sl@0
   364
		default:
sl@0
   365
			break;
sl@0
   366
		}
sl@0
   367
	return(EFailed);
sl@0
   368
	}
sl@0
   369
sl@0
   370
void CPcWindowMain::Draw()
sl@0
   371
	{
sl@0
   372
	TBuf<0x40> buf;
sl@0
   373
	if (iTest->State()==ECaptureDisabled)
sl@0
   374
		{
sl@0
   375
		switch(iTest->SubState())
sl@0
   376
			{
sl@0
   377
			case EMainWindow:
sl@0
   378
				buf.Copy(_L("Click on me"));
sl@0
   379
				break;
sl@0
   380
			}
sl@0
   381
		}
sl@0
   382
	else
sl@0
   383
		{
sl@0
   384
		switch(iTest->SubState())
sl@0
   385
			{
sl@0
   386
			case EMainWindow:
sl@0
   387
				buf.Copy(_L("Click on me"));
sl@0
   388
				break;
sl@0
   389
			case EChildWindow:
sl@0
   390
			case EOtherGroup:
sl@0
   391
			case EOtherSession:
sl@0
   392
				break;
sl@0
   393
			case ERootWindow:
sl@0
   394
				if (iTest->State()==ENormalCaptureWithoutFocus)
sl@0
   395
					buf.Copy(_L("Click on the root window, then press <Escape>"));
sl@0
   396
				else
sl@0
   397
					buf.Copy(_L("Click on the root window"));
sl@0
   398
				break;
sl@0
   399
			}
sl@0
   400
		}
sl@0
   401
	CPcWindowBase::Draw(buf);
sl@0
   402
	}
sl@0
   403
sl@0
   404
void CPcWindowMain::WinKeyL(const TKeyEvent &aKey,const TTime &)
sl@0
   405
	{
sl@0
   406
	switch(aKey.iCode)
sl@0
   407
		{
sl@0
   408
		case EKeyEscape:
sl@0
   409
			iTest->AbortTests();
sl@0
   410
			break;
sl@0
   411
		}
sl@0
   412
	}
sl@0
   413
sl@0
   414
//
sl@0
   415
sl@0
   416
CPcWindowChild::CPcWindowChild(TPointerCaptureTest *aTest) : CPcWindowBase(aTest)
sl@0
   417
	{
sl@0
   418
	iBack=TRgb::Gray256(85);
sl@0
   419
	}
sl@0
   420
sl@0
   421
TPointerCheckRet CPcWindowChild::PointerDown()
sl@0
   422
	{
sl@0
   423
	switch(iTest->State())
sl@0
   424
		{
sl@0
   425
		case ECaptureDisabled:
sl@0
   426
			break;
sl@0
   427
		default:
sl@0
   428
			switch(iTest->SubState())
sl@0
   429
				{
sl@0
   430
				case EChildWindow:
sl@0
   431
					return(EOkay);
sl@0
   432
				default:
sl@0
   433
					break;
sl@0
   434
				}
sl@0
   435
			break;
sl@0
   436
		}
sl@0
   437
	return(EFailed);
sl@0
   438
	}
sl@0
   439
sl@0
   440
TPointerCheckRet CPcWindowChild::DragDrop()
sl@0
   441
	{
sl@0
   442
	switch(iTest->State())
sl@0
   443
		{
sl@0
   444
		case EDragDropCapture:
sl@0
   445
		case EDragDropCaptureAllGroups:
sl@0
   446
			switch(iTest->SubState())
sl@0
   447
				{
sl@0
   448
				case EChildWindow:
sl@0
   449
					return(EOkay);
sl@0
   450
				default:
sl@0
   451
					break;
sl@0
   452
				}
sl@0
   453
			break;
sl@0
   454
		default:
sl@0
   455
			break;
sl@0
   456
		}
sl@0
   457
	return(EFailed);
sl@0
   458
	}
sl@0
   459
sl@0
   460
void CPcWindowChild::Draw()
sl@0
   461
	{
sl@0
   462
	TBuf<0x40> buf;
sl@0
   463
	if (iTest->State()!=ECaptureDisabled)
sl@0
   464
		{
sl@0
   465
		switch(iTest->SubState())
sl@0
   466
			{
sl@0
   467
			case EChildWindow:
sl@0
   468
				buf.Copy(_L("Click on me"));
sl@0
   469
				break;
sl@0
   470
			default:
sl@0
   471
				break;
sl@0
   472
			}
sl@0
   473
		}
sl@0
   474
	CPcWindowBase::Draw(buf);
sl@0
   475
	}
sl@0
   476
sl@0
   477
//
sl@0
   478
sl@0
   479
CPcWindowNickFocusGroup::CPcWindowNickFocusGroup(TPointerCaptureTest *aTest, CTClient *aClient) : CTWindowGroup(aClient), iTest(aTest)
sl@0
   480
	{
sl@0
   481
	}
sl@0
   482
sl@0
   483
void CPcWindowNickFocusGroup::KeyL(const TKeyEvent &aKey,const TTime &)
sl@0
   484
	{
sl@0
   485
	if (aKey.iCode==EKeyEscape)
sl@0
   486
		iTest->IncSubState(EFalse);
sl@0
   487
	}
sl@0
   488
sl@0
   489
//
sl@0
   490
sl@0
   491
CPcWindowAltGroup::CPcWindowAltGroup(TPointerCaptureTest *aTest) : CPcWindowBase(aTest)
sl@0
   492
	{
sl@0
   493
	iBack=TRgb::Gray256(236);
sl@0
   494
	}
sl@0
   495
sl@0
   496
TPointerCheckRet CPcWindowAltGroup::PointerDown()
sl@0
   497
	{
sl@0
   498
	switch(iTest->State())
sl@0
   499
		{
sl@0
   500
		case ECaptureDisabled:
sl@0
   501
			if (iTest->SubState()==EChildWindow)
sl@0
   502
				return(EOkay);
sl@0
   503
			break;
sl@0
   504
		case ENormalCapture:
sl@0
   505
		case EDragDropCapture:
sl@0
   506
		case ENormalCaptureWithoutFocus:
sl@0
   507
			switch(iTest->SubState())
sl@0
   508
				{
sl@0
   509
				case EOtherGroup:
sl@0
   510
					return(EOkay);
sl@0
   511
				default:
sl@0
   512
					break;
sl@0
   513
				}
sl@0
   514
			break;
sl@0
   515
		default:
sl@0
   516
			break;
sl@0
   517
		}
sl@0
   518
	return(EFailed);
sl@0
   519
	}
sl@0
   520
sl@0
   521
TPointerCheckRet CPcWindowAltGroup::DragDrop()
sl@0
   522
	{
sl@0
   523
	switch(iTest->State())
sl@0
   524
		{
sl@0
   525
		case EDragDropCapture:
sl@0
   526
		case EDragDropCaptureAllGroups:
sl@0
   527
			switch(iTest->SubState())
sl@0
   528
				{
sl@0
   529
				case EOtherGroup:
sl@0
   530
					return(EOkay);
sl@0
   531
				default:
sl@0
   532
					break;
sl@0
   533
				}
sl@0
   534
			break;
sl@0
   535
		default:
sl@0
   536
			break;
sl@0
   537
		}
sl@0
   538
	return(EFailed);
sl@0
   539
	}
sl@0
   540
sl@0
   541
void CPcWindowAltGroup::Draw()
sl@0
   542
	{
sl@0
   543
	TBuf<0x40> buf;
sl@0
   544
	if (iTest->State()==ECaptureDisabled)
sl@0
   545
		{
sl@0
   546
		switch(iTest->SubState())
sl@0
   547
			{
sl@0
   548
			case EMainWindow:
sl@0
   549
				break;
sl@0
   550
			case EChildWindow:
sl@0
   551
				buf.Copy(_L("Click on me"));
sl@0
   552
				break;
sl@0
   553
			}
sl@0
   554
		}
sl@0
   555
	else
sl@0
   556
		{
sl@0
   557
		switch(iTest->SubState())
sl@0
   558
			{
sl@0
   559
			case EOtherGroup:
sl@0
   560
				buf.Copy(_L("Click on me"));
sl@0
   561
				break;
sl@0
   562
			default:
sl@0
   563
				break;
sl@0
   564
			}
sl@0
   565
		}
sl@0
   566
	CPcWindowBase::Draw(buf);
sl@0
   567
	}
sl@0
   568
sl@0
   569
//
sl@0
   570
sl@0
   571
CPcWindowAltConnection::CPcWindowAltConnection(TPointerCaptureTest *aTest) : CPcWindowBase(aTest)
sl@0
   572
	{
sl@0
   573
	iBack=TRgb::Gray256(236);
sl@0
   574
	}
sl@0
   575
sl@0
   576
TPointerCheckRet CPcWindowAltConnection::PointerDown()
sl@0
   577
	{
sl@0
   578
	switch(iTest->State())
sl@0
   579
		{
sl@0
   580
		case ECaptureDisabled:
sl@0
   581
			if (iTest->SubState()==EChildWindow)
sl@0
   582
				return(EOkay);
sl@0
   583
			break;
sl@0
   584
		case ENormalCapture:
sl@0
   585
		case EDragDropCapture:
sl@0
   586
		case ENormalCaptureWithoutFocus:
sl@0
   587
			switch(iTest->SubState())
sl@0
   588
				{
sl@0
   589
				case EOtherSession:
sl@0
   590
					return(EOkay);
sl@0
   591
				default:
sl@0
   592
					break;
sl@0
   593
				}
sl@0
   594
			break;
sl@0
   595
		default:
sl@0
   596
			break;
sl@0
   597
		}
sl@0
   598
	return(EFailed);
sl@0
   599
	}
sl@0
   600
sl@0
   601
TPointerCheckRet CPcWindowAltConnection::DragDrop()
sl@0
   602
	{
sl@0
   603
	switch(iTest->State())
sl@0
   604
		{
sl@0
   605
		case EDragDropCapture:
sl@0
   606
		case EDragDropCaptureAllGroups:
sl@0
   607
			switch(iTest->SubState())
sl@0
   608
				{
sl@0
   609
				case EOtherSession:
sl@0
   610
					return(EOkay);
sl@0
   611
				default:
sl@0
   612
					break;
sl@0
   613
				}
sl@0
   614
			break;
sl@0
   615
		default:
sl@0
   616
			break;
sl@0
   617
		}
sl@0
   618
	return(EFailed);
sl@0
   619
	}
sl@0
   620
sl@0
   621
void CPcWindowAltConnection::Draw()
sl@0
   622
	{
sl@0
   623
	TBuf<0x40> buf;
sl@0
   624
	if (iTest->State()!=ECaptureDisabled)
sl@0
   625
		{
sl@0
   626
		switch(iTest->SubState())
sl@0
   627
			{
sl@0
   628
			case EOtherSession:
sl@0
   629
				buf.Copy(_L("Click on me"));
sl@0
   630
				break;
sl@0
   631
			default:
sl@0
   632
				break;
sl@0
   633
			}
sl@0
   634
		}
sl@0
   635
	CPcWindowBase::Draw(buf);
sl@0
   636
	}
sl@0
   637
sl@0
   638
//
sl@0
   639
sl@0
   640
TPointerCaptureTest::TPointerCaptureTest() : CTestBase(_L("Pointer Capture"))
sl@0
   641
	{}
sl@0
   642
sl@0
   643
TPointerCaptureTest::~TPointerCaptureTest()
sl@0
   644
	{
sl@0
   645
	delete iNickFocusBlankWin;
sl@0
   646
	delete iNickFocusGroup;
sl@0
   647
	delete iAltConnectionWin;
sl@0
   648
	delete iAltConnection;
sl@0
   649
	delete iChildWin;
sl@0
   650
	delete iMainWin;
sl@0
   651
	delete iMainGroup;
sl@0
   652
	delete iAltGroupWin;
sl@0
   653
	delete iAltGroup;
sl@0
   654
	}
sl@0
   655
sl@0
   656
void TPointerCaptureTest::TestFailed()
sl@0
   657
	{
sl@0
   658
	__ASSERT_DEBUG(iFailed==EFalse,TManPanic(ETManPanicPcFailed));
sl@0
   659
	iFailed=ETrue;
sl@0
   660
	Client()->iGroup->GroupWin()->SetOrdinalPosition(0,10);	// Put error dialog on top of test windows
sl@0
   661
	TInt dRet=1;
sl@0
   662
	TRAPD(err,dRet=doTestFailedL());
sl@0
   663
	Client()->iGroup->GroupWin()->SetOrdinalPosition(0,0);
sl@0
   664
	switch(dRet)
sl@0
   665
		{
sl@0
   666
		case 0:
sl@0
   667
			RestartTest();
sl@0
   668
			break;
sl@0
   669
		case 1:
sl@0
   670
			TRAP(err,TestL(EFalse));
sl@0
   671
			break;
sl@0
   672
		}
sl@0
   673
	}
sl@0
   674
sl@0
   675
TInt TPointerCaptureTest::doTestFailedL()
sl@0
   676
	{
sl@0
   677
	CTDialog *dialog=new(ELeave) CTDialog();
sl@0
   678
	dialog->SetTitle(_L("Pointer capture test failed"));
sl@0
   679
	dialog->SetNumButtons(2);
sl@0
   680
	dialog->SetButtonText(0,_L("Retest"));
sl@0
   681
	dialog->SetButtonText(1,_L("Fail"));
sl@0
   682
	dialog->ConstructLD(*Client()->iGroup,*Client()->iGc);
sl@0
   683
	return dialog->Display();
sl@0
   684
	}
sl@0
   685
sl@0
   686
TInt TPointerCaptureTest::State() const
sl@0
   687
	{
sl@0
   688
	return(iState);
sl@0
   689
	}
sl@0
   690
sl@0
   691
TInt TPointerCaptureTest::SubState() const
sl@0
   692
	{
sl@0
   693
	return(iSubState);
sl@0
   694
	}
sl@0
   695
sl@0
   696
void TPointerCaptureTest::doIncSubState()
sl@0
   697
	{
sl@0
   698
	iSubState++;
sl@0
   699
	TInt max=0;
sl@0
   700
	switch(iState)
sl@0
   701
		{
sl@0
   702
		case ECaptureDisabled:
sl@0
   703
			max=ESubStates1;
sl@0
   704
			break;
sl@0
   705
		case ENormalCapture:
sl@0
   706
			max=ESubStates2;
sl@0
   707
			break;
sl@0
   708
		case ECaptureAllGroups:
sl@0
   709
			max=ESubStates3;
sl@0
   710
			break;
sl@0
   711
		case EDragDropCapture:
sl@0
   712
			max=ESubStates4;
sl@0
   713
			break;
sl@0
   714
		case EDragDropCaptureAllGroups:
sl@0
   715
			max=ESubStates5;
sl@0
   716
			break;
sl@0
   717
		case ENormalCaptureWithoutFocus:
sl@0
   718
			max=ESubStates6;
sl@0
   719
			break;
sl@0
   720
		}
sl@0
   721
	if (iSubState==max)
sl@0
   722
		NextTest();
sl@0
   723
	StateChanged();
sl@0
   724
	}
sl@0
   725
sl@0
   726
void TPointerCaptureTest::GotDD()
sl@0
   727
	{
sl@0
   728
	if (iDDState==DDStateWaiting)
sl@0
   729
		doIncSubState();
sl@0
   730
	else
sl@0
   731
		iDDState=DDStateGot;
sl@0
   732
	}
sl@0
   733
sl@0
   734
void TPointerCaptureTest::IncSubState(TBool aNeedsDD)
sl@0
   735
	{
sl@0
   736
	if (!aNeedsDD)
sl@0
   737
		{
sl@0
   738
		if (iDDState!=DDStateNull)
sl@0
   739
			TestFailed();
sl@0
   740
		else
sl@0
   741
			doIncSubState();
sl@0
   742
		}
sl@0
   743
	else if (iDDState==DDStateGot)
sl@0
   744
		doIncSubState();
sl@0
   745
	else
sl@0
   746
		iDDState=DDStateWaiting;
sl@0
   747
	}
sl@0
   748
sl@0
   749
void TPointerCaptureTest::StateChanged()
sl@0
   750
	{
sl@0
   751
	iDDState=DDStateNull;
sl@0
   752
	iChildWin->SubStateChanged();
sl@0
   753
	iMainWin->SubStateChanged();
sl@0
   754
	iAltGroupWin->SubStateChanged();
sl@0
   755
	iAltConnectionWin->SubStateChanged();
sl@0
   756
	}
sl@0
   757
sl@0
   758
void TPointerCaptureTest::AbortTests()
sl@0
   759
	{
sl@0
   760
	iState=99;
sl@0
   761
	Request();
sl@0
   762
	}
sl@0
   763
sl@0
   764
void TPointerCaptureTest::NextTest()
sl@0
   765
	{
sl@0
   766
	iState++;
sl@0
   767
	Request();
sl@0
   768
	}
sl@0
   769
sl@0
   770
void TPointerCaptureTest::RestartTest()
sl@0
   771
	{
sl@0
   772
	Request();
sl@0
   773
	}
sl@0
   774
sl@0
   775
void TPointerCaptureTest::ConstructL()
sl@0
   776
	{
sl@0
   777
	TSize size(Client()->iGroup->Size());
sl@0
   778
	TInt winWidth2=size.iWidth/2-EWinBorderSize*2;
sl@0
   779
	TInt winWidth4=size.iWidth/4-EWinBorderSize*2;
sl@0
   780
	TInt winHeight=size.iHeight/2-EWinBorderSize*2;
sl@0
   781
//
sl@0
   782
	iMainGroup=new(ELeave) CTWindowGroup(Client());
sl@0
   783
	iMainGroup->ConstructL();
sl@0
   784
	iMainGroup->GroupWin()->SetOrdinalPosition(0,1);
sl@0
   785
	iMainWin=new(ELeave) CPcWindowMain(this);
sl@0
   786
	iMainWin->SetUpL(TPoint(EWinBorderSize,EWinBorderSize) ,TSize(winWidth2,winHeight) ,iMainGroup);
sl@0
   787
	iMainGroup->SetCurrentWindow(iMainWin);
sl@0
   788
	iChildWin=new(ELeave) CPcWindowChild(this);
sl@0
   789
	iChildWin->SetUpL(TPoint(0,winHeight/2) ,TSize(winWidth2,winHeight/2) ,iMainWin);
sl@0
   790
//
sl@0
   791
	iAltGroup=new(ELeave) CTWindowGroup(Client());
sl@0
   792
	iAltGroup->ConstructL();
sl@0
   793
	iAltGroup->GroupWin()->SetOrdinalPosition(0,1);
sl@0
   794
	iAltGroup->GroupWin()->EnableReceiptOfFocus(EFalse);
sl@0
   795
	iAltGroupWin=new(ELeave) CPcWindowAltGroup(this);
sl@0
   796
	iAltGroupWin->SetUpL(TPoint(size.iWidth/2+EWinBorderSize,EWinBorderSize) ,TSize(winWidth4,winHeight) ,iAltGroup);
sl@0
   797
//
sl@0
   798
	iAltConnection=new(ELeave) CPcConnection(this);
sl@0
   799
	iAltConnection->ConstructL();
sl@0
   800
	iAltConnectionWin=new(ELeave) CPcWindowAltConnection(this);
sl@0
   801
	iAltConnectionWin->SetUpL(TPoint(size.iWidth/4*3+EWinBorderSize,EWinBorderSize) ,TSize(winWidth4,winHeight),iAltConnection->iGroup,*iAltConnection->iGc);
sl@0
   802
	}
sl@0
   803
sl@0
   804
void TPointerCaptureTest::NickFocusL()
sl@0
   805
	{
sl@0
   806
	iNickFocusGroup=new(ELeave) CPcWindowNickFocusGroup(this,Client());
sl@0
   807
	iNickFocusGroup->ConstructL();
sl@0
   808
	iNickFocusGroup->GroupWin()->SetOrdinalPosition(0,2);
sl@0
   809
	iNickFocusBlankWin=new(ELeave) CTBlankWindow();
sl@0
   810
	iNickFocusBlankWin->ConstructL(*iNickFocusGroup);
sl@0
   811
	iNickFocusBlankWin->SetSize(TSize(1,1));
sl@0
   812
	iNickFocusBlankWin->Activate();
sl@0
   813
	}
sl@0
   814
sl@0
   815
void TPointerCaptureTest::SetCapture(TInt aCaptureFlags)
sl@0
   816
	{
sl@0
   817
	iMainWin->Win()->SetPointerCapture(aCaptureFlags);
sl@0
   818
	}
sl@0
   819
sl@0
   820
TestState TPointerCaptureTest::DoTestL()
sl@0
   821
	{
sl@0
   822
	iSubState=0;
sl@0
   823
	iFailed=EFalse;
sl@0
   824
	StateChanged();
sl@0
   825
	switch(iState)
sl@0
   826
		{
sl@0
   827
		case ECaptureDisabled:
sl@0
   828
			LogSubTest(_L("No capture"),1);
sl@0
   829
			SetCapture(RWindowBase::TCaptureDisabled);
sl@0
   830
			break;
sl@0
   831
		case ENormalCapture:
sl@0
   832
			LogSubTest(_L("Normal capture"),1);
sl@0
   833
			SetCapture(RWindowBase::TCaptureEnabled);
sl@0
   834
			break;
sl@0
   835
		case ECaptureAllGroups:
sl@0
   836
			LogSubTest(_L("All groups"),1);
sl@0
   837
			SetCapture(RWindowBase::TCaptureEnabled|RWindowBase::TCaptureFlagAllGroups);
sl@0
   838
			break;
sl@0
   839
		case EDragDropCapture:
sl@0
   840
			LogSubTest(_L("Drag & Drop"),1);
sl@0
   841
			SetCapture(RWindowBase::TCaptureDragDrop&~RWindowBase::TCaptureFlagAllGroups);
sl@0
   842
			break;
sl@0
   843
		case EDragDropCaptureAllGroups:
sl@0
   844
			LogSubTest(_L("Drag & Drop All groups"),1);
sl@0
   845
			SetCapture(RWindowBase::TCaptureDragDrop);
sl@0
   846
			break;
sl@0
   847
		case ENormalCaptureWithoutFocus:
sl@0
   848
			LogSubTest(_L("Without focus"),1);
sl@0
   849
			NickFocusL();
sl@0
   850
			SetCapture(RWindowBase::TCaptureEnabled);
sl@0
   851
			break;
sl@0
   852
		default:
sl@0
   853
			return(EFinished);
sl@0
   854
		}
sl@0
   855
	return(EContinue);
sl@0
   856
 	}