os/graphics/windowing/windowserver/test/tauto/TSPRITE.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
//
sl@0
    15
sl@0
    16
/**
sl@0
    17
 @file
sl@0
    18
 @test
sl@0
    19
 @internalComponent - Internal Symbian test code
sl@0
    20
*/
sl@0
    21
sl@0
    22
#include "TSPRITE.H"
sl@0
    23
sl@0
    24
CTTSprite::CTTSprite(CTestStep* aStep):
sl@0
    25
	CTWsGraphicsBase(aStep)
sl@0
    26
	{
sl@0
    27
	INFO_PRINTF1(_L("Testing TSprite functions"));
sl@0
    28
	}
sl@0
    29
sl@0
    30
void CTTSprite::SetUpMember(TSpriteMember &aMember)
sl@0
    31
	{
sl@0
    32
	aMember.iMaskBitmap=NULL;
sl@0
    33
	aMember.iInvertMask=EFalse;
sl@0
    34
	aMember.iDrawMode=CGraphicsContext::EDrawModePEN;
sl@0
    35
	aMember.iOffset=TPoint();
sl@0
    36
	aMember.iInterval=TTimeIntervalMicroSeconds32(0);
sl@0
    37
	aMember.iBitmap=&iBitmap;
sl@0
    38
	}
sl@0
    39
sl@0
    40
void CTTSprite::SetUpPointerCursorL(RWsPointerCursor &aCursor, RWsSession &aSession)
sl@0
    41
	{
sl@0
    42
	aCursor=RWsPointerCursor(aSession);
sl@0
    43
	TSpriteMember member;
sl@0
    44
	SetUpMember(member);
sl@0
    45
	User::LeaveIfError(aCursor.Construct(0));
sl@0
    46
	User::LeaveIfError(aCursor.AppendMember(member));
sl@0
    47
	User::LeaveIfError(aCursor.Activate());
sl@0
    48
	}
sl@0
    49
sl@0
    50
void CTTSprite::SetUpSpriteL(RWsSprite &aSprite, RWsSession &aSession, RWindowTreeNode &aWindow,TInt aFlags/*=0*/)
sl@0
    51
	{
sl@0
    52
	aSprite=RWsSprite(aSession);
sl@0
    53
	User::LeaveIfError(aSprite.Construct(aWindow,TPoint(),aFlags));
sl@0
    54
	TSpriteMember member;
sl@0
    55
	SetUpMember(member);
sl@0
    56
	User::LeaveIfError(aSprite.AppendMember(member));
sl@0
    57
	User::LeaveIfError(aSprite.Activate());
sl@0
    58
	}
sl@0
    59
sl@0
    60
void CTTSprite::ConstructL()
sl@0
    61
	{
sl@0
    62
  	User::LeaveIfError(iBitmap.Load(TEST_BITMAP_NAME,0));
sl@0
    63
	}
sl@0
    64
	
sl@0
    65
CTTSprite::~CTTSprite()
sl@0
    66
	{
sl@0
    67
	}
sl@0
    68
sl@0
    69
/**
sl@0
    70
@SYMTestCaseID		GRAPHICS-WSERV-0018
sl@0
    71
sl@0
    72
@SYMDEF  			DEF081259
sl@0
    73
sl@0
    74
@SYMTestCaseDesc    General cursor tests involving a sprite
sl@0
    75
sl@0
    76
@SYMTestPriority    High
sl@0
    77
sl@0
    78
@SYMTestStatus      Implemented
sl@0
    79
sl@0
    80
@SYMTestActions     Carries out cursor and window tests before updating
sl@0
    81
					a cursor's member with a sprite
sl@0
    82
sl@0
    83
@SYMTestExpectedResults When the cursor member is update returns KErrArgument
sl@0
    84
*/
sl@0
    85
sl@0
    86
void CTTSprite::GeneralTestsL()
sl@0
    87
	{
sl@0
    88
//
sl@0
    89
// Close cursor while still active on a window
sl@0
    90
//
sl@0
    91
	
sl@0
    92
	RWindow win(TheClient->iWs);
sl@0
    93
	win.Construct(*TheClient->iGroup->GroupWin(),1);
sl@0
    94
	win.Activate();
sl@0
    95
	SetUpPointerCursorL(iCursor1,TheClient->iWs);
sl@0
    96
	win.SetCustomPointerCursor(iCursor1);
sl@0
    97
	iCursor1.Close();
sl@0
    98
//
sl@0
    99
// Close window while cursor active on it
sl@0
   100
//
sl@0
   101
	SetUpPointerCursorL(iCursor1,TheClient->iWs);
sl@0
   102
	win.SetCustomPointerCursor(iCursor1);
sl@0
   103
	win.Close();
sl@0
   104
	iCursor1.Close();
sl@0
   105
	
sl@0
   106
//
sl@0
   107
// Close session with:
sl@0
   108
// An open cursor active on a window & A closed cursor active on another window
sl@0
   109
//
sl@0
   110
	RWsSession ws;
sl@0
   111
	User::LeaveIfError(ws.Connect());
sl@0
   112
	// use correct screen
sl@0
   113
	//
sl@0
   114
	ws.SetFocusScreen(iTest->iScreenNumber);
sl@0
   115
	CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
sl@0
   116
	CleanupStack::PushL(screen);
sl@0
   117
	User::LeaveIfError(screen->Construct(0));
sl@0
   118
sl@0
   119
	RWindowGroup group(ws);
sl@0
   120
	User::LeaveIfError(group.Construct(123));
sl@0
   121
	group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
sl@0
   122
	RWindow win2(ws);
sl@0
   123
	User::LeaveIfError(win2.Construct(group, 1));
sl@0
   124
	win2.Activate();
sl@0
   125
	RWindow win3(ws);
sl@0
   126
	User::LeaveIfError(win3.Construct(group, 2));
sl@0
   127
	win3.Activate();
sl@0
   128
//
sl@0
   129
	SetUpPointerCursorL(iCursor1,ws);
sl@0
   130
	SetUpPointerCursorL(iCursor2,ws);
sl@0
   131
	win2.SetCustomPointerCursor(iCursor1);
sl@0
   132
	win3.SetCustomPointerCursor(iCursor2);
sl@0
   133
//
sl@0
   134
	TSpriteMember member;
sl@0
   135
	member.iBitmap=member.iMaskBitmap=NULL;
sl@0
   136
	TInt err = iCursor1.UpdateMember(9999,member);
sl@0
   137
	TEST(err==KErrArgument);
sl@0
   138
	if (err!=KErrArgument)
sl@0
   139
		INFO_PRINTF3(_L("iCursor1.UpdateMember(9999,member) return value  - Expected: %d, Actual: %d"), KErrArgument, err);
sl@0
   140
sl@0
   141
	iCursor1.Close();
sl@0
   142
sl@0
   143
	CleanupStack::PopAndDestroy(screen);	
sl@0
   144
	ws.Close();
sl@0
   145
	}
sl@0
   146
sl@0
   147
/**
sl@0
   148
@SYMTestCaseID		GRAPHICS-WSERV-0019
sl@0
   149
sl@0
   150
@SYMDEF  			DEF081259
sl@0
   151
sl@0
   152
@SYMTestCaseDesc    Construct a sprite in a group window
sl@0
   153
sl@0
   154
@SYMTestPriority    High
sl@0
   155
sl@0
   156
@SYMTestStatus      Implemented
sl@0
   157
sl@0
   158
@SYMTestActions     Creates a sprite in a group window
sl@0
   159
sl@0
   160
@SYMTestExpectedResults The sprite is created without error
sl@0
   161
*/
sl@0
   162
void CTTSprite::GroupWindowSpritesL()
sl@0
   163
	{
sl@0
   164
	RWsSprite sprite1;
sl@0
   165
	RWsSprite sprite2;
sl@0
   166
	SetUpSpriteL(sprite1,TheClient->iWs,*TheClient->iGroup->GroupWin());
sl@0
   167
	SetUpSpriteL(sprite2,TheClient->iWs,*TheClient->iGroup->GroupWin());
sl@0
   168
	TheClient->iWs.Flush();
sl@0
   169
	sprite2.Close();
sl@0
   170
	sprite1.Close();
sl@0
   171
	}
sl@0
   172
sl@0
   173
/**
sl@0
   174
@SYMTestCaseID		GRAPHICS-WSERV-0020
sl@0
   175
sl@0
   176
@SYMDEF  			DEF081259
sl@0
   177
sl@0
   178
@SYMTestCaseDesc    Constructs a number of different sprites in different windows
sl@0
   179
sl@0
   180
@SYMTestPriority    High
sl@0
   181
sl@0
   182
@SYMTestStatus      Implemented
sl@0
   183
sl@0
   184
@SYMTestActions     Creates many sprites in three different windows and the checks
sl@0
   185
					the sprites can be manipulated
sl@0
   186
sl@0
   187
@SYMTestExpectedResults The sprite are created and manipulated without error
sl@0
   188
*/
sl@0
   189
#define NUM_SPRITES 8
sl@0
   190
void CTTSprite::LotsSpritesL()
sl@0
   191
	{
sl@0
   192
	CTBlankWindow* win=new(ELeave) CTBlankWindow();
sl@0
   193
	CTBlankWindow* win2=new(ELeave) CTBlankWindow();
sl@0
   194
	TSize size(100,120);
sl@0
   195
	win->ConstructL(*TheClient->iGroup);
sl@0
   196
	win2->ConstructL(*win);
sl@0
   197
	win2->SetExt(TPoint(100,100),size);
sl@0
   198
	win2->SetColor(TRgb::Gray4(2));
sl@0
   199
	RWindowBase window=*win->BaseWin();
sl@0
   200
	RWindowBase window2=*win2->BaseWin();
sl@0
   201
	window.Activate();
sl@0
   202
	window2.Activate();
sl@0
   203
	RWsSprite sprite[NUM_SPRITES];
sl@0
   204
	TInt ii;
sl@0
   205
	//TheClient->iWs.SetAutoFlush(ETrue);
sl@0
   206
	for (ii=0;ii<NUM_SPRITES;ii++)
sl@0
   207
		SetUpSpriteL(sprite[ii],TheClient->iWs,window);
sl@0
   208
	sprite[4].Close();
sl@0
   209
	sprite[2].SetPosition(TPoint(20,20));
sl@0
   210
	sprite[0].Close();
sl@0
   211
	win2->SetExt(TPoint(80,100),size);
sl@0
   212
	sprite[6].SetPosition(TPoint(60,120));
sl@0
   213
	sprite[7].Close();
sl@0
   214
	sprite[5].SetPosition(TPoint(100,120));
sl@0
   215
	sprite[3].Close();
sl@0
   216
	SetUpSpriteL(sprite[7],TheClient->iWs,window);
sl@0
   217
	sprite[7].SetPosition(TPoint(80,150));
sl@0
   218
	sprite[1].Close();
sl@0
   219
	win2->SetExt(TPoint(60,110),size);
sl@0
   220
	sprite[5].SetPosition(TPoint(50,40));
sl@0
   221
	sprite[7].Close();
sl@0
   222
	SetUpSpriteL(sprite[0],TheClient->iWs,window);
sl@0
   223
	sprite[0].SetPosition(TPoint(55,65));
sl@0
   224
	sprite[6].Close();
sl@0
   225
	win2->SetExt(TPoint(40,90),size);
sl@0
   226
	sprite[2].SetPosition(TPoint(80,45));
sl@0
   227
	sprite[5].Close();
sl@0
   228
	sprite[0].SetPosition(TPoint(90,60));
sl@0
   229
	sprite[2].Close();
sl@0
   230
	SetUpSpriteL(sprite[2],TheClient->iWs,window);
sl@0
   231
	sprite[2].SetPosition(TPoint(70,80));
sl@0
   232
	sprite[0].Close();
sl@0
   233
	win2->SetExt(TPoint(20,80),size);
sl@0
   234
	sprite[2].SetPosition(TPoint(600,200));
sl@0
   235
	sprite[2].Close();
sl@0
   236
	SetUpSpriteL(sprite[0],TheClient->iWs,window2,ESpriteFlash);
sl@0
   237
	sprite[0].SetPosition(TPoint(0,25));
sl@0
   238
	SetUpSpriteL(sprite[1],TheClient->iWs,window2,ESpriteFlash);
sl@0
   239
	SetUpSpriteL(sprite[2],TheClient->iWs,window2,ESpriteFlash);
sl@0
   240
	sprite[2].SetPosition(TPoint(25,0));
sl@0
   241
	win2->SetExt(TPoint(40,70),size);
sl@0
   242
	CTBlankWindow* win3=new(ELeave) CTBlankWindow();
sl@0
   243
	win3->ConstructL(*TheClient->iGroup);
sl@0
   244
	win3->SetExt(TPoint(30,60),TSize(30,30));
sl@0
   245
	win3->SetColor(TRgb::Gray4(1));
sl@0
   246
	win3->BaseWin()->SetShadowHeight(10);
sl@0
   247
	win3->BaseWin()->Activate();
sl@0
   248
	User::After(1000000);		//1 sec so sprites has time to flash
sl@0
   249
	delete win2;
sl@0
   250
	delete win;
sl@0
   251
	delete win3;
sl@0
   252
	sprite[0].Close();
sl@0
   253
	sprite[1].Close();
sl@0
   254
	sprite[2].Close();
sl@0
   255
	}
sl@0
   256
sl@0
   257
/**
sl@0
   258
@SYMTestCaseID		GRAPHICS-WSERV-0021
sl@0
   259
sl@0
   260
@SYMDEF  			DEF081259
sl@0
   261
sl@0
   262
@SYMTestCaseDesc    General PointerCursor Tests
sl@0
   263
sl@0
   264
@SYMTestPriority    High
sl@0
   265
sl@0
   266
@SYMTestStatus      Implemented
sl@0
   267
sl@0
   268
@SYMTestActions     Exercise the different pointercursor methods of a Window Server Session
sl@0
   269
sl@0
   270
@SYMTestExpectedResults The methods are called without error
sl@0
   271
*/
sl@0
   272
void CTTSprite::GeneralPointerCursor()
sl@0
   273
	{
sl@0
   274
	if (!TestBase()->ConfigurationSupportsPointerEventTesting())
sl@0
   275
	    {
sl@0
   276
	    INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing"));
sl@0
   277
	    return;
sl@0
   278
	    }
sl@0
   279
	TInt currentSMode=TheClient->iScreen->CurrentScreenMode();
sl@0
   280
	TInt altSMode=-1;
sl@0
   281
	if (TheClient->iScreen->NumScreenModes()>1)
sl@0
   282
		altSMode=(currentSMode==1?0:1);
sl@0
   283
	RWsSession &ws=TheClient->iWs;
sl@0
   284
	TRect rect=ws.PointerCursorArea();
sl@0
   285
	TRect testRect1(TPoint(rect.iBr.iX/4,rect.iBr.iY/4),TSize(rect.Width()/2,rect.Height()/2));
sl@0
   286
	TRect testRect2(TPoint(rect.iBr.iX/3,rect.iBr.iY/3),TSize(2*rect.Width()/3,2*rect.Height()/3));
sl@0
   287
	ws.SetPointerCursorArea(testRect1);
sl@0
   288
	TEST(ws.PointerCursorArea()==testRect1);
sl@0
   289
	TEST(ws.PointerCursorArea(currentSMode)==testRect1);
sl@0
   290
	ws.SetPointerCursorArea(currentSMode,testRect2);
sl@0
   291
	TEST(ws.PointerCursorArea()==testRect2);
sl@0
   292
	TEST(ws.PointerCursorArea(currentSMode)==testRect2);
sl@0
   293
	ws.SetPointerCursorArea(rect);
sl@0
   294
	TEST(ws.PointerCursorArea()==rect);
sl@0
   295
	
sl@0
   296
	if (altSMode>=0)
sl@0
   297
		{
sl@0
   298
		rect=ws.PointerCursorArea(altSMode);
sl@0
   299
		testRect1.iTl.iX=rect.iBr.iX/4;
sl@0
   300
		testRect1.iTl.iY=rect.iBr.iY/4;
sl@0
   301
		testRect1.SetWidth(rect.Width()/2);
sl@0
   302
		testRect1.SetHeight(rect.Height()/2);
sl@0
   303
		ws.SetPointerCursorArea(altSMode,testRect1);
sl@0
   304
		TEST(ws.PointerCursorArea(altSMode)==testRect1);
sl@0
   305
		ws.SetPointerCursorArea(altSMode,rect);
sl@0
   306
		TEST(ws.PointerCursorArea(altSMode)==rect);
sl@0
   307
		}
sl@0
   308
	TPointerCursorMode currentMode=ws.PointerCursorMode();
sl@0
   309
	TInt ii;
sl@0
   310
	TInt err1;
sl@0
   311
	for(ii=EPointerCursorFirstMode;ii<=EPointerCursorLastMode;ii++)
sl@0
   312
		{	
sl@0
   313
		ws.SetPointerCursorMode(STATIC_CAST(TPointerCursorMode,ii));
sl@0
   314
		err1 = ws.PointerCursorMode();
sl@0
   315
		TEST(ii==err1);
sl@0
   316
		if (ii!=err1)
sl@0
   317
			INFO_PRINTF3(_L("ws.PointerCursorMode() return value  - Expected: %d, Actual: %d"), ii, err1);		
sl@0
   318
		}
sl@0
   319
	ws.SetPointerCursorMode(currentMode);
sl@0
   320
	TEST(currentMode==ws.PointerCursorMode());
sl@0
   321
	TPoint point1(10,12);
sl@0
   322
	TPoint point2(24,20);
sl@0
   323
	ws.PointerCursorPosition();
sl@0
   324
	ws.SetPointerCursorPosition(point1);
sl@0
   325
	TEST(ws.PointerCursorPosition()==point1);
sl@0
   326
	ws.SetPointerCursorPosition(point2);
sl@0
   327
	TEST(ws.PointerCursorPosition()==point2);
sl@0
   328
	}
sl@0
   329
sl@0
   330
sl@0
   331
/**
sl@0
   332
@SYMTestCaseID      GRAPHICS-WSERV-0498
sl@0
   333
sl@0
   334
@SYMDEF             PDEF137614 - Propagation to TB92
sl@0
   335
sl@0
   336
@SYMTestCaseDesc    Test activating a pointer cursor
sl@0
   337
sl@0
   338
@SYMTestPriority    High
sl@0
   339
sl@0
   340
@SYMTestStatus      Implemented
sl@0
   341
sl@0
   342
@SYMTestActions     Construct and activate a pointer cursor. 
sl@0
   343
                    Check it is visible.
sl@0
   344
                    Deactivate it
sl@0
   345
                    Check it is removed
sl@0
   346
                    
sl@0
   347
sl@0
   348
@SYMTestExpectedResults 
sl@0
   349
                    The pointer cursor bitmp should be visible when activated and removed when deactivated.
sl@0
   350
*/
sl@0
   351
sl@0
   352
void CTTSprite::PointerCursorVisibleL()
sl@0
   353
    {
sl@0
   354
    if (!TestBase()->ConfigurationSupportsPointerEventTesting())
sl@0
   355
        {
sl@0
   356
        INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing"));
sl@0
   357
        return;
sl@0
   358
        }
sl@0
   359
    
sl@0
   360
    // The pointer events need time to have an affect on the wserv
sl@0
   361
    static const TInt eventPropagationDelay = 100 * 1000; // 100 ms
sl@0
   362
    
sl@0
   363
    TInt screenNumber = TheClient->iScreen->GetScreenNumber();
sl@0
   364
    
sl@0
   365
    if(screenNumber != 0) // pointer events only supported on emulator screen 0
sl@0
   366
        {
sl@0
   367
        LOG_MESSAGE(_L("Pointer Cursor Visible only runs on screen 0"));
sl@0
   368
        return;
sl@0
   369
        }
sl@0
   370
    
sl@0
   371
    // set up objects used in test
sl@0
   372
    // 50x50 red rectangle colour 24
sl@0
   373
    CFbsBitmap bitmap;
sl@0
   374
    User::LeaveIfError(bitmap.Load(TEST_BITMAP_NAME, 8));
sl@0
   375
    
sl@0
   376
    TSize bmSize = bitmap.SizeInPixels();
sl@0
   377
    TPoint bmSample = TPoint(bmSize.iWidth / 2, bmSize.iHeight / 2);
sl@0
   378
    TRgb bmColour;
sl@0
   379
    bitmap.GetPixel(bmColour, bmSample);
sl@0
   380
    TEST(bmColour == KRgbRed);
sl@0
   381
sl@0
   382
    // single window, size of screen
sl@0
   383
    RWindow win(TheClient->iWs);
sl@0
   384
    User::LeaveIfError(win.Construct(*TheClient->iGroup->GroupWin(),1));
sl@0
   385
    win.Activate();
sl@0
   386
sl@0
   387
    // setup cursor mode
sl@0
   388
    TheClient->iWs.SetPointerCursorMode(EPointerCursorWindow);
sl@0
   389
    
sl@0
   390
    // setup cursor to contain single 50x50 red bitmap
sl@0
   391
    RWsPointerCursor iCursor1 = RWsPointerCursor(TheClient->iWs);
sl@0
   392
    TSpriteMember member;
sl@0
   393
    SetUpMember(member);
sl@0
   394
    member.iBitmap=&bitmap;
sl@0
   395
    User::LeaveIfError(iCursor1.Construct(0));
sl@0
   396
    User::LeaveIfError(iCursor1.AppendMember(member));
sl@0
   397
    User::LeaveIfError(iCursor1.Activate());
sl@0
   398
    win.SetCustomPointerCursor(iCursor1);
sl@0
   399
    iCursor1.UpdateMember(0);
sl@0
   400
sl@0
   401
    // draw a green rect, size of screen as defined background and wait till it is rendered
sl@0
   402
    win.BeginRedraw();
sl@0
   403
    TheGc->Activate(win);
sl@0
   404
    TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
   405
    TheGc->SetBrushColor(KRgbGreen);
sl@0
   406
    TSize wSize = win.Size();
sl@0
   407
    TheGc->DrawRect(TRect(TPoint(0,0), wSize));
sl@0
   408
    TheGc->Deactivate();
sl@0
   409
    win.EndRedraw();
sl@0
   410
    TheClient->iWs.Finish();
sl@0
   411
    
sl@0
   412
    // #### do test ####
sl@0
   413
    // define locations of simulated pointer events and sample positions of where we expect to see the cursor
sl@0
   414
    // The cursor will be moved and a check will be made to see if this has actually happened
sl@0
   415
    
sl@0
   416
    TPoint pos1(wSize.iWidth / 2, wSize.iHeight / 2); // top left of cursor at centre screen
sl@0
   417
    TPoint sample1(pos1 + bmSample); // centre of sprite at pos1
sl@0
   418
    TPoint pos2 = pos1 - bmSize; // bottom right of cursor at centre screen
sl@0
   419
    TPoint sample2 = pos2 + bmSample;  // centre of sprite at pos2
sl@0
   420
sl@0
   421
    TRgb pixel;
sl@0
   422
    
sl@0
   423
    // check initial state of screen at both sample positions
sl@0
   424
    TheClient->iScreen->GetPixel(pixel, sample1);
sl@0
   425
    TEST(pixel == KRgbGreen);
sl@0
   426
sl@0
   427
    TheClient->iScreen->GetPixel(pixel, sample2);
sl@0
   428
    TEST(pixel == KRgbGreen);
sl@0
   429
    
sl@0
   430
    TRawEvent e; // to simulate pointer events
sl@0
   431
sl@0
   432
    // simulate button 1 down event at pos1
sl@0
   433
    e.Set(TRawEvent::EButton1Down, pos1.iX, pos1.iY);
sl@0
   434
    e.SetDeviceNumber(screenNumber);
sl@0
   435
    UserSvr::AddEvent(e);
sl@0
   436
sl@0
   437
    User::After(eventPropagationDelay);
sl@0
   438
    
sl@0
   439
    // check red cursor visible on top of background
sl@0
   440
    TheClient->iScreen->GetPixel(pixel, sample1);
sl@0
   441
    TEST(pixel == KRgbRed);
sl@0
   442
    
sl@0
   443
    // simulate button 1 up event
sl@0
   444
    e.Set(TRawEvent::EButton1Up, pos1.iX, pos1.iY);
sl@0
   445
    UserSvr::AddEvent(e);
sl@0
   446
    User::After(eventPropagationDelay);
sl@0
   447
    
sl@0
   448
    // Move cursor away to pos2 
sl@0
   449
    e.Set(TRawEvent::EButton1Down, pos2.iX, pos2.iY);
sl@0
   450
    e.SetDeviceNumber(screenNumber);
sl@0
   451
    UserSvr::AddEvent(e);
sl@0
   452
    
sl@0
   453
    User::After(eventPropagationDelay);
sl@0
   454
    
sl@0
   455
    // check cursor has left this position ...
sl@0
   456
    TheClient->iScreen->GetPixel(pixel, sample1);
sl@0
   457
    TEST(pixel == KRgbGreen);
sl@0
   458
    // and arrived at the correct place
sl@0
   459
    TheClient->iScreen->GetPixel(pixel, sample2);
sl@0
   460
    TEST(pixel == KRgbRed);
sl@0
   461
sl@0
   462
    // simulate button 1 up event
sl@0
   463
    e.Set(TRawEvent::EButton1Up, pos2.iX, pos2.iY);
sl@0
   464
    UserSvr::AddEvent(e);
sl@0
   465
    User::After(eventPropagationDelay);
sl@0
   466
    
sl@0
   467
    // remove the cursor
sl@0
   468
    win.ClearPointerCursor();
sl@0
   469
    User::After(eventPropagationDelay);
sl@0
   470
    
sl@0
   471
    // check it has gone
sl@0
   472
    TheClient->iScreen->GetPixel(pixel, sample2);
sl@0
   473
    TEST(pixel == KRgbGreen);
sl@0
   474
    
sl@0
   475
    // #### clean up ####
sl@0
   476
    iCursor1.Close();
sl@0
   477
    win.Close();
sl@0
   478
    }
sl@0
   479
sl@0
   480
sl@0
   481
/**
sl@0
   482
	@SYMTestCaseID GRAPHICS-CODEBASE-WSERV-0053-0001
sl@0
   483
  
sl@0
   484
	@SYMPREQ PGM027
sl@0
   485
  
sl@0
   486
	@SYMTestCaseDesc Tests RWsPointerCursor::UpdateMember APIs. 
sl@0
   487
   
sl@0
   488
	@SYMTestPriority 1 
sl@0
   489
  
sl@0
   490
	@SYMTestStatus Implemented
sl@0
   491
   
sl@0
   492
	@SYMTestActions This test calls RWsPointerCursor::UpdateMember
sl@0
   493
		
sl@0
   494
	@SYMTestExpectedResults Should run properly with out any Panics.
sl@0
   495
sl@0
   496
  */
sl@0
   497
void CTTSprite::SpriteUpdateMemberTestsL()
sl@0
   498
	{
sl@0
   499
	RWsPointerCursor iCursor1;
sl@0
   500
	
sl@0
   501
	CFbsBitmap bitmap;
sl@0
   502
	bitmap.Load(TEST_BITMAP_NAME,0);
sl@0
   503
		
sl@0
   504
	RWindow win(TheClient->iWs);
sl@0
   505
	win.Construct(*TheClient->iGroup->GroupWin(),1);
sl@0
   506
	win.Activate();
sl@0
   507
sl@0
   508
	iCursor1=RWsPointerCursor(TheClient->iWs);
sl@0
   509
	TSpriteMember member;
sl@0
   510
	SetUpMember(member);
sl@0
   511
	member.iBitmap=&bitmap;
sl@0
   512
	User::LeaveIfError(iCursor1.Construct(0));
sl@0
   513
	User::LeaveIfError(iCursor1.AppendMember(member));
sl@0
   514
	User::LeaveIfError(iCursor1.Activate());
sl@0
   515
	win.SetCustomPointerCursor(iCursor1);
sl@0
   516
	iCursor1.UpdateMember(0);
sl@0
   517
	
sl@0
   518
	RWsPointerCursor iCursor2;
sl@0
   519
	bitmap.Load(TEST_NEW_BITMAP_NAME,0);
sl@0
   520
	iCursor2=RWsPointerCursor(TheClient->iWs);
sl@0
   521
	User::LeaveIfError(iCursor2.Construct(0));
sl@0
   522
	User::LeaveIfError(iCursor2.AppendMember(member));
sl@0
   523
	User::LeaveIfError(iCursor2.Activate());
sl@0
   524
	win.SetCustomPointerCursor(iCursor2);
sl@0
   525
	iCursor2.UpdateMember(1);
sl@0
   526
	
sl@0
   527
	iCursor1.Close();
sl@0
   528
	iCursor2.Close();
sl@0
   529
	win.Close();
sl@0
   530
	}
sl@0
   531
sl@0
   532
/**
sl@0
   533
	@SYMTestCaseID GRAPHICS-CODEBASE-WSERV-0054-0001
sl@0
   534
  
sl@0
   535
	@SYMPREQ PGM027
sl@0
   536
  
sl@0
   537
	@SYMTestCaseDesc Negative Tests RWsSpriteBase::UpdateMember API. 
sl@0
   538
   
sl@0
   539
	@SYMTestPriority 1 
sl@0
   540
  
sl@0
   541
	@SYMTestStatus Implemented
sl@0
   542
   
sl@0
   543
	@SYMTestActions This test calls RWsPointerCursor::UpdateMember
sl@0
   544
		
sl@0
   545
	@SYMTestExpectedResults Should run properly with out any Panics.
sl@0
   546
sl@0
   547
 */
sl@0
   548
void CTTSprite::SpriteUpdateMemberNegTestsL()
sl@0
   549
	{
sl@0
   550
	RWsPointerCursor iCursor1;
sl@0
   551
	
sl@0
   552
	CFbsBitmap bitmap;
sl@0
   553
	bitmap.Load(TEST_BITMAP_NAME,0);
sl@0
   554
		
sl@0
   555
	RWindow win(TheClient->iWs);
sl@0
   556
	win.Construct(*TheClient->iGroup->GroupWin(),1);
sl@0
   557
	win.Activate();
sl@0
   558
sl@0
   559
	iCursor1=RWsPointerCursor(TheClient->iWs);
sl@0
   560
	TSpriteMember member;
sl@0
   561
	SetUpMember(member);
sl@0
   562
	member.iBitmap=&bitmap;
sl@0
   563
	User::LeaveIfError(iCursor1.Construct(0));
sl@0
   564
	User::LeaveIfError(iCursor1.AppendMember(member));
sl@0
   565
	User::LeaveIfError(iCursor1.Activate());
sl@0
   566
	win.SetCustomPointerCursor(iCursor1);
sl@0
   567
	iCursor1.UpdateMember(-100);
sl@0
   568
	
sl@0
   569
	RWsPointerCursor iCursor2;
sl@0
   570
	bitmap.Load(TEST_NEW_BITMAP_NAME,0);
sl@0
   571
	iCursor2=RWsPointerCursor(TheClient->iWs);
sl@0
   572
	User::LeaveIfError(iCursor2.Construct(0));
sl@0
   573
	User::LeaveIfError(iCursor2.AppendMember(member));
sl@0
   574
	User::LeaveIfError(iCursor2.Activate());
sl@0
   575
	win.SetCustomPointerCursor(iCursor2);
sl@0
   576
	iCursor2.UpdateMember(10000);
sl@0
   577
	
sl@0
   578
	iCursor1.Close();
sl@0
   579
	iCursor2.Close();
sl@0
   580
	win.Close();
sl@0
   581
	}
sl@0
   582
sl@0
   583
/**
sl@0
   584
	@SYMTestCaseID GRAPHICS-CODEBASE-WSERV-0055-0001
sl@0
   585
  
sl@0
   586
	@SYMPREQ PGM027
sl@0
   587
  
sl@0
   588
	@SYMTestCaseDesc Tests FindWindowGroupIdentifier API. 
sl@0
   589
   
sl@0
   590
	@SYMTestPriority 1 
sl@0
   591
  
sl@0
   592
	@SYMTestStatus Implemented
sl@0
   593
   
sl@0
   594
	@SYMTestActions Create windows session and call FindWindowGroupIdentifier \n
sl@0
   595
	with different thread Id's both with valid thread ids and in valid thread id's.
sl@0
   596
	
sl@0
   597
	@SYMTestExpectedResults Should run properly.
sl@0
   598
sl@0
   599
 */	
sl@0
   600
void CTTSprite::FindWindowGroupThreadTestsL()	
sl@0
   601
	{
sl@0
   602
	RThread proc;
sl@0
   603
	TInt ident;
sl@0
   604
	TUint64 id=proc.Id();
sl@0
   605
	RWsSession ws1;
sl@0
   606
	User::LeaveIfError(ws1.Connect());
sl@0
   607
	CleanupClosePushL(ws1);
sl@0
   608
	//Positive test for FindWindowGroupIdentifier
sl@0
   609
	ident=ws1.FindWindowGroupIdentifier(0,id);
sl@0
   610
	TEST(ws1.SetWindowGroupOrdinalPosition(ident,0)==KErrNone);
sl@0
   611
	TEST(ws1.SetWindowGroupOrdinalPosition(ident,1)==KErrNone);
sl@0
   612
	//Negative test for FindWindowGroupIdentifier
sl@0
   613
    TInt ret=ws1.FindWindowGroupIdentifier(0,id+200);
sl@0
   614
	TEST(ret==KErrNotFound);
sl@0
   615
	#if defined __WINS__ || defined __WINSCW__
sl@0
   616
	ret=ws1.FindWindowGroupIdentifier(0,-200);
sl@0
   617
	TEST(ret==KErrNotFound);
sl@0
   618
	#endif//defined __WINS__ || defined __WINSCW__
sl@0
   619
	CleanupStack::PopAndDestroy(1, &ws1);
sl@0
   620
	ws1.Close();
sl@0
   621
	}	
sl@0
   622
sl@0
   623
/**
sl@0
   624
@SYMTestCaseID		GRAPHICS-WSERV-0462
sl@0
   625
sl@0
   626
@SYMDEF  			PDEF114190
sl@0
   627
sl@0
   628
@SYMTestCaseDesc    Test sprite list cleanup when a window is deleted in low memory conditions
sl@0
   629
sl@0
   630
@SYMTestPriority    High
sl@0
   631
sl@0
   632
@SYMTestStatus      Implemented
sl@0
   633
sl@0
   634
@SYMTestActions     Have a loop which increases the number of allocations in the server thread before failure;
sl@0
   635
					Within the loop:
sl@0
   636
					1) Create a parent window and a child window of the parent;
sl@0
   637
					2) Create a sprite on the child window; 
sl@0
   638
					3) Delete the parent window only, but not the child window; 
sl@0
   639
					4) Create a testWindow and do redraw on this window; 
sl@0
   640
					5) Do redraw on the testWindow. This testWindow's redraw will force checking the sprite list. 
sl@0
   641
					This would panic the client thread due to this defect because the sprite on the orphaned 
sl@0
   642
					window (which is the previous child window) is still in the sprite list;
sl@0
   643
					6) Delete all the windows involved.
sl@0
   644
sl@0
   645
@SYMTestExpectedResults The sprite should be disabled when a window is deleted;
sl@0
   646
						The client thread should not be panic'd.
sl@0
   647
						The test should pass.
sl@0
   648
*/
sl@0
   649
void CTTSprite::SpriteOnWindowOrphanedTestsL()
sl@0
   650
	{
sl@0
   651
	TInt handles = 344;
sl@0
   652
	TInt loop = 0;
sl@0
   653
	TInt allocFailRate = 0;
sl@0
   654
	TInt err = KErrNone;
sl@0
   655
sl@0
   656
	CFbsBitmap* bitmap = new(ELeave) CFbsBitmap;
sl@0
   657
	CleanupStack::PushL(bitmap);
sl@0
   658
	User::LeaveIfError(bitmap->Create(TSize(500, 500), EColor16MU));
sl@0
   659
	TSpriteMember spritemember;
sl@0
   660
	spritemember.iBitmap = bitmap;
sl@0
   661
	spritemember.iMaskBitmap = NULL;	
sl@0
   662
	
sl@0
   663
	RWindowGroup group(TheClient->iWs);
sl@0
   664
	RWindow parent1(TheClient->iWs);
sl@0
   665
	RWindow child1(TheClient->iWs);
sl@0
   666
	RWindow testWindow(TheClient->iWs);
sl@0
   667
	RWsSprite sprite(TheClient->iWs);
sl@0
   668
	
sl@0
   669
	while (loop < 5)
sl@0
   670
		{
sl@0
   671
		TRect mainRect(TPoint(0,0), TSize(500,500));
sl@0
   672
		err = group.Construct(++handles, EFalse);	
sl@0
   673
		if (err == KErrNone)
sl@0
   674
			{
sl@0
   675
			TheClient->iWs.HeapSetFail(RHeap::EDeterministic, allocFailRate);
sl@0
   676
sl@0
   677
			//Create parent 1
sl@0
   678
			err = parent1.Construct(group,++handles);
sl@0
   679
			if (err == KErrNone)
sl@0
   680
				{
sl@0
   681
				parent1.SetExtent(mainRect.iTl, mainRect.Size());
sl@0
   682
				parent1.EnableRedrawStore(ETrue);
sl@0
   683
				parent1.Activate();
sl@0
   684
				}			
sl@0
   685
			}
sl@0
   686
		
sl@0
   687
		//Create child 1
sl@0
   688
		if (err == KErrNone)
sl@0
   689
			{
sl@0
   690
			TRect childRect(TPoint (10, 10), TSize (200, 150));
sl@0
   691
			err = child1.Construct(parent1,++handles);
sl@0
   692
			if (err == KErrNone)
sl@0
   693
				{
sl@0
   694
				child1.SetExtent(childRect.iTl, childRect.Size());
sl@0
   695
				child1.SetBackgroundColor(TRgb(128,100,255,20));
sl@0
   696
				child1.Activate();
sl@0
   697
				}
sl@0
   698
			}
sl@0
   699
		
sl@0
   700
		//Add sprite to child 1
sl@0
   701
		if (err == KErrNone) 
sl@0
   702
			{
sl@0
   703
			err = sprite.Construct(child1,TPoint(10,10), 0);
sl@0
   704
			if (err == KErrNone)
sl@0
   705
				{
sl@0
   706
				err = sprite.AppendMember(spritemember);
sl@0
   707
				if (err == KErrNone)
sl@0
   708
					err = sprite.Activate();	
sl@0
   709
				}
sl@0
   710
			}
sl@0
   711
sl@0
   712
		//Only delete parent 1, but not child 1	
sl@0
   713
		parent1.Close();		
sl@0
   714
sl@0
   715
		if (err == KErrNone) 
sl@0
   716
			{
sl@0
   717
			TRect testRect(TPoint(10, 30), TSize(200, 150));
sl@0
   718
			//Create testWindow
sl@0
   719
			err = testWindow.Construct(group,++handles);
sl@0
   720
			if (err == KErrNone)
sl@0
   721
				{
sl@0
   722
				testWindow.SetExtent(testRect.iTl, testRect.Size());
sl@0
   723
				testWindow.SetBackgroundColor(TRgb(128,100,255,20));
sl@0
   724
				testWindow.EnableRedrawStore(ETrue);
sl@0
   725
				testWindow.Activate();
sl@0
   726
				testWindow.BeginRedraw();
sl@0
   727
				testWindow.EndRedraw();	
sl@0
   728
				TheClient->Flush();			
sl@0
   729
				}
sl@0
   730
			}
sl@0
   731
		TheClient->iWs.HeapSetFail(RAllocator::ENone, 0);
sl@0
   732
sl@0
   733
		sprite.Close();
sl@0
   734
		child1.Close();
sl@0
   735
		testWindow.Close();
sl@0
   736
		group.Close();		
sl@0
   737
		++allocFailRate;
sl@0
   738
		loop = (err == KErrNone) ? loop + 1 : 0;
sl@0
   739
		}
sl@0
   740
	CleanupStack::PopAndDestroy(bitmap);
sl@0
   741
	}
sl@0
   742
void CTTSprite::ResizeMemberL()
sl@0
   743
	{
sl@0
   744
#ifndef __WINS__
sl@0
   745
	CTBlankWindow* win=new(ELeave) CTBlankWindow();
sl@0
   746
	CleanupStack::PushL(win);
sl@0
   747
	win->ConstructL(*TheClient->iGroup);
sl@0
   748
	win->SetExt(TPoint(),TSize(640,240));
sl@0
   749
	RWindowBase& window=*win->BaseWin();
sl@0
   750
	window.Activate();
sl@0
   751
	RWsSprite sprite(TheClient->iWs);
sl@0
   752
	CleanupClosePushL(sprite);
sl@0
   753
	User::LeaveIfError(sprite.Construct(window,TPoint(),0));
sl@0
   754
	TSpriteMember member;
sl@0
   755
	member.iMaskBitmap=NULL;
sl@0
   756
	member.iInvertMask=EFalse;
sl@0
   757
	member.iDrawMode=CGraphicsContext::EDrawModePEN;
sl@0
   758
	member.iOffset=TPoint();
sl@0
   759
	member.iInterval=TTimeIntervalMicroSeconds32(250000);
sl@0
   760
	member.iBitmap=&iBitmap;
sl@0
   761
	User::LeaveIfError(sprite.AppendMember(member));
sl@0
   762
	User::LeaveIfError(sprite.AppendMember(member));
sl@0
   763
	User::LeaveIfError(sprite.Activate());
sl@0
   764
	User::After(1000000); // // Interval is 1 sec.
sl@0
   765
	User::LeaveIfError(iBitmap.Resize(iBitmap.SizeInPixels() + TSize(100,100)));
sl@0
   766
	User::After(1000000);  // Interval is 1 sec.
sl@0
   767
	CleanupStack::PopAndDestroy(&sprite);
sl@0
   768
	CleanupStack::PopAndDestroy(win);
sl@0
   769
#endif // __WINS__
sl@0
   770
	}
sl@0
   771
sl@0
   772
sl@0
   773
void CTTSprite::SetUpSpriteL(RWsSprite &aSprite, RWindowTreeNode &aWindow,TPoint aPoint, TSpriteMember aMember, TInt aFlags/*=0*/)
sl@0
   774
	{
sl@0
   775
	User::LeaveIfError(aSprite.Construct(aWindow,aPoint,aFlags));
sl@0
   776
	User::LeaveIfError(aSprite.AppendMember(aMember));
sl@0
   777
	User::LeaveIfError(aSprite.Activate());
sl@0
   778
	}
sl@0
   779
/**
sl@0
   780
@SYMTestCaseID		GRAPHICS-WSERV-00-0001
sl@0
   781
sl@0
   782
@SYMDEF  			PDEF117721
sl@0
   783
sl@0
   784
@SYMTestCaseDesc    Test Screenrotation does not cause panic by sprite with NULL bitmap and NULL maskbitmap
sl@0
   785
sl@0
   786
@SYMTestPriority    High
sl@0
   787
sl@0
   788
@SYMTestStatus      Implemented
sl@0
   789
sl@0
   790
@SYMTestActions     Defines two sprites and one with Null iBitmap and Null iMaskBitmap, then rotate the screen to 90 degrees
sl@0
   791
sl@0
   792
@SYMTestExpectedResults the screen rotation will not cause wserv a panic
sl@0
   793
*/
sl@0
   794
void CTTSprite::RotateNullSpriteL()
sl@0
   795
	{
sl@0
   796
	if (TheClient->iScreen->NumScreenModes() < 2)
sl@0
   797
		{
sl@0
   798
		LOG_MESSAGE(_L("WARNING: Unable to rotate screen"));
sl@0
   799
		return;
sl@0
   800
		}
sl@0
   801
// Sprite Members		
sl@0
   802
	TSpriteMember spriteMember1,spriteMember2;
sl@0
   803
	SetUpMember(spriteMember1);
sl@0
   804
	SetUpMember(spriteMember2);
sl@0
   805
	spriteMember2.iBitmap = NULL;
sl@0
   806
	
sl@0
   807
// Create windows
sl@0
   808
	RWindowGroup group(TheClient->iWs);
sl@0
   809
	User::LeaveIfError(group.Construct(ENullWsHandle,EFalse));	//Creates a Group Window
sl@0
   810
	CleanupClosePushL(group);
sl@0
   811
	RBlankWindow win(TheClient->iWs);
sl@0
   812
	User::LeaveIfError(win.Construct(group,ENullWsHandle));	//Creates a Blank Window
sl@0
   813
	CleanupClosePushL(win);
sl@0
   814
	win.SetVisible(ETrue);
sl@0
   815
	win.SetColor(TRgb::Gray4(2));
sl@0
   816
	win.Activate();
sl@0
   817
	TheClient->Flush();
sl@0
   818
	
sl@0
   819
// Create Sprites
sl@0
   820
	RWsSprite sprite1(TheClient->iWs);
sl@0
   821
	CleanupClosePushL(sprite1);
sl@0
   822
	SetUpSpriteL(sprite1, win,TPoint(20,70),spriteMember1,0);
sl@0
   823
	RWsSprite sprite2(TheClient->iWs);
sl@0
   824
	CleanupClosePushL(sprite2);
sl@0
   825
	SetUpSpriteL(sprite2, win,TPoint(80,130),spriteMember2,0);
sl@0
   826
	RWsSprite sprite3(TheClient->iWs);
sl@0
   827
	CleanupClosePushL(sprite3);
sl@0
   828
	SetUpSpriteL(sprite3, win,TPoint(2800,2130),spriteMember1,0);
sl@0
   829
	TheClient->Flush();
sl@0
   830
sl@0
   831
// Get the original screen mode	
sl@0
   832
	CWsScreenDevice* device = TheClient->iScreen;
sl@0
   833
	TInt originalScreenMode = device->CurrentScreenMode();
sl@0
   834
	TPixelsTwipsAndRotation originalModeSettings;
sl@0
   835
	device->GetScreenModeSizeAndRotation(originalScreenMode,originalModeSettings);
sl@0
   836
sl@0
   837
// Rotate screens	
sl@0
   838
	TPixelsAndRotation pixelsAndRotation;
sl@0
   839
	device->SetScreenMode( 1 );
sl@0
   840
	device->GetDefaultScreenSizeAndRotation(pixelsAndRotation);
sl@0
   841
	device->SetCurrentRotations(1,pixelsAndRotation.iRotation);
sl@0
   842
	device->SetScreenSizeAndRotation(pixelsAndRotation);
sl@0
   843
	User::After(1000000);
sl@0
   844
	
sl@0
   845
	CleanupStack::PopAndDestroy(5,&group);
sl@0
   846
//	Restore the original screen mode	
sl@0
   847
	device->SetScreenMode(originalScreenMode);
sl@0
   848
	device->SetCurrentRotations(originalScreenMode,originalModeSettings.iRotation);
sl@0
   849
	device->SetScreenSizeAndRotation(originalModeSettings);
sl@0
   850
	TheClient->Flush();
sl@0
   851
	}
sl@0
   852
sl@0
   853
/**
sl@0
   854
@SYMTestCaseID		GRAPHICS-WSERV-GCE-0700
sl@0
   855
sl@0
   856
@SYMDEF  			DEF123129
sl@0
   857
sl@0
   858
@SYMTestCaseDesc    Test activating a sprite twice does not cause the system to hang
sl@0
   859
sl@0
   860
@SYMTestPriority    High
sl@0
   861
sl@0
   862
@SYMTestStatus      Implemented
sl@0
   863
sl@0
   864
@SYMTestActions     Construct a sprite and add a member to it. Activate twice.
sl@0
   865
sl@0
   866
@SYMTestExpectedResults The test should terminate smoothly and it should not hang the system.
sl@0
   867
*/
sl@0
   868
void CTTSprite::DoubleActivateL()
sl@0
   869
	{
sl@0
   870
	RWsSession ws;
sl@0
   871
	User::LeaveIfError(ws.Connect());
sl@0
   872
	CleanupClosePushL(ws);
sl@0
   873
	
sl@0
   874
	RWindowGroup group(ws);
sl@0
   875
	User::LeaveIfError(group.Construct(890, EFalse));
sl@0
   876
	CleanupClosePushL(group);
sl@0
   877
	
sl@0
   878
	RWsSprite sprite = RWsSprite(ws);
sl@0
   879
	User::LeaveIfError(sprite.Construct(group,TPoint(),0));
sl@0
   880
	CleanupClosePushL(sprite);
sl@0
   881
	CFbsBitmap* bitmap=new(ELeave) CFbsBitmap;
sl@0
   882
	CleanupStack::PushL(bitmap);
sl@0
   883
	User::LeaveIfError(bitmap->Create(TSize(10,12),EColor256));
sl@0
   884
	TSpriteMember member;
sl@0
   885
	member.iMaskBitmap=NULL;
sl@0
   886
	member.iInvertMask=EFalse;
sl@0
   887
	member.iDrawMode=CGraphicsContext::EDrawModePEN;
sl@0
   888
	member.iOffset=TPoint();
sl@0
   889
	member.iInterval=TTimeIntervalMicroSeconds32(0);
sl@0
   890
	member.iBitmap=bitmap;
sl@0
   891
	User::LeaveIfError(sprite.AppendMember(member));
sl@0
   892
	User::LeaveIfError(sprite.Activate());
sl@0
   893
	User::LeaveIfError(sprite.Activate());
sl@0
   894
	
sl@0
   895
	sprite.Close();
sl@0
   896
	CleanupStack::PopAndDestroy(4, &ws);
sl@0
   897
	
sl@0
   898
	group.Close();
sl@0
   899
	ws.Close();
sl@0
   900
	}
sl@0
   901
sl@0
   902
void CTTSprite::RunTestCaseL(TInt /*aCurTestCase*/)
sl@0
   903
	{	
sl@0
   904
	_LIT(KTest1, "General Tests");
sl@0
   905
	_LIT(KTest2, "Group Window Sprites Tests");
sl@0
   906
	_LIT(KTest3, "Lots Sprites Tests");
sl@0
   907
	_LIT(KTest4, "General Pointer Cursor Tests");
sl@0
   908
    _LIT(KTest5, "Pointer Cursor Visible Tests");
sl@0
   909
    _LIT(KTest6, "Update member tests");
sl@0
   910
    _LIT(KTest7, "Negative tests for Update member");
sl@0
   911
    _LIT(KTest8, "Window Group with Thread");
sl@0
   912
    _LIT(KTest9, "Resize Sprite Member Tests");
sl@0
   913
    _LIT(KTest10, "Rotate a NULL sprite");
sl@0
   914
    _LIT(KTest11, "Sprite On Window Orphaned Tests");
sl@0
   915
    _LIT(KTest12, "Sprite Double Activation Test");
sl@0
   916
	
sl@0
   917
	((CTTSpriteStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
sl@0
   918
	switch(++iTest->iState)
sl@0
   919
		{
sl@0
   920
	case 1:		
sl@0
   921
		((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0018"));
sl@0
   922
		TheClient->iWs.SetFocusScreen(0);
sl@0
   923
		iTest->LogSubTest(KTest1);
sl@0
   924
		GeneralTestsL();
sl@0
   925
		break;
sl@0
   926
	case 2:
sl@0
   927
		((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0019"));
sl@0
   928
		iTest->LogSubTest(KTest2);
sl@0
   929
		GroupWindowSpritesL();
sl@0
   930
		break;
sl@0
   931
	case 3:
sl@0
   932
		((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0020"));
sl@0
   933
		iTest->LogSubTest(KTest3);
sl@0
   934
		LotsSpritesL();
sl@0
   935
		break;
sl@0
   936
	case 4:
sl@0
   937
		((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0021"));
sl@0
   938
		iTest->LogSubTest(KTest4);
sl@0
   939
		GeneralPointerCursor();
sl@0
   940
		break;
sl@0
   941
    case 5:
sl@0
   942
        ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0498"));
sl@0
   943
        iTest->LogSubTest(KTest5);
sl@0
   944
        TRAPD(err, PointerCursorVisibleL());
sl@0
   945
        TEST(err == KErrNone);
sl@0
   946
        break;
sl@0
   947
	case 6:
sl@0
   948
		((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-CODEBASE-WSERV-0053-0001"));
sl@0
   949
		iTest->LogSubTest(KTest6);
sl@0
   950
		TRAP(err, SpriteUpdateMemberTestsL());
sl@0
   951
		TEST(err == KErrNone);
sl@0
   952
		break;
sl@0
   953
	case 7:
sl@0
   954
		((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-CODEBASE-WSERV-0054-0001"));
sl@0
   955
		iTest->LogSubTest(KTest7);
sl@0
   956
		TRAP(err, SpriteUpdateMemberNegTestsL());
sl@0
   957
		TEST(err == KErrNone);
sl@0
   958
		break;
sl@0
   959
	case 8:
sl@0
   960
		((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-CODEBASE-WSERV-0055-0001"));
sl@0
   961
		iTest->LogSubTest(KTest8);
sl@0
   962
		TRAP(err, FindWindowGroupThreadTestsL());
sl@0
   963
		TEST(err == KErrNone);
sl@0
   964
		break;
sl@0
   965
	case 9:
sl@0
   966
		((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0526"));
sl@0
   967
		iTest->LogSubTest(KTest9);
sl@0
   968
		ResizeMemberL();
sl@0
   969
		break;
sl@0
   970
	case 10:
sl@0
   971
		((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-00-0001"));
sl@0
   972
		iTest->LogSubTest(KTest10);
sl@0
   973
		RotateNullSpriteL();
sl@0
   974
		break;
sl@0
   975
	case 11:
sl@0
   976
		((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0462"));
sl@0
   977
		iTest->LogSubTest(KTest11);
sl@0
   978
		SpriteOnWindowOrphanedTestsL();
sl@0
   979
		break;
sl@0
   980
	case 12:
sl@0
   981
		((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-GCE-0700"));
sl@0
   982
		iTest->LogSubTest(KTest12);
sl@0
   983
		DoubleActivateL();
sl@0
   984
		break;
sl@0
   985
	default:
sl@0
   986
		((CTTSpriteStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
sl@0
   987
		((CTTSpriteStep*)iStep)->CloseTMSGraphicsStep();
sl@0
   988
		TestComplete();
sl@0
   989
		break;
sl@0
   990
		}
sl@0
   991
	((CTTSpriteStep*)iStep)->RecordTestResultL();
sl@0
   992
	}
sl@0
   993
sl@0
   994
//--------------
sl@0
   995
__WS_CONSTRUCT_STEP__(TSprite)
sl@0
   996