os/graphics/windowing/windowserver/test/tauto/TTEXTCURS.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 the text cursor.
sl@0
    15
//
sl@0
    16
// This suite of tests checks to see if the TextCursors are operating
sl@0
    17
// correctly for a number of use case scenarios; see doxygen comments
sl@0
    18
// for each sub-test.  This test suite is applicable on both winscw
sl@0
    19
// emulator and armv5 target hardware.  However, it must be noted that
sl@0
    20
// text cursors are special due to their timeliness.  The text cursor
sl@0
    21
// must flash every second: half a second ON, half a second OFF.  One
sl@0
    22
// consequence of this is that when the test suite is run on emulator,
sl@0
    23
// the PC must be otherwise quiescent.  No other IO or CPU intensive
sl@0
    24
// activities may occur on the system, because these will cause delays
sl@0
    25
// to the flashing of the text cursor giving unreliable results.
sl@0
    26
// Where timeliness is a consideration, we use TEST_SOFTFAIL_WINSCW so
sl@0
    27
// that if the test fails and we are running on the PC emulator, we only
sl@0
    28
// record the fact, but don't mark the test as failing.
sl@0
    29
sl@0
    30
/**
sl@0
    31
 @file
sl@0
    32
 @test
sl@0
    33
 @internalComponent - Internal Symbian test code
sl@0
    34
*/
sl@0
    35
sl@0
    36
#include "TTEXTCURS.H"
sl@0
    37
#include "graphics/windowserverconstants.h"
sl@0
    38
sl@0
    39
const TInt KNumberOfCustoTextCursors	= 3;
sl@0
    40
const TInt KTextCursorInitialIdValue	= 1001;
sl@0
    41
const TInt KTextCursorPanicUid1			= 200;
sl@0
    42
const TInt KTextCursorPanicUid2			= 2000;
sl@0
    43
const TInt KTextCursorPanicUid3			= 3000;
sl@0
    44
const TInt KTextCursorPanicUid4			= 4000;
sl@0
    45
const TInt KTextCursorPanicUid5			= 5000;
sl@0
    46
sl@0
    47
CTestBase* CTCursorTest::iStaticTest = NULL;
sl@0
    48
const TInt kWinWidth=400;
sl@0
    49
const TInt kWinHeight=100;
sl@0
    50
const TSize kWinSize(kWinWidth,kWinHeight);
sl@0
    51
const TInt kWinXPos=150;
sl@0
    52
const TInt kCursorWidth = 10;
sl@0
    53
const TInt kCursorHeight = 20;
sl@0
    54
const TSize kCursorSize(kCursorWidth,kCursorHeight);
sl@0
    55
const TPoint kWin1TopLeft(kWinXPos,0);
sl@0
    56
const TPoint kWin2TopLeft(kWinXPos,kWinHeight+10);
sl@0
    57
sl@0
    58
LOCAL_D void DeleteSpriteMember(TAny* aSpriteMember)
sl@0
    59
	{
sl@0
    60
	TSpriteMember* member=reinterpret_cast<TSpriteMember*>(aSpriteMember);
sl@0
    61
	delete member->iBitmap;
sl@0
    62
	member->iBitmap=NULL;
sl@0
    63
	delete member->iMaskBitmap;
sl@0
    64
	member->iMaskBitmap=NULL;
sl@0
    65
	}
sl@0
    66
sl@0
    67
CCustomTextCursor::~CCustomTextCursor()
sl@0
    68
	{
sl@0
    69
	const TInt count = iSpriteMemberArray.Count();
sl@0
    70
	for (TInt index=0; index<count; ++index)
sl@0
    71
		{
sl@0
    72
		DeleteSpriteMember(&iSpriteMemberArray[index]);
sl@0
    73
		}
sl@0
    74
	iSpriteMemberArray.Close();
sl@0
    75
	}
sl@0
    76
	
sl@0
    77
CCustomTextCursor::CCustomTextCursor(CTestBase* aTest)
sl@0
    78
	: iTest(aTest)
sl@0
    79
	{	
sl@0
    80
	}
sl@0
    81
sl@0
    82
void CCustomTextCursor::ConstructL(TInt aScreenNumber,TInt aBmpIndex)
sl@0
    83
	{
sl@0
    84
	ASSERT(aBmpIndex < KNumberOfCustoTextCursors);
sl@0
    85
	
sl@0
    86
sl@0
    87
	TSpriteMember spriteMember;
sl@0
    88
	spriteMember.iBitmap = NULL;
sl@0
    89
	spriteMember.iMaskBitmap = NULL;
sl@0
    90
	spriteMember.iInvertMask =EFalse;
sl@0
    91
	spriteMember.iDrawMode = CGraphicsContext::EDrawModePEN;
sl@0
    92
	spriteMember.iOffset = TPoint();
sl@0
    93
	spriteMember.iInterval = TTimeIntervalMicroSeconds32(0);
sl@0
    94
	CleanupStack::PushL(TCleanupItem(DeleteSpriteMember, &spriteMember));
sl@0
    95
	spriteMember.iBitmap = new (ELeave) CFbsBitmap;
sl@0
    96
	User::LeaveIfError(spriteMember.iBitmap->Load(TEST_BITMAP_NAME, EMbmWsautotestBmp1));
sl@0
    97
	spriteMember.iMaskBitmap = new (ELeave) CFbsBitmap;
sl@0
    98
	User::LeaveIfError(spriteMember.iMaskBitmap->Load(TEST_BITMAP_NAME, EMbmWsautotestBmp1mask));
sl@0
    99
sl@0
   100
	User::LeaveIfError(iSpriteMemberArray.Append(spriteMember));
sl@0
   101
	CleanupStack::Pop(&spriteMember);
sl@0
   102
sl@0
   103
	// create unique-id accross screens
sl@0
   104
	//
sl@0
   105
	iIdentifier = KTextCursorInitialIdValue + aScreenNumber*KNumberOfCustoTextCursors + aBmpIndex;
sl@0
   106
	iAlignment = (RWsSession::TCustomTextCursorAlignment)(aBmpIndex);
sl@0
   107
	}
sl@0
   108
sl@0
   109
CCustomTextCursor* CCustomTextCursor::CreateCustomTextCursorL(TInt aScreenNumber,TInt aBmpIndex,CTestBase* aTest)
sl@0
   110
	{
sl@0
   111
	CCustomTextCursor* customTextCursor = new (ELeave) CCustomTextCursor(aTest);
sl@0
   112
	CleanupStack::PushL(customTextCursor);
sl@0
   113
	customTextCursor->ConstructL(aScreenNumber,aBmpIndex);
sl@0
   114
	CleanupStack::Pop(customTextCursor);
sl@0
   115
	return customTextCursor;
sl@0
   116
	}
sl@0
   117
sl@0
   118
/*
sl@0
   119
 * Wrapper class for a list of custom text cursor.
sl@0
   120
 */
sl@0
   121
class CCustomTextCursorsWrapper : public CBase
sl@0
   122
	{
sl@0
   123
public:
sl@0
   124
	static CCustomTextCursorsWrapper* NewLC(TInt aScreenNumber,CTestBase* aTest);
sl@0
   125
	~CCustomTextCursorsWrapper();
sl@0
   126
	inline RPointerArray<CCustomTextCursor>& CustomTextCursorsArray();
sl@0
   127
	inline CCustomTextCursor& CustomTextCursor(TInt aIndex);
sl@0
   128
private:
sl@0
   129
	void ConstructL(TInt aScreenNumber,CTestBase* aTest);
sl@0
   130
private:
sl@0
   131
	RPointerArray<CCustomTextCursor> iCustomTextCursors;
sl@0
   132
	};
sl@0
   133
sl@0
   134
inline RPointerArray<CCustomTextCursor>& CCustomTextCursorsWrapper::CustomTextCursorsArray()
sl@0
   135
		{
sl@0
   136
		return iCustomTextCursors;
sl@0
   137
		}
sl@0
   138
sl@0
   139
inline CCustomTextCursor& CCustomTextCursorsWrapper::CustomTextCursor(TInt aIndex)
sl@0
   140
		{
sl@0
   141
		return *(iCustomTextCursors[aIndex]);
sl@0
   142
		}
sl@0
   143
sl@0
   144
CCustomTextCursorsWrapper* CCustomTextCursorsWrapper::NewLC(TInt aScreenNumber,CTestBase* aTest)
sl@0
   145
	{
sl@0
   146
	CCustomTextCursorsWrapper* self = new(ELeave) CCustomTextCursorsWrapper();
sl@0
   147
	CleanupStack::PushL(self);
sl@0
   148
	self->ConstructL(aScreenNumber,aTest);
sl@0
   149
	return self;
sl@0
   150
	}
sl@0
   151
sl@0
   152
CCustomTextCursorsWrapper::~CCustomTextCursorsWrapper()
sl@0
   153
	{
sl@0
   154
	iCustomTextCursors.ResetAndDestroy();
sl@0
   155
	iCustomTextCursors.Close();
sl@0
   156
	}
sl@0
   157
sl@0
   158
void CCustomTextCursorsWrapper::ConstructL(TInt aScreenNumber, CTestBase* aTest)
sl@0
   159
	{
sl@0
   160
	for (TInt index=0; index<KNumberOfCustoTextCursors; ++index)
sl@0
   161
		{
sl@0
   162
		CCustomTextCursor* customTextCursor=CCustomTextCursor::CreateCustomTextCursorL(aScreenNumber,index, aTest);
sl@0
   163
		CleanupStack::PushL(customTextCursor);
sl@0
   164
		User::LeaveIfError(iCustomTextCursors.Append(customTextCursor));
sl@0
   165
		CleanupStack::Pop(customTextCursor);
sl@0
   166
		}
sl@0
   167
	}
sl@0
   168
sl@0
   169
CTCursorTest::CTCursorTest(CTestStep* aStep) :
sl@0
   170
	CTWsGraphicsBase(aStep)
sl@0
   171
	{
sl@0
   172
	iCursorType = TTextCursor::ETypeFirst;
sl@0
   173
	iStaticTest=iTest;
sl@0
   174
	}
sl@0
   175
	
sl@0
   176
CTCursorTest::~CTCursorTest()
sl@0
   177
	{
sl@0
   178
	delete iWorkInProgress;
sl@0
   179
	delete iComparisonWindow;
sl@0
   180
	}
sl@0
   181
sl@0
   182
TInt CTCursorTest::DoPanicTest(TInt aInt, TAny *aScreenNumber)
sl@0
   183
	{
sl@0
   184
	RWsSession ws;
sl@0
   185
	if (ws.Connect()==KErrNone)
sl@0
   186
		{
sl@0
   187
		// use correct screen
sl@0
   188
		CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
sl@0
   189
		User::LeaveIfError(screen->Construct((TInt)aScreenNumber));
sl@0
   190
		RWindowGroup group(ws);
sl@0
   191
		if (group.Construct(444)==KErrNone)
sl@0
   192
			{
sl@0
   193
			group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
sl@0
   194
			RWindow wnd(ws);
sl@0
   195
			if (wnd.Construct(group, TInt32(&ws))==KErrNone)
sl@0
   196
				{
sl@0
   197
				TTextCursor tc;
sl@0
   198
				tc.iHeight=10;
sl@0
   199
				tc.iAscent=5;
sl@0
   200
				tc.iWidth=10;
sl@0
   201
				tc.iFlags=0;
sl@0
   202
				tc.iColor=TRgb(0,0,0);
sl@0
   203
				switch(aInt)
sl@0
   204
					{
sl@0
   205
					case 0:
sl@0
   206
						{
sl@0
   207
						/* TESTCASE:	6.1
sl@0
   208
						* TITLE:		Invalid use of a custom text cursor ID (basic text cursor).
sl@0
   209
						* IMPORTANCE:	1
sl@0
   210
						* REQUIREMENT:	Unknown.
sl@0
   211
						* 
sl@0
   212
						* ACTION:		This test tries to set a text cursor using an ID which is invalid.
sl@0
   213
						* 
sl@0
   214
						* CHECK:		The thread should panic with the exit reason EWservPanicInvalidTextCursor
sl@0
   215
						*/ 
sl@0
   216
						tc.iType=(TTextCursor::EType)KTextCursorPanicUid1;
sl@0
   217
						group.SetTextCursor(wnd,TPoint(10,10),tc);
sl@0
   218
						}
sl@0
   219
						break;
sl@0
   220
					case 1:
sl@0
   221
						{
sl@0
   222
						/* TESTCASE:	6.2
sl@0
   223
						* TITLE:		Invalid use of a window for a text cursor.
sl@0
   224
						* IMPORTANCE:	1
sl@0
   225
						* REQUIREMENT:	REQ 1079, CR RDEF-5F7Q24 (10/04/2003).
sl@0
   226
						* 
sl@0
   227
						* ACTION:		This test tries to set a text cursor using a window which is not part
sl@0
   228
						*				of the window group calling the setting API.
sl@0
   229
						* 
sl@0
   230
						* CHECK:		The thread should panic with the exit reason EWservPanicWindow
sl@0
   231
						*/ 
sl@0
   232
						tc.iType=(TTextCursor::EType)KTextCursorPanicUid2;
sl@0
   233
						group.SetTextCursor(*TestWin->Win(),TPoint(10,10),tc);
sl@0
   234
						}
sl@0
   235
						break;
sl@0
   236
					case 2:
sl@0
   237
						{
sl@0
   238
						/* TESTCASE:	6.3
sl@0
   239
						* TITLE:		Invalid use of a custom text cursor ID.
sl@0
   240
						* IMPORTANCE:	1
sl@0
   241
						* REQUIREMENT:	REQ 1079, CR RDEF-5F7Q24 (10/04/2003).
sl@0
   242
						* 
sl@0
   243
						* ACTION:		This test tries to set a text cursor using an ID which is associated to
sl@0
   244
						*				an non-existing custom text cursor.
sl@0
   245
						* 
sl@0
   246
						* CHECK:		The thread should panic with the exit reason EWservPanicNoCustomTextCursor
sl@0
   247
						*/ 
sl@0
   248
						tc.iType=(TTextCursor::EType)KTextCursorPanicUid3;
sl@0
   249
						group.SetTextCursor(wnd,TPoint(10,10),tc);
sl@0
   250
						}
sl@0
   251
						break;
sl@0
   252
					case 3:
sl@0
   253
						{
sl@0
   254
						/* TESTCASE:	6.4
sl@0
   255
						* TITLE:		Invalid use of a custom text cursor ID.
sl@0
   256
						* IMPORTANCE:	1
sl@0
   257
						* REQUIREMENT:	REQ 1079, CR RDEF-5F7Q24 (10/04/2003).
sl@0
   258
						* 
sl@0
   259
						* ACTION:		This test tries to set a custom text cursor which has been set to use
sl@0
   260
						*				an invalid alignment.
sl@0
   261
						* 
sl@0
   262
						* CHECK:		The thread should panic with the exit reason EWservPanicCustomTextCursorAlign
sl@0
   263
						*/ 
sl@0
   264
						CCustomTextCursor* customTextCursor=NULL;
sl@0
   265
						TRAPD(error, customTextCursor=CCustomTextCursor::CreateCustomTextCursorL((TInt)aScreenNumber,0,iStaticTest));
sl@0
   266
						if (error==KErrNone)
sl@0
   267
							{
sl@0
   268
							error = ws.SetCustomTextCursor(KTextCursorPanicUid4, customTextCursor->iSpriteMemberArray.Array(), 0, (RWsSession::TCustomTextCursorAlignment)(RWsSession::ECustomTextCursorAlignBottom+1));
sl@0
   269
							if (error==KErrNone || error==KErrAlreadyExists)
sl@0
   270
								{
sl@0
   271
								tc.iType=(TTextCursor::EType)KTextCursorPanicUid4;
sl@0
   272
								group.SetTextCursor(wnd,TPoint(10,10),tc);
sl@0
   273
								}
sl@0
   274
							}
sl@0
   275
						delete customTextCursor;
sl@0
   276
						}
sl@0
   277
						break;
sl@0
   278
					case 4:
sl@0
   279
						{
sl@0
   280
						/* TESTCASE:	6.5
sl@0
   281
						* TITLE:		Use of an invalid custom text cursor
sl@0
   282
						* IMPORTANCE:	1
sl@0
   283
						* REQUIREMENT:	REQ 1079, CR RDEF-5F7Q24 (10/04/2003).
sl@0
   284
						* 
sl@0
   285
						* ACTION:		This test tries to set a custom text cursor which does not have
sl@0
   286
						*				any sprite member set.
sl@0
   287
						* 
sl@0
   288
						* CHECK:		The thread should panic with the exit reason EWservPanicNoSpriteMember
sl@0
   289
						*/ 
sl@0
   290
						RArray<TSpriteMember> spriteMemberArray;
sl@0
   291
						const TInt error = ws.SetCustomTextCursor(KTextCursorPanicUid5, spriteMemberArray.Array(), 0, (RWsSession::TCustomTextCursorAlignment)(RWsSession::ECustomTextCursorAlignBottom));
sl@0
   292
						if (error==KErrNone || error==KErrAlreadyExists)
sl@0
   293
							{
sl@0
   294
							tc.iType=(TTextCursor::EType)KTextCursorPanicUid5;
sl@0
   295
							group.SetTextCursor(wnd,TPoint(10,10),tc);
sl@0
   296
							}
sl@0
   297
						}
sl@0
   298
						break;
sl@0
   299
					case 5:
sl@0
   300
						{
sl@0
   301
						// Uncover set.cursor.iType < TTextCursor::ETypeFirst code path
sl@0
   302
						tc.iType=(TTextCursor::EType)TTextCursor::ETypeFirst - 1;
sl@0
   303
						group.SetTextCursor(wnd,TPoint(10,10),tc);
sl@0
   304
						}
sl@0
   305
						break;
sl@0
   306
					case 6:
sl@0
   307
						{
sl@0
   308
						// Uncover (set.cursor.iFlags&static_cast<TUint>(TTextCursor::EPrivateFlags) code path
sl@0
   309
						tc.iFlags=ETextCursorPrivateFlags;
sl@0
   310
						group.SetTextCursor(wnd,TPoint(10,10),tc);
sl@0
   311
						}
sl@0
   312
						break;
sl@0
   313
					case 7:
sl@0
   314
						{
sl@0
   315
						// Uncover (iGroupWin != searchWin) i.e. bogus group window
sl@0
   316
						tc.iType=(TTextCursor::EType)TTextCursor::ETypeRectangle;
sl@0
   317
						RWindow windowNotAssociatedWithAGroup(ws);
sl@0
   318
						group.SetTextCursor(windowNotAssociatedWithAGroup, TPoint(10,10),tc);
sl@0
   319
						}
sl@0
   320
						break;
sl@0
   321
					}
sl@0
   322
				}
sl@0
   323
			ws.Flush();
sl@0
   324
			}
sl@0
   325
		}
sl@0
   326
	return(EWsExitReasonBad);
sl@0
   327
	}
sl@0
   328
sl@0
   329
void CTCursorTest::TestPanicsL()
sl@0
   330
	{	
sl@0
   331
		TEST(iTest->TestWsPanicL(DoPanicTest, EWservPanicInvalidTextCursor, 0, (TAny*)iTest->iScreenNumber));
sl@0
   332
		TEST(iTest->TestWsPanicL(DoPanicTest, EWservPanicWindow, 1, (TAny*)iTest->iScreenNumber));
sl@0
   333
		TEST(iTest->TestWsPanicL(DoPanicTest, EWservPanicNoCustomTextCursor, 2, (TAny*)iTest->iScreenNumber));
sl@0
   334
		TEST(iTest->TestWsPanicL(DoPanicTest, EWservPanicCustomTextCursorAlign, 3, (TAny*)iTest->iScreenNumber));
sl@0
   335
		TEST(iTest->TestWsPanicL(DoPanicTest, EWservPanicNoSpriteMember, 4, (TAny*)iTest->iScreenNumber));
sl@0
   336
		TEST(iTest->TestWsPanicL(DoPanicTest, EWservPanicInvalidTextCursor, 5, (TAny*)iTest->iScreenNumber));
sl@0
   337
		TEST(iTest->TestWsPanicL(DoPanicTest, EWservPanicInvalidTextCursor, 6, (TAny*)iTest->iScreenNumber));
sl@0
   338
		TEST(iTest->TestWsPanicL(DoPanicTest, EWservPanicWindow, 7, (TAny*)iTest->iScreenNumber));
sl@0
   339
		iTest->CloseAllPanicWindows();
sl@0
   340
	}
sl@0
   341
sl@0
   342
void CTCursorTest::TextCursorSetLCoverageTests()
sl@0
   343
	{
sl@0
   344
	ValidateWin(BaseWin,TRgb::Gray256(255));
sl@0
   345
	ValidateWin(TestWin,TRgb::Gray256(255));	
sl@0
   346
	TTextCursor textCursor;
sl@0
   347
	textCursor.iHeight = 10;
sl@0
   348
	textCursor.iAscent = 0;
sl@0
   349
	textCursor.iWidth = 10;
sl@0
   350
	textCursor.iFlags = 0;
sl@0
   351
	textCursor.iColor = KRgbBlack;
sl@0
   352
	textCursor.iType = (TTextCursor::EType)TTextCursor::ETypeRectangle;
sl@0
   353
	TPoint position(10, 10);
sl@0
   354
	TRect clipRect0(10, 10, 10, 10);
sl@0
   355
	TRect clipRect1(10, 10, 5, 5);
sl@0
   356
	RWindowGroup *group = TheClient->iGroup->GroupWin(); 
sl@0
   357
	group->SetTextCursor(*TestWin->Win(), position, textCursor);
sl@0
   358
	/*
sl@0
   359
	 * Duplicate the previous SetTextCursor command to uncover the code which checks for any delta in SetL
sl@0
   360
	 * compared to the current settings.
sl@0
   361
	 */
sl@0
   362
	group->SetTextCursor(*TestWin->Win(), position, textCursor);
sl@0
   363
	/*
sl@0
   364
	 * Change the type only to pick up that difference in SetL.
sl@0
   365
	 */
sl@0
   366
	textCursor.iType++;
sl@0
   367
	group->SetTextCursor(*TestWin->Win(), position, textCursor);
sl@0
   368
	textCursor.iType--;
sl@0
   369
	/*
sl@0
   370
	 * Vary the clipping rectangle.
sl@0
   371
	 */
sl@0
   372
	group->SetTextCursor(*TestWin->Win(), position, textCursor, clipRect0);
sl@0
   373
	group->SetTextCursor(*TestWin->Win(), position, textCursor, clipRect1);
sl@0
   374
	/*
sl@0
   375
	 * Vary the color.
sl@0
   376
	 */
sl@0
   377
	textCursor.iColor = KRgbGreen;
sl@0
   378
	group->SetTextCursor(*TestWin->Win(), position, textCursor);
sl@0
   379
	textCursor.iColor = KRgbBlack;
sl@0
   380
	group->SetTextCursor(*TestWin->Win(), position, textCursor);
sl@0
   381
	/*
sl@0
   382
	 * Vary the target Window.
sl@0
   383
	 */
sl@0
   384
	group->SetTextCursor(*BaseWin->Win(), position, textCursor);
sl@0
   385
	group->SetTextCursor(*TestWin->Win(), position, textCursor);
sl@0
   386
	/*
sl@0
   387
	 * Vary the size of the cursor.
sl@0
   388
	 */
sl@0
   389
	textCursor.iWidth++;
sl@0
   390
	group->SetTextCursor(*TestWin->Win(), position, textCursor);
sl@0
   391
	textCursor.iWidth--;
sl@0
   392
	/*
sl@0
   393
	 * Set different custom cursors.
sl@0
   394
	 */
sl@0
   395
	CCustomTextCursorsWrapper* customTextCursorsWrapper = CCustomTextCursorsWrapper::NewLC(iTest->iScreenNumber, iTest);
sl@0
   396
	const TInt count = customTextCursorsWrapper->CustomTextCursorsArray().Count();
sl@0
   397
	for (TInt index=0; index<count; ++index)
sl@0
   398
		{
sl@0
   399
		CCustomTextCursor& customTextCursor = customTextCursorsWrapper->CustomTextCursor(index);
sl@0
   400
		textCursor.iType = customTextCursor.iIdentifier;
sl@0
   401
		group->SetTextCursor(*TestWin->Win(), position, textCursor);
sl@0
   402
		}			
sl@0
   403
	CleanupStack::PopAndDestroy(customTextCursorsWrapper);
sl@0
   404
	/*
sl@0
   405
	 * Set the last custom cursor from the above loop again so the
sl@0
   406
	 * product code sees the same Custom Text Cursor settings come
sl@0
   407
	 * in a second time.
sl@0
   408
	 */
sl@0
   409
	group->SetTextCursor(*TestWin->Win(), position, textCursor);
sl@0
   410
	textCursor.iType = (TTextCursor::EType)TTextCursor::ETypeRectangle;
sl@0
   411
	/*
sl@0
   412
	 * Vary the horizontal clipping.
sl@0
   413
	 */
sl@0
   414
	textCursor.iFlags = TTextCursor::EFlagClipHorizontal;
sl@0
   415
	group->SetTextCursor(*TestWin->Win(), position, textCursor);
sl@0
   416
	/*
sl@0
   417
	 * Vary the horizontal clipping.
sl@0
   418
	 */
sl@0
   419
	textCursor.iFlags = TTextCursor::EFlagClipVertical;
sl@0
   420
	group->SetTextCursor(*TestWin->Win(), position, textCursor);
sl@0
   421
	/*
sl@0
   422
	 * Try both horizontal and vertical clipping.
sl@0
   423
	 */
sl@0
   424
	textCursor.iFlags = TTextCursor::EFlagClipVertical|TTextCursor::EFlagClipHorizontal;
sl@0
   425
	group->SetTextCursor(*TestWin->Win(), position, textCursor);
sl@0
   426
	textCursor.iFlags = 0;
sl@0
   427
	
sl@0
   428
	TheClient->iWs.Flush();
sl@0
   429
	CancelTextCursor();
sl@0
   430
	}
sl@0
   431
sl@0
   432
void CTCursorTest::SetCursor(const TPoint &aPos,const TSize &aSize,TRgb aColor, const TRect &aRect, TUint aFlags)
sl@0
   433
	{
sl@0
   434
	TTextCursor tc;
sl@0
   435
	tc.iType=iCursorType;
sl@0
   436
    tc.iHeight=aSize.iHeight;
sl@0
   437
    tc.iAscent=aSize.iHeight*4/5;
sl@0
   438
    tc.iWidth=aSize.iWidth;
sl@0
   439
    tc.iFlags=aFlags;
sl@0
   440
	tc.iColor=aColor;
sl@0
   441
	TheClient->iGroup->GroupWin()->SetTextCursor(*TestWin->Win(),TPoint(aPos.iX,aPos.iY+tc.iAscent),tc,aRect);
sl@0
   442
	}
sl@0
   443
sl@0
   444
void CTCursorTest::SetCursor(const TPoint &aPos,const TSize &aSize,TRgb aColor, TUint aFlags)
sl@0
   445
	{
sl@0
   446
	TTextCursor tc;
sl@0
   447
	tc.iType=iCursorType;
sl@0
   448
    tc.iHeight=aSize.iHeight;
sl@0
   449
    tc.iAscent=aSize.iHeight*4/5;
sl@0
   450
    tc.iWidth=aSize.iWidth;
sl@0
   451
    tc.iFlags=aFlags;
sl@0
   452
	tc.iColor=aColor;
sl@0
   453
	TheClient->iGroup->GroupWin()->SetTextCursor(*TestWin->Win(),TPoint(aPos.iX,aPos.iY+tc.iAscent),tc);
sl@0
   454
	}
sl@0
   455
sl@0
   456
void CTCursorTest::SetCursorPlusBox(const TPoint &aPos,const TSize &aSize,TRgb aColor, const TRect *aClipRect, TUint aFlags)
sl@0
   457
	{
sl@0
   458
	if (aClipRect)
sl@0
   459
		SetCursor(aPos,aSize,aColor,*aClipRect,aFlags);
sl@0
   460
	else
sl@0
   461
		SetCursor(aPos,aSize,aColor,aFlags);
sl@0
   462
	TRect rect(aPos,aSize);
sl@0
   463
	if (aClipRect)
sl@0
   464
		rect.Intersection(*aClipRect);
sl@0
   465
	rect.Grow(2,2);
sl@0
   466
	
sl@0
   467
	TheClient->iGc->Activate(*(TestWin->Win()));
sl@0
   468
	TestWin->Invalidate(rect);
sl@0
   469
	TestWin->Win()->BeginRedraw(rect);
sl@0
   470
	TheClient->iGc->SetPenColor(aColor);
sl@0
   471
	TheClient->iGc->SetDrawMode(CGraphicsContext::EDrawModeXOR);
sl@0
   472
sl@0
   473
	TheClient->iGc->DrawRect(rect);
sl@0
   474
	TheClient->iGc->Deactivate();
sl@0
   475
	TestWin->Win()->EndRedraw();
sl@0
   476
	
sl@0
   477
	}
sl@0
   478
sl@0
   479
void CTCursorTest::CancelTextCursor()
sl@0
   480
	{
sl@0
   481
	TheClient->iGroup->GroupWin()->CancelTextCursor();
sl@0
   482
	}
sl@0
   483
sl@0
   484
void CTCursorTest::ConstructL()
sl@0
   485
	{
sl@0
   486
	// for allocating some cached memory
sl@0
   487
	CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
sl@0
   488
	CleanupStack::PushL(bitmap);
sl@0
   489
	User::LeaveIfError(bitmap->Load(TEST_BITMAP_NAME, 0));
sl@0
   490
	CleanupStack::PopAndDestroy(bitmap);
sl@0
   491
sl@0
   492
	CCustomTextCursorsWrapper* customTextCursorsWrapper = CCustomTextCursorsWrapper::NewLC(iTest->iScreenNumber, iTest);
sl@0
   493
	const TInt count = customTextCursorsWrapper->CustomTextCursorsArray().Count();
sl@0
   494
	for (TInt index=0; index<count; ++index)
sl@0
   495
		{
sl@0
   496
		CCustomTextCursor& customTextCursor = customTextCursorsWrapper->CustomTextCursor(index);
sl@0
   497
		TInt err = TheClient->iWs.SetCustomTextCursor(customTextCursor.iIdentifier, customTextCursor.iSpriteMemberArray.Array(), customTextCursor.iSpriteFlags, customTextCursor.iAlignment);
sl@0
   498
		TEST(err == KErrNone || err == KErrAlreadyExists);
sl@0
   499
		if (err!=KErrNone && err != KErrAlreadyExists)
sl@0
   500
			INFO_PRINTF4(_L("TheClient->iWs.SetCustomTextCursor return value  - Expected: %d or %d, Actual: %d"), KErrNone, KErrAlreadyExists, err);
sl@0
   501
sl@0
   502
		__UHEAP_MARK;
sl@0
   503
		err = TheClient->iWs.SetCustomTextCursor(customTextCursor.iIdentifier, customTextCursor.iSpriteMemberArray.Array(), customTextCursor.iSpriteFlags, customTextCursor.iAlignment);
sl@0
   504
		__UHEAP_MARKEND;
sl@0
   505
		TEST(err == KErrAlreadyExists);
sl@0
   506
		if (err != KErrAlreadyExists)
sl@0
   507
			INFO_PRINTF3(_L("TheClient->iWs.SetCustomTextCursor return value  - Expected: %d, Actual: %d"), KErrAlreadyExists, err);
sl@0
   508
sl@0
   509
		}
sl@0
   510
	_LIT(KLog,"Text Cursor: Loaded %d Custom Cursors");
sl@0
   511
	TLogMessageText buf;
sl@0
   512
	buf.Format(KLog,count);
sl@0
   513
	TheClient->LogMessage(buf);
sl@0
   514
	CleanupStack::PopAndDestroy(customTextCursorsWrapper);
sl@0
   515
//
sl@0
   516
	ValidateWin(BaseWin,TRgb::Gray256(204));
sl@0
   517
	ValidateWin(TestWin,TRgb::Gray256(204));
sl@0
   518
//
sl@0
   519
	SetCursor(TPoint(10,90),TSize(80,100),TRgb(255,255,255));
sl@0
   520
//
sl@0
   521
	iWinState=0;
sl@0
   522
	iWinPos=TPoint(2*TheClient->iGroup->Size().iWidth/3,0);
sl@0
   523
//
sl@0
   524
	iMoveWin=new(ELeave) CBlankWindow(TRgb::Gray256(220));
sl@0
   525
	TDisplayMode mode=EGray16;
sl@0
   526
	TInt testWinWidth = TestWin->Size().iWidth;
sl@0
   527
	TInt halfTestWinWidth = testWinWidth/2;
sl@0
   528
	TInt halfTestWinHeight = TestWin->Size().iHeight/2;
sl@0
   529
	
sl@0
   530
	iMoveWin->SetUpL(iWinPos,TSize(halfTestWinHeight,halfTestWinHeight),
sl@0
   531
			TheClient->iGroup,*TheClient->iGc,&mode);
sl@0
   532
sl@0
   533
	iCheckWin=new(ELeave) CBlankWindow(TRgb::Gray256(220));
sl@0
   534
	iCheckWin->SetUpL(TPoint(testWinWidth+halfTestWinWidth,halfTestWinHeight),
sl@0
   535
			TSize(halfTestWinWidth,halfTestWinHeight),
sl@0
   536
			TheClient->iGroup,*TheClient->iGc,&mode);
sl@0
   537
	}
sl@0
   538
sl@0
   539
void CTCursorTest::DeleteMoveWindows()
sl@0
   540
	{
sl@0
   541
	delete iMoveWin;
sl@0
   542
	delete iCheckWin;
sl@0
   543
	CancelTextCursor();
sl@0
   544
	}
sl@0
   545
sl@0
   546
void CTCursorTest::ResetMoveWindowsL()
sl@0
   547
	{
sl@0
   548
	SetCursor(TPoint(10,90),TSize(80,100),TRgb(255,255,255));
sl@0
   549
	iWinState=0;
sl@0
   550
	iWinPos=TPoint(2*TheClient->iGroup->Size().iWidth/3,0);
sl@0
   551
	iMoveWin->SetExtL(iWinPos,TSize(TestWin->Size().iWidth/2,TestWin->Size().iHeight/2));
sl@0
   552
	iCheckWin->SetExtL(TPoint(TestWin->Size().iWidth+(TestWin->Size().iWidth>>1),TestWin->Size().iHeight>>1),
sl@0
   553
														TSize(TestWin->Size().iWidth/2,TestWin->Size().iHeight/2));
sl@0
   554
	}
sl@0
   555
sl@0
   556
TBool CTCursorTest::MoveWindow()
sl@0
   557
	{
sl@0
   558
	TSize scrSize(TheClient->iScreen->SizeInPixels());
sl@0
   559
	iWinState++;
sl@0
   560
	if (iWinState<20)
sl@0
   561
		iWinPos+=TPoint((4*scrSize.iWidth)/640,(4*scrSize.iHeight)/240);
sl@0
   562
	else if (iWinState<40)
sl@0
   563
		iWinPos+=TPoint((1*scrSize.iWidth)/640,(-3*scrSize.iHeight)/240);
sl@0
   564
	else if (iWinState<60)
sl@0
   565
		iWinPos+=TPoint((-6*scrSize.iWidth)/640,(3*scrSize.iHeight)/240);
sl@0
   566
	else
sl@0
   567
		iWinPos+=TPoint((1*scrSize.iWidth)/640,(-2*scrSize.iHeight)/240);
sl@0
   568
	iMoveWin->SetPos(iWinPos);
sl@0
   569
	return (iWinState==80);
sl@0
   570
	}
sl@0
   571
sl@0
   572
void CTCursorTest::ValidateWin(TestWindow *aWin, TRgb aColor)
sl@0
   573
	{
sl@0
   574
	aWin->Win()->Invalidate();
sl@0
   575
	RedrawWin(*aWin->Win(),aColor);
sl@0
   576
	}
sl@0
   577
sl@0
   578
void CTCursorTest::RedrawWin(RWindow &aWin, TRgb aColor)
sl@0
   579
	{
sl@0
   580
	aWin.BeginRedraw();
sl@0
   581
	TheClient->iGc->Activate(aWin);
sl@0
   582
	TheClient->iGc->SetBrushColor(aColor);
sl@0
   583
	TheClient->iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
   584
	TheClient->iGc->SetPenStyle(CGraphicsContext::ENullPen);
sl@0
   585
	TheClient->iGc->Clear();
sl@0
   586
	TheClient->iGc->Deactivate();
sl@0
   587
	aWin.EndRedraw();
sl@0
   588
	}
sl@0
   589
sl@0
   590
void CTCursorTest::ScrollTest()
sl@0
   591
	{
sl@0
   592
	const TSize size(20,40);
sl@0
   593
	ValidateWin(TestWin,TRgb::Gray256(255));
sl@0
   594
sl@0
   595
	SetCursor(TPoint(10,20),size,TRgb::Gray256(255),TTextCursor::EFlagNoFlash);
sl@0
   596
	TheClient->iWs.Flush();
sl@0
   597
	TheClient->WaitForRedrawsToFinish();
sl@0
   598
	TheClient->iWs.Finish();
sl@0
   599
sl@0
   600
	for(TInt ii=0;ii<20;ii++)
sl@0
   601
		{
sl@0
   602
		TInt dist=(ii&3)*2;
sl@0
   603
		TInt nx=ii&0x1?1:-1;
sl@0
   604
		TInt ny=ii&0x2?1:-1;
sl@0
   605
		TestWin->Win()->Scroll(TPoint(dist*nx,dist*ny),TRect(10,20,30,40));
sl@0
   606
		TheClient->iWs.Flush();
sl@0
   607
		}
sl@0
   608
	TheClient->WaitForRedrawsToFinish();
sl@0
   609
	TheClient->iWs.Finish();
sl@0
   610
sl@0
   611
	BaseWin->Win()->Invalidate();
sl@0
   612
	BaseWin->Win()->BeginRedraw();
sl@0
   613
	TheClient->iGc->Activate(*(BaseWin->Win()));
sl@0
   614
	TheClient->iGc->Clear();
sl@0
   615
	TheClient->iGc->SetBrushColor(TRgb::Gray256(255));
sl@0
   616
	TheClient->iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
   617
	TheClient->iGc->SetPenStyle(CGraphicsContext::ENullPen);
sl@0
   618
	TheClient->iGc->Clear(TRect(TPoint(10,20),size));
sl@0
   619
	TheClient->iGc->Deactivate();
sl@0
   620
	BaseWin->Win()->EndRedraw();
sl@0
   621
sl@0
   622
	TheClient->iWs.Flush();
sl@0
   623
	TheClient->WaitForRedrawsToFinish();
sl@0
   624
	TheClient->iWs.Finish();
sl@0
   625
sl@0
   626
	/*
sl@0
   627
	 * NOTE: Reason for removal of COMPARE_WINDOWS_SOFTFAIL_WINSCW
sl@0
   628
	 * Due to the new implementation of sprites in wserv2, the sprites no longer keep a 
sl@0
   629
	 * backup bitmap of what the screen looks like beneath them. As it is not possible to 
sl@0
   630
	 * move the sprites associated with the custom text cursors that were created in second 
sl@0
   631
	 * phase construction of the CTCursorTest object, the COMPARE_WINDOWS_SOFTFAIL_WINSCW; 
sl@0
   632
	 * macro function has been removed. Otherwise the test case is going to subject to the
sl@0
   633
	 * timing of the flashing sprite. An alternative solution would be to assign NULL values
sl@0
   634
	 * to the sprite bitmaps in second phase construction, but this is avoided as it would
sl@0
   635
	 * trigger failures in some test cases later on (that are depended on these "embedded"
sl@0
   636
	 * sprite images).
sl@0
   637
	 */	
sl@0
   638
	CancelTextCursor();
sl@0
   639
	}
sl@0
   640
sl@0
   641
void DrawTestSprite(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *)
sl@0
   642
	{
sl@0
   643
	aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 2));
sl@0
   644
	aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
   645
	aGc->SetPenStyle(CGraphicsContext::ENullPen);
sl@0
   646
	aGc->DrawRect(TRect(aSize));
sl@0
   647
	aGc->SetPenStyle(CGraphicsContext::ESolidPen);
sl@0
   648
	aGc->SetPenColor(TRgb::Gray4(aDoMask ? 3 : 0));
sl@0
   649
	aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 3 : 1));
sl@0
   650
	aGc->DrawEllipse(TRect(aSize));
sl@0
   651
	}
sl@0
   652
sl@0
   653
CTSprite *CTCursorTest::CreateTestSpriteLC(RWindowTreeNode &aWindow, const TPoint &aPos, TInt aCount)
sl@0
   654
//
sl@0
   655
// At the moment aCount must be 1 or 2
sl@0
   656
//
sl@0
   657
	{
sl@0
   658
	TSpriteCreateParams params(TSize(30,70),TPoint(0,0),DrawTestSprite);
sl@0
   659
	TSpriteCreateParams paramarray[2];
sl@0
   660
	params.iInterval=TTimeIntervalMicroSeconds32(200000);
sl@0
   661
sl@0
   662
	paramarray[0]=params;
sl@0
   663
	paramarray[1]=params;
sl@0
   664
	paramarray[1].iSize=TSize(100,10);
sl@0
   665
	CTSprite *sprite=new(ELeave) CTSprite(TheClient->iWs);
sl@0
   666
	CleanupStack::PushL(sprite);
sl@0
   667
	sprite->ConstructL(aWindow,aPos,aCount,&paramarray[0],0);
sl@0
   668
	return(sprite);
sl@0
   669
	}
sl@0
   670
sl@0
   671
void CTCursorTest::doMoveWindowTestL()
sl@0
   672
	{
sl@0
   673
	RBlankWindow blankwin(TheClient->iWs);
sl@0
   674
	User::LeaveIfError(blankwin.Construct(*TestWin->Win(),1));
sl@0
   675
	CleanupStack::PushL(TCleanupItem(CleanUpWindow,&blankwin));
sl@0
   676
//
sl@0
   677
	blankwin.SetExtent(TPoint(35,165),TSize(40,40));
sl@0
   678
	blankwin.SetColor(TRgb::Gray256(220));
sl@0
   679
	blankwin.Activate();
sl@0
   680
	TheClient->iWs.SetAutoFlush(ETrue);
sl@0
   681
	User::After(500000);
sl@0
   682
	blankwin.SetPosition(TPoint(25,55));
sl@0
   683
	User::After(500000);
sl@0
   684
	blankwin.SetPosition(TPoint(30,160));
sl@0
   685
	User::After(500000);
sl@0
   686
	blankwin.SetPosition(TPoint(12,22));	// Almost totally covering sprite
sl@0
   687
	User::After(500000);
sl@0
   688
	blankwin.SetPosition(TPoint(-100,-100));	// Totally off the sprite
sl@0
   689
	User::After(500000);
sl@0
   690
	blankwin.SetPosition(TPoint(10,20));	// Write on top of sprite
sl@0
   691
	User::After(500000);
sl@0
   692
	blankwin.SetPosition(TPoint(24,24));	// moving off...
sl@0
   693
	User::After(500000);
sl@0
   694
	blankwin.SetPosition(TPoint(38,28));	// ...
sl@0
   695
	User::After(500000);
sl@0
   696
	blankwin.SetPosition(TPoint(58,48));	// ...
sl@0
   697
	User::After(500000);
sl@0
   698
	blankwin.SetPosition(TPoint(92,62));	// ... off
sl@0
   699
	User::After(500000);
sl@0
   700
	CleanupStack::PopAndDestroy();	// blank window
sl@0
   701
	TheClient->iWs.Flush();
sl@0
   702
	TheClient->WaitForRedrawsToFinish();
sl@0
   703
	TheClient->iWs.Finish();
sl@0
   704
sl@0
   705
	TheClient->iWs.SetAutoFlush(EFalse);
sl@0
   706
	}
sl@0
   707
sl@0
   708
void CTCursorTest::MoveWindowTest1L()
sl@0
   709
	{
sl@0
   710
	ValidateWin(TestWin,TRgb::Gray256(255));
sl@0
   711
// Check it with a static sprite
sl@0
   712
	CTSprite * sprite_static = CreateTestSpriteLC(*TestWin->Win(), TPoint(10,20), 1);
sl@0
   713
	doMoveWindowTestL();
sl@0
   714
	(sprite_static->Sprite()).SetPosition(TPoint(500,500)); //move the sprite out of the viewing area before the window comparison 
sl@0
   715
	CleanupStack::PopAndDestroy(1);	// sprite
sl@0
   716
// Check it an animated sprite
sl@0
   717
	CTSprite * sprite_anim = CreateTestSpriteLC(*TestWin->Win(), TPoint(10,20), 2);
sl@0
   718
	doMoveWindowTestL();
sl@0
   719
	(sprite_anim->Sprite()).SetPosition(TPoint(500,500)); //move the sprite out of the viewing area before the window comparison
sl@0
   720
	CleanupStack::PopAndDestroy(1);	// sprite
sl@0
   721
	}
sl@0
   722
sl@0
   723
void CTCursorTest::MoveWindowTest2L()
sl@0
   724
	{
sl@0
   725
	const TSize size(20,40);
sl@0
   726
// Check it with a text cursor
sl@0
   727
	ValidateWin(TestWin,TRgb::Gray256(255));
sl@0
   728
	SetCursor(TPoint(10,25),size,TRgb::Gray256(255),TTextCursor::EFlagNoFlash);
sl@0
   729
	doMoveWindowTestL();
sl@0
   730
	CancelTextCursor();
sl@0
   731
// Check it with an anaimated sprite and a text cursor
sl@0
   732
	ValidateWin(TestWin,TRgb::Gray256(255));
sl@0
   733
	CTSprite * sprite_anim = CreateTestSpriteLC(*TestWin->Win(), TPoint(10,20), 2);
sl@0
   734
	SetCursor(TPoint(10,45),size,TRgb::Gray256(255),TTextCursor::EFlagNoFlash);
sl@0
   735
	doMoveWindowTestL();
sl@0
   736
	(sprite_anim->Sprite()).SetPosition(TPoint(500,500));
sl@0
   737
	CancelTextCursor();
sl@0
   738
	CleanupStack::PopAndDestroy(1);	// sprite
sl@0
   739
	}
sl@0
   740
sl@0
   741
TBool CTCursorTest::IncrementCursorType()
sl@0
   742
	{
sl@0
   743
	// each screen has it own set of cursor
sl@0
   744
	//
sl@0
   745
	// the values would be ETypeLast=2 ETypeLastBasic=1009
sl@0
   746
	//
sl@0
   747
	if (iCursorType == TTextCursor::ETypeFirst)
sl@0
   748
		{
sl@0
   749
		iCursorType = (TTextCursor::EType)(TTextCursor::ETypeLastBasic + 1 + iTest->iScreenNumber*KNumberOfCustoTextCursors);
sl@0
   750
		return ETrue;
sl@0
   751
		}
sl@0
   752
	else if (iCursorType >= TTextCursor::ETypeLastBasic + (iTest->iScreenNumber+1)*KNumberOfCustoTextCursors)
sl@0
   753
		{
sl@0
   754
		iCursorType = TTextCursor::ETypeFirst;
sl@0
   755
		return EFalse;
sl@0
   756
		}
sl@0
   757
	else
sl@0
   758
		{
sl@0
   759
		iCursorType = (TTextCursor::EType)(iCursorType + 1);
sl@0
   760
		return ETrue;
sl@0
   761
		}
sl@0
   762
	}
sl@0
   763
sl@0
   764
void CTCursorTest::GeneralTestsL()
sl@0
   765
	{
sl@0
   766
	const TInt winColor=255;		//Best to use Light Grey that is 170, but this code is bugged and doing so shows them up.
sl@0
   767
	ValidateWin(BaseWin,TRgb::Gray256(255));
sl@0
   768
	ValidateWin(TestWin,TRgb::Gray256(255));
sl@0
   769
	SetCursor(TPoint(-1000,10),TSize(10,30),TRgb::Gray256(255));
sl@0
   770
	TheClient->iWs.Flush();
sl@0
   771
	SetCursor(TPoint(10,10),TSize(10,30),TRgb::Gray256(255));
sl@0
   772
	TheClient->iWs.Flush();
sl@0
   773
	TRect rect(15,15,18,25);
sl@0
   774
	SetCursorPlusBox(TPoint(10,10),TSize(10,30),TRgb::Gray256(255), &rect);
sl@0
   775
	CancelTextCursor();
sl@0
   776
//
sl@0
   777
	ValidateWin(BaseWin,TRgb::Gray256(255));
sl@0
   778
	ValidateWin(TestWin,TRgb::Gray256(255));
sl@0
   779
	TheClient->iWs.Flush();
sl@0
   780
	for(TInt winType=0;winType<3;winType++)
sl@0
   781
		{
sl@0
   782
		RWindowBase *cursorwin=NULL;
sl@0
   783
		RBackedUpWindow backcursorwin(TheClient->iWs);
sl@0
   784
		RWindow backwindow(TheClient->iWs);
sl@0
   785
		RBlankWindow backblankwin(TheClient->iWs);
sl@0
   786
		switch(winType)
sl@0
   787
			{
sl@0
   788
			case 0:
sl@0
   789
				cursorwin=&backcursorwin;
sl@0
   790
				User::LeaveIfError(backcursorwin.Construct(*TestWin->BaseWin(),EGray4,1));
sl@0
   791
				break;
sl@0
   792
			case 1:
sl@0
   793
				cursorwin=&backwindow;
sl@0
   794
				User::LeaveIfError(backwindow.Construct(*TestWin->BaseWin(),1));
sl@0
   795
				break;
sl@0
   796
			case 2:
sl@0
   797
				cursorwin=&backblankwin;
sl@0
   798
				User::LeaveIfError(backblankwin.Construct(*TestWin->BaseWin(),1));
sl@0
   799
				break;
sl@0
   800
			}
sl@0
   801
		CleanupStack::PushL(TCleanupItem(CleanUpWindow,cursorwin));
sl@0
   802
		User::LeaveIfError(cursorwin->SetSizeErr(TestWin->BaseWin()->Size()));
sl@0
   803
		cursorwin->Activate();
sl@0
   804
//
sl@0
   805
		TTextCursor tc;
sl@0
   806
		tc.iType=iCursorType;
sl@0
   807
		tc.iHeight=30;
sl@0
   808
		tc.iAscent=0;
sl@0
   809
		tc.iWidth=50;
sl@0
   810
		tc.iFlags=0;
sl@0
   811
		tc.iColor=TRgb::Gray256(255);
sl@0
   812
		TheClient->iGroup->GroupWin()->SetTextCursor(*cursorwin,TPoint(10,10),tc);
sl@0
   813
//
sl@0
   814
		CreateTestSpriteLC(*cursorwin, TPoint(10,20), 2);
sl@0
   815
//
sl@0
   816
		if (cursorwin==&backwindow)
sl@0
   817
			RedrawWin(backwindow,TRgb::Gray256(255));
sl@0
   818
		for(TInt count=0;count<9;count++)
sl@0
   819
			{
sl@0
   820
			RWindowBase *pwin=NULL;
sl@0
   821
			RBackedUpWindow backedup(TheClient->iWs);
sl@0
   822
			RWindow window(TheClient->iWs);
sl@0
   823
			RBlankWindow blankwin(TheClient->iWs);
sl@0
   824
			switch(count%3)
sl@0
   825
				{
sl@0
   826
				case 0:
sl@0
   827
					pwin=&window;
sl@0
   828
					window.Construct(*cursorwin,2);
sl@0
   829
					window.SetBackgroundColor(TRgb(winColor,winColor,winColor));
sl@0
   830
					break;
sl@0
   831
				case 1:
sl@0
   832
					pwin=&backedup;
sl@0
   833
					backedup.Construct(*cursorwin,EGray4,2);
sl@0
   834
					break;
sl@0
   835
				case 2:
sl@0
   836
					pwin=&blankwin;
sl@0
   837
					blankwin.Construct(*cursorwin,2);
sl@0
   838
					blankwin.SetColor(TRgb(winColor,winColor,winColor));
sl@0
   839
					break;
sl@0
   840
				}
sl@0
   841
			CleanupStack::PushL(TCleanupItem(CleanUpWindow,pwin));
sl@0
   842
			pwin->SetExtentErr(TPoint(30,30),TSize(50,80));
sl@0
   843
			pwin->Activate();
sl@0
   844
			TheClient->iWs.Flush();
sl@0
   845
			CleanupStack::PopAndDestroy();	// window
sl@0
   846
			if (cursorwin==&backwindow)
sl@0
   847
				RedrawWin(backwindow,TRgb::Gray256(255));
sl@0
   848
			TheClient->iWs.Flush();
sl@0
   849
			TheClient->WaitForRedrawsToFinish();
sl@0
   850
			COMPARE_WINDOWS_SOFTFAIL_WINSCW;
sl@0
   851
			User::After(200000);	// Wait a fifth of a second to make sure the test is run during different states of flashing
sl@0
   852
			}
sl@0
   853
		for(TInt count2=0;count2<4;count2++)
sl@0
   854
			{
sl@0
   855
			cursorwin->SetPosition(TPoint(10,5));
sl@0
   856
			TheClient->iWs.Flush();
sl@0
   857
			User::After(100000);
sl@0
   858
			cursorwin->SetPosition(TPoint(5,10));
sl@0
   859
			TheClient->iWs.Flush();
sl@0
   860
			User::After(100000);
sl@0
   861
			cursorwin->SetPosition(TPoint(0,0));
sl@0
   862
			TheClient->iWs.Flush();
sl@0
   863
			User::After(100000);
sl@0
   864
			TheClient->WaitForRedrawsToFinish();
sl@0
   865
			COMPARE_WINDOWS_SOFTFAIL_WINSCW;
sl@0
   866
			}
sl@0
   867
		CleanupStack::PopAndDestroy(2);	// sprite & window containing sprite and cursor
sl@0
   868
		}
sl@0
   869
	CancelTextCursor();
sl@0
   870
	}
sl@0
   871
sl@0
   872
void CTCursorTest::INC040489L()
sl@0
   873
	{
sl@0
   874
	INFO_PRINTF1(_L("AUTO_TCur INC040489 "));
sl@0
   875
	RWindowGroup group1(TheClient->iWs);
sl@0
   876
	PushWindowL(&group1);
sl@0
   877
	User::LeaveIfError(group1.Construct(ENullWsHandle));
sl@0
   878
	RBlankWindow blank1(TheClient->iWs);
sl@0
   879
	PushWindowL(&blank1);
sl@0
   880
	User::LeaveIfError(blank1.Construct(group1,ENullWsHandle));
sl@0
   881
	blank1.SetRequiredDisplayMode(EColor4K);
sl@0
   882
	blank1.SetColor(TRgb(250,150,0));
sl@0
   883
	blank1.Activate();
sl@0
   884
	RWindowGroup group2(TheClient->iWs);
sl@0
   885
	PushWindowL(&group2);
sl@0
   886
	User::LeaveIfError(group2.Construct(ENullWsHandle));
sl@0
   887
	RBlankWindow blank2(TheClient->iWs);
sl@0
   888
	PushWindowL(&blank2);
sl@0
   889
	User::LeaveIfError(blank2.Construct(group2,ENullWsHandle));
sl@0
   890
	blank2.SetRequiredDisplayMode(EColor4K);
sl@0
   891
	blank2.SetColor(TRgb(75,200,125));
sl@0
   892
	blank2.Activate();
sl@0
   893
	TheClient->Flush();
sl@0
   894
	INFO_PRINTF1(_L(" Created Windows "));
sl@0
   895
	TTextCursor tc;
sl@0
   896
	tc.iType=KTextCursorInitialIdValue + iTest->iScreenNumber*KNumberOfCustoTextCursors;
sl@0
   897
	tc.iHeight=80;
sl@0
   898
	tc.iAscent=10;
sl@0
   899
	tc.iWidth=30;
sl@0
   900
	tc.iFlags=0;
sl@0
   901
	tc.iColor=TRgb::Gray256(255);
sl@0
   902
	INFO_PRINTF1(_L(" About to Set Text Cursor 1 "));
sl@0
   903
	group2.SetTextCursor(blank2,TPoint(20,20),tc);
sl@0
   904
	TheClient->Flush();
sl@0
   905
	INFO_PRINTF1(_L(" Set Text Cursor 1 "));
sl@0
   906
	User::After(2000000);		//2sec
sl@0
   907
	TheClient->iWs.PrepareForSwitchOff();
sl@0
   908
	TheClient->Flush();
sl@0
   909
	User::After(2000000);		//2sec
sl@0
   910
	group1.SetOrdinalPosition(0);
sl@0
   911
	group2.CancelTextCursor();
sl@0
   912
	TheClient->Flush();
sl@0
   913
	INFO_PRINTF1(_L(" Canceled Text Cursor "));
sl@0
   914
	User::After(2000000);		//2sec
sl@0
   915
	//
sl@0
   916
	// Before applying the fix, the following operations makes the Custom Text 
sl@0
   917
	// Cursor Sprite invisible (happens even without wserv heartbeat suppression)
sl@0
   918
	INFO_PRINTF1(_L(" About to Set Text Cursor 2 "));
sl@0
   919
	group1.SetOrdinalPosition(2);
sl@0
   920
	group2.SetTextCursor(blank2,TPoint(20,20),tc);
sl@0
   921
	TheClient->Flush();
sl@0
   922
	INFO_PRINTF1(_L(" Set Text Cursor 2 "));
sl@0
   923
	User::After(2000000);		//2sec
sl@0
   924
	TRawEvent event;
sl@0
   925
	event.Set(TRawEvent::EActive);
sl@0
   926
	TheClient->iWs.SimulateRawEvent(event);
sl@0
   927
	TheClient->Flush();
sl@0
   928
	INFO_PRINTF1(_L(" Simulated Active Event "));
sl@0
   929
	User::After(2000000);		//2sec
sl@0
   930
	CleanupStack::PopAndDestroy(4, &group1);
sl@0
   931
	INFO_PRINTF1(_L(" End of test "));
sl@0
   932
	}
sl@0
   933
sl@0
   934
void CTCursorTest::CursorUpdatedBeforeWindowRenderedL()
sl@0
   935
	{
sl@0
   936
	INFO_PRINTF1(_L("CursorUpdatedBeforeWindowRenderedL"));
sl@0
   937
	TheClient->iGroup->WinTreeNode()->SetOrdinalPosition(0);
sl@0
   938
	// We use some unique looking colors otherwise its harder
sl@0
   939
	// to spot which test is which
sl@0
   940
	TRgb kAqua(134, 242, 251);
sl@0
   941
	
sl@0
   942
	iWorkInProgress = new(ELeave) CBlankWindow(kAqua);
sl@0
   943
	iComparisonWindow = new(ELeave) CBlankWindow(kAqua);
sl@0
   944
	CancelTextCursor();
sl@0
   945
	
sl@0
   946
	const TSize screenSize=TheClient->iGroup->Size();
sl@0
   947
	const TInt kPad = 5;
sl@0
   948
	const TInt kThirdOfScreenWidth = screenSize.iWidth/3;
sl@0
   949
	const TInt kWinWidth = kThirdOfScreenWidth - 2*kPad;
sl@0
   950
	const TInt kWinHeight = screenSize.iHeight - 2*kPad;
sl@0
   951
	const TSize kWinSize(kWinWidth, kWinHeight);
sl@0
   952
	const TPoint kCursorPos(30, 30);
sl@0
   953
	iComparisonWindow->SetUpL(TPoint(2*kThirdOfScreenWidth + kPad, kPad), kWinSize, TheClient->iGroup, *TheClient->iGc);
sl@0
   954
	iWorkInProgress->SetUpL(  TPoint(  kThirdOfScreenWidth + kPad, kPad), kWinSize, TheClient->iGroup, *TheClient->iGc);
sl@0
   955
	
sl@0
   956
	TTextCursor nonFlashingCursor;
sl@0
   957
	nonFlashingCursor.iType = TTextCursor::ETypeRectangle;
sl@0
   958
	nonFlashingCursor.iHeight=kCursorHeight;
sl@0
   959
	nonFlashingCursor.iAscent=0;
sl@0
   960
	nonFlashingCursor.iWidth=kCursorWidth;
sl@0
   961
	nonFlashingCursor.iFlags=TTextCursor::EFlagNoFlash;
sl@0
   962
	nonFlashingCursor.iColor = KRgbBlack; 
sl@0
   963
	TheClient->iGroup->GroupWin()->SetTextCursor(*iWorkInProgress->BaseWin(), kCursorPos, nonFlashingCursor);
sl@0
   964
	
sl@0
   965
	// Up till this point, there has not been a CWsWindow::Render() for iWorkInProgress
sl@0
   966
	// because the window has not been invalid
sl@0
   967
	
sl@0
   968
	/*
sl@0
   969
	 * Here is the crux of the test.  We want to create the following condition in a window group:
sl@0
   970
	 * 1) None of its windows have yet been Rendered using CWsWindow::Render()
sl@0
   971
	 * 2) A text cursor is present
sl@0
   972
	 * 3) Focus is lost then received
sl@0
   973
	 * 
sl@0
   974
	 * It used to be the case that Wserv picked up the handle to the Render Stage Text Cursor
sl@0
   975
	 * drawer upon a Refresh caused by Rendering the window.  But drawing the Text Cursor could
sl@0
   976
	 * come either from a Window Render or a change to the state of the Text Cursor, such as
sl@0
   977
	 * receiving focus in the window.  A bug was experienced when the Text Cursor was drawn in
sl@0
   978
	 * a window which never had been rendered.  This meant that the handle was not set up causing
sl@0
   979
	 * an assert.
sl@0
   980
	 * 
sl@0
   981
	 * The code has been modified since then, to setup the handle to the Render Stage Text
sl@0
   982
	 * Cursor during Wserv initialisation.  However, to guard against future changes, its
sl@0
   983
	 * worthwhile to have this corner case test to ensure it is possible to receive focus
sl@0
   984
	 * in a window which has never been rendered.  That is because the text cursor state
sl@0
   985
	 * is updated in such circumstances, and that might trigger a draw of the cursor in a
sl@0
   986
	 * future version of the text cursor code.
sl@0
   987
	 */
sl@0
   988
	TheClient->iGroup->WinTreeNode()->SetOrdinalPosition(1);  // lose focus
sl@0
   989
	TheClient->iWs.Finish();
sl@0
   990
	TheClient->iGroup->WinTreeNode()->SetOrdinalPosition(0); // gain focus
sl@0
   991
	TheClient->iWs.Finish();
sl@0
   992
	
sl@0
   993
	// If we get this far without a panic or assert, we have passed this test.
sl@0
   994
	
sl@0
   995
	// Now allow CWsWindow::Render() to occur in iWorkInProgress
sl@0
   996
	// The reason for doing this is so that when you watch the test
sl@0
   997
	// progress you can see visual confirmation via the progress message and
sl@0
   998
	// the coloured windows appear on the screen.  Otherwise you would think
sl@0
   999
	// that the test had either been skipped or had broken.
sl@0
  1000
	iWorkInProgress->Invalidate();
sl@0
  1001
	iWorkInProgress->Redraw();
sl@0
  1002
	iComparisonWindow->Invalidate();
sl@0
  1003
	iComparisonWindow->Redraw();
sl@0
  1004
	TheClient->iWs.Finish();
sl@0
  1005
	delete iWorkInProgress;
sl@0
  1006
	iWorkInProgress = NULL;
sl@0
  1007
	delete iComparisonWindow;
sl@0
  1008
	iComparisonWindow = NULL;
sl@0
  1009
	INFO_PRINTF1(_L("End of test"));
sl@0
  1010
	}
sl@0
  1011
sl@0
  1012
void CTCursorTest::INC097774()
sl@0
  1013
	{
sl@0
  1014
	TTimeIntervalMicroSeconds32 initialRepeatRate;
sl@0
  1015
	TTimeIntervalMicroSeconds32 repeatRate;
sl@0
  1016
	TheClient->iWs.GetKeyboardRepeatRate(initialRepeatRate,repeatRate);
sl@0
  1017
	
sl@0
  1018
	//simulates a text cursor moving across the screen as if a user was holding down
sl@0
  1019
	//a key to scroll the cursor through a section of text.
sl@0
  1020
	//before applying the fix the cursor only shows up intermittently instead of smoothly
sl@0
  1021
	//scrolling across the screen.
sl@0
  1022
	const TSize cursorSize(3,20);
sl@0
  1023
	const TInt moveInterval=10;
sl@0
  1024
	SetCursor(TPoint(0,20),cursorSize,TRgb::Gray256(255),TTextCursor::EFlagNoFlash);
sl@0
  1025
	TheClient->Flush();
sl@0
  1026
	User::After(initialRepeatRate);
sl@0
  1027
	for(TInt offset=10;offset<=100;offset+=moveInterval)
sl@0
  1028
		{
sl@0
  1029
		SetCursor(TPoint(offset,20),cursorSize,TRgb::Gray256(255),TTextCursor::EFlagNoFlash);
sl@0
  1030
		TheClient->Flush();
sl@0
  1031
		User::After(repeatRate);
sl@0
  1032
		}
sl@0
  1033
		
sl@0
  1034
	//simulate clipped text cursor moving accross the screen
sl@0
  1035
	TRect rect(0,20,3,40);
sl@0
  1036
	SetCursor(TPoint(0,20),cursorSize,TRgb::Gray256(255),rect,TTextCursor::EFlagNoFlash);
sl@0
  1037
	TheClient->Flush();
sl@0
  1038
	User::After(initialRepeatRate);
sl@0
  1039
	for(TInt offset=10;offset<=100;offset+=moveInterval)
sl@0
  1040
		{
sl@0
  1041
		rect.Move(moveInterval,0);
sl@0
  1042
		SetCursor(TPoint(offset,20),cursorSize,TRgb::Gray256(255),rect,TTextCursor::EFlagNoFlash);
sl@0
  1043
		TheClient->Flush();
sl@0
  1044
		User::After(repeatRate);
sl@0
  1045
		}	
sl@0
  1046
	}
sl@0
  1047
/** What happens when a cursor becomes off-screen when the screen is resized/rotated? 
sl@0
  1048
 * 
sl@0
  1049
 * 
sl@0
  1050
 **/
sl@0
  1051
void CTCursorTest::INC117232()
sl@0
  1052
	{
sl@0
  1053
	const TInt initialRepeatRate=300000;	// 3/10 seconds should be long enough to update everything!
sl@0
  1054
	TInt currMode=TheClient->iScreen->CurrentScreenMode();
sl@0
  1055
	TInt testMode=currMode;
sl@0
  1056
	TPixelsTwipsAndRotation currModeSize;
sl@0
  1057
	TheClient->iScreen->GetScreenModeSizeAndRotation(currMode, currModeSize);
sl@0
  1058
	//find a (rotated) mode where the dimensions of the screen shrank
sl@0
  1059
	for (TInt mode=0;mode<TheClient->iScreenModes.Count();mode++)
sl@0
  1060
		{
sl@0
  1061
		TPixelsTwipsAndRotation testModeSize;
sl@0
  1062
		TheClient->iScreen->GetScreenModeSizeAndRotation(mode,testModeSize);
sl@0
  1063
		if (	testModeSize.iPixelSize.iWidth<currModeSize.iPixelSize.iWidth-10
sl@0
  1064
			||	testModeSize.iPixelSize.iHeight<currModeSize.iPixelSize.iHeight-10
sl@0
  1065
			)
sl@0
  1066
			{
sl@0
  1067
			testMode=mode;
sl@0
  1068
			break;
sl@0
  1069
			}
sl@0
  1070
		}
sl@0
  1071
	if (testMode==currMode)
sl@0
  1072
		{
sl@0
  1073
		_LIT(KLog,"No smaller screen-size modes available - INC117232 test skipped");
sl@0
  1074
		LOG_MESSAGE(KLog);
sl@0
  1075
		//iStep->SetTestStepResult(EInconclusive);		//With this line the whole test fails which is too drastic
sl@0
  1076
		return;
sl@0
  1077
		}
sl@0
  1078
	//enable a cursor on the bottom right corner of the screen
sl@0
  1079
	TestWin->SetFullScreenExtL();
sl@0
  1080
	TheClient->Flush();
sl@0
  1081
	iCursorType=TTextCursor::ETypeRectangle;
sl@0
  1082
	SetCursor(TPoint(-20,-20)+TestWin->Size(),TSize(40,40),KRgbDarkMagenta,TTextCursor::EFlagNoFlash);
sl@0
  1083
	TheClient->Flush();
sl@0
  1084
	User::After(initialRepeatRate);
sl@0
  1085
	//shrink the screen
sl@0
  1086
	TheClient->iScreen->SetScreenMode(testMode);
sl@0
  1087
	TheClient->iScreen->SetAppScreenMode(testMode);
sl@0
  1088
	//The defect was that WServ would now crash! 
sl@0
  1089
	TheClient->Flush();
sl@0
  1090
	User::After(initialRepeatRate);
sl@0
  1091
	//Set everything back
sl@0
  1092
	TheClient->iScreen->SetScreenMode(currMode);
sl@0
  1093
	TheClient->iScreen->SetAppScreenMode(currMode);
sl@0
  1094
	TheClient->Flush();
sl@0
  1095
	User::After(initialRepeatRate);
sl@0
  1096
	}
sl@0
  1097
sl@0
  1098
#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
sl@0
  1099
/**
sl@0
  1100
 * Sets up a text cursor whose attributes indicate it should not be flashing
sl@0
  1101
 * and then checks to ensure this is the actual behaviour.
sl@0
  1102
 */
sl@0
  1103
void CTCursorTest::TextCursorNoFlashTestL()
sl@0
  1104
	{
sl@0
  1105
	TheClient->iGroup->WinTreeNode()->SetOrdinalPosition(0);
sl@0
  1106
	// We use some unique looking colors otherwise its harder
sl@0
  1107
	// to spot which test is which
sl@0
  1108
	TRgb kGentleYellow(251, 249, 198);
sl@0
  1109
	TRgb kGentlePink(253, 196, 221);
sl@0
  1110
	
sl@0
  1111
	iWorkInProgress = new(ELeave) CBlankWindow(kGentleYellow);
sl@0
  1112
	iComparisonWindow = new(ELeave) CBlankWindow(kGentleYellow);
sl@0
  1113
	CancelTextCursor();
sl@0
  1114
	TheClient->Flush();
sl@0
  1115
	
sl@0
  1116
	const TSize screenSize=TheClient->iGroup->Size();
sl@0
  1117
	const TInt kPad = 5;
sl@0
  1118
	const TInt kThirdOfScreenWidth = screenSize.iWidth/3;
sl@0
  1119
	const TInt kWinWidth = kThirdOfScreenWidth - 2*kPad;
sl@0
  1120
	const TInt kWinHeight = screenSize.iHeight - 2*kPad;
sl@0
  1121
	const TSize kWinSize(kWinWidth, kWinHeight);
sl@0
  1122
	const TPoint kCursorPos(30, 30);
sl@0
  1123
	iWorkInProgress->SetUpL(  TPoint(  kThirdOfScreenWidth + kPad, kPad), kWinSize, TheClient->iGroup, *TheClient->iGc);
sl@0
  1124
	iComparisonWindow->SetUpL(TPoint(2*kThirdOfScreenWidth + kPad, kPad), kWinSize, TheClient->iGroup, *TheClient->iGc);
sl@0
  1125
	
sl@0
  1126
	TTextCursor nonFlashingCursor;
sl@0
  1127
	
sl@0
  1128
	nonFlashingCursor.iType = TTextCursor::ETypeRectangle;
sl@0
  1129
	nonFlashingCursor.iHeight=kCursorHeight;
sl@0
  1130
	nonFlashingCursor.iAscent=0;
sl@0
  1131
	nonFlashingCursor.iWidth=kCursorWidth;
sl@0
  1132
	nonFlashingCursor.iFlags=TTextCursor::EFlagNoFlash;
sl@0
  1133
	nonFlashingCursor.iColor = kGentlePink; // We expect a Flicker Buffer Render Stage to ignore this color
sl@0
  1134
	
sl@0
  1135
	iWorkInProgress->Invalidate();
sl@0
  1136
	iWorkInProgress->Redraw();
sl@0
  1137
	iComparisonWindow->Invalidate();
sl@0
  1138
	iComparisonWindow->Redraw();
sl@0
  1139
	
sl@0
  1140
	DrawTextCursorSimilarToRenderStage(*TheClient->iGc, *iComparisonWindow->Win(), kCursorPos, nonFlashingCursor);
sl@0
  1141
	TheClient->iGroup->GroupWin()->SetTextCursor(*iWorkInProgress->BaseWin(), kCursorPos, nonFlashingCursor);
sl@0
  1142
	TheClient->Flush();
sl@0
  1143
		
sl@0
  1144
	CheckCursorDoesNotFlash(iWorkInProgress->BaseWin()->Size());
sl@0
  1145
	
sl@0
  1146
	delete iWorkInProgress;
sl@0
  1147
	iWorkInProgress = NULL;
sl@0
  1148
	delete iComparisonWindow;
sl@0
  1149
	iComparisonWindow = NULL;
sl@0
  1150
	}
sl@0
  1151
sl@0
  1152
void CTCursorTest::TextCursorFlashTestL()
sl@0
  1153
	{
sl@0
  1154
	TheClient->iGroup->WinTreeNode()->SetOrdinalPosition(0);
sl@0
  1155
	// We use some unique looking colors otherwise its harder
sl@0
  1156
	// to spot which test is which
sl@0
  1157
	TRgb kMildPurple(218, 155, 244);
sl@0
  1158
	TRgb kPaleGreen(146, 190, 12);
sl@0
  1159
	
sl@0
  1160
	iWorkInProgress = new(ELeave) CBlankWindow(kMildPurple);
sl@0
  1161
	iComparisonWindow = new(ELeave) CBlankWindow(kMildPurple);
sl@0
  1162
	CancelTextCursor();
sl@0
  1163
	TheClient->Flush();
sl@0
  1164
	
sl@0
  1165
	const TSize screenSize=TheClient->iGroup->Size();
sl@0
  1166
	const TInt kPad = 5;
sl@0
  1167
	const TInt kThirdOfScreenWidth = screenSize.iWidth/3;
sl@0
  1168
	const TInt kWinWidth = kThirdOfScreenWidth - 2*kPad;
sl@0
  1169
	const TInt kWinHeight = screenSize.iHeight - 2*kPad;
sl@0
  1170
	const TSize kWinSize(kWinWidth, kWinHeight);
sl@0
  1171
	const TPoint kCursorPos(30, 30);
sl@0
  1172
	iWorkInProgress->SetUpL(  TPoint(  kThirdOfScreenWidth + kPad, kPad), kWinSize, TheClient->iGroup, *TheClient->iGc);
sl@0
  1173
	iComparisonWindow->SetUpL(TPoint(2*kThirdOfScreenWidth + kPad, kPad), kWinSize, TheClient->iGroup, *TheClient->iGc);
sl@0
  1174
	
sl@0
  1175
	TTextCursor flashingCursor;
sl@0
  1176
	
sl@0
  1177
	flashingCursor.iType = TTextCursor::ETypeRectangle;
sl@0
  1178
	flashingCursor.iHeight=kCursorHeight;
sl@0
  1179
	flashingCursor.iAscent=0;
sl@0
  1180
	flashingCursor.iWidth=kCursorWidth;
sl@0
  1181
	flashingCursor.iFlags=0; // implies that cursor SHOULD flash
sl@0
  1182
	flashingCursor.iColor = kPaleGreen; // We expect a Flicker Buffer Render Stage to ignore this color
sl@0
  1183
sl@0
  1184
	iWorkInProgress->Invalidate();
sl@0
  1185
	iWorkInProgress->Redraw();
sl@0
  1186
	iComparisonWindow->Invalidate();
sl@0
  1187
	iComparisonWindow->Redraw();
sl@0
  1188
	
sl@0
  1189
	DrawTextCursorSimilarToRenderStage(*TheClient->iGc, *iComparisonWindow->Win(), kCursorPos, flashingCursor);
sl@0
  1190
	TheClient->iGroup->GroupWin()->SetTextCursor(*iWorkInProgress->BaseWin(), kCursorPos, flashingCursor);
sl@0
  1191
	TheClient->Flush();
sl@0
  1192
	
sl@0
  1193
	CheckCursorDoesFlash(kCursorPos, flashingCursor, kMildPurple);
sl@0
  1194
	CancelTextCursor();
sl@0
  1195
	TheClient->Flush();
sl@0
  1196
	
sl@0
  1197
	delete iWorkInProgress;
sl@0
  1198
	iWorkInProgress = NULL;
sl@0
  1199
	delete iComparisonWindow;
sl@0
  1200
	iComparisonWindow = NULL;
sl@0
  1201
	}
sl@0
  1202
sl@0
  1203
void CTCursorTest::DrawTextCursorSimilarToRenderStage(CWindowGc& aGc, RWindow& aWin, const TPoint& aPos, const TTextCursor& aTextCursor)
sl@0
  1204
	{
sl@0
  1205
	// This method duplicates the way in which the default FlickerBuffer Render
sl@0
  1206
	// Stage draws a Text Cursor of ETypeRectangle.  @see CFbRenderStage::DrawTextCursor
sl@0
  1207
	// This code must be kept in sync with the FlickerBuffer Render Stage
sl@0
  1208
	
sl@0
  1209
	ASSERT(aTextCursor.iType == TTextCursor::ETypeRectangle);
sl@0
  1210
	const TRect updatedRegion(aPos,TSize(aTextCursor.iWidth,aTextCursor.iHeight));
sl@0
  1211
	aWin.Invalidate();
sl@0
  1212
	aWin.BeginRedraw();
sl@0
  1213
	aGc.Activate(aWin);
sl@0
  1214
	aGc.Clear();
sl@0
  1215
	aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
  1216
	aGc.SetBrushColor(KRgbBlack);
sl@0
  1217
	aGc.SetPenStyle(CGraphicsContext::ENullPen);
sl@0
  1218
	aGc.Clear(updatedRegion);
sl@0
  1219
	aGc.Deactivate();
sl@0
  1220
	aWin.EndRedraw();
sl@0
  1221
	}
sl@0
  1222
sl@0
  1223
void CTCursorTest::CheckCursorDoesNotFlash(const TSize& aSize)
sl@0
  1224
	{
sl@0
  1225
	const TInt kSampleTime = 100000; // one tenth of a second
sl@0
  1226
	const TInt kSampleLimit = 100;
sl@0
  1227
	TInt sampleIteration = 0;
sl@0
  1228
	TBool comparisonOkay = EFalse;
sl@0
  1229
	
sl@0
  1230
	while (sampleIteration < kSampleLimit)
sl@0
  1231
		{	
sl@0
  1232
		comparisonOkay = DoCheckRect(iWorkInProgress, iComparisonWindow, TRect(TPoint(), aSize), CWsScreenDevice::EIncludeTextCursor);
sl@0
  1233
		if (!comparisonOkay)
sl@0
  1234
			{
sl@0
  1235
			INFO_PRINTF2(_L("CheckCursorDoesNotFlash difference found after %d milliseconds"), sampleIteration*100);
sl@0
  1236
			break;
sl@0
  1237
			}
sl@0
  1238
		sampleIteration++;
sl@0
  1239
		User::After(kSampleTime);
sl@0
  1240
		}
sl@0
  1241
	TEST(comparisonOkay);
sl@0
  1242
	}
sl@0
  1243
sl@0
  1244
void CTCursorTest::UpdateCountersOnCursorTransition(
sl@0
  1245
		const TBool	aTransitionedToOn,
sl@0
  1246
		TTime& 		aNow,
sl@0
  1247
		TInt64&		aDeltaTime,
sl@0
  1248
		TTime&		aLastDeltaTime,
sl@0
  1249
		TInt&		aWarmUpIterations,
sl@0
  1250
		const TInt&	aFlashChangeTime,
sl@0
  1251
		const TInt&	aToleranceMargin,
sl@0
  1252
		TInt&		aSampleNumber,
sl@0
  1253
		TInt&		aToleranceViolations
sl@0
  1254
		)
sl@0
  1255
	{
sl@0
  1256
	_LIT(KTxtOn,	" On");
sl@0
  1257
	_LIT(KTxtOff,	"Off");
sl@0
  1258
	TBufC<3> transitionType;	
sl@0
  1259
	transitionType = aTransitionedToOn ? KTxtOn : KTxtOff;
sl@0
  1260
	
sl@0
  1261
	aNow.UniversalTime();
sl@0
  1262
	aDeltaTime = aNow.MicroSecondsFrom(aLastDeltaTime).Int64();
sl@0
  1263
	aLastDeltaTime = aNow;
sl@0
  1264
	
sl@0
  1265
	if (aWarmUpIterations > 0)
sl@0
  1266
		{
sl@0
  1267
		aWarmUpIterations--;
sl@0
  1268
		}
sl@0
  1269
	else
sl@0
  1270
		{
sl@0
  1271
		if (aDeltaTime > aFlashChangeTime + aToleranceMargin ||
sl@0
  1272
				aDeltaTime < aFlashChangeTime - aToleranceMargin)
sl@0
  1273
			{
sl@0
  1274
			INFO_PRINTF5(_L(" Iteration %d, Cursor %S after %d, errorDelta %d microseconds"),
sl@0
  1275
					aSampleNumber, &transitionType, I64INT(aDeltaTime), I64INT(aDeltaTime - aFlashChangeTime));
sl@0
  1276
			aToleranceViolations++;
sl@0
  1277
			}
sl@0
  1278
		}
sl@0
  1279
	}
sl@0
  1280
void CTCursorTest::CheckCursorDoesFlash(const TPoint& aPos, const TTextCursor& aTextCursor, TRgb /* aBackgroundColor */)
sl@0
  1281
	{	
sl@0
  1282
	
sl@0
  1283
	/**
sl@0
  1284
	 * Quality of Service based thresholding
sl@0
  1285
	 * 
sl@0
  1286
	 * The idea behind this test is to identify tolerances which would either
sl@0
  1287
	 * cause the test to fail when the user would perceive the text cursor as
sl@0
  1288
	 * not flashing uniformly, or would point to an unexpected delay outside
sl@0
  1289
	 * the way the flashing (and scheduling of animations) is supposed to work.
sl@0
  1290
	 * 
sl@0
  1291
	 * Potentially the cursor can be late if we miss a V-SYNC from hardware.  In
sl@0
  1292
	 * such cases we expect to see the cursor on the next frame.  Since the V-SYNC
sl@0
  1293
	 * is typically 1/50 second, a tolerance of two frames, or 1/25 second is reasonable.
sl@0
  1294
	 * 
sl@0
  1295
	 * If the cursor is delayed longer than this, say a long time of 1 second, but this
sl@0
  1296
	 * does not happen too often, then the user is likely to still be happy.  So we
sl@0
  1297
	 * set the period of testing to 60 seconds, and set the violations limit to 2.
sl@0
  1298
	 */
sl@0
  1299
	const TInt kOneSecond = 1000000;
sl@0
  1300
	const TInt kFlashPeriod = kOneSecond; 		// comprises one "ON" and one "OFF"
sl@0
  1301
	const TInt kToleranceFactor = 25; 			// meaning 1/25 of a Flash Period
sl@0
  1302
	const TInt kNumberTestFlashPeriods = 60;	// meaning 60 Flash Periods worth of testing
sl@0
  1303
	const TInt kMaximumToleranceViolations = 2;	// number of times an occassional flash may be late or early
sl@0
  1304
	
sl@0
  1305
	const TInt kToleranceMargin = kFlashPeriod / kToleranceFactor;
sl@0
  1306
	const TInt kNumberSamples = kNumberTestFlashPeriods * kToleranceFactor;
sl@0
  1307
	const TInt kFlashChangeTime = kFlashPeriod / 2;
sl@0
  1308
	
sl@0
  1309
	// The first couple of changes to the cursor should be ignored because
sl@0
  1310
	// when the test is started, the cursor may have been on for a while.
sl@0
  1311
	// Then when the cursor goes off, it appears to have switched to the
sl@0
  1312
	// off state too early.  We therefore ignore the first two changes
sl@0
  1313
	// so we start cleanly.
sl@0
  1314
	TInt warmUpIterations = 2;
sl@0
  1315
	
sl@0
  1316
	// Empirically we see that cursors mostly flash with good timeliness apart from
sl@0
  1317
	// occasional events causing them to be either early or late.  In order to keep
sl@0
  1318
	// a tight tolerance (1/50 second is around the screen refresh time) but still
sl@0
  1319
	// allow for the occasional variance (seen to be 1/23 second) we use a counter
sl@0
  1320
	// toleranceViolations < kMaximumToleranceViolations
sl@0
  1321
	TInt toleranceViolations = 0;
sl@0
  1322
	TBool cursorShownLastTime = EFalse;
sl@0
  1323
	TBool cursorShown = EFalse;
sl@0
  1324
	TTime lastDeltaTime;
sl@0
  1325
	TTime now;
sl@0
  1326
	TInt64 deltaTime = 0;
sl@0
  1327
	lastDeltaTime.UniversalTime();
sl@0
  1328
	now.UniversalTime();
sl@0
  1329
sl@0
  1330
	TRect textCursorRect(TRect(aPos, TSize(aTextCursor.iWidth, aTextCursor.iHeight)));
sl@0
  1331
sl@0
  1332
	for (TInt sampleNumber = 0; sampleNumber < kNumberSamples; sampleNumber++)
sl@0
  1333
		{
sl@0
  1334
		cursorShown = DoCheckRect(iWorkInProgress, iComparisonWindow, textCursorRect, CWsScreenDevice::EIncludeTextCursor);
sl@0
  1335
sl@0
  1336
		if (cursorShown && !cursorShownLastTime)
sl@0
  1337
			{
sl@0
  1338
			cursorShownLastTime = ETrue;
sl@0
  1339
			UpdateCountersOnCursorTransition(
sl@0
  1340
					cursorShownLastTime, now, deltaTime, lastDeltaTime, warmUpIterations, kFlashChangeTime,
sl@0
  1341
					kToleranceMargin, sampleNumber, toleranceViolations);
sl@0
  1342
			}
sl@0
  1343
		else if (!cursorShown && cursorShownLastTime)
sl@0
  1344
			{
sl@0
  1345
			cursorShownLastTime = EFalse;
sl@0
  1346
			UpdateCountersOnCursorTransition(
sl@0
  1347
					cursorShownLastTime, now, deltaTime, lastDeltaTime, warmUpIterations, kFlashChangeTime,
sl@0
  1348
					kToleranceMargin, sampleNumber, toleranceViolations);
sl@0
  1349
			}
sl@0
  1350
sl@0
  1351
		if (toleranceViolations > kMaximumToleranceViolations)
sl@0
  1352
			break;
sl@0
  1353
sl@0
  1354
		User::After(kToleranceMargin);
sl@0
  1355
		}
sl@0
  1356
	// Check was some flashing
sl@0
  1357
	TEST_SOFTFAIL_WINSCW(warmUpIterations == 0);
sl@0
  1358
	// Check cursor flashed on and off, regularly and on-time
sl@0
  1359
	TEST_SOFTFAIL_WINSCW(toleranceViolations <= kMaximumToleranceViolations);
sl@0
  1360
	}
sl@0
  1361
#endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
sl@0
  1362
sl@0
  1363
void CTCursorTest::MakeCursors(TTextCursor& aTextCursor, TTextCursor& aCustomCursor)
sl@0
  1364
	{
sl@0
  1365
	aCustomCursor.iType = KTextCursorInitialIdValue + iTest->iScreenNumber*KNumberOfCustoTextCursors; // custom text cursor
sl@0
  1366
	aCustomCursor.iAscent=0;
sl@0
  1367
	aCustomCursor.iHeight=kCursorHeight;
sl@0
  1368
	aCustomCursor.iWidth=kCursorWidth;
sl@0
  1369
	aCustomCursor.iFlags=TTextCursor::EFlagNoFlash; 
sl@0
  1370
	aCustomCursor.iColor=TRgb::Color256(217);	
sl@0
  1371
		
sl@0
  1372
	// Create a standard cursor for the tests
sl@0
  1373
	aTextCursor.iType = TTextCursor::ETypeRectangle; // Normal rectangular text cursor
sl@0
  1374
	aTextCursor.iHeight=kCursorHeight;
sl@0
  1375
	aTextCursor.iAscent=0;
sl@0
  1376
	aTextCursor.iWidth=kCursorWidth;
sl@0
  1377
	aTextCursor.iFlags=TTextCursor::EFlagNoFlash;
sl@0
  1378
	}
sl@0
  1379
sl@0
  1380
void CTCursorTest::StartDoubleCursorTestL(TInt aTestNumber)
sl@0
  1381
	{
sl@0
  1382
	// general setup
sl@0
  1383
	CBlankWindow* win1=new(ELeave) CBlankWindow(KRgbWhite);
sl@0
  1384
	CleanupStack::PushL(win1);
sl@0
  1385
sl@0
  1386
	win1->SetUpL(kWin1TopLeft,kWinSize,TheClient->iGroup,*TheClient->iGc,EColor64K);
sl@0
  1387
	
sl@0
  1388
	win1->Redraw();
sl@0
  1389
	
sl@0
  1390
	// Create the second window
sl@0
  1391
	CBlankWindow* win2=new(ELeave) CBlankWindow(KRgbWhite);
sl@0
  1392
	CleanupStack::PushL(win2);
sl@0
  1393
sl@0
  1394
	win2->SetUpL(kWin2TopLeft,kWinSize,TheClient->iGroup,*TheClient->iGc,EColor64K);
sl@0
  1395
	win2->Redraw();
sl@0
  1396
sl@0
  1397
	// Create normal and custom cursor for the tests
sl@0
  1398
	TTextCursor textCursor;
sl@0
  1399
	TTextCursor customCursor;
sl@0
  1400
	MakeCursors(textCursor, customCursor);
sl@0
  1401
sl@0
  1402
	TheClient->Flush();
sl@0
  1403
	CWindowGc* winGc = TheClient->iGc;	
sl@0
  1404
sl@0
  1405
	switch(aTestNumber)
sl@0
  1406
		{
sl@0
  1407
		case 1:
sl@0
  1408
		CheckNoDoubleCursorTest1L(win1, win2, textCursor, customCursor, winGc);
sl@0
  1409
		break;
sl@0
  1410
		
sl@0
  1411
		case 2:
sl@0
  1412
		CheckNoDoubleCursorTest2L(win1, win2, textCursor, customCursor, winGc);
sl@0
  1413
		break;
sl@0
  1414
		
sl@0
  1415
		case 3:
sl@0
  1416
		CheckNoDoubleCursorTest3L(win1, win2, textCursor, customCursor, winGc);
sl@0
  1417
		break;
sl@0
  1418
		
sl@0
  1419
		default:
sl@0
  1420
		TEST(EFalse);
sl@0
  1421
		break;
sl@0
  1422
		}
sl@0
  1423
	CleanupStack::PopAndDestroy(2); 	
sl@0
  1424
	}
sl@0
  1425
sl@0
  1426
// DEF098704
sl@0
  1427
void CTCursorTest::CheckNoDoubleCursorTest1L(CBlankWindow* aWin1, CBlankWindow* aWin2, TTextCursor& /*aTextCursor*/, TTextCursor& aCustomCursor, CWindowGc* aWinGc)
sl@0
  1428
	{
sl@0
  1429
	// Test that changing the focus of a custom text cursor does not leave that cursor drawn where it was (INC093898)
sl@0
  1430
sl@0
  1431
	TheClient->iGroup->GroupWin()->SetTextCursor(*aWin1->BaseWin(),TPoint(),aCustomCursor);
sl@0
  1432
		
sl@0
  1433
	// Bit blit the TEST_BITMAP_NAME image to the second window to use as a comparison
sl@0
  1434
	// this is the same image that the custom cursor is using
sl@0
  1435
	CFbsBitmap* bitmap = new(ELeave) CFbsBitmap;
sl@0
  1436
	CleanupStack::PushL(bitmap);
sl@0
  1437
	TEST(KErrNone == bitmap->Load(TEST_BITMAP_NAME,0,ETrue)); 
sl@0
  1438
sl@0
  1439
	aWinGc->Activate(*aWin2->Win());
sl@0
  1440
	TRect updateArea(TPoint(0,0), bitmap->SizeInPixels());
sl@0
  1441
	aWin2->Win()->Invalidate(updateArea);
sl@0
  1442
	aWin2->Win()->BeginRedraw(updateArea);
sl@0
  1443
	aWinGc->BitBlt(TPoint(0,0),bitmap); 
sl@0
  1444
	aWinGc->Deactivate();
sl@0
  1445
	aWin2->Win()->EndRedraw();
sl@0
  1446
	TheClient->Flush();
sl@0
  1447
	doCheckNoDoubleCursor(aWin1,aWin2,kWin1TopLeft,kWin2TopLeft,aCustomCursor,bitmap->SizeInPixels(),CWsScreenDevice::EIncludeSprite);
sl@0
  1448
	CleanupStack::PopAndDestroy(1); // bitmap
sl@0
  1449
	}
sl@0
  1450
sl@0
  1451
// DEF098704
sl@0
  1452
void CTCursorTest::CheckNoDoubleCursorTest2L(CBlankWindow* aWin1, CBlankWindow* aWin2, TTextCursor& /*aTextCursor*/, TTextCursor& aCustomCursor, CWindowGc* aWinGc)
sl@0
  1453
	{
sl@0
  1454
	//TEST 2: Checks that no artifacts are left behind when a text cursor is moved from under a transparent sprite
sl@0
  1455
	
sl@0
  1456
	// Construct the window win1 with a transparent sprite
sl@0
  1457
	
sl@0
  1458
	// Clear the top and bottom windows
sl@0
  1459
	ResetWindows(aWinGc,aWin1,aWin2);	
sl@0
  1460
	
sl@0
  1461
	// Create a bitmap and a corresponding bitmap mask
sl@0
  1462
	CFbsBitmap* bitmap = new(ELeave) CFbsBitmap;
sl@0
  1463
	CleanupStack::PushL(bitmap);
sl@0
  1464
	TEST(KErrNone == bitmap->Load(TEST_BITMAP_NAME,0,ETrue)); 
sl@0
  1465
	CBitmap* spriteBitmap=CBitmap::NewL(kWinSize,EColor256);
sl@0
  1466
	CleanupStack::PushL(spriteBitmap);
sl@0
  1467
	spriteBitmap->Gc().SetBrushColor(KRgbBlack);
sl@0
  1468
	spriteBitmap->Gc().SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
  1469
	spriteBitmap->Gc().SetPenStyle(CGraphicsContext::ESolidPen); 
sl@0
  1470
	spriteBitmap->Gc().DrawRect(TRect(kWinSize));
sl@0
  1471
	CBitmap* mask=CBitmap::NewL(kWinSize,EColor256);
sl@0
  1472
	CleanupStack::PushL(mask);
sl@0
  1473
	mask->Gc().SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
  1474
	mask->Gc().SetBrushColor(KRgbBlack);
sl@0
  1475
	mask->Gc().DrawRect(TRect(kWinSize));	
sl@0
  1476
	
sl@0
  1477
	// Create a sprite
sl@0
  1478
	RWsSprite sprite = RWsSprite(TheClient->iWs);
sl@0
  1479
	CleanupClosePushL(sprite);
sl@0
  1480
	TEST(KErrNone == sprite.Construct(*aWin1->BaseWin(),TPoint(),0));
sl@0
  1481
	
sl@0
  1482
	// Add the bitmap to the sprite
sl@0
  1483
	TSpriteMember member;
sl@0
  1484
	member.iInvertMask=EFalse;
sl@0
  1485
	member.iDrawMode=CGraphicsContext::EDrawModePEN;
sl@0
  1486
	member.iOffset=TPoint();
sl@0
  1487
	member.iInterval=TTimeIntervalMicroSeconds32(0);
sl@0
  1488
	member.iBitmap = &spriteBitmap->Bitmap();
sl@0
  1489
	member.iMaskBitmap = &mask->Bitmap(); 
sl@0
  1490
	TEST(KErrNone == sprite.AppendMember(member));
sl@0
  1491
	
sl@0
  1492
	// Activate the sprite in win1
sl@0
  1493
	TEST(KErrNone == sprite.Activate());
sl@0
  1494
	
sl@0
  1495
	// Put a cursor in win1
sl@0
  1496
	TheClient->iGroup->GroupWin()->SetTextCursor(*aWin1->BaseWin(),TPoint(),aCustomCursor);
sl@0
  1497
	
sl@0
  1498
	// Bit blit the matching bitmap to the bottom window
sl@0
  1499
	TRect bitmapArea(TPoint(0,0), bitmap->SizeInPixels());
sl@0
  1500
	aWin2->Win()->Invalidate(bitmapArea);
sl@0
  1501
	aWin2->Win()->BeginRedraw(bitmapArea);
sl@0
  1502
	aWinGc->Activate(*aWin2->Win());
sl@0
  1503
	aWinGc->BitBlt(TPoint(),bitmap); 
sl@0
  1504
	aWinGc->Deactivate();
sl@0
  1505
	aWin2->Win()->EndRedraw();
sl@0
  1506
		
sl@0
  1507
	TheClient->Flush();
sl@0
  1508
	doCheckNoDoubleCursor(aWin1,aWin2,kWin1TopLeft,kWin2TopLeft,aCustomCursor,bitmap->SizeInPixels(),CWsScreenDevice::EIncludeSprite);
sl@0
  1509
	CleanupStack::PopAndDestroy(4); // sprite, mask, spriteBitmap, bitmap
sl@0
  1510
	}
sl@0
  1511
sl@0
  1512
// DEF098704		
sl@0
  1513
void CTCursorTest::CheckNoDoubleCursorTest3L(CBlankWindow* aWin1, CBlankWindow* aWin2, TTextCursor& aTextCursor,TTextCursor& aCustomCursor, CWindowGc* aWinGc)
sl@0
  1514
	{
sl@0
  1515
	//
sl@0
  1516
	// TEST 3: Test a flashing text cursor does not leave artifacts when a redraw + change position happens during
sl@0
  1517
	// the time the cursor flashing 'off'
sl@0
  1518
	// 
sl@0
  1519
	// This test moves a flashing cursor a number of times over a two second period to a seconds position.
sl@0
  1520
	// it does it a number of times so some of the redraws will occur during the 'flash off' period
sl@0
  1521
	// We then compare the 'after' position to what we expect
sl@0
  1522
	// 
sl@0
  1523
	// There are four possible outcomes when we look at the bitmap after the redraw + move
sl@0
  1524
	// Position 1 is the original position, position 2 is the new position after the redraw
sl@0
  1525
	// 
sl@0
  1526
	// cursor artifact @ pos1 and flashed on cursor @ pos2
sl@0
  1527
	// cursor artifact at pos1 and flashed off cursor @ pos2
sl@0
  1528
	// no artifact at pos1 and flashed off cursor @ pos2
sl@0
  1529
	// no artifact at pos1 and flashed on cursor @ pos2
sl@0
  1530
	// 
sl@0
  1531
	// any artifacts left over will cause the complete test to fail.
sl@0
  1532
	//
sl@0
  1533
	
sl@0
  1534
	//
sl@0
  1535
	// PART A: 
sl@0
  1536
	aTextCursor.iFlags=0; 	// flashing
sl@0
  1537
sl@0
  1538
	ResetWindows(aWinGc,aWin1,aWin2);	
sl@0
  1539
	TestForArtifacts(aWin1, aTextCursor);
sl@0
  1540
	
sl@0
  1541
	//
sl@0
  1542
	// PART B - For a non-custom text cursor
sl@0
  1543
	aCustomCursor.iFlags=0; // flashing
sl@0
  1544
sl@0
  1545
	ResetWindows(aWinGc,aWin1,aWin2);	
sl@0
  1546
	TestForArtifacts(aWin1, aCustomCursor);	
sl@0
  1547
	}
sl@0
  1548
	
sl@0
  1549
// moves the cursor between two positions while flashing and tests no artifacts are left at the position it moved from
sl@0
  1550
// The moves take place in a loop so it is tested happening when the cursor is flashed on and also off
sl@0
  1551
void CTCursorTest::TestForArtifacts(CBlankWindow* aWin1, TTextCursor& aCursor)
sl@0
  1552
	{
sl@0
  1553
	const TInt KIterations = 30;
sl@0
  1554
	const TPoint kStartPos(0,0);
sl@0
  1555
	const TPoint kMoveToPos(200,0);
sl@0
  1556
	TRect r1(kWin1TopLeft,kCursorSize);
sl@0
  1557
	TRect r2(kWin2TopLeft,kCursorSize);
sl@0
  1558
	const TPoint kWin1TopLeft; 
sl@0
  1559
	const TPoint kWin2TopLeft; 
sl@0
  1560
	const TSize aCursorSize;
sl@0
  1561
sl@0
  1562
	TheClient->iGroup->GroupWin()->SetTextCursor(*aWin1->BaseWin(),kStartPos,aCursor);
sl@0
  1563
	TheClient->Flush();
sl@0
  1564
sl@0
  1565
	TInt initialRepeatRate = 1000000; 
sl@0
  1566
	const TInt KIncrement = 30000;
sl@0
  1567
	TInt i=0;
sl@0
  1568
sl@0
  1569
	for(i=0; i<KIterations; i++)		
sl@0
  1570
		{
sl@0
  1571
		// move the cursor to its new position
sl@0
  1572
		TheClient->iGroup->GroupWin()->SetTextCursor(*aWin1->BaseWin(),kMoveToPos,aCursor);
sl@0
  1573
		TheClient->Flush();
sl@0
  1574
sl@0
  1575
		User::After(initialRepeatRate);
sl@0
  1576
		
sl@0
  1577
		// check no artifact was left in position 1 by comparing against (blank) win2
sl@0
  1578
		if(!TheClient->iScreen->RectCompare( r1,r2, CWsScreenDevice::EIncludeTextCursor))
sl@0
  1579
			{
sl@0
  1580
			break; // detected an artifact remaining, test failed
sl@0
  1581
			}
sl@0
  1582
sl@0
  1583
		// move the cursor back to its start position, this resets the flash timer which is why we increment initialRepeatRate 
sl@0
  1584
		TheClient->iGroup->GroupWin()->SetTextCursor(*aWin1->BaseWin(),kStartPos,aCursor);
sl@0
  1585
		TheClient->Flush();
sl@0
  1586
		initialRepeatRate += KIncrement;
sl@0
  1587
		}
sl@0
  1588
		
sl@0
  1589
		// if all went well i should equal KIterations, if it doesnt its because we detected 
sl@0
  1590
		// an artifact and quit the test early
sl@0
  1591
	TEST_SOFTFAIL_WINSCW(i==KIterations);
sl@0
  1592
	}
sl@0
  1593
	
sl@0
  1594
sl@0
  1595
// Tests the two windows match, moves the cursor off win 1 then tests they no longer match 		
sl@0
  1596
void CTCursorTest::doCheckNoDoubleCursor(CBlankWindow* aWin1,
sl@0
  1597
											CBlankWindow* aWin2,
sl@0
  1598
											const TPoint& aWin1Tl,
sl@0
  1599
											const TPoint& aWin2Tl,
sl@0
  1600
											const TTextCursor& aCursor,
sl@0
  1601
											const TSize& aCursorSize,
sl@0
  1602
											CWsScreenDevice::TSpriteInCompare aFlags)
sl@0
  1603
	{
sl@0
  1604
	TRect r1(aWin1Tl,aCursorSize);
sl@0
  1605
	TRect r2(aWin2Tl,aCursorSize);
sl@0
  1606
	
sl@0
  1607
	TInt compareTries = 0;
sl@0
  1608
	const TInt compareLimit = 5;
sl@0
  1609
	
sl@0
  1610
	TBool correctComparison = EFalse;
sl@0
  1611
	while (!correctComparison && compareTries < compareLimit)
sl@0
  1612
		{
sl@0
  1613
		compareTries++;
sl@0
  1614
		User::After(500000);
sl@0
  1615
		correctComparison = TheClient->iScreen->RectCompare(r1,r2, aFlags);
sl@0
  1616
		}
sl@0
  1617
sl@0
  1618
	INFO_PRINTF3(_L("Result Before %d (attempts %d)"), correctComparison, compareTries);
sl@0
  1619
	TEST_SOFTFAIL_WINSCW(correctComparison);
sl@0
  1620
sl@0
  1621
	
sl@0
  1622
	// Change the focus off win1, by drawing the text cursor on the second window
sl@0
  1623
	TheClient->iGroup->GroupWin()->SetTextCursor(*aWin2->BaseWin(),aWin2Tl,aCursor);
sl@0
  1624
	TheClient->Flush();
sl@0
  1625
sl@0
  1626
	// Cause a redraw
sl@0
  1627
	aWin1->CTWin::DrawNow();
sl@0
  1628
	TheClient->WaitForRedrawsToFinish();
sl@0
  1629
sl@0
  1630
	// make sure any cursor has actually moved	
sl@0
  1631
	User::After(1000000); // 1 sec
sl@0
  1632
	
sl@0
  1633
	TBool resultAfter;
sl@0
  1634
	resultAfter = !TheClient->iScreen->RectCompare(r1,r2, aFlags);
sl@0
  1635
	INFO_PRINTF2(_L("Result After %d"), resultAfter);
sl@0
  1636
	TEST_SOFTFAIL_WINSCW(resultAfter);
sl@0
  1637
	}	
sl@0
  1638
sl@0
  1639
// resets the windows to their initial state
sl@0
  1640
void CTCursorTest::ResetWindows(CWindowGc* aWinGc,CBlankWindow* aWin1,CBlankWindow* aWin2)
sl@0
  1641
	{
sl@0
  1642
	TheClient->iGroup->GroupWin()->CancelTextCursor();
sl@0
  1643
	aWinGc->Activate(*aWin1->Win());
sl@0
  1644
	aWinGc->Reset();
sl@0
  1645
	aWinGc->Clear();
sl@0
  1646
	aWinGc->Deactivate();
sl@0
  1647
sl@0
  1648
	aWin1->Invalidate();
sl@0
  1649
	aWin1->Redraw();
sl@0
  1650
	aWin2->Invalidate();
sl@0
  1651
	aWin2->Redraw();
sl@0
  1652
	TheClient->Flush();
sl@0
  1653
	}
sl@0
  1654
	
sl@0
  1655
void CTCursorTest::RunTestCaseL(TInt /*aCurTestCase*/)
sl@0
  1656
	{
sl@0
  1657
	TBool deleteMove=EFalse;
sl@0
  1658
	((CTCursorTestStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
sl@0
  1659
sl@0
  1660
	switch(++iTest->iState)
sl@0
  1661
		{
sl@0
  1662
/**
sl@0
  1663
@SYMTestCaseID		GRAPHICS-WSERV-0241
sl@0
  1664
sl@0
  1665
@SYMDEF				DEF081259
sl@0
  1666
sl@0
  1667
@SYMTestCaseDesc    Test the text cursor functions properly as a window is moved
sl@0
  1668
sl@0
  1669
@SYMTestPriority    High
sl@0
  1670
sl@0
  1671
@SYMTestStatus      Implemented
sl@0
  1672
sl@0
  1673
@SYMTestActions     Move a window about the screen and meanwhile check the text
sl@0
  1674
					cursor functions correctly
sl@0
  1675
sl@0
  1676
@SYMTestExpectedResults The text cursor functions correctly as the window is moved
sl@0
  1677
*/
sl@0
  1678
	case 1:
sl@0
  1679
		((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0241"));
sl@0
  1680
		while (!deleteMove)
sl@0
  1681
			{
sl@0
  1682
			if (iCursorType==TTextCursor::ETypeFirst)
sl@0
  1683
				iTest->LogSubTest(_L("Cursor 1"));
sl@0
  1684
			if (MoveWindow())
sl@0
  1685
				{
sl@0
  1686
				if (IncrementCursorType())
sl@0
  1687
					{
sl@0
  1688
					ResetMoveWindowsL();
sl@0
  1689
					}
sl@0
  1690
				else
sl@0
  1691
					{
sl@0
  1692
					DeleteMoveWindows();
sl@0
  1693
					deleteMove =true;
sl@0
  1694
					}
sl@0
  1695
				}
sl@0
  1696
			}
sl@0
  1697
		break;
sl@0
  1698
sl@0
  1699
/**
sl@0
  1700
@SYMTestCaseID		GRAPHICS-WSERV-0242
sl@0
  1701
sl@0
  1702
@SYMDEF				DEF081259
sl@0
  1703
sl@0
  1704
@SYMTestCaseDesc    Test the text cursor functions properly as the window is scrolled
sl@0
  1705
sl@0
  1706
@SYMTestPriority    High
sl@0
  1707
sl@0
  1708
@SYMTestStatus      Implemented
sl@0
  1709
sl@0
  1710
@SYMTestActions     Scroll the window and meanwhile check the text cursor functions correctly
sl@0
  1711
sl@0
  1712
@SYMTestExpectedResults The text cursor functions correctly as the window is scrolled
sl@0
  1713
*/
sl@0
  1714
		case 2:
sl@0
  1715
			((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0242"));
sl@0
  1716
			iTest->LogSubTest(_L("Cursor 2"));
sl@0
  1717
			iCursorType=TTextCursor::ETypeRectangle;
sl@0
  1718
			ScrollTest();
sl@0
  1719
			iCursorType=TTextCursor::ETypeFirst;
sl@0
  1720
			break;
sl@0
  1721
/**
sl@0
  1722
@SYMTestCaseID		GRAPHICS-WSERV-0244
sl@0
  1723
sl@0
  1724
@SYMDEF				DEF081259
sl@0
  1725
sl@0
  1726
@SYMTestCaseDesc    Test the text cursor functions properly as a blank window is moved
sl@0
  1727
sl@0
  1728
@SYMTestPriority    High
sl@0
  1729
sl@0
  1730
@SYMTestStatus      Implemented
sl@0
  1731
sl@0
  1732
@SYMTestActions     Move a blank window about the screen and meanwhile check the text
sl@0
  1733
					cursor functions correctly
sl@0
  1734
sl@0
  1735
@SYMTestExpectedResults The text cursor functions correctly as the blank window is moved
sl@0
  1736
*/
sl@0
  1737
		case 3:
sl@0
  1738
			((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0244"));
sl@0
  1739
			iTest->LogSubTest(_L("Move window1"));
sl@0
  1740
			MoveWindowTest1L();
sl@0
  1741
			break;
sl@0
  1742
/**
sl@0
  1743
@SYMTestCaseID		GRAPHICS-WSERV-0245
sl@0
  1744
sl@0
  1745
@SYMDEF				DEF081259
sl@0
  1746
sl@0
  1747
@SYMTestCaseDesc    Test that a non flashing text cursor functions properly as a 
sl@0
  1748
					blank window is moved
sl@0
  1749
sl@0
  1750
@SYMTestPriority    High
sl@0
  1751
sl@0
  1752
@SYMTestStatus      Implemented
sl@0
  1753
sl@0
  1754
@SYMTestActions     Move a blank window about the screen and meanwhile check that a non
sl@0
  1755
					flashing text cursor functions correctly
sl@0
  1756
sl@0
  1757
@SYMTestExpectedResults The text cursor functions correctly as the blank window is moved
sl@0
  1758
*/
sl@0
  1759
		case 4:
sl@0
  1760
			((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0245"));
sl@0
  1761
			while (IncrementCursorType())
sl@0
  1762
				{
sl@0
  1763
				iTest->LogSubTest(_L("Move window2"));
sl@0
  1764
				MoveWindowTest2L();
sl@0
  1765
				}
sl@0
  1766
			break;		
sl@0
  1767
/**
sl@0
  1768
@SYMTestCaseID		GRAPHICS-WSERV-0247
sl@0
  1769
sl@0
  1770
@SYMDEF				DEF081259
sl@0
  1771
sl@0
  1772
@SYMTestCaseDesc    Tests a Custom Text Cursor Sprite visibility after wserv hearbeat suppression
sl@0
  1773
					REQUIREMENT:	INC040489.
sl@0
  1774
sl@0
  1775
@SYMTestPriority    High
sl@0
  1776
sl@0
  1777
@SYMTestStatus      Implemented
sl@0
  1778
sl@0
  1779
@SYMTestActions     Create a window group with an associated window for it, then activate it.
sl@0
  1780
					Create another window group with an associated window along with a custom cursor, 
sl@0
  1781
					then active it. Make a call to suppress the wserv hearbeat, which will stop 
sl@0
  1782
					the custom cursor from flashing with flash ON state. Bring the first window 
sl@0
  1783
					group to the foreground and cancel the custom test cursor in the second window group.
sl@0
  1784
					After that, put the first window group to the background and set the custom test 
sl@0
  1785
					cursor in the second window group. Simulate a raw key event to start 
sl@0
  1786
					the wserv heartbeat, which will make the custom cursor flashing.
sl@0
  1787
sl@0
  1788
@SYMTestExpectedResults The Custom text cursor in the second window group should be visible and flashing, 
sl@0
  1789
						when it comes to the foreground after the first window group sent to the background.
sl@0
  1790
*/
sl@0
  1791
		case 5:
sl@0
  1792
			((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0247"));
sl@0
  1793
			iTest->LogSubTest(_L("Custom Text Cursor Sprite visibility"));
sl@0
  1794
			INC040489L();
sl@0
  1795
			break;
sl@0
  1796
/**
sl@0
  1797
@SYMTestCaseID		GRAPHICS-WSERV-2095-0015
sl@0
  1798
sl@0
  1799
@SYMTestCaseDesc    Text Cursor allows Update before Rendering the owning window
sl@0
  1800
sl@0
  1801
@SYMTestPriority    Normal
sl@0
  1802
sl@0
  1803
@SYMTestStatus      Implemented
sl@0
  1804
sl@0
  1805
@SYMTestActions     Create a window group and two windows, one with a Text Cursor.
sl@0
  1806
					Stimulate a state change in the Text Cursor by receiving
sl@0
  1807
					window focus, but before the Window has ever been Rendered.
sl@0
  1808
					This shakes out logic in RWsTextCursor which depends on
sl@0
  1809
					side effects arising from having executed CWsWindow::Render()
sl@0
  1810
					
sl@0
  1811
@SYMTestExpectedResults 
sl@0
  1812
					There should be no panic or assertion.
sl@0
  1813
*/
sl@0
  1814
		case 6:
sl@0
  1815
			((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-2095-0015"));
sl@0
  1816
			iTest->LogSubTest(_L("Update before Render"));
sl@0
  1817
			CursorUpdatedBeforeWindowRenderedL();
sl@0
  1818
			break;
sl@0
  1819
sl@0
  1820
/**
sl@0
  1821
@SYMTestCaseID		GRAPHICS-WSERV-0248
sl@0
  1822
sl@0
  1823
@SYMDEF  			DEF081259
sl@0
  1824
sl@0
  1825
@SYMTestCaseDesc    Tests a bad use of text cursor functionality from a client.
sl@0
  1826
					REQ 1079, CR RDEF-5F7Q24 (10/04/2003).
sl@0
  1827
sl@0
  1828
@SYMTestPriority    High
sl@0
  1829
sl@0
  1830
@SYMTestStatus      Implemented
sl@0
  1831
sl@0
  1832
@SYMTestActions     This test case checks whether the window server is able to detect a bad
sl@0
  1833
					use of the text cursor functionality (including the custom text cursor)
sl@0
  1834
					by a client.
sl@0
  1835
					This test case launches several threads and each of them will try
sl@0
  1836
					to use the text cursor functionality in a non-proper way.
sl@0
  1837
sl@0
  1838
@SYMTestExpectedResults Each new thread has panic code associated to it. This is the expected panic when
sl@0
  1839
						the thread dies.
sl@0
  1840
						The thread once launched is expected to panic and the returning panic code should
sl@0
  1841
						match the expected one.
sl@0
  1842
*/
sl@0
  1843
		case 7:
sl@0
  1844
			((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0248"));
sl@0
  1845
			iTest->LogSubTest(_L("Panic"));
sl@0
  1846
			TestPanicsL();
sl@0
  1847
			break;
sl@0
  1848
/**
sl@0
  1849
@SYMTestCaseID		GRAPHICS-WSERV-0400
sl@0
  1850
sl@0
  1851
@SYMDEF				PDEF099013
sl@0
  1852
sl@0
  1853
@SYMTestCaseDesc    Cursor moves slowly in text editors. 
sl@0
  1854
sl@0
  1855
@SYMTestPriority    High
sl@0
  1856
sl@0
  1857
@SYMTestStatus      Implemented
sl@0
  1858
sl@0
  1859
@SYMTestActions     This test case is a VISUAL TEST only on whether a scrolling text cursor is drawn to the
sl@0
  1860
					screen correctly. 2 types of cursor are checked both clipped and non clipped cursors.
sl@0
  1861
					In each case the test simulates a text cursor moving across the screen as if a user were
sl@0
  1862
					holding down a key to scroll the cursor through a section of text.
sl@0
  1863
sl@0
  1864
@SYMTestExpectedResults The text cursor in both cases should scroll smoothly to the centre of the screen.
sl@0
  1865
						In versions prior to this fix the cursor was not correctly drawn and appeared to move 	
sl@0
  1866
						slowly.
sl@0
  1867
*/
sl@0
  1868
		case 8:
sl@0
  1869
			((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0400"));
sl@0
  1870
			iTest->LogSubTest(_L("Text Cursor Update Tests"));
sl@0
  1871
			INC097774();
sl@0
  1872
			break;	
sl@0
  1873
		
sl@0
  1874
/**
sl@0
  1875
@SYMTestCaseID		GRAPHICS-WSERV-0401
sl@0
  1876
sl@0
  1877
@SYMDEF  			DEF098704
sl@0
  1878
sl@0
  1879
@SYMTestCaseDesc    Test code for implemented fix to remove double cursors 
sl@0
  1880
					
sl@0
  1881
@SYMTestPriority    Normal
sl@0
  1882
sl@0
  1883
@SYMTestStatus      Implemented
sl@0
  1884
sl@0
  1885
@SYMTestActions     This test case tests for artifacts left over when normal/custon flashing/non-flashing cursors are drawn.
sl@0
  1886
					Test that changing the focus of a custom text cursor does not leave that cursor drawn where it was (INC093898)
sl@0
  1887
sl@0
  1888
@SYMTestExpectedResults 
sl@0
  1889
*/			
sl@0
  1890
	case 9:
sl@0
  1891
		((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0401"));
sl@0
  1892
		iTest->LogSubTest(_L("Double cursors test 1"));
sl@0
  1893
		StartDoubleCursorTestL(1);
sl@0
  1894
		break;
sl@0
  1895
sl@0
  1896
	/**
sl@0
  1897
	@SYMTestCaseID		GRAPHICS-WSERV-0402
sl@0
  1898
sl@0
  1899
	@SYMDEF				DEF098704
sl@0
  1900
sl@0
  1901
	@SYMTestCaseDesc    Test code for implemented fix to remove double cursors 
sl@0
  1902
sl@0
  1903
	@SYMTestPriority    Normal
sl@0
  1904
sl@0
  1905
	@SYMTestStatus      Implemented
sl@0
  1906
sl@0
  1907
	@SYMTestActions     Checks that no artifacts are left behind when a text cursor is moved from under a transparent sprite
sl@0
  1908
sl@0
  1909
	@SYMTestExpectedResults 
sl@0
  1910
	*/
sl@0
  1911
	case 10:
sl@0
  1912
		((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0402"));
sl@0
  1913
		iTest->LogSubTest(_L("Double cursors test 2"));
sl@0
  1914
		StartDoubleCursorTestL(2);
sl@0
  1915
		break;
sl@0
  1916
sl@0
  1917
	/**
sl@0
  1918
	@SYMTestCaseID		GRAPHICS-WSERV-0403
sl@0
  1919
sl@0
  1920
	@SYMDEF				DEF098704
sl@0
  1921
sl@0
  1922
	@SYMTestCaseDesc    Test code for implemented fix to remove double cursors 
sl@0
  1923
						
sl@0
  1924
	@SYMTestPriority    Normal
sl@0
  1925
sl@0
  1926
	@SYMTestStatus      Implemented
sl@0
  1927
sl@0
  1928
	@SYMTestActions     This test moves a flashing cursor a number of times over a two second period to a seconds position.
sl@0
  1929
						it does it a number of times so some of the redraws will occur during the 'flash off' period
sl@0
  1930
						We then compare the 'after' position to what we expect
sl@0
  1931
sl@0
  1932
	@SYMTestExpectedResults 
sl@0
  1933
	*/
sl@0
  1934
	case 11:
sl@0
  1935
		((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0403"));
sl@0
  1936
		iTest->LogSubTest(_L("Double cursors test 3"));
sl@0
  1937
		StartDoubleCursorTestL(3);
sl@0
  1938
		break;
sl@0
  1939
sl@0
  1940
	/**
sl@0
  1941
	@SYMTestCaseID		GRAPHICS-WSERV-0483
sl@0
  1942
sl@0
  1943
	@SYMDEF				INC117232
sl@0
  1944
sl@0
  1945
	@SYMTestCaseDesc    Test code: Refreshing cursors becoming offscreen due to screen size change should not panic 
sl@0
  1946
sl@0
  1947
	@SYMTestPriority    Normal
sl@0
  1948
sl@0
  1949
	@SYMTestStatus      Implemented
sl@0
  1950
sl@0
  1951
	@SYMTestActions     Create a cursor on bottom right of screen, change to a screen mode that excludes that coordinate
sl@0
  1952
sl@0
  1953
	@SYMTestExpectedResults 
sl@0
  1954
						The server should not panic.
sl@0
  1955
	*/
sl@0
  1956
	case 12:
sl@0
  1957
		((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0483"));
sl@0
  1958
		iTest->LogSubTest(_L("Screen resize invalidate cursor off-screen"));
sl@0
  1959
		INC117232();
sl@0
  1960
		break;
sl@0
  1961
sl@0
  1962
	/**
sl@0
  1963
	@SYMTestCaseID		GRAPHICS-WSERV-2095-0016
sl@0
  1964
sl@0
  1965
	@SYMTestCaseDesc    Text Cursor flag TTextCursor::EFlagNoFlash honored 
sl@0
  1966
sl@0
  1967
	@SYMTestPriority    Normal
sl@0
  1968
sl@0
  1969
	@SYMTestStatus      Implemented
sl@0
  1970
sl@0
  1971
	@SYMTestActions     Create a text cursor with the TTextCursor::EFlagNoFlash setting.  Observe the screen over
sl@0
  1972
						a short period of time to verify that it remains continuously in the Flash ON state.
sl@0
  1973
sl@0
  1974
	@SYMTestExpectedResults 
sl@0
  1975
						The text cursor should be always shown.
sl@0
  1976
	*/
sl@0
  1977
	case 13:
sl@0
  1978
	#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
sl@0
  1979
		((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-2095-0016"));
sl@0
  1980
		iTest->LogSubTest(_L("Text cursor EFlagNoFlash test"));
sl@0
  1981
		TextCursorNoFlashTestL();
sl@0
  1982
	#endif
sl@0
  1983
		break;
sl@0
  1984
sl@0
  1985
	/**
sl@0
  1986
	@SYMTestCaseID		GRAPHICS-WSERV-2095-0009
sl@0
  1987
sl@0
  1988
	@SYMTestCaseDesc    Text Cursor flashes when flag value is 0
sl@0
  1989
sl@0
  1990
	@SYMTestPriority    Normal
sl@0
  1991
sl@0
  1992
	@SYMTestStatus      Implemented
sl@0
  1993
sl@0
  1994
	@SYMTestActions     Create a text cursor with the 0 flag setting.  Observe the screen over
sl@0
  1995
						a short period of time to verify that the cursor flashes ON and OFF at
sl@0
  1996
						the correct period of one second.
sl@0
  1997
sl@0
  1998
	@SYMTestExpectedResults 
sl@0
  1999
						The text cursor should flash.
sl@0
  2000
	*/
sl@0
  2001
	case 14:
sl@0
  2002
	#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
sl@0
  2003
		((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-2095-0009"));
sl@0
  2004
		iTest->LogSubTest(_L("Text cursor will Flash test"));
sl@0
  2005
		TextCursorFlashTestL();
sl@0
  2006
	#endif
sl@0
  2007
		break;
sl@0
  2008
sl@0
  2009
	/**
sl@0
  2010
	@SYMTestCaseID		GRAPHICS-WSERV-2095-0017
sl@0
  2011
sl@0
  2012
	@SYMTestCaseDesc    Text Cursor handles different valid Cursor Setttings
sl@0
  2013
sl@0
  2014
	@SYMTestPriority    Normal
sl@0
  2015
sl@0
  2016
	@SYMTestStatus      Implemented
sl@0
  2017
sl@0
  2018
	@SYMTestActions     Create a text cursor and then issue a SetTextCursor.  Then repeatedly
sl@0
  2019
						call SetTextCursor, varying the arguments relating to the Text Cursor
sl@0
  2020
						as well as keeping the arguments the same on one occassion.
sl@0
  2021
sl@0
  2022
	@SYMTestExpectedResults 
sl@0
  2023
						The system should not panic as the arguments supplied are never invalid.
sl@0
  2024
	*/
sl@0
  2025
	case 15:
sl@0
  2026
		((CTCursorTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-2095-0017"));
sl@0
  2027
		iTest->LogSubTest(_L("SetTextCursor test"));
sl@0
  2028
		TextCursorSetLCoverageTests();
sl@0
  2029
		break;
sl@0
  2030
sl@0
  2031
		default:
sl@0
  2032
			((CTCursorTestStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
sl@0
  2033
			((CTCursorTestStep*)iStep)->CloseTMSGraphicsStep();
sl@0
  2034
			TestComplete();
sl@0
  2035
			break;
sl@0
  2036
		}
sl@0
  2037
	((CTCursorTestStep*)iStep)->RecordTestResultL();
sl@0
  2038
	}
sl@0
  2039
sl@0
  2040
__WS_CONSTRUCT_STEP__(CursorTest)