First public contribution.
1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 @internalComponent - Internal Symbian test code
24 CTTSprite::CTTSprite(CTestStep* aStep):
25 CTWsGraphicsBase(aStep)
27 INFO_PRINTF1(_L("Testing TSprite functions"));
30 void CTTSprite::SetUpMember(TSpriteMember &aMember)
32 aMember.iMaskBitmap=NULL;
33 aMember.iInvertMask=EFalse;
34 aMember.iDrawMode=CGraphicsContext::EDrawModePEN;
35 aMember.iOffset=TPoint();
36 aMember.iInterval=TTimeIntervalMicroSeconds32(0);
37 aMember.iBitmap=&iBitmap;
40 void CTTSprite::SetUpPointerCursorL(RWsPointerCursor &aCursor, RWsSession &aSession)
42 aCursor=RWsPointerCursor(aSession);
45 User::LeaveIfError(aCursor.Construct(0));
46 User::LeaveIfError(aCursor.AppendMember(member));
47 User::LeaveIfError(aCursor.Activate());
50 void CTTSprite::SetUpSpriteL(RWsSprite &aSprite, RWsSession &aSession, RWindowTreeNode &aWindow,TInt aFlags/*=0*/)
52 aSprite=RWsSprite(aSession);
53 User::LeaveIfError(aSprite.Construct(aWindow,TPoint(),aFlags));
56 User::LeaveIfError(aSprite.AppendMember(member));
57 User::LeaveIfError(aSprite.Activate());
60 void CTTSprite::ConstructL()
62 User::LeaveIfError(iBitmap.Load(TEST_BITMAP_NAME,0));
65 CTTSprite::~CTTSprite()
70 @SYMTestCaseID GRAPHICS-WSERV-0018
74 @SYMTestCaseDesc General cursor tests involving a sprite
78 @SYMTestStatus Implemented
80 @SYMTestActions Carries out cursor and window tests before updating
81 a cursor's member with a sprite
83 @SYMTestExpectedResults When the cursor member is update returns KErrArgument
86 void CTTSprite::GeneralTestsL()
89 // Close cursor while still active on a window
92 RWindow win(TheClient->iWs);
93 win.Construct(*TheClient->iGroup->GroupWin(),1);
95 SetUpPointerCursorL(iCursor1,TheClient->iWs);
96 win.SetCustomPointerCursor(iCursor1);
99 // Close window while cursor active on it
101 SetUpPointerCursorL(iCursor1,TheClient->iWs);
102 win.SetCustomPointerCursor(iCursor1);
107 // Close session with:
108 // An open cursor active on a window & A closed cursor active on another window
111 User::LeaveIfError(ws.Connect());
112 // use correct screen
114 ws.SetFocusScreen(iTest->iScreenNumber);
115 CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
116 CleanupStack::PushL(screen);
117 User::LeaveIfError(screen->Construct(0));
119 RWindowGroup group(ws);
120 User::LeaveIfError(group.Construct(123));
121 group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close
123 User::LeaveIfError(win2.Construct(group, 1));
126 User::LeaveIfError(win3.Construct(group, 2));
129 SetUpPointerCursorL(iCursor1,ws);
130 SetUpPointerCursorL(iCursor2,ws);
131 win2.SetCustomPointerCursor(iCursor1);
132 win3.SetCustomPointerCursor(iCursor2);
134 TSpriteMember member;
135 member.iBitmap=member.iMaskBitmap=NULL;
136 TInt err = iCursor1.UpdateMember(9999,member);
137 TEST(err==KErrArgument);
138 if (err!=KErrArgument)
139 INFO_PRINTF3(_L("iCursor1.UpdateMember(9999,member) return value - Expected: %d, Actual: %d"), KErrArgument, err);
143 CleanupStack::PopAndDestroy(screen);
148 @SYMTestCaseID GRAPHICS-WSERV-0019
152 @SYMTestCaseDesc Construct a sprite in a group window
154 @SYMTestPriority High
156 @SYMTestStatus Implemented
158 @SYMTestActions Creates a sprite in a group window
160 @SYMTestExpectedResults The sprite is created without error
162 void CTTSprite::GroupWindowSpritesL()
166 SetUpSpriteL(sprite1,TheClient->iWs,*TheClient->iGroup->GroupWin());
167 SetUpSpriteL(sprite2,TheClient->iWs,*TheClient->iGroup->GroupWin());
168 TheClient->iWs.Flush();
174 @SYMTestCaseID GRAPHICS-WSERV-0020
178 @SYMTestCaseDesc Constructs a number of different sprites in different windows
180 @SYMTestPriority High
182 @SYMTestStatus Implemented
184 @SYMTestActions Creates many sprites in three different windows and the checks
185 the sprites can be manipulated
187 @SYMTestExpectedResults The sprite are created and manipulated without error
189 #define NUM_SPRITES 8
190 void CTTSprite::LotsSpritesL()
192 CTBlankWindow* win=new(ELeave) CTBlankWindow();
193 CTBlankWindow* win2=new(ELeave) CTBlankWindow();
195 win->ConstructL(*TheClient->iGroup);
196 win2->ConstructL(*win);
197 win2->SetExt(TPoint(100,100),size);
198 win2->SetColor(TRgb::Gray4(2));
199 RWindowBase window=*win->BaseWin();
200 RWindowBase window2=*win2->BaseWin();
203 RWsSprite sprite[NUM_SPRITES];
205 //TheClient->iWs.SetAutoFlush(ETrue);
206 for (ii=0;ii<NUM_SPRITES;ii++)
207 SetUpSpriteL(sprite[ii],TheClient->iWs,window);
209 sprite[2].SetPosition(TPoint(20,20));
211 win2->SetExt(TPoint(80,100),size);
212 sprite[6].SetPosition(TPoint(60,120));
214 sprite[5].SetPosition(TPoint(100,120));
216 SetUpSpriteL(sprite[7],TheClient->iWs,window);
217 sprite[7].SetPosition(TPoint(80,150));
219 win2->SetExt(TPoint(60,110),size);
220 sprite[5].SetPosition(TPoint(50,40));
222 SetUpSpriteL(sprite[0],TheClient->iWs,window);
223 sprite[0].SetPosition(TPoint(55,65));
225 win2->SetExt(TPoint(40,90),size);
226 sprite[2].SetPosition(TPoint(80,45));
228 sprite[0].SetPosition(TPoint(90,60));
230 SetUpSpriteL(sprite[2],TheClient->iWs,window);
231 sprite[2].SetPosition(TPoint(70,80));
233 win2->SetExt(TPoint(20,80),size);
234 sprite[2].SetPosition(TPoint(600,200));
236 SetUpSpriteL(sprite[0],TheClient->iWs,window2,ESpriteFlash);
237 sprite[0].SetPosition(TPoint(0,25));
238 SetUpSpriteL(sprite[1],TheClient->iWs,window2,ESpriteFlash);
239 SetUpSpriteL(sprite[2],TheClient->iWs,window2,ESpriteFlash);
240 sprite[2].SetPosition(TPoint(25,0));
241 win2->SetExt(TPoint(40,70),size);
242 CTBlankWindow* win3=new(ELeave) CTBlankWindow();
243 win3->ConstructL(*TheClient->iGroup);
244 win3->SetExt(TPoint(30,60),TSize(30,30));
245 win3->SetColor(TRgb::Gray4(1));
246 win3->BaseWin()->SetShadowHeight(10);
247 win3->BaseWin()->Activate();
248 User::After(1000000); //1 sec so sprites has time to flash
258 @SYMTestCaseID GRAPHICS-WSERV-0021
262 @SYMTestCaseDesc General PointerCursor Tests
264 @SYMTestPriority High
266 @SYMTestStatus Implemented
268 @SYMTestActions Exercise the different pointercursor methods of a Window Server Session
270 @SYMTestExpectedResults The methods are called without error
272 void CTTSprite::GeneralPointerCursor()
274 if (!TestBase()->ConfigurationSupportsPointerEventTesting())
276 INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing"));
279 TInt currentSMode=TheClient->iScreen->CurrentScreenMode();
281 if (TheClient->iScreen->NumScreenModes()>1)
282 altSMode=(currentSMode==1?0:1);
283 RWsSession &ws=TheClient->iWs;
284 TRect rect=ws.PointerCursorArea();
285 TRect testRect1(TPoint(rect.iBr.iX/4,rect.iBr.iY/4),TSize(rect.Width()/2,rect.Height()/2));
286 TRect testRect2(TPoint(rect.iBr.iX/3,rect.iBr.iY/3),TSize(2*rect.Width()/3,2*rect.Height()/3));
287 ws.SetPointerCursorArea(testRect1);
288 TEST(ws.PointerCursorArea()==testRect1);
289 TEST(ws.PointerCursorArea(currentSMode)==testRect1);
290 ws.SetPointerCursorArea(currentSMode,testRect2);
291 TEST(ws.PointerCursorArea()==testRect2);
292 TEST(ws.PointerCursorArea(currentSMode)==testRect2);
293 ws.SetPointerCursorArea(rect);
294 TEST(ws.PointerCursorArea()==rect);
298 rect=ws.PointerCursorArea(altSMode);
299 testRect1.iTl.iX=rect.iBr.iX/4;
300 testRect1.iTl.iY=rect.iBr.iY/4;
301 testRect1.SetWidth(rect.Width()/2);
302 testRect1.SetHeight(rect.Height()/2);
303 ws.SetPointerCursorArea(altSMode,testRect1);
304 TEST(ws.PointerCursorArea(altSMode)==testRect1);
305 ws.SetPointerCursorArea(altSMode,rect);
306 TEST(ws.PointerCursorArea(altSMode)==rect);
308 TPointerCursorMode currentMode=ws.PointerCursorMode();
311 for(ii=EPointerCursorFirstMode;ii<=EPointerCursorLastMode;ii++)
313 ws.SetPointerCursorMode(STATIC_CAST(TPointerCursorMode,ii));
314 err1 = ws.PointerCursorMode();
317 INFO_PRINTF3(_L("ws.PointerCursorMode() return value - Expected: %d, Actual: %d"), ii, err1);
319 ws.SetPointerCursorMode(currentMode);
320 TEST(currentMode==ws.PointerCursorMode());
321 TPoint point1(10,12);
322 TPoint point2(24,20);
323 ws.PointerCursorPosition();
324 ws.SetPointerCursorPosition(point1);
325 TEST(ws.PointerCursorPosition()==point1);
326 ws.SetPointerCursorPosition(point2);
327 TEST(ws.PointerCursorPosition()==point2);
332 @SYMTestCaseID GRAPHICS-WSERV-0498
334 @SYMDEF PDEF137614 - Propagation to TB92
336 @SYMTestCaseDesc Test activating a pointer cursor
338 @SYMTestPriority High
340 @SYMTestStatus Implemented
342 @SYMTestActions Construct and activate a pointer cursor.
348 @SYMTestExpectedResults
349 The pointer cursor bitmp should be visible when activated and removed when deactivated.
352 void CTTSprite::PointerCursorVisibleL()
354 if (!TestBase()->ConfigurationSupportsPointerEventTesting())
356 INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing"));
360 // The pointer events need time to have an affect on the wserv
361 static const TInt eventPropagationDelay = 100 * 1000; // 100 ms
363 TInt screenNumber = TheClient->iScreen->GetScreenNumber();
365 if(screenNumber != 0) // pointer events only supported on emulator screen 0
367 LOG_MESSAGE(_L("Pointer Cursor Visible only runs on screen 0"));
371 // set up objects used in test
372 // 50x50 red rectangle colour 24
374 User::LeaveIfError(bitmap.Load(TEST_BITMAP_NAME, 8));
376 TSize bmSize = bitmap.SizeInPixels();
377 TPoint bmSample = TPoint(bmSize.iWidth / 2, bmSize.iHeight / 2);
379 bitmap.GetPixel(bmColour, bmSample);
380 TEST(bmColour == KRgbRed);
382 // single window, size of screen
383 RWindow win(TheClient->iWs);
384 User::LeaveIfError(win.Construct(*TheClient->iGroup->GroupWin(),1));
388 TheClient->iWs.SetPointerCursorMode(EPointerCursorWindow);
390 // setup cursor to contain single 50x50 red bitmap
391 RWsPointerCursor iCursor1 = RWsPointerCursor(TheClient->iWs);
392 TSpriteMember member;
394 member.iBitmap=&bitmap;
395 User::LeaveIfError(iCursor1.Construct(0));
396 User::LeaveIfError(iCursor1.AppendMember(member));
397 User::LeaveIfError(iCursor1.Activate());
398 win.SetCustomPointerCursor(iCursor1);
399 iCursor1.UpdateMember(0);
401 // draw a green rect, size of screen as defined background and wait till it is rendered
403 TheGc->Activate(win);
404 TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
405 TheGc->SetBrushColor(KRgbGreen);
406 TSize wSize = win.Size();
407 TheGc->DrawRect(TRect(TPoint(0,0), wSize));
410 TheClient->iWs.Finish();
413 // define locations of simulated pointer events and sample positions of where we expect to see the cursor
414 // The cursor will be moved and a check will be made to see if this has actually happened
416 TPoint pos1(wSize.iWidth / 2, wSize.iHeight / 2); // top left of cursor at centre screen
417 TPoint sample1(pos1 + bmSample); // centre of sprite at pos1
418 TPoint pos2 = pos1 - bmSize; // bottom right of cursor at centre screen
419 TPoint sample2 = pos2 + bmSample; // centre of sprite at pos2
423 // check initial state of screen at both sample positions
424 TheClient->iScreen->GetPixel(pixel, sample1);
425 TEST(pixel == KRgbGreen);
427 TheClient->iScreen->GetPixel(pixel, sample2);
428 TEST(pixel == KRgbGreen);
430 TRawEvent e; // to simulate pointer events
432 // simulate button 1 down event at pos1
433 e.Set(TRawEvent::EButton1Down, pos1.iX, pos1.iY);
434 e.SetDeviceNumber(screenNumber);
435 UserSvr::AddEvent(e);
437 User::After(eventPropagationDelay);
439 // check red cursor visible on top of background
440 TheClient->iScreen->GetPixel(pixel, sample1);
441 TEST(pixel == KRgbRed);
443 // simulate button 1 up event
444 e.Set(TRawEvent::EButton1Up, pos1.iX, pos1.iY);
445 UserSvr::AddEvent(e);
446 User::After(eventPropagationDelay);
448 // Move cursor away to pos2
449 e.Set(TRawEvent::EButton1Down, pos2.iX, pos2.iY);
450 e.SetDeviceNumber(screenNumber);
451 UserSvr::AddEvent(e);
453 User::After(eventPropagationDelay);
455 // check cursor has left this position ...
456 TheClient->iScreen->GetPixel(pixel, sample1);
457 TEST(pixel == KRgbGreen);
458 // and arrived at the correct place
459 TheClient->iScreen->GetPixel(pixel, sample2);
460 TEST(pixel == KRgbRed);
462 // simulate button 1 up event
463 e.Set(TRawEvent::EButton1Up, pos2.iX, pos2.iY);
464 UserSvr::AddEvent(e);
465 User::After(eventPropagationDelay);
468 win.ClearPointerCursor();
469 User::After(eventPropagationDelay);
472 TheClient->iScreen->GetPixel(pixel, sample2);
473 TEST(pixel == KRgbGreen);
475 // #### clean up ####
482 @SYMTestCaseID GRAPHICS-CODEBASE-WSERV-0053-0001
486 @SYMTestCaseDesc Tests RWsPointerCursor::UpdateMember APIs.
490 @SYMTestStatus Implemented
492 @SYMTestActions This test calls RWsPointerCursor::UpdateMember
494 @SYMTestExpectedResults Should run properly with out any Panics.
497 void CTTSprite::SpriteUpdateMemberTestsL()
499 RWsPointerCursor iCursor1;
502 bitmap.Load(TEST_BITMAP_NAME,0);
504 RWindow win(TheClient->iWs);
505 win.Construct(*TheClient->iGroup->GroupWin(),1);
508 iCursor1=RWsPointerCursor(TheClient->iWs);
509 TSpriteMember member;
511 member.iBitmap=&bitmap;
512 User::LeaveIfError(iCursor1.Construct(0));
513 User::LeaveIfError(iCursor1.AppendMember(member));
514 User::LeaveIfError(iCursor1.Activate());
515 win.SetCustomPointerCursor(iCursor1);
516 iCursor1.UpdateMember(0);
518 RWsPointerCursor iCursor2;
519 bitmap.Load(TEST_NEW_BITMAP_NAME,0);
520 iCursor2=RWsPointerCursor(TheClient->iWs);
521 User::LeaveIfError(iCursor2.Construct(0));
522 User::LeaveIfError(iCursor2.AppendMember(member));
523 User::LeaveIfError(iCursor2.Activate());
524 win.SetCustomPointerCursor(iCursor2);
525 iCursor2.UpdateMember(1);
533 @SYMTestCaseID GRAPHICS-CODEBASE-WSERV-0054-0001
537 @SYMTestCaseDesc Negative Tests RWsSpriteBase::UpdateMember API.
541 @SYMTestStatus Implemented
543 @SYMTestActions This test calls RWsPointerCursor::UpdateMember
545 @SYMTestExpectedResults Should run properly with out any Panics.
548 void CTTSprite::SpriteUpdateMemberNegTestsL()
550 RWsPointerCursor iCursor1;
553 bitmap.Load(TEST_BITMAP_NAME,0);
555 RWindow win(TheClient->iWs);
556 win.Construct(*TheClient->iGroup->GroupWin(),1);
559 iCursor1=RWsPointerCursor(TheClient->iWs);
560 TSpriteMember member;
562 member.iBitmap=&bitmap;
563 User::LeaveIfError(iCursor1.Construct(0));
564 User::LeaveIfError(iCursor1.AppendMember(member));
565 User::LeaveIfError(iCursor1.Activate());
566 win.SetCustomPointerCursor(iCursor1);
567 iCursor1.UpdateMember(-100);
569 RWsPointerCursor iCursor2;
570 bitmap.Load(TEST_NEW_BITMAP_NAME,0);
571 iCursor2=RWsPointerCursor(TheClient->iWs);
572 User::LeaveIfError(iCursor2.Construct(0));
573 User::LeaveIfError(iCursor2.AppendMember(member));
574 User::LeaveIfError(iCursor2.Activate());
575 win.SetCustomPointerCursor(iCursor2);
576 iCursor2.UpdateMember(10000);
584 @SYMTestCaseID GRAPHICS-CODEBASE-WSERV-0055-0001
588 @SYMTestCaseDesc Tests FindWindowGroupIdentifier API.
592 @SYMTestStatus Implemented
594 @SYMTestActions Create windows session and call FindWindowGroupIdentifier \n
595 with different thread Id's both with valid thread ids and in valid thread id's.
597 @SYMTestExpectedResults Should run properly.
600 void CTTSprite::FindWindowGroupThreadTestsL()
604 TUint64 id=proc.Id();
606 User::LeaveIfError(ws1.Connect());
607 CleanupClosePushL(ws1);
608 //Positive test for FindWindowGroupIdentifier
609 ident=ws1.FindWindowGroupIdentifier(0,id);
610 TEST(ws1.SetWindowGroupOrdinalPosition(ident,0)==KErrNone);
611 TEST(ws1.SetWindowGroupOrdinalPosition(ident,1)==KErrNone);
612 //Negative test for FindWindowGroupIdentifier
613 TInt ret=ws1.FindWindowGroupIdentifier(0,id+200);
614 TEST(ret==KErrNotFound);
615 #if defined __WINS__ || defined __WINSCW__
616 ret=ws1.FindWindowGroupIdentifier(0,-200);
617 TEST(ret==KErrNotFound);
618 #endif//defined __WINS__ || defined __WINSCW__
619 CleanupStack::PopAndDestroy(1, &ws1);
624 @SYMTestCaseID GRAPHICS-WSERV-0462
628 @SYMTestCaseDesc Test sprite list cleanup when a window is deleted in low memory conditions
630 @SYMTestPriority High
632 @SYMTestStatus Implemented
634 @SYMTestActions Have a loop which increases the number of allocations in the server thread before failure;
636 1) Create a parent window and a child window of the parent;
637 2) Create a sprite on the child window;
638 3) Delete the parent window only, but not the child window;
639 4) Create a testWindow and do redraw on this window;
640 5) Do redraw on the testWindow. This testWindow's redraw will force checking the sprite list.
641 This would panic the client thread due to this defect because the sprite on the orphaned
642 window (which is the previous child window) is still in the sprite list;
643 6) Delete all the windows involved.
645 @SYMTestExpectedResults The sprite should be disabled when a window is deleted;
646 The client thread should not be panic'd.
647 The test should pass.
649 void CTTSprite::SpriteOnWindowOrphanedTestsL()
653 TInt allocFailRate = 0;
656 CFbsBitmap* bitmap = new(ELeave) CFbsBitmap;
657 CleanupStack::PushL(bitmap);
658 User::LeaveIfError(bitmap->Create(TSize(500, 500), EColor16MU));
659 TSpriteMember spritemember;
660 spritemember.iBitmap = bitmap;
661 spritemember.iMaskBitmap = NULL;
663 RWindowGroup group(TheClient->iWs);
664 RWindow parent1(TheClient->iWs);
665 RWindow child1(TheClient->iWs);
666 RWindow testWindow(TheClient->iWs);
667 RWsSprite sprite(TheClient->iWs);
671 TRect mainRect(TPoint(0,0), TSize(500,500));
672 err = group.Construct(++handles, EFalse);
675 TheClient->iWs.HeapSetFail(RHeap::EDeterministic, allocFailRate);
678 err = parent1.Construct(group,++handles);
681 parent1.SetExtent(mainRect.iTl, mainRect.Size());
682 parent1.EnableRedrawStore(ETrue);
690 TRect childRect(TPoint (10, 10), TSize (200, 150));
691 err = child1.Construct(parent1,++handles);
694 child1.SetExtent(childRect.iTl, childRect.Size());
695 child1.SetBackgroundColor(TRgb(128,100,255,20));
700 //Add sprite to child 1
703 err = sprite.Construct(child1,TPoint(10,10), 0);
706 err = sprite.AppendMember(spritemember);
708 err = sprite.Activate();
712 //Only delete parent 1, but not child 1
717 TRect testRect(TPoint(10, 30), TSize(200, 150));
719 err = testWindow.Construct(group,++handles);
722 testWindow.SetExtent(testRect.iTl, testRect.Size());
723 testWindow.SetBackgroundColor(TRgb(128,100,255,20));
724 testWindow.EnableRedrawStore(ETrue);
725 testWindow.Activate();
726 testWindow.BeginRedraw();
727 testWindow.EndRedraw();
731 TheClient->iWs.HeapSetFail(RAllocator::ENone, 0);
738 loop = (err == KErrNone) ? loop + 1 : 0;
740 CleanupStack::PopAndDestroy(bitmap);
742 void CTTSprite::ResizeMemberL()
745 CTBlankWindow* win=new(ELeave) CTBlankWindow();
746 CleanupStack::PushL(win);
747 win->ConstructL(*TheClient->iGroup);
748 win->SetExt(TPoint(),TSize(640,240));
749 RWindowBase& window=*win->BaseWin();
751 RWsSprite sprite(TheClient->iWs);
752 CleanupClosePushL(sprite);
753 User::LeaveIfError(sprite.Construct(window,TPoint(),0));
754 TSpriteMember member;
755 member.iMaskBitmap=NULL;
756 member.iInvertMask=EFalse;
757 member.iDrawMode=CGraphicsContext::EDrawModePEN;
758 member.iOffset=TPoint();
759 member.iInterval=TTimeIntervalMicroSeconds32(250000);
760 member.iBitmap=&iBitmap;
761 User::LeaveIfError(sprite.AppendMember(member));
762 User::LeaveIfError(sprite.AppendMember(member));
763 User::LeaveIfError(sprite.Activate());
764 User::After(1000000); // // Interval is 1 sec.
765 User::LeaveIfError(iBitmap.Resize(iBitmap.SizeInPixels() + TSize(100,100)));
766 User::After(1000000); // Interval is 1 sec.
767 CleanupStack::PopAndDestroy(&sprite);
768 CleanupStack::PopAndDestroy(win);
773 void CTTSprite::SetUpSpriteL(RWsSprite &aSprite, RWindowTreeNode &aWindow,TPoint aPoint, TSpriteMember aMember, TInt aFlags/*=0*/)
775 User::LeaveIfError(aSprite.Construct(aWindow,aPoint,aFlags));
776 User::LeaveIfError(aSprite.AppendMember(aMember));
777 User::LeaveIfError(aSprite.Activate());
780 @SYMTestCaseID GRAPHICS-WSERV-00-0001
784 @SYMTestCaseDesc Test Screenrotation does not cause panic by sprite with NULL bitmap and NULL maskbitmap
786 @SYMTestPriority High
788 @SYMTestStatus Implemented
790 @SYMTestActions Defines two sprites and one with Null iBitmap and Null iMaskBitmap, then rotate the screen to 90 degrees
792 @SYMTestExpectedResults the screen rotation will not cause wserv a panic
794 void CTTSprite::RotateNullSpriteL()
796 if (TheClient->iScreen->NumScreenModes() < 2)
798 LOG_MESSAGE(_L("WARNING: Unable to rotate screen"));
802 TSpriteMember spriteMember1,spriteMember2;
803 SetUpMember(spriteMember1);
804 SetUpMember(spriteMember2);
805 spriteMember2.iBitmap = NULL;
808 RWindowGroup group(TheClient->iWs);
809 User::LeaveIfError(group.Construct(ENullWsHandle,EFalse)); //Creates a Group Window
810 CleanupClosePushL(group);
811 RBlankWindow win(TheClient->iWs);
812 User::LeaveIfError(win.Construct(group,ENullWsHandle)); //Creates a Blank Window
813 CleanupClosePushL(win);
814 win.SetVisible(ETrue);
815 win.SetColor(TRgb::Gray4(2));
820 RWsSprite sprite1(TheClient->iWs);
821 CleanupClosePushL(sprite1);
822 SetUpSpriteL(sprite1, win,TPoint(20,70),spriteMember1,0);
823 RWsSprite sprite2(TheClient->iWs);
824 CleanupClosePushL(sprite2);
825 SetUpSpriteL(sprite2, win,TPoint(80,130),spriteMember2,0);
826 RWsSprite sprite3(TheClient->iWs);
827 CleanupClosePushL(sprite3);
828 SetUpSpriteL(sprite3, win,TPoint(2800,2130),spriteMember1,0);
831 // Get the original screen mode
832 CWsScreenDevice* device = TheClient->iScreen;
833 TInt originalScreenMode = device->CurrentScreenMode();
834 TPixelsTwipsAndRotation originalModeSettings;
835 device->GetScreenModeSizeAndRotation(originalScreenMode,originalModeSettings);
838 TPixelsAndRotation pixelsAndRotation;
839 device->SetScreenMode( 1 );
840 device->GetDefaultScreenSizeAndRotation(pixelsAndRotation);
841 device->SetCurrentRotations(1,pixelsAndRotation.iRotation);
842 device->SetScreenSizeAndRotation(pixelsAndRotation);
843 User::After(1000000);
845 CleanupStack::PopAndDestroy(5,&group);
846 // Restore the original screen mode
847 device->SetScreenMode(originalScreenMode);
848 device->SetCurrentRotations(originalScreenMode,originalModeSettings.iRotation);
849 device->SetScreenSizeAndRotation(originalModeSettings);
854 @SYMTestCaseID GRAPHICS-WSERV-GCE-0700
858 @SYMTestCaseDesc Test activating a sprite twice does not cause the system to hang
860 @SYMTestPriority High
862 @SYMTestStatus Implemented
864 @SYMTestActions Construct a sprite and add a member to it. Activate twice.
866 @SYMTestExpectedResults The test should terminate smoothly and it should not hang the system.
868 void CTTSprite::DoubleActivateL()
871 User::LeaveIfError(ws.Connect());
872 CleanupClosePushL(ws);
874 RWindowGroup group(ws);
875 User::LeaveIfError(group.Construct(890, EFalse));
876 CleanupClosePushL(group);
878 RWsSprite sprite = RWsSprite(ws);
879 User::LeaveIfError(sprite.Construct(group,TPoint(),0));
880 CleanupClosePushL(sprite);
881 CFbsBitmap* bitmap=new(ELeave) CFbsBitmap;
882 CleanupStack::PushL(bitmap);
883 User::LeaveIfError(bitmap->Create(TSize(10,12),EColor256));
884 TSpriteMember member;
885 member.iMaskBitmap=NULL;
886 member.iInvertMask=EFalse;
887 member.iDrawMode=CGraphicsContext::EDrawModePEN;
888 member.iOffset=TPoint();
889 member.iInterval=TTimeIntervalMicroSeconds32(0);
890 member.iBitmap=bitmap;
891 User::LeaveIfError(sprite.AppendMember(member));
892 User::LeaveIfError(sprite.Activate());
893 User::LeaveIfError(sprite.Activate());
896 CleanupStack::PopAndDestroy(4, &ws);
902 void CTTSprite::RunTestCaseL(TInt /*aCurTestCase*/)
904 _LIT(KTest1, "General Tests");
905 _LIT(KTest2, "Group Window Sprites Tests");
906 _LIT(KTest3, "Lots Sprites Tests");
907 _LIT(KTest4, "General Pointer Cursor Tests");
908 _LIT(KTest5, "Pointer Cursor Visible Tests");
909 _LIT(KTest6, "Update member tests");
910 _LIT(KTest7, "Negative tests for Update member");
911 _LIT(KTest8, "Window Group with Thread");
912 _LIT(KTest9, "Resize Sprite Member Tests");
913 _LIT(KTest10, "Rotate a NULL sprite");
914 _LIT(KTest11, "Sprite On Window Orphaned Tests");
915 _LIT(KTest12, "Sprite Double Activation Test");
917 ((CTTSpriteStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
918 switch(++iTest->iState)
921 ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0018"));
922 TheClient->iWs.SetFocusScreen(0);
923 iTest->LogSubTest(KTest1);
927 ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0019"));
928 iTest->LogSubTest(KTest2);
929 GroupWindowSpritesL();
932 ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0020"));
933 iTest->LogSubTest(KTest3);
937 ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0021"));
938 iTest->LogSubTest(KTest4);
939 GeneralPointerCursor();
942 ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0498"));
943 iTest->LogSubTest(KTest5);
944 TRAPD(err, PointerCursorVisibleL());
945 TEST(err == KErrNone);
948 ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-CODEBASE-WSERV-0053-0001"));
949 iTest->LogSubTest(KTest6);
950 TRAP(err, SpriteUpdateMemberTestsL());
951 TEST(err == KErrNone);
954 ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-CODEBASE-WSERV-0054-0001"));
955 iTest->LogSubTest(KTest7);
956 TRAP(err, SpriteUpdateMemberNegTestsL());
957 TEST(err == KErrNone);
960 ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-CODEBASE-WSERV-0055-0001"));
961 iTest->LogSubTest(KTest8);
962 TRAP(err, FindWindowGroupThreadTestsL());
963 TEST(err == KErrNone);
966 ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0526"));
967 iTest->LogSubTest(KTest9);
971 ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-00-0001"));
972 iTest->LogSubTest(KTest10);
976 ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0462"));
977 iTest->LogSubTest(KTest11);
978 SpriteOnWindowOrphanedTestsL();
981 ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-GCE-0700"));
982 iTest->LogSubTest(KTest12);
986 ((CTTSpriteStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
987 ((CTTSpriteStep*)iStep)->CloseTMSGraphicsStep();
991 ((CTTSpriteStep*)iStep)->RecordTestResultL();
995 __WS_CONSTRUCT_STEP__(TSprite)