os/graphics/windowing/windowserver/test/tauto/TOOM.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-2010 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
// Out of memory tests
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
/**
sl@0
    19
 @file
sl@0
    20
 @test
sl@0
    21
 @internalComponent - Internal Symbian test code
sl@0
    22
*/
sl@0
    23
sl@0
    24
sl@0
    25
#include "TOOM.H"
sl@0
    26
sl@0
    27
 
sl@0
    28
typedef COomFailBase *(*COmmCreate)(CTOom *aTest);
sl@0
    29
sl@0
    30
COomFailBase *CreateOomConnect(CTOom *aTest)
sl@0
    31
	{return(new(ELeave) COomConnect(aTest));}
sl@0
    32
sl@0
    33
COomFailBase *CreateOomWindow(CTOom *aTest)
sl@0
    34
	{return(new(ELeave) COomWindow(aTest));}
sl@0
    35
sl@0
    36
COomFailBase *CreateOomWindowGroup(CTOom *aTest)
sl@0
    37
	{return(new(ELeave) COomWindowGroup(aTest));}
sl@0
    38
sl@0
    39
COomFailBase *CreateOomBackedUpWindow(CTOom *aTest)
sl@0
    40
	{return(new(ELeave) COomBackedUpWindow(aTest));}
sl@0
    41
sl@0
    42
COomFailBase *CreateOomBackupResize(CTOom *aTest)
sl@0
    43
	{return(new(ELeave) COomBackupResize(aTest));}
sl@0
    44
sl@0
    45
COomFailBase *CreateOomBlankWindow(CTOom *aTest)
sl@0
    46
	{return(new(ELeave) COomBlankWindow(aTest));}
sl@0
    47
sl@0
    48
COomFailBase *CreateOomGc(CTOom *aTest)
sl@0
    49
	{return(new(ELeave) COomGc(aTest));}
sl@0
    50
sl@0
    51
COomFailBase *CreateOomScreenDevice(CTOom *aTest)
sl@0
    52
	{return(new(ELeave) COomScreenDevice(aTest));}
sl@0
    53
sl@0
    54
COomFailBase *CreateOomPointerBuffer(CTOom *aTest)
sl@0
    55
	{return(new(ELeave) COomPointerBuffer(aTest));}
sl@0
    56
sl@0
    57
COomFailBase *CreateOomPolygon(CTOom *aTest)
sl@0
    58
	{return(new(ELeave) COomPolygon(aTest));}
sl@0
    59
sl@0
    60
COomFailBase *CreateOomPriorityKey(CTOom *aTest)
sl@0
    61
	{return(new(ELeave) COomPriorityKey(aTest));}
sl@0
    62
sl@0
    63
COomFailBase *CreateOomCaptureKey(CTOom *aTest)
sl@0
    64
	{return(new(ELeave) COomCaptureKey(aTest));}
sl@0
    65
sl@0
    66
COomFailBase *CreateOomCaptureKeyUpDown(CTOom *aTest)
sl@0
    67
	{return(new(ELeave) COomCaptureKeyUpDown(aTest));}
sl@0
    68
sl@0
    69
COomFailBase *CreateOomLongKeyCapture(CTOom *aTest)
sl@0
    70
	{return(new(ELeave) COomLongKeyCapture(aTest));}
sl@0
    71
sl@0
    72
COomFailBase *CreateOomHotKey(CTOom *aTest)
sl@0
    73
	{return(new(ELeave) COomHotKey(aTest));}
sl@0
    74
sl@0
    75
COomFailBase *CreateOomGroupName(CTOom *aTest)
sl@0
    76
	{return(new(ELeave) COomGroupName(aTest));}
sl@0
    77
sl@0
    78
COomFailBase *CreateOomMessageSend(CTOom *aTest)
sl@0
    79
	{return(new(ELeave) COomMessageSend(aTest));}
sl@0
    80
sl@0
    81
COomFailBase *CreateOomMessageFetch(CTOom *aTest)
sl@0
    82
	{return(new(ELeave) COomMessageFetch(aTest));}
sl@0
    83
sl@0
    84
COomFailBase *CreateOomSprite(CTOom *aTest)
sl@0
    85
	{return(new(ELeave) COomSprite(aTest));}
sl@0
    86
sl@0
    87
COomFailBase *CreateOomPointerCursor(CTOom *aTest)
sl@0
    88
	{return(new(ELeave) COomPointerCursor(aTest));}
sl@0
    89
sl@0
    90
COomFailBase *CreateOomCopyScreen(CTOom *aTest)
sl@0
    91
	{return(new(ELeave) COomCopyScreen(aTest));}
sl@0
    92
sl@0
    93
COomFailBase *CreateOomRequestEvents(CTOom *aTest)
sl@0
    94
	{return(new(ELeave) COomRequestEvents(aTest));}
sl@0
    95
sl@0
    96
COomFailBase *CreateOomCustomTextCursor(CTOom *aTest)
sl@0
    97
	{return(new(ELeave) COomCustomTextCursor(aTest));}
sl@0
    98
sl@0
    99
COomFailBase *CreateOomTranspWindow(CTOom *aTest)
sl@0
   100
	{return(new(ELeave) COomTranspWindow(aTest));}
sl@0
   101
sl@0
   102
COomFailBase *CreateOomObscuredWindow(CTOom *aTest)
sl@0
   103
	{return(new(ELeave) COomObscuredWindow(aTest));}
sl@0
   104
sl@0
   105
COmmCreate CreateOomFailTest[]={
sl@0
   106
	CreateOomConnect,
sl@0
   107
	CreateOomWindow,
sl@0
   108
	CreateOomWindowGroup,
sl@0
   109
	CreateOomBackedUpWindow,
sl@0
   110
	CreateOomBackupResize,
sl@0
   111
	CreateOomBlankWindow,
sl@0
   112
	CreateOomGc,
sl@0
   113
	CreateOomScreenDevice,
sl@0
   114
	CreateOomPointerBuffer,
sl@0
   115
	CreateOomPolygon,
sl@0
   116
	CreateOomPriorityKey,
sl@0
   117
	CreateOomCaptureKey,
sl@0
   118
	CreateOomCaptureKeyUpDown,
sl@0
   119
	CreateOomLongKeyCapture,
sl@0
   120
	CreateOomHotKey,
sl@0
   121
	CreateOomGroupName,
sl@0
   122
	CreateOomSprite,
sl@0
   123
	CreateOomPointerCursor,
sl@0
   124
	CreateOomCopyScreen,
sl@0
   125
	CreateOomRequestEvents,
sl@0
   126
	CreateOomMessageSend,
sl@0
   127
	CreateOomMessageFetch,
sl@0
   128
	CreateOomCustomTextCursor,
sl@0
   129
	CreateOomTranspWindow,
sl@0
   130
	CreateOomObscuredWindow,
sl@0
   131
	};
sl@0
   132
sl@0
   133
//
sl@0
   134
// Individual out of memory test classes //
sl@0
   135
//
sl@0
   136
sl@0
   137
COomFailBase::COomFailBase(CTOom *aTest) : iTest(aTest)
sl@0
   138
	{}
sl@0
   139
sl@0
   140
void COomFailBase::ConstructL()
sl@0
   141
	{
sl@0
   142
	iTest->INFO_PRINTF1(TestName());
sl@0
   143
	}
sl@0
   144
sl@0
   145
void COomFailBase::PreFail()
sl@0
   146
	{}
sl@0
   147
sl@0
   148
void COomFailBase::ClearUpL()
sl@0
   149
	{}
sl@0
   150
sl@0
   151
void COomFailBase::Flush()
sl@0
   152
	{
sl@0
   153
	iWs.Flush();
sl@0
   154
	}
sl@0
   155
sl@0
   156
COomConnect::COomConnect(CTOom *aTest) : COomFailBase(aTest)
sl@0
   157
	{}
sl@0
   158
sl@0
   159
TOomTestName COomConnect::TestName()
sl@0
   160
	{
sl@0
   161
	return(_L("Connect"));
sl@0
   162
	}
sl@0
   163
sl@0
   164
/** Creates a wserv session, connects and creates CWsScreenDevice object
sl@0
   165
*/
sl@0
   166
TInt COomConnect::Fail()
sl@0
   167
	{
sl@0
   168
	TInt err = iWs.Connect();
sl@0
   169
	if (err!=KErrNone)
sl@0
   170
		return err;
sl@0
   171
	
sl@0
   172
	TRAP(err, iDummyScreen = new (ELeave) CWsScreenDevice(iWs));
sl@0
   173
	if (err!=KErrNone)
sl@0
   174
		{
sl@0
   175
		iWs.Close();
sl@0
   176
		return err;
sl@0
   177
		}
sl@0
   178
		
sl@0
   179
	if ((err=iDummyScreen->Construct(iTest->ScreenNumber()))!=KErrNone)
sl@0
   180
		{
sl@0
   181
		delete iDummyScreen;
sl@0
   182
		iDummyScreen = NULL;
sl@0
   183
		iWs.Close();
sl@0
   184
		return err;
sl@0
   185
		}
sl@0
   186
		
sl@0
   187
	return err;
sl@0
   188
	}
sl@0
   189
sl@0
   190
void COomConnect::ClearUpL()
sl@0
   191
	{
sl@0
   192
	if (iDummyScreen)
sl@0
   193
		{
sl@0
   194
		delete iDummyScreen;
sl@0
   195
		iDummyScreen = NULL;
sl@0
   196
		}
sl@0
   197
	iWs.Close();
sl@0
   198
	}
sl@0
   199
sl@0
   200
//
sl@0
   201
sl@0
   202
COomSetup::COomSetup(CTOom *aTest) : COomFailBase(aTest)
sl@0
   203
	{}
sl@0
   204
sl@0
   205
void COomSetup::ConstructL()
sl@0
   206
	{
sl@0
   207
	COomFailBase::ConstructL();
sl@0
   208
	User::LeaveIfError(iWs.Connect());
sl@0
   209
	iDummyScreen = new (ELeave) CWsScreenDevice(iWs);
sl@0
   210
	User::LeaveIfError(iDummyScreen->Construct(iTest->ScreenNumber()));
sl@0
   211
	
sl@0
   212
	iWinGroup=RWindowGroup(iWs);
sl@0
   213
	iWinGroup.Construct(556);
sl@0
   214
	iWinGroup.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
sl@0
   215
	}
sl@0
   216
sl@0
   217
COomSetup::~COomSetup()
sl@0
   218
	{
sl@0
   219
	iWinGroup.Close();
sl@0
   220
	delete iDummyScreen;
sl@0
   221
	iDummyScreen = NULL;
sl@0
   222
	
sl@0
   223
	iTest->TEST(iWs.ResourceCount()==0);
sl@0
   224
	if (iWs.ResourceCount()!=0)
sl@0
   225
		iTest->INFO_PRINTF3(_L("iWs.ResourceCount() return value - Expected: %d, Actual: %d"), 0, iWs.ResourceCount());			
sl@0
   226
sl@0
   227
	iWs.Close();
sl@0
   228
	}
sl@0
   229
sl@0
   230
//
sl@0
   231
sl@0
   232
COomWindowGroup::COomWindowGroup(CTOom *aTest) : COomSetup(aTest)
sl@0
   233
	{}
sl@0
   234
sl@0
   235
TOomTestName COomWindowGroup::TestName()
sl@0
   236
	{
sl@0
   237
	return(_L("Window Group"));
sl@0
   238
	}
sl@0
   239
sl@0
   240
/** Creates a RWindowGroup object
sl@0
   241
*/
sl@0
   242
TInt COomWindowGroup::Fail()
sl@0
   243
	{
sl@0
   244
	iFailWinGroup=RWindowGroup(iWs);
sl@0
   245
	return(iFailWinGroup.Construct(987));
sl@0
   246
	}
sl@0
   247
sl@0
   248
void COomWindowGroup::ClearUpL()
sl@0
   249
	{
sl@0
   250
	iFailWinGroup.Close();
sl@0
   251
	}
sl@0
   252
sl@0
   253
//
sl@0
   254
sl@0
   255
COomWindow::COomWindow(CTOom *aTest) : COomSetup(aTest)
sl@0
   256
	{}
sl@0
   257
sl@0
   258
TOomTestName COomWindow::TestName()
sl@0
   259
	{
sl@0
   260
	return(_L("Window"));
sl@0
   261
	}
sl@0
   262
sl@0
   263
/** Creates a RWindow object
sl@0
   264
*/
sl@0
   265
TInt COomWindow::Fail()
sl@0
   266
	{
sl@0
   267
	iFailWin=RWindow(iWs);
sl@0
   268
	return(iFailWin.Construct(iWinGroup,11));
sl@0
   269
	}
sl@0
   270
sl@0
   271
void COomWindow::ClearUpL()
sl@0
   272
	{
sl@0
   273
	iFailWin.Close();
sl@0
   274
	}
sl@0
   275
sl@0
   276
//
sl@0
   277
sl@0
   278
COomBackedUpWindow::COomBackedUpWindow(CTOom *aTest) : COomSetup(aTest)
sl@0
   279
	{}
sl@0
   280
sl@0
   281
TOomTestName COomBackedUpWindow::TestName()
sl@0
   282
	{
sl@0
   283
	return(_L("Backed up window"));
sl@0
   284
	}
sl@0
   285
sl@0
   286
/** Creates a RBackedUpWindow object
sl@0
   287
*/
sl@0
   288
TInt COomBackedUpWindow::Fail()
sl@0
   289
	{
sl@0
   290
	iFailWin=RBackedUpWindow(iWs);
sl@0
   291
	return(iFailWin.Construct(iWinGroup,EGray16,22));
sl@0
   292
	}
sl@0
   293
sl@0
   294
void COomBackedUpWindow::ClearUpL()
sl@0
   295
	{
sl@0
   296
	iFailWin.Close();
sl@0
   297
	}
sl@0
   298
sl@0
   299
//
sl@0
   300
sl@0
   301
COomBackupResize::COomBackupResize(CTOom *aTest) : COomSetup(aTest)
sl@0
   302
	{}
sl@0
   303
sl@0
   304
COomBackupResize::~COomBackupResize()
sl@0
   305
	{
sl@0
   306
	iFailWin.Close();
sl@0
   307
	}
sl@0
   308
sl@0
   309
TOomTestName COomBackupResize::TestName()
sl@0
   310
	{
sl@0
   311
	return(_L("Resize backed up window"));
sl@0
   312
	}
sl@0
   313
sl@0
   314
void COomBackupResize::ConstructL()
sl@0
   315
	{
sl@0
   316
	COomSetup::ConstructL();
sl@0
   317
	iFailWin=RBackedUpWindow(iWs);
sl@0
   318
	User::LeaveIfError(iFailWin.Construct(iWinGroup,EGray16,33));
sl@0
   319
	User::LeaveIfError(iFailWin.SetSizeErr(TSize(10,10)));
sl@0
   320
	iFailWin.Activate();
sl@0
   321
	}
sl@0
   322
	
sl@0
   323
/** Sets the size of previously created backed-up window
sl@0
   324
*/
sl@0
   325
TInt COomBackupResize::Fail()
sl@0
   326
	{
sl@0
   327
	return(iFailWin.SetSizeErr(TSize(100,100)));
sl@0
   328
	}
sl@0
   329
sl@0
   330
void COomBackupResize::ClearUpL()
sl@0
   331
//Virtual fn declared in CoomFailBase. This is the only one that can leave, I think, but one is enough
sl@0
   332
	{
sl@0
   333
	User::LeaveIfError(iFailWin.SetSizeErr(TSize(10,10)));
sl@0
   334
	}
sl@0
   335
sl@0
   336
//
sl@0
   337
sl@0
   338
COomBlankWindow::COomBlankWindow(CTOom *aTest) : COomSetup(aTest)
sl@0
   339
	{}
sl@0
   340
sl@0
   341
TOomTestName COomBlankWindow::TestName()
sl@0
   342
	{
sl@0
   343
	return(_L("Blank window"));
sl@0
   344
	}
sl@0
   345
sl@0
   346
/** Creates a RBlankWindow object
sl@0
   347
*/
sl@0
   348
TInt COomBlankWindow::Fail()
sl@0
   349
	{
sl@0
   350
	iFailWin=RBlankWindow(iWs);
sl@0
   351
	return(iFailWin.Construct(iWinGroup,44));
sl@0
   352
	}
sl@0
   353
sl@0
   354
void COomBlankWindow::ClearUpL()
sl@0
   355
	{
sl@0
   356
	iFailWin.Close();
sl@0
   357
	}
sl@0
   358
sl@0
   359
//
sl@0
   360
sl@0
   361
COomPointerBuffer::COomPointerBuffer(CTOom *aTest) : COomSetup(aTest)
sl@0
   362
	{}
sl@0
   363
sl@0
   364
COomPointerBuffer::~COomPointerBuffer()
sl@0
   365
	{
sl@0
   366
	iFailWin.Close();
sl@0
   367
	}
sl@0
   368
sl@0
   369
TOomTestName COomPointerBuffer::TestName()
sl@0
   370
	{
sl@0
   371
	return(_L("Pointer buffer"));
sl@0
   372
	}
sl@0
   373
sl@0
   374
void COomPointerBuffer::ConstructL()
sl@0
   375
	{
sl@0
   376
	COomSetup::ConstructL();
sl@0
   377
	iFailWin=RBackedUpWindow(iWs);
sl@0
   378
	User::LeaveIfError(iFailWin.Construct(iWinGroup,EGray16,55));
sl@0
   379
	User::LeaveIfError(iFailWin.SetSizeErr(TSize(10,10)));
sl@0
   380
	iFailWin.Activate();
sl@0
   381
	}
sl@0
   382
sl@0
   383
/** Allocates a buffer for storing pointer movements for previously created backed-up window
sl@0
   384
*/
sl@0
   385
TInt COomPointerBuffer::Fail()
sl@0
   386
	{
sl@0
   387
	return(iFailWin.AllocPointerMoveBuffer(10,0));
sl@0
   388
	}
sl@0
   389
sl@0
   390
void COomPointerBuffer::ClearUpL()
sl@0
   391
	{
sl@0
   392
	iFailWin.FreePointerMoveBuffer();
sl@0
   393
	}
sl@0
   394
sl@0
   395
//
sl@0
   396
sl@0
   397
COomPriorityKey::COomPriorityKey(CTOom *aTest) : COomSetup(aTest)
sl@0
   398
	{}
sl@0
   399
sl@0
   400
COomPriorityKey::~COomPriorityKey()
sl@0
   401
	{
sl@0
   402
	}
sl@0
   403
sl@0
   404
TOomTestName COomPriorityKey::TestName()
sl@0
   405
	{
sl@0
   406
	return(_L("Priority key"));
sl@0
   407
	}
sl@0
   408
sl@0
   409
void COomPriorityKey::ConstructL()
sl@0
   410
	{
sl@0
   411
	COomSetup::ConstructL();
sl@0
   412
	}
sl@0
   413
sl@0
   414
/** Adds a priority key for a previously created window group
sl@0
   415
*/
sl@0
   416
TInt COomPriorityKey::Fail()
sl@0
   417
	{
sl@0
   418
	return(iWinGroup.AddPriorityKey(1,0,0));
sl@0
   419
	}
sl@0
   420
sl@0
   421
void COomPriorityKey::ClearUpL()
sl@0
   422
	{
sl@0
   423
	iWinGroup.RemovePriorityKey(1,0,0);
sl@0
   424
	}
sl@0
   425
sl@0
   426
//
sl@0
   427
sl@0
   428
COomCaptureKeyBase::COomCaptureKeyBase(CTOom *aTest) : COomSetup(aTest)
sl@0
   429
	{}
sl@0
   430
sl@0
   431
COomCaptureKeyBase::~COomCaptureKeyBase()
sl@0
   432
	{}
sl@0
   433
sl@0
   434
void COomCaptureKeyBase::ConstructL()
sl@0
   435
	{
sl@0
   436
	COomSetup::ConstructL();
sl@0
   437
	}
sl@0
   438
sl@0
   439
COomCaptureKey::COomCaptureKey(CTOom *aTest) : COomCaptureKeyBase(aTest)
sl@0
   440
	{}
sl@0
   441
sl@0
   442
COomCaptureKey::~COomCaptureKey()
sl@0
   443
	{
sl@0
   444
	}
sl@0
   445
sl@0
   446
TOomTestName COomCaptureKey::TestName()
sl@0
   447
	{
sl@0
   448
	return(_L("Capture key"));
sl@0
   449
	}
sl@0
   450
sl@0
   451
/** Requests a capture keys for a previously created window group
sl@0
   452
*/
sl@0
   453
TInt COomCaptureKey::Fail()
sl@0
   454
	{
sl@0
   455
	for (iIndex=0;iIndex<(TInt)(sizeof(iCapKey)/sizeof(iCapKey[0]));iIndex++)
sl@0
   456
		{
sl@0
   457
		TInt ret=iWinGroup.CaptureKey('a',0,0);
sl@0
   458
		if (ret<0)
sl@0
   459
			return(ret);
sl@0
   460
		iCapKey[iIndex]=ret;
sl@0
   461
		}
sl@0
   462
	return(KErrNone);
sl@0
   463
	}
sl@0
   464
sl@0
   465
void COomCaptureKey::ClearUpL()
sl@0
   466
	{
sl@0
   467
	for (TInt index=0;index<iIndex;index++)
sl@0
   468
		iWinGroup.CancelCaptureKey(iCapKey[index]);
sl@0
   469
	}
sl@0
   470
sl@0
   471
//
sl@0
   472
sl@0
   473
COomCaptureKeyUpDown::COomCaptureKeyUpDown(CTOom *aTest) : COomCaptureKeyBase(aTest)
sl@0
   474
	{}
sl@0
   475
sl@0
   476
COomCaptureKeyUpDown::~COomCaptureKeyUpDown()
sl@0
   477
	{
sl@0
   478
	}
sl@0
   479
sl@0
   480
TOomTestName COomCaptureKeyUpDown::TestName()
sl@0
   481
	{
sl@0
   482
	return(_L("Capture up/down keys"));
sl@0
   483
	}
sl@0
   484
sl@0
   485
/** Requests the capture of key-up and key-down events for a previously created window group
sl@0
   486
*/
sl@0
   487
TInt COomCaptureKeyUpDown::Fail()
sl@0
   488
	{
sl@0
   489
	for (iIndex=0;iIndex<(TInt)(sizeof(iCapKey)/sizeof(iCapKey[0]));iIndex++)
sl@0
   490
		{
sl@0
   491
		TInt ret=iWinGroup.CaptureKeyUpAndDowns('a',0,0);
sl@0
   492
		if (ret<0)
sl@0
   493
			return(ret);
sl@0
   494
		iCapKey[iIndex]=ret;
sl@0
   495
		}
sl@0
   496
	return(KErrNone);
sl@0
   497
	}
sl@0
   498
sl@0
   499
void COomCaptureKeyUpDown::ClearUpL()
sl@0
   500
	{
sl@0
   501
	for (TInt index=0;index<iIndex;index++)
sl@0
   502
		iWinGroup.CancelCaptureKeyUpAndDowns(iCapKey[index]);
sl@0
   503
	}
sl@0
   504
sl@0
   505
//
sl@0
   506
sl@0
   507
COomLongKeyCapture::COomLongKeyCapture(CTOom *aTest) : COomCaptureKeyBase(aTest)
sl@0
   508
	{}
sl@0
   509
sl@0
   510
COomLongKeyCapture::~COomLongKeyCapture()
sl@0
   511
	{
sl@0
   512
	}
sl@0
   513
sl@0
   514
TOomTestName COomLongKeyCapture::TestName()
sl@0
   515
	{
sl@0
   516
	_LIT(KLongKeyCapTestName, "Long key capture");
sl@0
   517
	return KLongKeyCapTestName();
sl@0
   518
	}
sl@0
   519
sl@0
   520
/** 
sl@0
   521
Requests capture of long key events for a previously created window group
sl@0
   522
*/
sl@0
   523
TInt COomLongKeyCapture::Fail()
sl@0
   524
	{
sl@0
   525
	for (iIndex=0; iIndex < KNumCapKeyRequest; iIndex++)
sl@0
   526
		{
sl@0
   527
		TInt ret=iWinGroup.CaptureLongKey(' ','a',0,0,2,ELongCaptureNormal);
sl@0
   528
		if (ret<0)
sl@0
   529
			return(ret);
sl@0
   530
		iCapKey[iIndex]=ret;
sl@0
   531
		}
sl@0
   532
	return(KErrNone);
sl@0
   533
	}
sl@0
   534
sl@0
   535
void COomLongKeyCapture::ClearUpL()
sl@0
   536
	{
sl@0
   537
	for (TInt index=0;index<iIndex;index++)
sl@0
   538
		iWinGroup.CancelCaptureLongKey(iCapKey[index]);
sl@0
   539
	}
sl@0
   540
sl@0
   541
//
sl@0
   542
sl@0
   543
COomHotKey::COomHotKey(CTOom *aTest) : COomSetup(aTest)
sl@0
   544
	{}
sl@0
   545
sl@0
   546
COomHotKey::~COomHotKey()
sl@0
   547
	{
sl@0
   548
	}
sl@0
   549
sl@0
   550
TOomTestName COomHotKey::TestName()
sl@0
   551
	{
sl@0
   552
	return(_L("hot keys"));
sl@0
   553
	}
sl@0
   554
sl@0
   555
void COomHotKey::ConstructL()
sl@0
   556
	{
sl@0
   557
	COomSetup::ConstructL();
sl@0
   558
	}
sl@0
   559
sl@0
   560
/** Sets hot key for the session.
sl@0
   561
*/
sl@0
   562
TInt COomHotKey::Fail()
sl@0
   563
	{
sl@0
   564
	return(iWs.SetHotKey(EHotKeyEnableLogging,'a',0,0));
sl@0
   565
	}
sl@0
   566
sl@0
   567
void COomHotKey::ClearUpL()
sl@0
   568
	{
sl@0
   569
	iWs.RestoreDefaultHotKey(EHotKeyEnableLogging);
sl@0
   570
	}
sl@0
   571
sl@0
   572
//
sl@0
   573
sl@0
   574
COomGroupName::COomGroupName(CTOom *aTest) : COomSetup(aTest)
sl@0
   575
	{}
sl@0
   576
sl@0
   577
COomGroupName::~COomGroupName()
sl@0
   578
	{
sl@0
   579
	}
sl@0
   580
sl@0
   581
TOomTestName COomGroupName::TestName()
sl@0
   582
	{
sl@0
   583
	return(_L("Group name"));
sl@0
   584
	}
sl@0
   585
sl@0
   586
void COomGroupName::ConstructL()
sl@0
   587
	{
sl@0
   588
	COomSetup::ConstructL();
sl@0
   589
	}
sl@0
   590
sl@0
   591
/** Sets the window group's name.
sl@0
   592
*/
sl@0
   593
TInt COomGroupName::Fail()
sl@0
   594
	{
sl@0
   595
	return(iWinGroup.SetName(_L("A Name")));
sl@0
   596
	}
sl@0
   597
sl@0
   598
void COomGroupName::ClearUpL()
sl@0
   599
	{
sl@0
   600
	iWinGroup.SetName(_L(""));
sl@0
   601
	}
sl@0
   602
sl@0
   603
//
sl@0
   604
sl@0
   605
COomMessageSend::COomMessageSend(CTOom *aTest) : COomSetup(aTest)
sl@0
   606
	{}
sl@0
   607
sl@0
   608
COomMessageSend::~COomMessageSend()
sl@0
   609
	{
sl@0
   610
	}
sl@0
   611
sl@0
   612
TOomTestName COomMessageSend::TestName()
sl@0
   613
	{
sl@0
   614
	return(_L("MessageSend"));
sl@0
   615
	}
sl@0
   616
sl@0
   617
void COomMessageSend::ConstructL()
sl@0
   618
	{
sl@0
   619
	COomSetup::ConstructL();
sl@0
   620
	}
sl@0
   621
sl@0
   622
void COomMessageSend::PreFail()
sl@0
   623
	{
sl@0
   624
	iWinGroup2=RWindowGroup(iWs);
sl@0
   625
	iWinGroup2.Construct(557);
sl@0
   626
	iWinGroup2.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
sl@0
   627
	}
sl@0
   628
sl@0
   629
/** Sends a message to another window group
sl@0
   630
*/
sl@0
   631
TInt COomMessageSend::Fail()
sl@0
   632
	{
sl@0
   633
	TBuf8<0x20> params(_L8("SomeParams"));
sl@0
   634
	return(iWs.SendMessageToWindowGroup(iWinGroup2.Identifier(),TUid::Uid(123),params));
sl@0
   635
	}
sl@0
   636
sl@0
   637
void COomMessageSend::ClearUpL()
sl@0
   638
	{
sl@0
   639
	iWinGroup2.Close();
sl@0
   640
	}
sl@0
   641
sl@0
   642
//
sl@0
   643
sl@0
   644
COomMessageFetch::COomMessageFetch(CTOom *aTest) : COomSetup(aTest)
sl@0
   645
	{}
sl@0
   646
sl@0
   647
COomMessageFetch::~COomMessageFetch()
sl@0
   648
	{
sl@0
   649
	}
sl@0
   650
sl@0
   651
TOomTestName COomMessageFetch::TestName()
sl@0
   652
	{
sl@0
   653
	return(_L("MessageFetch"));
sl@0
   654
	}
sl@0
   655
sl@0
   656
void COomMessageFetch::ConstructL()
sl@0
   657
	{
sl@0
   658
	COomSetup::ConstructL();
sl@0
   659
	}
sl@0
   660
sl@0
   661
#define CLIENT_HANDLE 555
sl@0
   662
#define UID_VALUE 123
sl@0
   663
#define MESSAGE_LEN 0x20
sl@0
   664
void COomMessageFetch::PreFail()
sl@0
   665
	{
sl@0
   666
	iWinGroup2=RWindowGroup(iWs);
sl@0
   667
	iWinGroup2.Construct(CLIENT_HANDLE);
sl@0
   668
	iWinGroup2.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
sl@0
   669
	TBuf8<MESSAGE_LEN> params(_L8("SomeParams"));
sl@0
   670
	TBool retVal = iWs.SendMessageToWindowGroup(iWinGroup2.Identifier(),TUid::Uid(UID_VALUE),params);
sl@0
   671
	iTest->TEST(retVal==KErrNone);
sl@0
   672
	if (retVal!=KErrNone)
sl@0
   673
		iTest->INFO_PRINTF3(_L("iWs.SendMessageToWindowGroup() return value - Expected: %d, Actual: %d"), KErrNone, retVal);			
sl@0
   674
	}
sl@0
   675
sl@0
   676
/** Fetches a message
sl@0
   677
*/
sl@0
   678
TInt COomMessageFetch::Fail()
sl@0
   679
	{
sl@0
   680
	TWsEvent event;
sl@0
   681
	TPtr8 ptr(NULL,0);
sl@0
   682
	TUid uid;
sl@0
   683
	event.SetType(EEventMessageReady);
sl@0
   684
	event.SetHandle(CLIENT_HANDLE);
sl@0
   685
	event.SetTimeNow();
sl@0
   686
	SEventMessageReady& eventMessageReady=*(SEventMessageReady*)event.EventData();
sl@0
   687
	eventMessageReady.iWindowGroupIdentifier=iWinGroup2.Identifier();
sl@0
   688
	eventMessageReady.iMessageUid=TUid::Uid(UID_VALUE);
sl@0
   689
	eventMessageReady.iMessageParametersSize=MESSAGE_LEN;
sl@0
   690
	TInt ret=TheClient->iWs.FetchMessage(uid,ptr,event);
sl@0
   691
	if (ret==KErrNone)
sl@0
   692
		User::Free((TAny *)ptr.Ptr());
sl@0
   693
	return(ret);
sl@0
   694
	}
sl@0
   695
sl@0
   696
void COomMessageFetch::ClearUpL()
sl@0
   697
	{
sl@0
   698
	iWinGroup2.Close();
sl@0
   699
	}
sl@0
   700
sl@0
   701
//
sl@0
   702
sl@0
   703
COomRequestEvents::COomRequestEvents(CTOom *aTest) : COomSetup(aTest)
sl@0
   704
	{}
sl@0
   705
sl@0
   706
COomRequestEvents::~COomRequestEvents()
sl@0
   707
	{
sl@0
   708
	}
sl@0
   709
sl@0
   710
TOomTestName COomRequestEvents::TestName()
sl@0
   711
	{
sl@0
   712
	return(_L("Request events"));
sl@0
   713
	}
sl@0
   714
sl@0
   715
void COomRequestEvents::ConstructL()
sl@0
   716
	{
sl@0
   717
	COomSetup::ConstructL();
sl@0
   718
	}
sl@0
   719
sl@0
   720
/** Enables window group change events and modifier change events
sl@0
   721
*/
sl@0
   722
TInt COomRequestEvents::Fail()
sl@0
   723
	{
sl@0
   724
	TInt err;
sl@0
   725
	if ((err=iWinGroup.EnableOnEvents())==KErrNone)
sl@0
   726
		if ((err=iWinGroup.EnableGroupChangeEvents())==KErrNone)
sl@0
   727
			err=iWinGroup.EnableModifierChangedEvents(EModifierCapsLock,EEventControlAlways);
sl@0
   728
	return(err);
sl@0
   729
	}
sl@0
   730
sl@0
   731
void COomRequestEvents::ClearUpL()
sl@0
   732
	{
sl@0
   733
	iWinGroup.DisableOnEvents();
sl@0
   734
	iWinGroup.DisableGroupChangeEvents();
sl@0
   735
	iWinGroup.DisableModifierChangedEvents();
sl@0
   736
	}
sl@0
   737
sl@0
   738
//
sl@0
   739
sl@0
   740
COomCopyScreen::COomCopyScreen(CTOom *aTest) : COomSetup(aTest)
sl@0
   741
	{}
sl@0
   742
sl@0
   743
TOomTestName COomCopyScreen::TestName()
sl@0
   744
	{
sl@0
   745
	return(_L("Copy screen"));
sl@0
   746
	}
sl@0
   747
sl@0
   748
COomCopyScreen::~COomCopyScreen()
sl@0
   749
	{
sl@0
   750
	delete iScrDev;
sl@0
   751
	delete iBitmap;
sl@0
   752
	}
sl@0
   753
sl@0
   754
void COomCopyScreen::ConstructL()
sl@0
   755
	{
sl@0
   756
	COomSetup::ConstructL();
sl@0
   757
	iScrDev=new(ELeave) CWsScreenDevice(iWs);
sl@0
   758
	User::LeaveIfError(iScrDev->Construct(iTest->ScreenNumber()));
sl@0
   759
	iBitmap=new(ELeave) CFbsBitmap();
sl@0
   760
	User::LeaveIfError(iBitmap->Create(TSize(100,100),EGray4));
sl@0
   761
	}
sl@0
   762
sl@0
   763
/** Copies screen to bitmap
sl@0
   764
*/
sl@0
   765
TInt COomCopyScreen::Fail()
sl@0
   766
	{
sl@0
   767
	TInt ret=iScrDev->CopyScreenToBitmap(iBitmap);
sl@0
   768
	if (ret==KErrNone)
sl@0
   769
		ret=iScrDev->CopyScreenToBitmap(iBitmap,TRect(10,10,50,50));
sl@0
   770
	return(ret);
sl@0
   771
	}
sl@0
   772
sl@0
   773
void COomCopyScreen::ClearUpL()
sl@0
   774
	{
sl@0
   775
	}
sl@0
   776
sl@0
   777
//
sl@0
   778
sl@0
   779
COomSpriteBase::COomSpriteBase(CTOom *aTest) : COomSetup(aTest)
sl@0
   780
	{}
sl@0
   781
sl@0
   782
COomSpriteBase::~COomSpriteBase()
sl@0
   783
	{
sl@0
   784
	iWin.Close();
sl@0
   785
	delete iBitmap;
sl@0
   786
	delete iMask;
sl@0
   787
	delete iBitmap2;
sl@0
   788
	delete iMask2;
sl@0
   789
	}
sl@0
   790
sl@0
   791
void COomSpriteBase::ConstructL()
sl@0
   792
	{
sl@0
   793
	COomSetup::ConstructL();
sl@0
   794
	iWin=RWindow(iWs);
sl@0
   795
	User::LeaveIfError(iWin.Construct(iWinGroup,33));
sl@0
   796
	User::LeaveIfError(iWin.SetSizeErr(TSize(100,100)));
sl@0
   797
	iWin.Activate();
sl@0
   798
	iBitmap=new(ELeave) CFbsBitmap();
sl@0
   799
	User::LeaveIfError(iBitmap->Create(TSize(10,10),EGray4));
sl@0
   800
	iBitmap2=new(ELeave) CFbsBitmap();
sl@0
   801
	User::LeaveIfError(iBitmap2->Create(TSize(40,40),EGray4));
sl@0
   802
	iMask=new(ELeave) CFbsBitmap();
sl@0
   803
	User::LeaveIfError(iMask->Create(TSize(10,10),EGray4));
sl@0
   804
	iMask2=new(ELeave) CFbsBitmap();
sl@0
   805
	User::LeaveIfError(iMask2->Create(TSize(40,40),EGray4));
sl@0
   806
	}
sl@0
   807
sl@0
   808
//
sl@0
   809
sl@0
   810
COomSprite::COomSprite(CTOom *aTest) : COomSpriteBase(aTest)
sl@0
   811
	{}
sl@0
   812
sl@0
   813
TOomTestName COomSprite::TestName()
sl@0
   814
	{
sl@0
   815
	return(_L("Sprites"));
sl@0
   816
	}
sl@0
   817
sl@0
   818
/** Creates a sprite.
sl@0
   819
*/
sl@0
   820
TInt COomSprite::Fail()
sl@0
   821
	{
sl@0
   822
	iSprite=RWsSprite(iWs);
sl@0
   823
	TInt err=iSprite.Construct(iWin,TPoint(10,10),0);
sl@0
   824
	if (err==KErrNone)
sl@0
   825
		{
sl@0
   826
		TSpriteMember sprite;
sl@0
   827
		sprite.iBitmap=iBitmap;
sl@0
   828
		sprite.iMaskBitmap=iMask;
sl@0
   829
		sprite.iInvertMask=EFalse;
sl@0
   830
		sprite.iDrawMode=CGraphicsContext::EDrawModePEN;
sl@0
   831
		sprite.iOffset=TPoint(0,0);
sl@0
   832
		sprite.iInterval=TTimeIntervalMicroSeconds32(100000);
sl@0
   833
		if ((err=iSprite.AppendMember(sprite))==KErrNone)
sl@0
   834
			if ((err=iSprite.Activate())==KErrNone)
sl@0
   835
				{
sl@0
   836
				sprite.iBitmap=iBitmap2;		// Bigger bitmap to force resize of bitmap
sl@0
   837
				sprite.iMaskBitmap=iMask2;
sl@0
   838
				if ((err=iSprite.AppendMember(sprite))==KErrNone)
sl@0
   839
					err=iSprite.UpdateMember(1,sprite);
sl@0
   840
				}
sl@0
   841
		}
sl@0
   842
	return(err);
sl@0
   843
	}
sl@0
   844
sl@0
   845
void COomSprite::ClearUpL()
sl@0
   846
	{
sl@0
   847
	iSprite.Close();
sl@0
   848
	}
sl@0
   849
sl@0
   850
//
sl@0
   851
sl@0
   852
COomPointerCursor::COomPointerCursor(CTOom *aTest) : COomSpriteBase(aTest)
sl@0
   853
	{}
sl@0
   854
sl@0
   855
TOomTestName COomPointerCursor::TestName()
sl@0
   856
	{
sl@0
   857
	return(_L("Pointer cursor"));
sl@0
   858
	}
sl@0
   859
sl@0
   860
/** Creates a pointer cursor.
sl@0
   861
*/
sl@0
   862
TInt COomPointerCursor::Fail()
sl@0
   863
	{
sl@0
   864
	iPointerCursor=RWsPointerCursor(iWs);
sl@0
   865
	TInt err=iPointerCursor.Construct(0);
sl@0
   866
	if (err==KErrNone)
sl@0
   867
		{
sl@0
   868
		TSpriteMember sprite;
sl@0
   869
		sprite.iBitmap=iBitmap;
sl@0
   870
		sprite.iMaskBitmap=iMask;
sl@0
   871
		sprite.iInvertMask=EFalse;
sl@0
   872
		sprite.iDrawMode=CGraphicsContext::EDrawModePEN;
sl@0
   873
		sprite.iOffset=TPoint(0,0);
sl@0
   874
		sprite.iInterval=TTimeIntervalMicroSeconds32(100000);
sl@0
   875
		if ((err=iPointerCursor.AppendMember(sprite))==KErrNone)
sl@0
   876
			if ((err=iPointerCursor.Activate())==KErrNone)
sl@0
   877
				{
sl@0
   878
				sprite.iBitmap=iBitmap2;		// Bigger bitmap to force resize of bitmap
sl@0
   879
				sprite.iMaskBitmap=iMask2;
sl@0
   880
				if ((err=iPointerCursor.AppendMember(sprite))==KErrNone)
sl@0
   881
					err=iPointerCursor.UpdateMember(1,sprite);
sl@0
   882
				}
sl@0
   883
		}
sl@0
   884
	return(err);
sl@0
   885
	}
sl@0
   886
sl@0
   887
void COomPointerCursor::ClearUpL()
sl@0
   888
	{
sl@0
   889
	iPointerCursor.Close();
sl@0
   890
	}
sl@0
   891
sl@0
   892
//
sl@0
   893
sl@0
   894
COomGc::COomGc(CTOom *aTest) : COomSetup(aTest)
sl@0
   895
	{}
sl@0
   896
sl@0
   897
COomGc::~COomGc()
sl@0
   898
	{
sl@0
   899
	delete iScrDev;
sl@0
   900
	}
sl@0
   901
sl@0
   902
TOomTestName COomGc::TestName()
sl@0
   903
	{
sl@0
   904
	return(_L("Graphic Context"));
sl@0
   905
	}
sl@0
   906
sl@0
   907
void COomGc::ConstructL()
sl@0
   908
	{
sl@0
   909
	COomSetup::ConstructL();
sl@0
   910
	iScrDev=new(ELeave) CWsScreenDevice(iWs);
sl@0
   911
	User::LeaveIfError(iScrDev->Construct(iTest->ScreenNumber()));
sl@0
   912
	}
sl@0
   913
sl@0
   914
/** Creates a graphical context for a previously created screen device.
sl@0
   915
*/
sl@0
   916
TInt COomGc::Fail()
sl@0
   917
	{
sl@0
   918
	TRAPD(err,iFailGc=new(ELeave) CWindowGc(iScrDev));
sl@0
   919
	if (err!=KErrNone)
sl@0
   920
		return(err);
sl@0
   921
	return(iFailGc->Construct());
sl@0
   922
	}
sl@0
   923
sl@0
   924
void COomGc::ClearUpL()
sl@0
   925
	{
sl@0
   926
	delete iFailGc;
sl@0
   927
	iFailGc=NULL;
sl@0
   928
	}
sl@0
   929
sl@0
   930
//
sl@0
   931
sl@0
   932
COomPolygon::COomPolygon(CTOom *aTest) : COomSetup(aTest), iPnts(5)
sl@0
   933
	{}
sl@0
   934
sl@0
   935
COomPolygon::~COomPolygon()
sl@0
   936
	{
sl@0
   937
	delete iGc;
sl@0
   938
	delete iScrDev;
sl@0
   939
	iWin.Close();
sl@0
   940
	}
sl@0
   941
sl@0
   942
TOomTestName COomPolygon::TestName()
sl@0
   943
	{
sl@0
   944
	return(_L("Polygon"));
sl@0
   945
	}
sl@0
   946
sl@0
   947
void COomPolygon::ConstructL()
sl@0
   948
	{
sl@0
   949
	COomSetup::ConstructL();
sl@0
   950
	iScrDev=new(ELeave) CWsScreenDevice(iWs);
sl@0
   951
	User::LeaveIfError(iScrDev->Construct(iTest->ScreenNumber()));
sl@0
   952
	User::LeaveIfError(iScrDev->CreateContext(iGc));
sl@0
   953
	iWin=RBackedUpWindow(iWs);
sl@0
   954
	User::LeaveIfError(iWin.Construct(iWinGroup,EGray16,33));
sl@0
   955
	User::LeaveIfError(iWin.SetSizeErr(TSize(40,40)));
sl@0
   956
	iWin.Activate();
sl@0
   957
	TInt index;
sl@0
   958
	for(index=0;index<20;index+=2)
sl@0
   959
		iPnts.AppendL(TPoint(20+index,index));
sl@0
   960
	for(index=0;index<20;index+=2)
sl@0
   961
		iPnts.AppendL(TPoint(40-index,20+index));
sl@0
   962
	for(index=0;index<20;index+=2)
sl@0
   963
		iPnts.AppendL(TPoint(20-index,40-index));
sl@0
   964
	for(index=0;index<20;index+=2)
sl@0
   965
		iPnts.AppendL(TPoint(index,20-index));
sl@0
   966
	}
sl@0
   967
sl@0
   968
/** Draws a polygon.
sl@0
   969
*/
sl@0
   970
TInt COomPolygon::Fail()
sl@0
   971
	{
sl@0
   972
	iGc->Activate(iWin);
sl@0
   973
	iGc->Clear();
sl@0
   974
	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
   975
	iGc->SetBrushColor(TRgb::Gray4(2));
sl@0
   976
	iGc->SetPenColor(TRgb::Gray4(0));
sl@0
   977
	TInt err=iGc->DrawPolygon(&iPnts,CGraphicsContext::EAlternate);
sl@0
   978
	if (err!=KErrNone)
sl@0
   979
		return(err);
sl@0
   980
	err=iGc->DrawPolygon(&iPnts,CGraphicsContext::EWinding);
sl@0
   981
	if (err!=KErrNone)
sl@0
   982
		return(err);
sl@0
   983
	return(KErrNone);
sl@0
   984
	}
sl@0
   985
sl@0
   986
void COomPolygon::ClearUpL()
sl@0
   987
	{
sl@0
   988
	iGc->Deactivate();
sl@0
   989
	}
sl@0
   990
sl@0
   991
//
sl@0
   992
sl@0
   993
COomScreenDevice::COomScreenDevice(CTOom *aTest) : COomSetup(aTest)
sl@0
   994
	{}
sl@0
   995
sl@0
   996
TOomTestName COomScreenDevice::TestName()
sl@0
   997
	{
sl@0
   998
	return(_L("Screen device"));
sl@0
   999
	}
sl@0
  1000
sl@0
  1001
/** Creates a screen device handle.
sl@0
  1002
*/
sl@0
  1003
TInt COomScreenDevice::Fail()
sl@0
  1004
	{
sl@0
  1005
	TRAPD(err,iScrDev=new(ELeave) CWsScreenDevice(iWs));
sl@0
  1006
	if (err!=KErrNone)
sl@0
  1007
		return(err);
sl@0
  1008
	return(iScrDev->Construct(iTest->ScreenNumber()));
sl@0
  1009
	}
sl@0
  1010
sl@0
  1011
void COomScreenDevice::ClearUpL()
sl@0
  1012
	{
sl@0
  1013
	delete iScrDev;
sl@0
  1014
	iScrDev=NULL;
sl@0
  1015
	}
sl@0
  1016
sl@0
  1017
//
sl@0
  1018
sl@0
  1019
COomCustomTextCursor::COomCustomTextCursor(CTOom *aTest) : COomSetup(aTest)
sl@0
  1020
	{}
sl@0
  1021
sl@0
  1022
COomCustomTextCursor::~COomCustomTextCursor()
sl@0
  1023
	{
sl@0
  1024
	delete iMemberArray;
sl@0
  1025
	delete iBitmap;
sl@0
  1026
	}
sl@0
  1027
sl@0
  1028
TOomTestName COomCustomTextCursor::TestName()
sl@0
  1029
	{
sl@0
  1030
	return(_L("Custom Text Cursor"));
sl@0
  1031
	}
sl@0
  1032
sl@0
  1033
void COomCustomTextCursor::ConstructL()
sl@0
  1034
	{
sl@0
  1035
	COomSetup::ConstructL();
sl@0
  1036
sl@0
  1037
	iBitmap = new(ELeave) CFbsBitmap;
sl@0
  1038
	User::LeaveIfError(iBitmap->Load(TEST_BITMAP_NAME, EMbmWsautotestBmp1));
sl@0
  1039
sl@0
  1040
	TSpriteMember member;
sl@0
  1041
	member.iMaskBitmap=NULL;
sl@0
  1042
	member.iInvertMask=EFalse;
sl@0
  1043
	member.iDrawMode=CGraphicsContext::EDrawModePEN;
sl@0
  1044
	member.iOffset=TPoint();
sl@0
  1045
	member.iInterval=TTimeIntervalMicroSeconds32(0);
sl@0
  1046
	member.iBitmap = iBitmap;
sl@0
  1047
sl@0
  1048
	iMemberArray = new(ELeave) CArrayFixFlat<TSpriteMember>(1);
sl@0
  1049
	iMemberArray->AppendL(member);
sl@0
  1050
	}
sl@0
  1051
sl@0
  1052
/** Adds a custom text cursor to the server's list of cursors.
sl@0
  1053
*/
sl@0
  1054
TInt COomCustomTextCursor::Fail()
sl@0
  1055
	{
sl@0
  1056
	TInt err = TheClient->iWs.SetCustomTextCursor(0x98765432, iMemberArray->Array(), 0, RWsSession::ECustomTextCursorAlignTop);
sl@0
  1057
	if (err == KErrAlreadyExists)
sl@0
  1058
		return KErrNone;
sl@0
  1059
	else
sl@0
  1060
		return err;
sl@0
  1061
	}
sl@0
  1062
sl@0
  1063
void COomCustomTextCursor::ClearUpL()
sl@0
  1064
	{
sl@0
  1065
	}
sl@0
  1066
sl@0
  1067
COomTranspWindow::COomTranspWindow(CTOom *aTest) : COomSetup(aTest)
sl@0
  1068
	{}
sl@0
  1069
sl@0
  1070
COomTranspWindow::~COomTranspWindow()
sl@0
  1071
	{
sl@0
  1072
	delete iBackgroundWin;
sl@0
  1073
	delete iFirst;
sl@0
  1074
	delete iSecond;
sl@0
  1075
	
sl@0
  1076
	delete iFbsBitmap;
sl@0
  1077
	delete iWsBitmap;
sl@0
  1078
	delete iFbsBitmapDevice; 
sl@0
  1079
	delete iFbsBitmapGc;
sl@0
  1080
	delete iWsBitmapDevice; 
sl@0
  1081
	delete iWsBitmapGc;				
sl@0
  1082
	}
sl@0
  1083
sl@0
  1084
TOomTestName COomTranspWindow::TestName()
sl@0
  1085
	{
sl@0
  1086
	return(_L("Transparent Window"));
sl@0
  1087
	}
sl@0
  1088
sl@0
  1089
void COomTranspWindow::ConstructL()
sl@0
  1090
	{
sl@0
  1091
	COomSetup::ConstructL();
sl@0
  1092
	
sl@0
  1093
	iTransparencyEnabled = (TransparencySupportedL() == KErrNone);
sl@0
  1094
	if(!iTransparencyEnabled)
sl@0
  1095
		return;
sl@0
  1096
sl@0
  1097
	iFbsBitmap = new (ELeave) CFbsBitmap;
sl@0
  1098
sl@0
  1099
	// Do the creation 
sl@0
  1100
	const TSize KSizeForBitmap(10,10);
sl@0
  1101
	iFbsBitmap->Create(KSizeForBitmap,EGray256);
sl@0
  1102
	
sl@0
  1103
	// Fill the bitmap with a colour		
sl@0
  1104
	iFbsBitmapDevice=CFbsBitmapDevice::NewL(iFbsBitmap);
sl@0
  1105
		
sl@0
  1106
	iFbsBitmapDevice->CreateContext(iFbsBitmapGc);
sl@0
  1107
	
sl@0
  1108
	iFbsBitmapGc->SetPenStyle(CGraphicsContext::ENullPen);
sl@0
  1109
	iFbsBitmapGc->SetBrushStyle(CGraphicsContext::ESolidBrush);	
sl@0
  1110
	iFbsBitmapGc->SetBrushColor(128);
sl@0
  1111
	iFbsBitmapGc->DrawRect(TRect(KSizeForBitmap));
sl@0
  1112
	
sl@0
  1113
	// Create a CWsBitmap, and fill it with a colour	
sl@0
  1114
	iWsBitmap = new (ELeave) CWsBitmap(TheClient->iWs);
sl@0
  1115
	
sl@0
  1116
	// Do the creation 
sl@0
  1117
	iWsBitmap->Create(KSizeForBitmap,EGray256);	
sl@0
  1118
		
sl@0
  1119
	// Fill the bitmap with a colour		
sl@0
  1120
	iWsBitmapDevice=CFbsBitmapDevice::NewL(iWsBitmap);	
sl@0
  1121
			
sl@0
  1122
	iWsBitmapDevice->CreateContext(iWsBitmapGc);		
sl@0
  1123
	iWsBitmapGc->SetPenStyle(CGraphicsContext::ENullPen);
sl@0
  1124
	iWsBitmapGc->SetBrushStyle(CGraphicsContext::ESolidBrush);	
sl@0
  1125
	iWsBitmapGc->SetBrushColor(128);
sl@0
  1126
	iWsBitmapGc->DrawRect(TRect(KSizeForBitmap));				
sl@0
  1127
	}
sl@0
  1128
	
sl@0
  1129
sl@0
  1130
/** Does nothing if transparency is not enabled. Creates a blank window with 
sl@0
  1131
* two transparent child-windows. Tests setting the transparency via a factor, CFbsBitmap
sl@0
  1132
* or a CWsBitmap, and changing from one to the other.
sl@0
  1133
* Changes child-windows' sizes and toggles their visibility.
sl@0
  1134
*/
sl@0
  1135
TInt COomTranspWindow::Fail()
sl@0
  1136
	{
sl@0
  1137
	if(!iTransparencyEnabled)
sl@0
  1138
		return KErrNone;
sl@0
  1139
	TSize scrSize(TheClient->iScreen->SizeInPixels());
sl@0
  1140
	TRAPD(res, iBackgroundWin = new (ELeave) CBlankWindow(TRgb(0,0,238)));
sl@0
  1141
	if(res != KErrNone)
sl@0
  1142
		{
sl@0
  1143
		return res;	
sl@0
  1144
		}
sl@0
  1145
sl@0
  1146
	TDisplayMode mode=EColor256;
sl@0
  1147
	TRAP(res, iBackgroundWin->SetUpL(TPoint(50,50),scrSize-TSize(100,100),TheClient->iGroup,*TheClient->iGc,&mode));
sl@0
  1148
	if(res != KErrNone)
sl@0
  1149
		{
sl@0
  1150
		return res;
sl@0
  1151
		}
sl@0
  1152
sl@0
  1153
	TheClient->Flush();
sl@0
  1154
	TheClient->WaitForRedrawsToFinish();
sl@0
  1155
sl@0
  1156
	iBackgroundWin->Win()->SetBackgroundColor(TRgb(51,204,51));
sl@0
  1157
	iBackgroundWin->Invalidate();
sl@0
  1158
sl@0
  1159
	TheClient->Flush();
sl@0
  1160
	TheClient->WaitForRedrawsToFinish();
sl@0
  1161
sl@0
  1162
	TRect	thePos1(20, 20, 60, 60);
sl@0
  1163
	TRect	thePos2(100, 40, 160, 80);
sl@0
  1164
	TRAP(res, iFirst = CTransWindow::NewL(iBackgroundWin, TRgb(255,0,0,128),&mode));
sl@0
  1165
	if(res != KErrNone)
sl@0
  1166
		{
sl@0
  1167
		return res;
sl@0
  1168
		}
sl@0
  1169
sl@0
  1170
	TRAP(res, iSecond = CTransWindow::NewL(iBackgroundWin, TRgb(255,0,0,128),&mode));
sl@0
  1171
	if(res != KErrNone)
sl@0
  1172
		{
sl@0
  1173
		return res;
sl@0
  1174
		}
sl@0
  1175
sl@0
  1176
	TRAP(res, iFirst->SetExtL(thePos1.iTl,thePos1.Size()));
sl@0
  1177
	if(res != KErrNone)
sl@0
  1178
		{
sl@0
  1179
		return res;
sl@0
  1180
		}
sl@0
  1181
sl@0
  1182
	TRAP(res, iSecond->SetExtL(thePos2.iTl,thePos2.Size()));
sl@0
  1183
	if(res != KErrNone)
sl@0
  1184
		{
sl@0
  1185
		return res;
sl@0
  1186
		}
sl@0
  1187
sl@0
  1188
	res=SetTransparencyTesting();
sl@0
  1189
	if(res != KErrNone)
sl@0
  1190
		{
sl@0
  1191
		return res;
sl@0
  1192
		}
sl@0
  1193
sl@0
  1194
	TheClient->Flush();
sl@0
  1195
	//TheClient->WaitForRedrawsToFinish();
sl@0
  1196
sl@0
  1197
	iFirst->Activate();
sl@0
  1198
	iFirst->AssignGC(*TheClient->iGc);
sl@0
  1199
sl@0
  1200
	iSecond->Activate();
sl@0
  1201
	iSecond->AssignGC(*TheClient->iGc);
sl@0
  1202
sl@0
  1203
	iFirst->Win()->SetBackgroundColor(TRgb(0, 0, 255));
sl@0
  1204
	iSecond->Win()->SetBackgroundColor(TRgb(0, 0, 255));
sl@0
  1205
	iFirst->Invalidate();
sl@0
  1206
	iSecond->Invalidate();
sl@0
  1207
	
sl@0
  1208
	iFirst->AdjustSize(150,10, 0);
sl@0
  1209
	iSecond->AdjustSize(150,10, 0);
sl@0
  1210
sl@0
  1211
	TheClient->Flush();
sl@0
  1212
	TheClient->WaitForRedrawsToFinish();
sl@0
  1213
sl@0
  1214
	iFirst->ToggleVisibility();
sl@0
  1215
	iSecond->ToggleVisibility();
sl@0
  1216
sl@0
  1217
	TheClient->Flush();
sl@0
  1218
	TheClient->WaitForRedrawsToFinish();
sl@0
  1219
	
sl@0
  1220
	iFirst->AdjustSize(200,10, 0);
sl@0
  1221
	iSecond->AdjustSize(200,10, 0);
sl@0
  1222
sl@0
  1223
	iFirst->ToggleVisibility();
sl@0
  1224
	iSecond->ToggleVisibility();
sl@0
  1225
sl@0
  1226
	TheClient->Flush();
sl@0
  1227
	TheClient->WaitForRedrawsToFinish();
sl@0
  1228
sl@0
  1229
	return KErrNone;
sl@0
  1230
	}
sl@0
  1231
sl@0
  1232
sl@0
  1233
// This function tests setting the transparency via a factor, CFbsBitmap
sl@0
  1234
// or a CWsBitmap, and changing from one to the other.
sl@0
  1235
TInt COomTranspWindow::SetTransparencyTesting()
sl@0
  1236
	{
sl@0
  1237
	TInt res;	
sl@0
  1238
	TLogMessageText buf;
sl@0
  1239
		
sl@0
  1240
	// Need all nine transitions, from the 3 ways to the same 3 ways.
sl@0
  1241
	// The ways are Factor, CWsBitmap, CFbsBitmap
sl@0
  1242
	const TRgb KTransparencyFactor(128,128,128);
sl@0
  1243
	res=iFirst->Win()->SetTransparencyFactor(KTransparencyFactor);
sl@0
  1244
	if (res!=KErrNone)
sl@0
  1245
		{
sl@0
  1246
		buf=_L("test failure!! with SetTransparencyFactor -1");
sl@0
  1247
		TheClient->LogMessage(buf);
sl@0
  1248
		return res;
sl@0
  1249
		}
sl@0
  1250
			
sl@0
  1251
	res=iFirst->Win()->SetTransparencyBitmap(*iFbsBitmap);
sl@0
  1252
	if (res!=KErrNone)
sl@0
  1253
		{
sl@0
  1254
		buf=_L("test failure!! with SetTransparencyBitmap - fbs -2");
sl@0
  1255
		TheClient->LogMessage(buf);
sl@0
  1256
		return res;
sl@0
  1257
		}			
sl@0
  1258
		
sl@0
  1259
	res=iFirst->Win()->SetTransparencyWsBitmap(*iWsBitmap);
sl@0
  1260
	if (res!=KErrNone)
sl@0
  1261
		{
sl@0
  1262
		buf=_L("test failure!! with SetTransparencyBitmap - Ws -3");
sl@0
  1263
		TheClient->LogMessage(buf);
sl@0
  1264
		return res;
sl@0
  1265
		}
sl@0
  1266
				
sl@0
  1267
	res=iFirst->Win()->SetTransparencyFactor(KTransparencyFactor);
sl@0
  1268
	if (res!=KErrNone)
sl@0
  1269
		{
sl@0
  1270
		buf=_L("test failure!! with SetTransparencyBitmap - fbs -4");
sl@0
  1271
		TheClient->LogMessage(buf);
sl@0
  1272
		return res;
sl@0
  1273
		}	
sl@0
  1274
	res=iFirst->Win()->SetTransparencyWsBitmap(*iWsBitmap);
sl@0
  1275
	if (res!=KErrNone)
sl@0
  1276
		{
sl@0
  1277
		buf=_L("test failure!! with SetTransparencyBitmap - Ws -5");
sl@0
  1278
		TheClient->LogMessage(buf);
sl@0
  1279
		return res;
sl@0
  1280
		}
sl@0
  1281
	res=iFirst->Win()->SetTransparencyWsBitmap(*iWsBitmap);
sl@0
  1282
	if (res!=KErrNone)
sl@0
  1283
		{
sl@0
  1284
		buf=_L("test failure!! with SetTransparencyBitmap - Ws -6");
sl@0
  1285
		TheClient->LogMessage(buf);
sl@0
  1286
		return res;
sl@0
  1287
		}			
sl@0
  1288
		
sl@0
  1289
	res=iFirst->Win()->SetTransparencyBitmap(*iFbsBitmap);
sl@0
  1290
	if (res!=KErrNone)
sl@0
  1291
		{
sl@0
  1292
		buf=_L("test failure!! with SetTransparencyBitmap - fbs -7");
sl@0
  1293
		TheClient->LogMessage(buf);
sl@0
  1294
		return res;
sl@0
  1295
		}	
sl@0
  1296
		
sl@0
  1297
	res=iFirst->Win()->SetTransparencyBitmap(*iFbsBitmap);
sl@0
  1298
	if (res!=KErrNone)
sl@0
  1299
		{
sl@0
  1300
		buf=_L("test failure!! with SetTransparencyBitmap - fbs -8");
sl@0
  1301
		TheClient->LogMessage(buf);
sl@0
  1302
		return res;
sl@0
  1303
		}
sl@0
  1304
		
sl@0
  1305
	res=iFirst->Win()->SetTransparencyFactor(KTransparencyFactor);
sl@0
  1306
	if (res!=KErrNone)
sl@0
  1307
		{
sl@0
  1308
		buf=_L("test failure!! with SetTransparencyFactor -9");
sl@0
  1309
		TheClient->LogMessage(buf);
sl@0
  1310
		return res;
sl@0
  1311
		}				
sl@0
  1312
		
sl@0
  1313
	res=iFirst->Win()->SetTransparencyFactor(KTransparencyFactor);
sl@0
  1314
	if (res!=KErrNone)
sl@0
  1315
		{
sl@0
  1316
		buf=_L("test failure!! with SetTransparencyFactor -10");
sl@0
  1317
		TheClient->LogMessage(buf);
sl@0
  1318
		return res;
sl@0
  1319
		}
sl@0
  1320
					
sl@0
  1321
	return res;
sl@0
  1322
	}	
sl@0
  1323
sl@0
  1324
void COomTranspWindow::ClearUpL()
sl@0
  1325
	{
sl@0
  1326
	delete iFirst;
sl@0
  1327
	iFirst = NULL;
sl@0
  1328
	delete iSecond;
sl@0
  1329
	iSecond = NULL;
sl@0
  1330
	delete iBackgroundWin;
sl@0
  1331
	iBackgroundWin = NULL;
sl@0
  1332
	}
sl@0
  1333
sl@0
  1334
//
sl@0
  1335
sl@0
  1336
CWindowWithOneLine* CWindowWithOneLine::NewL(CTWinBase& aParent, const TRect& aExtent)
sl@0
  1337
	{
sl@0
  1338
	CWindowWithOneLine* self = new(ELeave) CWindowWithOneLine;
sl@0
  1339
	CleanupStack::PushL(self);
sl@0
  1340
	self->ConstructL(aParent);
sl@0
  1341
	const TSize screenSize(TheClient->iScreen->SizeInPixels());	
sl@0
  1342
	self->SetExtL(aExtent.iTl, aExtent.Size());
sl@0
  1343
	self->AssignGC(*TheClient->iGc);
sl@0
  1344
	self->Activate();
sl@0
  1345
	self->DrawNow();
sl@0
  1346
	CleanupStack::Pop(self);
sl@0
  1347
	return self;
sl@0
  1348
	}
sl@0
  1349
sl@0
  1350
void CWindowWithOneLine::Draw()
sl@0
  1351
	{
sl@0
  1352
	iGc->DrawLine(TPoint(0,0), TPoint(Size().iWidth, Size().iHeight));
sl@0
  1353
	}
sl@0
  1354
sl@0
  1355
//
sl@0
  1356
sl@0
  1357
COomObscuredWindow::COomObscuredWindow(CTOom *aTest) : COomSetup(aTest)
sl@0
  1358
	{}
sl@0
  1359
sl@0
  1360
TOomTestName COomObscuredWindow::TestName()
sl@0
  1361
	{
sl@0
  1362
	return(_L("Obscured window"));
sl@0
  1363
	}
sl@0
  1364
sl@0
  1365
TInt COomObscuredWindow::Fail()
sl@0
  1366
	{
sl@0
  1367
	TRAPD(err, DoFailL());
sl@0
  1368
	return err;
sl@0
  1369
	}
sl@0
  1370
sl@0
  1371
	
sl@0
  1372
void COomObscuredWindow::DoFailL()
sl@0
  1373
	{
sl@0
  1374
#ifdef __WINS__
sl@0
  1375
	RDebug::Print(_L("COomObscuredWindow::DoFailL - enter"));
sl@0
  1376
#endif
sl@0
  1377
	const TRect extent(20, 20, 100, 100);
sl@0
  1378
	CBlankWindow* backgroundWindow = new(ELeave) CBlankWindow(TRgb(12, 23, 34));
sl@0
  1379
	CleanupStack::PushL(backgroundWindow);
sl@0
  1380
	TDisplayMode mode = EColor16MAP;
sl@0
  1381
	backgroundWindow->SetUpL(extent.iTl, extent.Size(), TheClient->iGroup, *TheClient->iGc, &mode);
sl@0
  1382
	
sl@0
  1383
	CWindowWithOneLine* window = CWindowWithOneLine::NewL(*backgroundWindow, extent);
sl@0
  1384
	CleanupStack::PushL(window);
sl@0
  1385
#ifdef __WINS__
sl@0
  1386
	RDebug::Print(_L("COomObscuredWindow - WaitForRedrawsToFinish - 1"));
sl@0
  1387
#endif
sl@0
  1388
	TheClient->WaitForRedrawsToFinish();
sl@0
  1389
	
sl@0
  1390
	CBlankWindow* obscuringWindow = new(ELeave) CBlankWindow(TRgb(255, 0, 0));
sl@0
  1391
	CleanupStack::PushL(obscuringWindow);
sl@0
  1392
	obscuringWindow->SetUpL(extent.iTl, extent.Size(), backgroundWindow, *TheClient->iGc, &mode);
sl@0
  1393
sl@0
  1394
	TheClient->Flush();
sl@0
  1395
#ifdef __WINS__
sl@0
  1396
    RDebug::Print(_L("COomObscuredWindow - WaitForRedrawsToFinish - 2"));
sl@0
  1397
#endif
sl@0
  1398
	TheClient->WaitForRedrawsToFinish();
sl@0
  1399
sl@0
  1400
	window->Invalidate();
sl@0
  1401
sl@0
  1402
	for(TInt i = 0; i < 50; i++)
sl@0
  1403
		{
sl@0
  1404
		RWindow anotherWin(iWs);
sl@0
  1405
		User::LeaveIfError(anotherWin.Construct(iWinGroup, 11));
sl@0
  1406
		anotherWin.Close();
sl@0
  1407
		
sl@0
  1408
		if(i % 4)
sl@0
  1409
			window->Invalidate();
sl@0
  1410
sl@0
  1411
		TheClient->Flush();
sl@0
  1412
#ifdef __WINS__
sl@0
  1413
	    RDebug::Print(_L("COomObscuredWindow - WaitForRedrawsToFinish - 3 - %d"), i);
sl@0
  1414
#endif
sl@0
  1415
	    TheClient->WaitForRedrawsToFinish();
sl@0
  1416
		}
sl@0
  1417
sl@0
  1418
	TheClient->Flush();
sl@0
  1419
#ifdef __WINS__
sl@0
  1420
    RDebug::Print(_L("COomObscuredWindow - WaitForRedrawsToFinish - 4"));
sl@0
  1421
#endif
sl@0
  1422
	TheClient->WaitForRedrawsToFinish();
sl@0
  1423
sl@0
  1424
	CleanupStack::PopAndDestroy(obscuringWindow);
sl@0
  1425
	CleanupStack::PopAndDestroy(window);
sl@0
  1426
	CleanupStack::PopAndDestroy(backgroundWindow);
sl@0
  1427
#ifdef __WINS__
sl@0
  1428
    RDebug::Print(_L("COomObscuredWindow::DoFailL - exit"));
sl@0
  1429
#endif
sl@0
  1430
	}
sl@0
  1431
sl@0
  1432
void COomObscuredWindow::ClearUpL()
sl@0
  1433
	{
sl@0
  1434
	}	
sl@0
  1435
sl@0
  1436
//
sl@0
  1437
sl@0
  1438
CTOom::CTOom(CTestStep* aStep) : CTWsGraphicsBase(aStep)
sl@0
  1439
	{
sl@0
  1440
	iState = 0;
sl@0
  1441
	}
sl@0
  1442
	
sl@0
  1443
const TDesC& CTOom::TestName() const
sl@0
  1444
	{
sl@0
  1445
	_LIT(KTestName,"CTOom");
sl@0
  1446
	return(KTestName());
sl@0
  1447
	}
sl@0
  1448
	
sl@0
  1449
void CTOom::DoOomTestL(COomFailBase *aOomTest)
sl@0
  1450
	{
sl@0
  1451
	//TLogMessageText buf;
sl@0
  1452
	TEST(aOomTest!=NULL);
sl@0
  1453
	if (aOomTest==NULL)
sl@0
  1454
		INFO_PRINTF1(_L("aOomTest - Expected: Not Null, Actual: NULL"));			
sl@0
  1455
sl@0
  1456
	TRAPD(ret1,aOomTest->ConstructL());
sl@0
  1457
	TEST(ret1==KErrNone);
sl@0
  1458
	if (ret1!=KErrNone)
sl@0
  1459
		INFO_PRINTF3(_L("aOomTest->ConstructL() return value - Expected: %d, Actual: %d"), KErrNone, ret1);			
sl@0
  1460
sl@0
  1461
	aOomTest->Flush();
sl@0
  1462
	__UHEAP_MARK;
sl@0
  1463
//	TInt oldCount=TheClient->iWs.HeapCount();
sl@0
  1464
	for(TInt mode=0;mode<3;mode++)
sl@0
  1465
		{
sl@0
  1466
		/*buf.Format(_L("OOMTest[%d] Mode=%d"),iState,mode),
sl@0
  1467
		TheClient->LogMessage(buf);*/
sl@0
  1468
		TInt successCount=0;
sl@0
  1469
		for(TInt count=1;;count++)
sl@0
  1470
			{
sl@0
  1471
			TInt ret;
sl@0
  1472
			aOomTest->PreFail();
sl@0
  1473
			if (mode==0)
sl@0
  1474
				TheClient->iWs.HeapSetFail(RHeap::EDeterministic,count);
sl@0
  1475
			else if (mode==1)
sl@0
  1476
				TheClient->iWs.HeapSetBurstFail(RHeap::EBurstFailNext, count, KMaxTUint16);
sl@0
  1477
			else if (mode==3)
sl@0
  1478
				{
sl@0
  1479
				__UHEAP_SETFAIL(RHeap::EDeterministic,count);	//Leavescan will complain about EFailNext, although it isn't a leaving function
sl@0
  1480
				}
sl@0
  1481
			ret=aOomTest->Fail();
sl@0
  1482
			if (mode==0)
sl@0
  1483
				TheClient->iWs.HeapSetFail(RHeap::ENone,0);
sl@0
  1484
			else if (mode==1)
sl@0
  1485
				TheClient->iWs.HeapSetBurstFail(RHeap::ENone, 0, 0);
sl@0
  1486
			else if (mode==2)
sl@0
  1487
				{
sl@0
  1488
				__UHEAP_RESET;
sl@0
  1489
				}
sl@0
  1490
			aOomTest->ClearUpL();  //In just 1 case this could leave...
sl@0
  1491
			aOomTest->Flush();
sl@0
  1492
			if (ret==KErrNone)
sl@0
  1493
				{
sl@0
  1494
				if (successCount==10)
sl@0
  1495
					break;
sl@0
  1496
				successCount++;
sl@0
  1497
				}
sl@0
  1498
			else
sl@0
  1499
				{
sl@0
  1500
				/*if (successCount>0)
sl@0
  1501
					{
sl@0
  1502
					buf.Format(_L("[%d,%d] Count=%d, MaxSuccess=%d"),iState,mode,count,successCount);
sl@0
  1503
					TheClient->LogMessage(buf);
sl@0
  1504
					}*/
sl@0
  1505
				successCount=0;
sl@0
  1506
				/*if (ret!=KErrNoMemory)
sl@0
  1507
					{
sl@0
  1508
					buf.Format(_L("[%d,%d] Fail, Count=%d, Error=%d"),iState,mode,count,ret);
sl@0
  1509
					TheClient->LogMessage(buf);
sl@0
  1510
					}*/
sl@0
  1511
				TEST(ret==KErrNoMemory);
sl@0
  1512
				if (ret!=KErrNoMemory)
sl@0
  1513
					INFO_PRINTF3(_L("aOomTest->Fail() return value - Expected: %d, Actual: %d"), KErrNoMemory, ret);			
sl@0
  1514
sl@0
  1515
				}
sl@0
  1516
			}
sl@0
  1517
		/*buf.Format(_L("[%d,%d] LastCount=%d"),iState,mode,count),
sl@0
  1518
		TheClient->LogMessage(buf);*/
sl@0
  1519
		}
sl@0
  1520
//	TEST(oldCount>=TheClient->iWs.HeapCount());
sl@0
  1521
	__UHEAP_MARKEND;
sl@0
  1522
	delete aOomTest;
sl@0
  1523
	/*buf.Format(_L("OOMTest[%d] Finished"),iState);
sl@0
  1524
	TheClient->LogMessage(buf);*/
sl@0
  1525
	}
sl@0
  1526
sl@0
  1527
void CTOom::ConstructL()
sl@0
  1528
	{
sl@0
  1529
	iShieldWin=RBlankWindow(TheClient->iWs);
sl@0
  1530
	User::LeaveIfError(iShieldWin.Construct(*(TheClient->iGroup->GroupWin()),1));
sl@0
  1531
//	iShieldWin.SetOrdinalPosition(0,-1);
sl@0
  1532
	iShieldWin.Activate();
sl@0
  1533
	}
sl@0
  1534
sl@0
  1535
CTOom::~CTOom()
sl@0
  1536
	{
sl@0
  1537
	iShieldWin.Close();
sl@0
  1538
	}
sl@0
  1539
sl@0
  1540
/**
sl@0
  1541
@SYMTestCaseID		GRAPHICS-WSERV-0124
sl@0
  1542
sl@0
  1543
@SYMDEF             DEF081259
sl@0
  1544
sl@0
  1545
@SYMTestCaseDesc    Out of memory tests
sl@0
  1546
sl@0
  1547
@SYMTestPriority    High
sl@0
  1548
sl@0
  1549
@SYMTestStatus      Implemented
sl@0
  1550
sl@0
  1551
@SYMTestActions     Uses deterministic heap failure mode to test WSERV classes against out-of-memory errors.
sl@0
  1552
					Sets and unsets deterministic mode using both RWsSession.HeapSetFail() methods and
sl@0
  1553
					__UHEAP_SETFAIL/__UHEAP_RESET macros (doing this both client and WSERV threads are tested). 
sl@0
  1554
					On each step the test creates a failure object and repeatedly asks it to do some work (calling Fail() method).
sl@0
  1555
					A failure object is an object which encapsulates some allocation functionality inside it's Fail() method.
sl@0
  1556
					The test is performed for 23 different failure objects that do the following:
sl@0
  1557
						1. Creates a wserv session, connects and creates CWsScreenDevice object.
sl@0
  1558
						2. Creates a RWindowGroup object.
sl@0
  1559
						3. Creates a RWindow object.
sl@0
  1560
						4. Creates a RBackedUpWindow object.
sl@0
  1561
						5. Sets the size of previously created backed-up window.
sl@0
  1562
						6. Creates a RBlankWindow object.
sl@0
  1563
						7. Allocates a buffer for storing pointer movements for a previously created backed-up window.
sl@0
  1564
						8. Adds a priority key for a previously created window group.
sl@0
  1565
						9. Requests a capture keys for a previously created window group.
sl@0
  1566
						10. Requests the capture of key-up and key-down events for a previously created window group.
sl@0
  1567
						11. Sets hot key for the session.
sl@0
  1568
						12. Sets the window group's name.
sl@0
  1569
						13. Sends a message to another window group.
sl@0
  1570
						14. Fetches a message.
sl@0
  1571
						15. Enables window group change events and modifier change events.
sl@0
  1572
						16. Copies screen to bitmap.
sl@0
  1573
						17. Creates a sprite.
sl@0
  1574
						18. Creates a pointer cursor.
sl@0
  1575
						19. Creates a graphical context for a previously created screen device.
sl@0
  1576
						20. Draws a polygon.
sl@0
  1577
						21. Creates a screen device handle.
sl@0
  1578
						22. Adds a custom text cursor to the server's list of cursors.
sl@0
  1579
						23. Does nothing if transparency is not enabled. Creates a blank window with 
sl@0
  1580
							two transparent child-windows. Tests setting the transparency via a factor, CFbsBitmap
sl@0
  1581
							or a CWsBitmap, and changing from one to the other.
sl@0
  1582
							Changes child-windows' sizes and toggles their visibility.
sl@0
  1583
					
sl@0
  1584
sl@0
  1585
@SYMTestExpectedResults The test checks that the creation failure objects doesn't fail and their's work either causes no errors or causes KErrNoMemory error.
sl@0
  1586
*/
sl@0
  1587
void CTOom::RunTestCaseL(TInt /*aCurTestCase*/) 
sl@0
  1588
	{
sl@0
  1589
	((CTOomStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0124"));
sl@0
  1590
	if (iState==0)
sl@0
  1591
		{
sl@0
  1592
		// commented by Anton Golovko, 01.03.2006 while converting to TEF
sl@0
  1593
		// the code below prevented the test to do anything.
sl@0
  1594
//		if (iTest->IsFullRomL()) 
sl@0
  1595
//			{
sl@0
  1596
//			TestComplete();
sl@0
  1597
//			return;
sl@0
  1598
//			}
sl@0
  1599
		iOldCount=TheClient->iWs.HeapCount();
sl@0
  1600
		}
sl@0
  1601
	else if (iState==sizeof(CreateOomFailTest)/sizeof(CreateOomFailTest[0]))
sl@0
  1602
		{
sl@0
  1603
		iTest->CloseAllPanicWindows();
sl@0
  1604
		TInt heapCount=TheClient->iWs.HeapCount();
sl@0
  1605
		if (heapCount>iOldCount)
sl@0
  1606
			{
sl@0
  1607
			TEST(iOldCount>=heapCount-184);		//For some uninvestigated reason 184 object get allocated on the server side, partly because of INFO_PRINTF1
sl@0
  1608
			if (iOldCount<heapCount-184)
sl@0
  1609
					INFO_PRINTF3(_L("iOldCount>=heapCount-174 - Expected: %d, Actual: %d"), heapCount-184, iOldCount);			
sl@0
  1610
sl@0
  1611
			}
sl@0
  1612
		((CTOomStep*)iStep)->CloseTMSGraphicsStep();
sl@0
  1613
		TestComplete();
sl@0
  1614
		return;
sl@0
  1615
		}
sl@0
  1616
	DoOomTestL(CreateOomFailTest[iState++](this));
sl@0
  1617
	((CTOomStep*)iStep)->RecordTestResultL();
sl@0
  1618
	}
sl@0
  1619
	
sl@0
  1620
	
sl@0
  1621
	
sl@0
  1622
	
sl@0
  1623
__WS_CONSTRUCT_STEP__(Oom)
sl@0
  1624