Update contrib.
1 // Copyright (c) 2006-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.
14 // This test step contains a series of tests cases to validate the correct behaviour of PREQ1246 implementation.
15 // In order to create these test cases, basic implementations of the objects involved in this PREQ will be created,
16 // .i.e. CWsGraphic-derived objects (generically named CWsGraphicTest) and CWsGraphicDrawer-derived objects
17 // (generically named CWsGraphicDrawerTest).
18 // Actual construction is performed by a UI-specific entity such as a theme manager. The test code shall replace
19 // that theme manager functionality, in terms of being the test code who owns a collection of CWsGraphicTest
27 @internalComponent - Internal Symbian test code
30 #include "TWSGRAPHS.H"
31 #include "../inc/WSGRAPHICDRAWERARRAY.H"
32 #include "../../nga/graphicdrawer/panics.h"
33 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
34 #include "wsbufferdrawer.h"
37 _LIT(KTestExe, "TWSGRAPHICTEST.exe");
40 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
41 const TInt KCustomTextCursorId = TTextCursor::ETypeLastBasic + 57; // 57 is arbitrary
44 CCrWin* CCrWin::NewL(TInt aScreenId, TBool aDraw)
46 CCrWin* win = new(ELeave) CCrWin;
47 CleanupStack::PushL(win);
48 win->ConstructL(aScreenId, aDraw);
49 CleanupStack::Pop(win);
62 void CCrWin::ConstructL(TInt aScreenId, TBool aDraw)
64 User::LeaveIfError(iWs.Connect());
65 iScr = new(ELeave) CWsScreenDevice(iWs);
66 User::LeaveIfError(iScr->Construct(aScreenId));
67 User::LeaveIfError(iScr->CreateContext(iGc));
68 iGroup = RWindowGroup(iWs);
69 User::LeaveIfError(iGroup.Construct(0xbadbabe,ETrue));
70 iGroup.SetOrdinalPosition(0,100);
72 User::LeaveIfError(iWin.Construct(iGroup,0xbadcafe));
73 iWin.SetRequiredDisplayMode(EColor64K);
84 iGc->SetBrushColor(KRgbRed);
85 iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
86 TRect rect(iScr->SizeInPixels());
88 iGc->SetBrushColor(KRgbBlue);
89 iGc->DrawEllipse(TRect(rect.iTl.iX,rect.iTl.iY,rect.iBr.iX/2,rect.iBr.iY));
90 iGc->DrawEllipse(TRect(rect.iBr.iX/2,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY));
97 void CCrWin::DrawFirstHalf()
101 iGc->SetBrushColor(KRgbRed);
102 iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
103 TRect rect(TPoint(0,0),TSize(iScr->SizeInPixels().iWidth/2,iScr->SizeInPixels().iHeight));
108 void CCrWin::DrawSecondHalf()
110 TRect rect(TPoint(iScr->SizeInPixels().iWidth/2,0),TSize(iScr->SizeInPixels().iWidth/2,iScr->SizeInPixels().iHeight));
118 The objective of this function is, two animations should run independently
119 with respective frame rate in the given time interval.
120 The time delay allows to draw animations freely and the plug-in
121 calculates number of times DoDraw() function called during this interval.
123 @param TInt Wsgrphic test plug-in id.
125 void CCrWin::DrawGraphic(TInt aWsId)
127 // draw the animation in two positions
128 const TSize screenSize = iScr->SizeInPixels();
129 const TRect position(0,0,screenSize.iWidth/2,screenSize.iHeight);
130 const TRect position2((screenSize.iWidth/2)+1,0,screenSize.iWidth,screenSize.iHeight);
131 //PeterI if CWsGraphic animation areas overlap then when one redraws the other will as well.
132 //2 separate positions are needed otherwise the framerates will be identical.
136 const TUint8 animid1=0;
137 const TUint8 fps1=20;
139 animData1.Append(animid1); //animId1
140 animData1.Append(fps1); //20fps
141 iGc->DrawWsGraphic(aWsId,position,animData1);
144 const TUint8 animid2=1;
145 const TUint8 fps2=60;
147 animData2.Append(animid2); //animId2
148 animData2.Append(fps2); //60fps
149 iGc->DrawWsGraphic(aWsId,position2,animData2);
158 * Set a standard text cursor on this window.
159 * @see RWindowGroup::SetTextCursor()
161 void CCrWin::SetTextCursor(const TPoint &aPos, const TTextCursor &aCursor)
163 iGroup.SetTextCursor(iWin, aPos, aCursor);
167 * Cancel a text cursor from this window.
168 * @see RWindowGroup::CancelTextCursor()
170 void CCrWin::CancelTextCursor()
172 iGroup.CancelTextCursor();
175 CCrAlphaWin* CCrAlphaWin::NewL(TInt aScreenId)
177 CCrAlphaWin* win = new(ELeave) CCrAlphaWin;
178 CleanupStack::PushL(win);
179 win->ConstructL(aScreenId);
180 CleanupStack::Pop(win);
184 CCrAlphaWin::~CCrAlphaWin()
192 void CCrAlphaWin::ConstructL(TInt aScreenId)
194 User::LeaveIfError(iWs.Connect());
195 iScr = new(ELeave) CWsScreenDevice(iWs);
196 User::LeaveIfError(iScr->Construct(aScreenId));
197 iGroup = RWindowGroup(iWs);
198 User::LeaveIfError(iGroup.Construct(0xbadc0de,ETrue));
199 iGroup.SetOrdinalPosition(0,100);
201 User::LeaveIfError(iWin.Construct(iGroup,0xbadbeef));
202 iWin.SetRequiredDisplayMode(EColor64K);
203 iWin.SetTransparencyAlphaChannel();
204 iWin.SetBackgroundColor(TRgb(0xff,0xff,0,0x80));
214 CTWsGraphs::CTWsGraphs(CTestStep* aStep):
215 CTWsGraphicsBase(aStep)
219 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
220 LOCAL_D void DeleteSpriteMember(TAny* aSpriteMember)
222 TSpriteMember* member=reinterpret_cast<TSpriteMember*>(aSpriteMember);
223 delete member->iBitmap;
224 member->iBitmap=NULL;
225 delete member->iMaskBitmap;
226 member->iMaskBitmap=NULL;
230 CTWsGraphs::~CTWsGraphs()
232 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
233 DeleteSpriteMember(&iSpriteMemberArray[0]);
234 iSpriteMemberArray.Close();
237 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
246 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
251 void CTWsGraphs::ConstructL()
253 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
254 iRedir = CWsRedir::NewL(iTest->iScreenNumber,ETrue);
255 iRedir->SetCallBack(TCallBack(CTWsGraphs::PluginCallBack,this));
257 iNotify1 = CWsNotify::NewL(EFalse);
258 iNotify2 = CWsNotify::NewL(ETrue);
259 iListen = CWsListen::NewL(ETrue);
260 iListen->SetCallBack(TCallBack(CTWsGraphs::PluginCallBack,this));
261 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
262 iFrontCopy = new(ELeave) CFbsBitmap;
263 iBackCopy = new(ELeave) CFbsBitmap;
264 iBefore = new(ELeave) CFbsBitmap;
265 User::LeaveIfError(iBefore->Create(TheClient->iScreen->SizeInPixels(), EColor64K));
266 iAfter = new(ELeave) CFbsBitmap;
267 User::LeaveIfError(iAfter->Create(TheClient->iScreen->SizeInPixels(), EColor64K));
269 iGdCoverage = CWsGdCoverage::NewL();
270 iGdCoverage->SetCallBack(TCallBack(CTWsGraphs::PluginCallBack,this));
271 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
272 TSpriteMember spriteMember;
273 spriteMember.iBitmap = NULL;
274 spriteMember.iMaskBitmap = NULL;
275 spriteMember.iInvertMask =EFalse;
276 spriteMember.iDrawMode = CGraphicsContext::EDrawModePEN;
277 spriteMember.iOffset = TPoint();
278 spriteMember.iInterval = TTimeIntervalMicroSeconds32(0);
279 CleanupStack::PushL(TCleanupItem(DeleteSpriteMember, &spriteMember));
280 spriteMember.iBitmap = new (ELeave) CFbsBitmap;
281 User::LeaveIfError(spriteMember.iBitmap->Load(TEST_BITMAP_NAME, EMbmWsautotestBmp1));
282 spriteMember.iMaskBitmap = new (ELeave) CFbsBitmap;
283 User::LeaveIfError(spriteMember.iMaskBitmap->Load(TEST_BITMAP_NAME, EMbmWsautotestBmp1mask));
284 User::LeaveIfError(iSpriteMemberArray.Append(spriteMember));
285 CleanupStack::Pop(&spriteMember);
289 void CTWsGraphs::LaunchNewProcess(const TDesC& aExecutable)
293 args.AppendNum(iTest->iScreenNumber);
295 TInt err = pr.Create(aExecutable,args);
298 TRequestStatus status;
301 User::WaitForRequest(status);
302 err = pr.ExitReason();
306 _LIT(KLog,"%S returned error: %d. Check RDebug output.");
307 LOG_MESSAGE3(KLog, &aExecutable, err);
312 _LIT(KLog,"Can't create the process (%S), err=%d");
313 LOG_MESSAGE3(KLog, &aExecutable, err);
315 TEST(err == KErrNone);
316 // Restore main test group to foreground.
317 TheClient->iGroup->GroupWin()->SetOrdinalPosition(0);
320 TInt CTWsGraphs::PluginCallBack(TAny* /*aArg*/)
325 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
328 @SYMTestCaseID GRAPHICS-WSERV-0371
330 @SYMTestCaseDesc Test interface extension
331 @SYMTestPriority High
332 @SYMTestStatus Implemented
333 @SYMTestActions Retrieves object interfaces from Content Rendering Plugin (plugin).
336 -Query interfaces obtained from plugin side
337 @SYMTestExpectedResults Supported interfaces should return non null
339 TestState CTWsGraphs::TestInterfaceExtensionL()
343 _LIT(KTestInterfaceExtension, "TestInterfaceExtension");
344 INFO_PRINTF1(KTestInterfaceExtension);
347 Mem::FillZ(&iRedirInfo, sizeof(TRedirectorInfo));
348 iRedir->QueryPlugin(iRedirInfo);
351 TEST(iRedirInfo.iScreenConfigInterface!=NULL);
352 TEST(iRedirInfo.iFrontBufferInterface!=NULL);
353 TEST(iRedirInfo.iScreenBitmapHandle!=0);
354 iFrontCopy->Duplicate(iRedirInfo.iScreenBitmapHandle);
356 if (TransparencySupportedL()!=KErrNotSupported)
358 TEST(iRedirInfo.iBackBufferInterface!=NULL);
359 TEST(iRedirInfo.iFlickerBitmapHandle!=0);
360 iBackCopy->Duplicate(iRedirInfo.iFlickerBitmapHandle);
368 #endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
370 void CTWsGraphs::CreateWindowL(TBool aDraw)
372 iWin = CCrWin::NewL(iTest->iScreenNumber, aDraw);
375 void CTWsGraphs::DestroyWindowL()
381 void CTWsGraphs::CreateAlphaWindowL()
383 iAlpha = CCrAlphaWin::NewL(iTest->iScreenNumber);
386 void CTWsGraphs::DestroyAlphaWindowL()
392 TBool CTWsGraphs::CompareBitmapArea16Bpp(CFbsBitmap* aBmp1, const TPoint& aPos1, CFbsBitmap* aBmp2, const TPoint& aPos2, const TSize& aSize)
394 const TDisplayMode dispmode = aBmp1->DisplayMode();
395 if (dispmode!=aBmp2->DisplayMode())
397 const TInt stride1 = aBmp1->DataStride();
398 const TInt stride2 = aBmp2->DataStride();
399 const TInt linebytes = aSize.iWidth * 2;
400 const TInt pixelbytes = 2;
402 const TUint8* p1 = ((const TUint8*)aBmp1->DataAddress())+aPos1.iY*stride1+aPos1.iX*pixelbytes;
403 const TUint8* p2 = ((const TUint8*)aBmp2->DataAddress())+aPos2.iY*stride2+aPos2.iX*pixelbytes;
404 for (TInt y=0; y<aSize.iHeight; ++y)
406 if (Mem::Compare(p1+y*stride1,linebytes,p2+y*stride2,linebytes)!=0)
416 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
417 TestState CTWsGraphs::TestScreenRedirectionL()
421 _LIT(KTestScreenRedirection, "TestScreenRedirection");
422 INFO_PRINTF1(KTestScreenRedirection);
426 @SYMTestCaseID GRAPHICS-WSERV-0372
428 @SYMTestCaseDesc Redirect wserv screen drawing to custom graphics context
429 @SYMTestPriority High
430 @SYMTestStatus Implemented
431 @SYMTestActions Redirects wserv screen drawing to bitmap context owned by plugin.
434 -Save screen content to a bitmap
435 -Instruct plugin to redirect wserv screen drawing to a bitmap device
436 -Draw the same window again
437 -Retrieve plugin bitmap and compare against the saved bitmap
438 @SYMTestExpectedResults Bitmap content match
441 TheClient->iScreen->CopyScreenToBitmap(iBefore);
443 iRedir->Redirect(CWsRedir::EFrontBuffer, ETrue);
451 TSize sz = iBefore->SizeInPixels();
452 TInt bytes = sz.iWidth*sz.iHeight*2; // EColor64K
454 TEST(Mem::Compare((const TUint8*)iFrontCopy->DataAddress(),bytes,(const TUint8*)iBefore->DataAddress(),bytes)==0);
455 iBefore->UnlockHeap();
457 Mem::FillZ(&iRedirInfo, sizeof(TRedirectorInfo));
458 iRedir->QueryPlugin(iRedirInfo);
466 @SYMTestCaseID GRAPHICS-WSERV-0047
467 @SYMTestCaseDesc Screen update event
468 @SYMTestPriority Medium
469 @SYMTestStatus Implemented
470 @SYMTestActions Check plugin receive screen update event during redirection
471 @SYMTestExpectedResults Counter is non-zero
473 TEST(iRedirInfo.iUpdateCounter>0);
477 @SYMTestCaseID GRAPHICS-WSERV-0373
479 @SYMTestCaseDesc Stop wserv screen drawing redirection
480 @SYMTestPriority High
481 @SYMTestStatus Implemented
482 @SYMTestActions Stop wserv screen drawing redirection.
484 -Instruct plugin to stop wserv screen drawing redirection
485 -Draw the same window again
486 -Save screen content to another bitmap
487 -Compare the saved bitmap against newly saved bitmap
488 @SYMTestExpectedResults Bitmap content match
490 iRedir->Redirect(CWsRedir::EFrontBuffer, EFalse);
498 TheClient->iScreen->CopyScreenToBitmap(iAfter);
499 TSize sz = iBefore->SizeInPixels();
500 TInt bytes = sz.iWidth*sz.iHeight*2; // EColor64K
502 TEST(Mem::Compare((const TUint8*)iAfter->DataAddress(),bytes,(const TUint8*)iBefore->DataAddress(),bytes)==0);
503 iAfter->UnlockHeap();
506 Mem::FillZ(&iRedirInfo, sizeof(TRedirectorInfo));
507 iRedir->QueryPlugin(iRedirInfo);
512 @SYMTestCaseID GRAPHICS-WSERV-0374
513 @SYMTestCaseDesc Screen update event
514 @SYMTestPriority Medium
515 @SYMTestStatus Implemented
516 @SYMTestActions Check plugin receive no screen update event when redirection is terminated
517 @SYMTestExpectedResults Counter is zero
519 TEST(iRedirInfo.iUpdateCounter==0);
527 TestState CTWsGraphs::TestTextCursorUnderRedirectionL(TTestCursorType aCursorType)
530 @SYMTestCaseID GRAPHICS-WSERV-0363
531 @SYMTestCaseDesc Text Cursor when drawing redirected
532 @SYMTestPriority Medium
533 @SYMTestStatus Implemented
534 @SYMTestActions Action steps:
535 - Draw the text cursor in the left side of the screen
536 - Re-direct the Front Buffer
537 - Move the text cursor to the right side of the screen
538 - Pause 0.5 seconds because this amount of time is needed
539 to change from the flash ON phase to the flash OFF phase
541 - See if when we exit re-direction in a different place in
542 the phase of the text cursor flashing, whether we get
543 non-text cursor drawing artefacts in the old location
544 where the text cursor used to be
545 @SYMTestExpectedResults Left side of the screen does not show a Text Cursor
548 ASSERT(aCursorType == ETestStandardTextCursor || aCursorType == ETestCustomTextCursor);
550 // Cursor Flash Period is 1 second (comprising two phases; ON and OFF)
551 const TInt KCursorFlashPeriod = 1000000;
552 const TInt KWaitForNextFlashPhase = KCursorFlashPeriod / 2;
554 // Size of the cursor; it may be either a standard or custom text cursor
555 TSize cursorSize = (aCursorType == ETestStandardTextCursor) ? TSize(15, 20) : TSize(80, 80);
557 // Original Text Cursor position in the left part of the screen
558 const TPoint originalCursorPos(45, 40);
560 // New Text Cursor position in the right half of the screen
561 const TPoint newCursorPos((TheClient->iScreen->SizeInPixels().iWidth/2) + 45, 40);
563 // Clean area of the screen which never had a text cursor
564 const TPoint cleanReferencePos(45, 40 + 80);
566 /* Initial setup to get a window with a standard flashing text cursor */
570 CreateWindowL(ETrue);
572 if (aCursorType == ETestStandardTextCursor)
574 _LIT(KTestTextCursorUnderRedirection, "TestTextCursorUnderRedirection(Standard Cursor)");
575 INFO_PRINTF1(KTestTextCursorUnderRedirection);
576 iTextCursor.iType=TTextCursor::ETypeRectangle;
577 iTextCursor.iHeight=cursorSize.iHeight;
578 iTextCursor.iAscent=0;
579 iTextCursor.iWidth=cursorSize.iWidth;
580 iTextCursor.iFlags=0; // means flash the cursor
581 iTextCursor.iColor=KRgbGreen;
582 iWin->SetTextCursor(originalCursorPos, iTextCursor);
584 else if (aCursorType == ETestCustomTextCursor)
586 _LIT(KTestTextCursorUnderRedirection, "TestTextCursorUnderRedirection(Custom Cursor)");
587 INFO_PRINTF1(KTestTextCursorUnderRedirection);
589 TInt err = TheClient->iWs.SetCustomTextCursor(
591 iSpriteMemberArray.Array(),
593 RWsSession::ECustomTextCursorAlignTop
595 iTextCursor.iType=KCustomTextCursorId;
596 iTextCursor.iHeight=cursorSize.iHeight;
597 iTextCursor.iAscent=0;
598 iTextCursor.iWidth=cursorSize.iWidth;
599 iTextCursor.iFlags=TTextCursor::EFlagClipHorizontal; // means flash the cursor and clip the sprite
600 iTextCursor.iColor=KRgbCyan;
601 iWin->SetTextCursor(originalCursorPos, iTextCursor);
605 // unknown type of test being requested
608 iWin->DrawFirstHalf();
612 * Re-direct drawing to another Front Buffer. Whilst re-directed, change the
613 * position of the text cursor. Then pause 0.5 seconds because this is how
614 * long it will take to enter the next phase in the flashing cycle. Finally
615 * stop re-directing. We exit the re-direction in a different point in the
616 * phase of the text cursor from when we entered it.
617 * This is key to testing for faulty behaviour.
622 User::After(KCursorFlashPeriod * 2); // so its easy to visually review progress
623 iRedir->Redirect(CWsRedir::EFrontBuffer, ETrue);
624 iWin->SetTextCursor(newCursorPos, iTextCursor);
625 User::After(KWaitForNextFlashPhase);
626 iRedir->Redirect(CWsRedir::EFrontBuffer, EFalse);
630 * Paint the right hand side of the screen which should now have a text cursor.
635 iWin->DrawSecondHalf();
639 * Let the cursor flash a few times, as it assists manual viewing of the progress
645 User::After(KCursorFlashPeriod * 3);
649 * Check to see if the text cursor did move to the right of the screen.
655 /* When we do a screen comparison, we supply flag 0, which means
656 * don't include the text cursor. We do this because we are interested
657 * in screen artefacts.
659 TEST(TheClient->iScreen->RectCompare(
660 TRect(originalCursorPos, cursorSize),
661 TRect(cleanReferencePos, cursorSize),
662 0)); // must not supply CWsScreenDevice::EIncludeTextCursor
670 iWin->CancelTextCursor();
680 @SYMTestCaseID GRAPHICS-WSERV-0375
682 @SYMTestCaseDesc Redirect wserv flickerfree drawing to custom graphics context
683 @SYMTestPriority Medium
684 @SYMTestStatus Implemented
685 @SYMTestActions Redirect wserv flickerfree buffer drawing.
687 -Draw opaque window (as background) and transparent window
688 -Save screen content to a bitmap
689 -Instruct plugin to redirect wserv flickerfree buffer drawing
690 -Draw the same opaque window and transparent window again
691 -Retrieve plugin bitmap and compare against the saved bitmap
692 @SYMTestExpectedResults Bitmap content match
695 @SYMTestCaseID GRAPHICS-WSERV-0376
697 @SYMTestCaseDesc Stop wserv flickerfree drawing redirection
698 @SYMTestPriority Medium
699 @SYMTestStatus Implemented
700 @SYMTestActions Stop wserv flickerfree buffer drawing redirection.
702 -Instruct plugin to stop wserv filckerfree drawing redirection
703 -Draw the same opaque and transparent window
704 -Save screen content to another bitmap
705 -Compare saved bitmap against newly saved bitmap
706 @SYMTestExpectedResults Bitmap content match
709 TestState CTWsGraphs::TestFlickerRedirectionL()
711 if (TransparencySupportedL()==KErrNotSupported)
717 // flush transparent window destruction created in TransparencySupportedL before
718 // proceeding with the test
720 TheClient->iWs.Flush();
724 _LIT(KTestFlickerRedirection, "TestFlickerRedirection");
725 INFO_PRINTF1(KTestFlickerRedirection);
730 CreateAlphaWindowL();
731 TheClient->iScreen->CopyScreenToBitmap(iBefore);
732 DestroyAlphaWindowL();
734 iRedir->Redirect(CWsRedir::EBackBuffer, ETrue);
742 CreateAlphaWindowL();
743 TSize sz = iBefore->SizeInPixels();
744 TInt bytes = sz.iWidth*sz.iHeight*2; // EColor64K
746 TInt ret=Mem::Compare((const TUint8*)iBackCopy->DataAddress(),bytes,(const TUint8*)iBefore->DataAddress(),bytes);
750 _LIT(KLog,"The memory of two bitmaps doesn't match");
753 iBefore->UnlockHeap();
754 DestroyAlphaWindowL();
756 iRedir->Redirect(CWsRedir::EBackBuffer, EFalse);
761 CreateAlphaWindowL();
762 TheClient->iScreen->CopyScreenToBitmap(iAfter);
763 TSize sz = iBefore->SizeInPixels();
764 TInt bytes = sz.iWidth*sz.iHeight*2; // EColor64K
766 TEST(Mem::Compare((const TUint8*)iAfter->DataAddress(),bytes,(const TUint8*)iBefore->DataAddress(),bytes)==0);
767 iAfter->UnlockHeap();
768 DestroyAlphaWindowL();
776 #endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
779 @SYMTestCaseID GRAPHICS-WSERV-0377
781 @SYMTestCaseDesc Enable event notification
782 @SYMTestPriority Medium
783 @SYMTestStatus Implemented
784 @SYMTestActions Enable plugin to register to event notification.
786 -Instruct plugin to register event handler
787 -Draw fullscreen window (plugin will receive window visibility changed event)
788 -Query visibility region from plugin side
789 -Compare window visible region against value obtained by plugin
790 @SYMTestExpectedResults Visible region match
793 @SYMTestCaseID GRAPHICS-WSERV-0378
795 @SYMTestCaseDesc Disable event notification
796 @SYMTestPriority Medium
797 @SYMTestStatus Implemented
798 @SYMTestActions Disable plugin to register to event notification.
800 -Instruct plugin to unregister event handler
801 -Destroy fullscreen window (plugin will not receive window visibility changed event)
802 -Query visibility region from plugin side
804 @SYMTestExpectedResults Plugin does not receive events notification
806 TestState CTWsGraphs::TestEventNotificationL()
810 _LIT(KTestEventNotification, "TestEventNotification");
811 INFO_PRINTF1(KTestEventNotification);
814 iListen->Enable(ETrue);
816 Mem::FillZ(&iListenInfo, sizeof(TListenerInfo));
817 TheClient->iWs.Finish();
818 TheClient->WaitForRedrawsToFinish();
819 iListen->QueryPlugin(iListenInfo);
826 iListen->Enable(EFalse);
827 TEST(iListenInfo.iNumRect==1);
828 TEST(iListenInfo.iRect==TRect(TPoint(0,0),TheClient->iScreen->SizeInPixels()));
830 Mem::FillZ(&iListenInfo, sizeof(TListenerInfo));
831 iListen->QueryPlugin(iListenInfo);
832 iListen->Enable(EFalse);
837 TEST(iListenInfo.iNumRect==0);
844 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
846 TestState CTWsGraphs::TestRedirectionUsingWsBackBufferL()
848 if (TransparencySupportedL()==KErrNotSupported)
854 // flush transparent window destruction created in TransparencySupportedL before
855 // proceeding with the test
857 TheClient->iWs.Flush();
861 _LIT(KTestRedirectionWsBack, "TestRedirectionUsingWsBackBuffer");
862 INFO_PRINTF1(KTestRedirectionWsBack);
867 @SYMTestCaseID GRAPHICS-WSERV-0379
868 @SYMTestCaseDesc Redirect wserv flickerfree to MWsBackBuffer object
869 @SYMTestPriority Medium
870 @SYMTestStatus Implemented
871 @SYMTestActions -Draw opaque window (as background) and transparent window
872 -Save screen content to a bitmap
873 -Instruct plugin to redirect flickerfree buffer to MWsBackBuffer object
874 -Draw the same opaque window and transparent window again
875 -Retrieve plugin bitmap and compare against the saved bitmap
876 @SYMTestExpectedResults Bitmap content match
878 ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0379"));
880 CreateAlphaWindowL();
881 TheClient->iScreen->CopyScreenToBitmap(iBefore);
882 DestroyAlphaWindowL();
884 iRedir->RedirectUsingWsBackBuffer(ETrue);
892 CreateAlphaWindowL();
893 TSize sz = iBefore->SizeInPixels();
894 TInt bytes = sz.iWidth*sz.iHeight*2; // EColor64K
896 TInt ret=Mem::Compare((const TUint8*)iBackCopy->DataAddress(),bytes,(const TUint8*)iBefore->DataAddress(),bytes);
900 _LIT(KLog,"The memory of two bitmaps doesn't match");
903 iBefore->UnlockHeap();
904 DestroyAlphaWindowL();
908 @SYMTestCaseID GRAPHICS-WSERV-0380
909 @SYMTestCaseDesc Restore wserv flickerfree redirection from MWsBackBuffer object
910 @SYMTestPriority Medium
911 @SYMTestStatus Implemented
912 @SYMTestActions -Instruct plugin to stop wserv filckerfree drawing redirection
913 -Draw the same opaque and transparent window
914 -Save screen content to another bitmap
915 -Compare saved bitmap against newly saved bitmap
916 @SYMTestExpectedResults Bitmap content match
918 ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0380"));
919 iRedir->RedirectUsingWsBackBuffer(EFalse);
924 CreateAlphaWindowL();
925 TheClient->iScreen->CopyScreenToBitmap(iAfter);
926 TSize sz = iBefore->SizeInPixels();
927 TInt bytes = sz.iWidth*sz.iHeight*2; // EColor64K
929 TEST(Mem::Compare((const TUint8*)iAfter->DataAddress(),bytes,(const TUint8*)iBefore->DataAddress(),bytes)==0);
930 iAfter->UnlockHeap();
931 DestroyAlphaWindowL();
934 @SYMTestCaseID GRAPHICS-WSERV-0527
936 ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0527"));
942 #endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
944 //A call to do coverage through a plugin.
945 //This can serve as a basis for future coverage to objects exposed by the
946 //plugin. For now a single simple test is implmeneted.
947 TestState CTWsGraphs::TestGraphicDrawerCoverage()
949 __ASSERT_ALWAYS(iGdCoverage->RunTest(1)==KErrNone||KErrNotReady, User::Invariant());
953 //Simplified non-functional class to create a few dummy CWsGraphicDrawer instances.
954 //This code is intended to test the Array class, not the Drawer.
955 //Note that this object is not at all functional! The only guaranteed method is Id().
956 //WsGraphicDrawer is declared as a friend and is actually intended to be the factory class for CWsGraphicDrawer
957 class WsGraphicDrawer:public CWsGraphicDrawer
963 //stub for virtual construction. Most members are ignored
964 virtual void ConstructL(MWsGraphicDrawerEnvironment& ,const TGraphicDrawerId& id,MWsClient& ,const TDesC8& )
968 //simplified custom construction
969 void ConstructL(const TGraphicDrawerId& id)
971 MWsGraphicDrawerEnvironment* nullEnv=NULL;
972 MWsGraphicDrawerEnvironment& aEnv=*nullEnv;
973 MWsClient* nullClient=NULL;
974 MWsClient& aOwner=*nullClient;
975 this->BaseConstructL(aEnv,id,aOwner);
976 this->iDtor_ID_Key=TUid::Null();
979 //stubs for pure virtual methods
980 virtual void HandleMessage(const TDesC8& )
982 virtual void DoDraw(MWsGc& ,const TRect& ,const TDesC8& ) const
986 //Class to allow me to pre-allocate the CWsGraphicDrawerArray so it doesn't pop up a false-positive memory allocation!
987 class DummyCleanup:public TCleanupItem
990 static void CleanUp(TAny*) {}
991 DummyCleanup(): TCleanupItem(CleanUp,this) {}
992 operator DummyCleanup*() { return this; }
996 //Helper function to explain test fails. Most other tests are against KErrNone
997 void CTWsGraphs::ReportNegativeResultfail(TInt aLine,TInt aResult,TInt aExpectedResult)
999 testBooleanTrue((aResult==aExpectedResult), (TText8*)__FILE__, aLine);
1000 if (aResult!=aExpectedResult)
1002 INFO_PRINTF3(_L("Expected return code %i, got %i"),aExpectedResult,aResult);
1007 //This is an attempt to use wserv test's pre-existing Panic handler to perform some negative tests.
1008 //At present this handler appears to be broken:
1009 // 1) It doesn't write to the correct html log file
1010 // 2) It no longer writes to the WSERV.LOG file it was writing to a few versions ago
1011 // 3) It doesn't close the panic window so subsequent tests that check the display output fail.
1012 //That was a waste of effort.
1013 struct CTWsGraphs::WrapTestCall
1015 CTWsGraphs* thisThis;
1017 TBool continueTests;
1018 TUint testFailedLine;
1019 //This field was intended to allow threaded panicing tests to report other errors
1020 //As I can't get threaded panicing tests to operate correctly, I have not implemented support for the field.
1021 //TBuf<1024> errorMessages;
1023 WrapTestCall ( CTWsGraphs* thisThis, TUint testCount):
1024 thisThis(thisThis), testCount(testCount)
1025 { continueTests=false;testFailedLine=0; }
1028 TInt CTWsGraphs::DoNegTestCall(TInt /*aInt*/, TAny *aPtr)
1030 CTWsGraphs::WrapTestCall* aWrap=static_cast<CTWsGraphs::WrapTestCall*>(aPtr);
1031 aWrap->continueTests=aWrap->thisThis->NegTestAddSwapGDArrayL(aWrap->testCount,aWrap);
1035 TBool CTWsGraphs::LaunchNegTestCall(TUint aTestCount,TUint PanicCode,const TDesC &aPanicCategory)
1037 WrapTestCall wt(this,aTestCount);
1039 (void)aPanicCategory;
1040 //I have disabled the panicing tests because they don't output diagnostics
1041 //and the open panic window causes subsequent screen bitmap comparrisson tests to fail.
1042 // iTest->TestPanicL(DoNegTestCall,aPanicCode,3,&wt,aPanicCategory);
1043 return wt.continueTests;
1047 Loops through all the positive and negative tests associated with the GraphicDrawerArray.
1048 The aim is to perform isolated testing of these classes as some are not currently being used.
1051 void CTWsGraphs::TestAddSwapGDArrayL()
1055 INFO_PRINTF1(_L("Positive tests for GraphicDrawerArray"));
1056 for (TInt i=0;PosTestAddSwapGDArrayL(i);i++)
1061 INFO_PRINTF1(_L("Verifying that negative tests for GraphicDrawerArray don't actually panic"));
1062 for (TInt i=1;NegTestAddSwapGDArrayL(i);i++)
1066 Resets and deallocates the GDA withoud deleting the objects.
1067 @param testArray the array to reset
1068 @return true if the array was already empty.
1070 static bool ResetArray(CWsGraphicDrawerArray& testArray)
1072 bool rv=(testArray.IsEmpty());
1073 MWsClient* nullClient=NULL;
1074 testArray.RemoveAll(*nullClient);
1075 testArray.ResetAndDestroy();
1079 @SYMTestCaseID GRAPHICS-WSERV-AddSwapGDArray-0001
1082 @SYMTestCaseDesc DEF093926: Check for stability of Add and Swap unwind methods in isolation.
1083 Note that this code is testing the functionality of a class internal to CWindowServer.
1084 At present CWindowServer presents just a simple shim on this class,
1085 but if that implementation of CWindowServer changes than this test will be redudant.
1087 @SYMTestPriority High
1089 @SYMTestStatus Implemented
1092 The sequence for each of these positive test sections is pretty much the same:
1093 Add one record with id 1234(test for errors)
1094 Add one record with id Badf00d
1095 Swap with another record with id Badf00d
1099 Add/Swap: no Cleanup item - no leaks after Remove the added items
1100 AddTLC/SwapTLC: Cleanup item requires Commit - check for no leaks after Remove.
1101 AddTLC/SwapTLC: Cleanup item gets executed by forced Leave - check for no leaks after.
1102 AddTLC, SwapTLC in allocation failure scenarios. Add/Swap don't allocate anything!
1103 obsoleted AddLC/SwapLC to ensure correct function when forced Leave - check for no leaks after
1104 obsoleted AddLC/SwapLC to ensure correct function. These will always leak in good case.
1105 @SYMTestExpectedResults
1106 no exceptions or panics within this fn.
1107 only the old AddLC and SwapLC should leak as indicated.
1109 TBool CTWsGraphs::PosTestAddSwapGDArrayL(TInt testcase)
1111 ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-AddSwapGDArray-0001"));
1112 CWsGraphicDrawerArray testArray;
1113 //Represents the memory cached in the array once it has been used even when it is then resized to zero
1115 const TInt KArrayMemUseBaseline=1;
1117 //Use testArray.IsEmpty() to prove the array is clear when it should be!
1118 TGraphicDrawerId id1234= { 1234, EFalse };
1119 TGraphicDrawerId idBADF00D= { 0xBADF00D, EFalse };
1120 WsGraphicDrawer dg1234;
1121 dg1234.ConstructL(id1234);
1122 WsGraphicDrawer dgBADF00D;
1123 dgBADF00D.ConstructL(idBADF00D);
1124 WsGraphicDrawer dgBADF00D_2;
1125 dgBADF00D_2.ConstructL(idBADF00D);
1126 CWsGraphicDrawerArray::XRollBackBase* rollBack1;
1127 TInt errCode=KErrAbort;
1128 TInt leaveCode=KErrNone;
1129 DummyCleanup markerCleanup;
1130 CleanupStack::PushL(markerCleanup); //This allows me to check the stack is clear!
1131 //expected result of this fn: no exceptions or panics.
1132 //Put as much as you like in here, so long as it shouldn't fail.
1136 TUint expectedLeakCount=0;
1137 TBool returnCode=ETrue;
1142 INFO_PRINTF1(_L("Sub test P0: AddL/Swap: no Cleanup item"));
1143 TEST(testArray.IsEmpty());
1144 TRAP(leaveCode,errCode=testArray.Add(&dg1234));
1145 TEST(errCode==KErrNone);
1146 TEST(leaveCode==KErrNone);
1147 TEST(!testArray.IsEmpty());
1148 TRAP(leaveCode,errCode=testArray.Add(&dgBADF00D));
1149 TEST(errCode==KErrNone);
1150 TEST(leaveCode==KErrNone);
1151 TRAP(leaveCode,errCode=testArray.Swap(&dgBADF00D_2));
1152 TEST(errCode==KErrNone);
1153 TEST(leaveCode==KErrNone);
1154 TRAP(leaveCode,errCode=testArray.Remove(dg1234.Id()));
1155 TEST(errCode==KErrNone);
1156 TEST(leaveCode==KErrNone);
1157 //Note that it is the ID that matters here... dgBADF00D & dgBADF00D_2 have same id.
1158 TRAP(leaveCode,errCode=testArray.Remove(dgBADF00D_2.Id()));
1159 TEST(errCode==KErrNone);
1160 TEST(leaveCode==KErrNone);
1161 TEST(testArray.IsEmpty());
1165 INFO_PRINTF1(_L("Sub test P1: AddTLC/SwapTLC: Cleanup item requires Commit."));
1168 TEST(testArray.IsEmpty());
1170 rollBack1=testArray.AddTLC(&dg1234);
1171 CleanupStack::Check(rollBack1);
1172 testArray.CommitP(rollBack1);
1174 TEST(rollBack1!=NULL);
1175 TEST(leaveCode==KErrNone);
1176 TEST(!testArray.IsEmpty());
1179 rollBack1=testArray.AddTLC(&dgBADF00D);
1180 CleanupStack::Check(rollBack1);
1181 testArray.CommitP(rollBack1);
1183 TEST(rollBack1!=NULL);
1184 TEST(leaveCode==KErrNone);
1187 rollBack1=testArray.SwapTLC(&dgBADF00D_2);
1188 CleanupStack::Check(rollBack1);
1189 testArray.CommitP(rollBack1);
1191 TEST(rollBack1!=NULL);
1192 TEST(leaveCode==KErrNone);
1195 rollBack1=testArray.RemoveTLC(dg1234.Id());
1196 CleanupStack::Check(rollBack1);
1197 testArray.CommitP(rollBack1);
1199 TEST(rollBack1!=NULL);
1200 TEST(leaveCode==KErrNone);
1203 rollBack1=testArray.RemoveTLC(dgBADF00D_2.Id());
1204 CleanupStack::Check(rollBack1);
1205 testArray.CommitP(rollBack1);
1207 TEST(rollBack1!=NULL);
1208 TEST(leaveCode==KErrNone);
1210 TEST(testArray.IsEmpty());
1214 INFO_PRINTF1(_L("Sub test P2: AddTLC/SwapTLC: Cleanup item gets executed."));
1217 TEST(testArray.IsEmpty());
1219 rollBack1=testArray.AddTLC(&dg1234);
1222 TEST(rollBack1!=NULL);
1223 TEST(leaveCode==1234);
1224 TEST(testArray.IsEmpty());
1226 CleanupStack::Check(markerCleanup);
1227 __UHEAP_CHECK(KArrayMemUseBaseline);
1229 TRAP(leaveCode, errCode=testArray.Add(&dgBADF00D));
1230 TEST(errCode==KErrNone);
1231 TEST(leaveCode==KErrNone);
1234 rollBack1=testArray.SwapTLC(&dgBADF00D_2);
1237 TEST(rollBack1!=NULL);
1238 TEST(leaveCode==1234);
1239 TEST(!testArray.IsEmpty());
1242 rollBack1=testArray.RemoveTLC(dgBADF00D_2.Id());
1243 TEST(testArray.IsEmpty());
1246 TEST(rollBack1!=NULL);
1247 TEST(leaveCode==1234);
1248 TEST(!testArray.IsEmpty());
1251 TRAP(leaveCode,errCode=testArray.Remove(dgBADF00D_2.Id()));
1252 TEST(errCode==KErrNone);
1253 TEST(leaveCode==KErrNone);
1254 TEST(testArray.IsEmpty());
1259 INFO_PRINTF1(_L("Sub test P3: AddLC/SwapLC: Cleanup item gets executed - doesn't leak"));
1260 TEST(testArray.IsEmpty());
1262 testArray.AddLC(&dg1234);
1265 TEST(leaveCode==1234);
1266 TEST(testArray.IsEmpty());
1268 __UHEAP_CHECK(KArrayMemUseBaseline); //because it threw it didn't leak
1270 //use my new method to add the object to be swapped out so no leak
1271 TRAP(leaveCode,errCode=testArray.Add(&dgBADF00D));
1272 TEST(errCode==KErrNone);
1273 TEST(leaveCode==KErrNone);
1274 __UHEAP_CHECK(KArrayMemUseBaseline); //new method doesn't leak.
1277 errCode=testArray.SwapLC(&dgBADF00D_2);
1280 TEST(errCode==KErrNone);
1281 TEST(leaveCode==1234);
1282 TEST(!testArray.IsEmpty());
1284 TRAP(leaveCode,errCode=testArray.Remove(dgBADF00D_2.Id()));
1285 TEST(errCode==KErrNone);
1286 TEST(leaveCode==KErrNone);
1287 TEST(testArray.IsEmpty());
1293 //I don't really care whether the individual calls succeed or fail,
1294 //just whether it leaks overall, and that the error codes correspond to no-action
1295 for (TInt faultRate=1;faultRate<5;faultRate++)
1297 INFO_PRINTF2(_L("Sub test P4: Add/Swap: memory faulting %i"),faultRate);
1298 __UHEAP_SETFAIL(RAllocator::EDeterministic,faultRate);
1302 errCode=testArray.Add(&dg1234);
1305 __UHEAP_SETFAIL(RAllocator::ENone,0);
1306 TRAP(leaveCode,errCode=testArray.Add(&dgBADF00D));
1307 __UHEAP_SETFAIL(RAllocator::EDeterministic,faultRate);
1310 errCode=testArray.Swap(&dgBADF00D_2);
1312 __UHEAP_SETFAIL(RAllocator::ENone,0);
1313 //If the first Add fails then the object should not be removed
1316 TRAP(leaveCode,errCode=testArray.Remove(dg1234.Id()));
1317 TEST(errCode==KErrNone);
1318 TEST(leaveCode==KErrNone);
1320 //If the swap fails, then the add still needs to be removed
1321 //Note that it is the ID that matters here... dgBADF00D & dgBADF00D_2 have same id.
1322 TRAP(leaveCode,errCode=testArray.Remove(dgBADF00D_2.Id()));
1323 TEST(errCode==KErrNone);
1324 TEST(leaveCode==KErrNone);
1325 TEST(testArray.IsEmpty());
1326 ResetArray(testArray);
1327 CleanupStack::Check(markerCleanup);
1334 //I don't really care whether the individual calls succeed or fail,
1335 //just whether it leaks overall, and that the error codes correspond to no-action
1336 for (TInt faultRate=1;faultRate<5;faultRate++)
1338 INFO_PRINTF2(_L("Sub test P5: AddTLC/SwapTLC: memory faulting %i"),faultRate);
1339 __UHEAP_SETFAIL(RAllocator::EDeterministic,faultRate);
1340 TInt err1=KErrNone,err2=KErrNone,err3=KErrNone;
1343 rollBack1=testArray.AddTLC(&dg1234);
1344 CleanupStack::Check(rollBack1);
1345 testArray.CommitP(rollBack1);
1348 __UHEAP_SETFAIL(RAllocator::ENone,0);
1349 TRAP(leaveCode,errCode=testArray.Add(&dgBADF00D));
1350 __UHEAP_SETFAIL(RAllocator::EDeterministic,faultRate);
1353 rollBack1=testArray.SwapTLC(&dgBADF00D_2);
1354 CleanupStack::Check(rollBack1);
1355 testArray.CommitP(rollBack1);
1357 //If the first Add fails then the object should not be removed
1361 rollBack1=testArray.RemoveTLC(dg1234.Id());
1362 CleanupStack::Check(rollBack1);
1363 testArray.CommitP(rollBack1);
1367 //If the swap fails, then the add still needs to be removed
1368 //Note that it is the ID that matters here... dgBADF00D & dgBADF00D_2 have same id.
1370 rollBack1=testArray.RemoveTLC(dgBADF00D_2.Id());
1371 CleanupStack::Check(rollBack1);
1372 testArray.CommitP(rollBack1);
1377 __UHEAP_SETFAIL(RAllocator::ENone,0);
1378 //If the Removes failed then the object should be removed again
1381 TRAP(leaveCode,errCode=testArray.Remove(dg1234.Id()));
1382 TEST(errCode==KErrNone);
1383 TEST(leaveCode==KErrNone);
1387 TRAP(leaveCode,errCode=testArray.Remove(dgBADF00D_2.Id()));
1388 TEST(errCode==KErrNone);
1389 TEST(leaveCode==KErrNone);
1391 TEST(testArray.IsEmpty());
1392 ResetArray(testArray);
1393 CleanupStack::Check(markerCleanup);
1400 //this set does leak:
1402 INFO_PRINTF1(_L("Sub test P6: AddLC/SwapLC: Cleanup item gets popped - unfixable leaks"));
1403 TEST(testArray.IsEmpty());
1405 testArray.AddLC(&dg1234);
1406 CleanupStack::Pop();
1408 TEST(leaveCode==KErrNone);
1409 TEST(!testArray.IsEmpty());
1411 CleanupStack::Check(markerCleanup);
1412 __UHEAP_CHECK(KArrayMemUseBaseline+1);
1415 testArray.AddLC(&dgBADF00D);
1416 CleanupStack::Pop();
1418 TEST(leaveCode==KErrNone);
1419 CleanupStack::Check(markerCleanup);
1420 __UHEAP_CHECK(KArrayMemUseBaseline+2);
1423 errCode=testArray.SwapLC(&dgBADF00D_2);
1424 CleanupStack::Pop();
1426 TEST(errCode==KErrNone);
1427 TEST(leaveCode==KErrNone);
1428 TEST(!testArray.IsEmpty());
1429 TRAP(leaveCode,errCode=testArray.Remove(dg1234.Id()));
1430 TEST(errCode==KErrNone);
1431 TEST(leaveCode==KErrNone);
1432 TRAP(leaveCode,errCode=testArray.Remove(dgBADF00D_2.Id()));
1433 TEST(errCode==KErrNone);
1434 TEST(leaveCode==KErrNone);
1435 TEST(testArray.IsEmpty());
1437 expectedLeakCount=3;
1444 ResetArray(testArray);
1445 CleanupStack::Check(markerCleanup);
1446 __UHEAP_CHECK(expectedLeakCount);
1447 __UHEAP_MARKENDC(expectedLeakCount);
1448 if (expectedLeakCount!=0)
1449 { //Ensure that the leaked items are no longer associated with this debug level.
1450 //Note that __DbgSetAllocFail(FALSE,RAllocator::EReset,1) resets the debug level to 0,
1451 //so levels can't be nested when using this call.
1453 __UHEAP_TOTAL_RESET;
1454 INFO_PRINTF2(_L("Anticipated %i leaks declassified"),expectedLeakCount); //can't get here if wrong
1457 CleanupStack::PopAndDestroy(markerCleanup);
1458 ((CTWsGraphsStep*)iStep)->RecordTestResultL();
1463 @param failcase index to test to perform
1464 @param aWrappedParams represents inter-thread information when test is run on a private thread
1465 if aWrappedParams is NULL then the test is running on the main thread.
1466 @return true if there are higher-numbered fail cases.
1468 @SYMTestCaseID GRAPHICS-WSERV-NegAddSwapGDArray-0001
1471 @SYMTestCaseDesc DEF093926: Check for stability of Add and Swap unwind methods in isolation,
1472 specifically checking that bad inputs are rejected gracefully.
1473 Note that this code is testing the functionality of a class internal to CWindowServer.
1474 At present CWindowServer presents just a simple shim on this class,
1475 but if that implementation of CWindowServer changes than this test will be redudant.
1477 @SYMTestPriority High
1479 @SYMTestStatus Implemented
1483 Add/Swap: no Cleanup item - no leaks after Remove the added items
1484 AddTLC/SwapTLC: Cleanup item requires Commit - check for no leaks after Remove.
1485 AddTLC/SwapTLC: Cleanup item gets executed by forced Leave - check for no leaks after.
1486 AddTLC, SwapTLC in allocation failure scenarios. Add/Swap don't allocate anything!
1487 obsoleted AddLC/SwapLC to ensure correct function when forced Leave - check for no leaks after
1488 obsoleted AddLC/SwapLC to ensure correct function. These will always leak in good case.
1489 Calls NegTestAddSwapGDArrayL.
1490 case 1/2/3: Tests AddL, AddLC, AddTLC that a NULL input is rejected
1491 case 4/5/6: Tests SwapL, SwapLC, SwapTLC that a NULL input is rejected
1492 case 7/8/9: Tests AddL, AddLC, AddTLC that a repeat input is rejected
1493 case 10/11/12: Tests SwapL, SwapLC, SwapTLC that a non-repeat input is rejected
1494 @SYMTestExpectedResults
1496 TBool CTWsGraphs::NegTestAddSwapGDArrayL(TInt failcase,WrapTestCall*aWrappedParams)
1498 ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-NegAddSwapGDArray-0001"));
1499 _LIT(KCategory,"WsGraphicDrawer");
1500 if (!aWrappedParams)
1502 INFO_PRINTF2(_L("NegTestAddSwapGDArrayL Negative sub test %i"),failcase);
1504 CWsGraphicDrawerArray testArray;
1505 TGraphicDrawerId id1234= { 1234, EFalse };
1506 TGraphicDrawerId idBADF00D= { 0xBADF00D, EFalse };
1507 WsGraphicDrawer dg1234;
1508 dg1234.ConstructL(id1234);
1509 WsGraphicDrawer dgBADF00D;
1510 dgBADF00D.ConstructL(idBADF00D);
1511 WsGraphicDrawer dgBADF00D_2;
1512 dgBADF00D_2.ConstructL(idBADF00D);
1513 CWsGraphicDrawerArray::XRollBackBase* rollBack1=NULL;
1514 TInt errCode=KErrAbort;
1515 TInt leaveCode=KErrNone;
1516 TBool returnMoreTests=ETrue;
1517 DummyCleanup markerCleanup;
1518 TBool mayPanic=EFalse;
1523 CleanupStack::PushL(markerCleanup); //This allows me to check the stack is clear!
1528 case 1: //NULL arg: expected result: returns KErrArgument
1530 errCode=testArray.Add(NULL);
1532 TEST(leaveCode==KErrNone);
1533 ReportNegativeResultfail(__LINE__,errCode,KErrArgument);
1535 case 2: //NULL arg: expected result: throws KErrArgument
1537 rollBack1=testArray.AddTLC(NULL);
1538 TEST(EFalse); //Should never get here!
1540 TEST(rollBack1==NULL);
1541 ReportNegativeResultfail(__LINE__,leaveCode,KErrArgument);
1543 case 3: //NULL arg: expected result: debug: panic. In release doesn't return any information!
1544 if (!aWrappedParams && mayPanic)
1546 LaunchNegTestCall(failcase,EWsGraphicDrawerPanicBadArgument,KCategory);
1551 testArray.AddLC(NULL);
1552 User::Leave(1234); //Panics before here in debug. No leak if cleanup is taken.
1554 TEST(leaveCode==1234); //Panics before here in debug
1558 case 4: //NULL arg: expected result: returns KErrArgument
1560 errCode=testArray.Swap(NULL)
1562 TEST(leaveCode==KErrNone);
1563 ReportNegativeResultfail(__LINE__,errCode,KErrArgument);
1565 case 5: //expected result: throws KErrArgument
1567 rollBack1=testArray.SwapTLC(NULL);
1568 testArray.CommitP(rollBack1);
1570 TEST(rollBack1==NULL);
1571 ReportNegativeResultfail(__LINE__,leaveCode,KErrArgument);
1573 case 6: //NULL arg: expected result: debug: panic. In release doesn't return any information!
1574 if (!aWrappedParams && mayPanic)
1576 LaunchNegTestCall(failcase,EWsGraphicDrawerPanicBadArgument,KCategory);
1581 errCode=testArray.SwapLC(NULL);
1582 User::Leave(1234); //Panics before here in debug. No leak if cleanup is taken.
1584 TEST(leaveCode==1234); //Panics before here in debug
1585 TEST(errCode==KErrNotFound);
1589 case 7: //Add overwrites: expected result: returns KErrAlreadyExists
1591 errCode=testArray.Add(&dg1234);
1593 TEST(errCode==KErrNone);
1594 TEST(leaveCode==KErrNone);
1596 errCode=testArray.Add(&dg1234); //oops! Already added!
1598 TEST(leaveCode==KErrNone);
1599 ReportNegativeResultfail(__LINE__,errCode,KErrAlreadyExists);
1601 case 8: //Add overwrites: expected result: throws KErrAlreadyExists
1603 errCode=testArray.Add(&dg1234);
1605 TEST(errCode==KErrNone);
1606 TEST(leaveCode==KErrNone);
1608 rollBack1=testArray.AddTLC(&dg1234); //oops! Already added!
1609 testArray.CommitP(rollBack1);
1611 TEST(rollBack1==NULL);
1612 ReportNegativeResultfail(__LINE__,leaveCode,KErrAlreadyExists);
1614 case 9: //Add overwrites: expected result: debug: does not panic, but throws KErrAlreadyExists.
1616 errCode=testArray.Add(&dg1234);
1618 TEST(errCode==KErrNone);
1619 TEST(leaveCode==KErrNone);
1621 testArray.AddLC(&dg1234); //oops! Already added! Should leave.
1622 User::Leave(1234); //Should leave before here! No leak if cleanup is taken.
1624 ReportNegativeResultfail(__LINE__,leaveCode,KErrAlreadyExists);
1627 case 10: //Swap empty slot: expected result: returns KErrNotFound
1629 errCode=testArray.Swap(&dg1234) //oops! Nothing to swap with!
1631 TEST(leaveCode==KErrNone);
1632 ReportNegativeResultfail(__LINE__,errCode,KErrNotFound);
1634 case 11: //Swap empty slot: expected result: throws KErrNotFound
1636 rollBack1=testArray.SwapTLC(&dg1234); //oops! Nothing to swap with!
1637 testArray.CommitP(rollBack1);
1639 TEST(rollBack1==NULL);
1640 ReportNegativeResultfail(__LINE__,leaveCode,KErrNotFound);
1642 case 12: //Swap empty slot: expected result: debug: panic. In release doesn't return any information!
1643 if (!aWrappedParams && mayPanic)
1645 LaunchNegTestCall(failcase,EWsGraphicDrawerPanicBadArgument,KCategory);
1650 errCode=testArray.SwapLC(&dg1234); //oops! Nothing to swap with!
1651 User::Leave(1234); //Panics before here in debug. No leak if cleanup is taken.
1653 TEST(leaveCode==1234); //Panics before here in debug
1654 TEST(errCode==KErrNotFound); //Panics before here in debug
1660 returnMoreTests=EFalse;
1662 ResetArray(testArray);
1663 CleanupStack::Check(markerCleanup);
1665 __UHEAP_MARKENDC(0);
1667 // CWsGraphicDrawerArray::testArrayValidator::ResetArray(&testArray);
1668 CleanupStack::PopAndDestroy(markerCleanup);
1669 return returnMoreTests;
1673 @SYMTestCaseID GRAPHICS-WSERV-LeakInService-0001
1675 @SYMTestCaseDesc Check for leaks over repeated re-assignments.
1677 @SYMTestPriority High
1679 @SYMTestStatus Implemented
1682 Repeatedly create the same bitmap instance
1683 After a few initial wobbles in the server-side HeapCount it should not increase
1684 5 calls are made without checking the level, then 5 more check the level.
1685 Note that as we are testing the main server heap,
1686 other threads may interrupt and perform operations that change the memory figures.
1688 @SYMTestExpectedResults The CWsGraphicBitmap objects are created and no leaks are reported.
1690 void CTWsGraphs::DoTestLeakInServiceL()
1692 INFO_PRINTF1(_L("DoTestLeakInServiceL"));
1693 const TInt prepCount=5;
1694 const TInt testCount=5;
1697 TUid uid1 = {0x10000001};
1698 TUid uid2 = {0x10000002};
1700 TWsGraphicId twsGraphicId1(uid1);
1701 TEST(twsGraphicId1.Uid()==uid1);
1703 TWsGraphicId twsGraphicId2(uid2);
1704 TEST(twsGraphicId2.Uid()==uid2);
1706 TWsGraphicId twsGraphicId3(twsGraphicId2);
1707 TEST(twsGraphicId3.Uid()==uid2);
1709 TWsGraphicId twsGraphicId4(1);
1710 twsGraphicId4.Set(uid1);
1711 TEST(twsGraphicId4.Uid()==uid1);
1713 TSize screenSize = TheClient->iScreen->SizeInPixels();
1717 // Create local shared CWsGraphicBitmap
1718 // Repeat operation for any sign of memory leak...
1722 bitmap2.Create(screenSize,TheClient->iScreen->DisplayMode());
1723 mask2.Create(bitmap2.SizeInPixels(),TheClient->iScreen->DisplayMode());
1725 TInt c0=TheClient->iWs.HeapCount();
1726 CWsGraphicBitmap* bTestX = CWsGraphicBitmap::NewL(twsGraphicId2.Uid(), &bitmap2,&mask2);
1727 for (TInt i=0;i<prepCount;i++)
1729 //TInt c2=TheClient->iWs.HeapCount();
1731 //TInt c3=TheClient->iWs.HeapCount();
1732 bTestX = CWsGraphicBitmap::NewL(twsGraphicId2.Uid(), &bitmap2,&mask2);
1733 //TInt c4=TheClient->iWs.HeapCount();
1735 // Give WSERV a chance to settle.
1736 TheClient->iWs.Finish();
1737 User::After (1000000); //1s
1739 TInt c1=TheClient->iWs.HeapCount();
1741 for (TInt i=0;i<testCount;i++)
1743 TInt c2=TheClient->iWs.HeapCount();
1745 //TInt c3=TheClient->iWs.HeapCount();
1746 //The heap count doesn't go down after delete operation
1747 //because the delete message is buffered by the server, because it does not have a return value.
1748 //Aparrently, although CWsGraphicBitmap and TheClient terminate at the same server,
1749 //and use the same general heap (I have tested this under debug),
1750 //they do not share the same session, so flushing TheClient does not effect CWsGraphicBitmap
1751 bTestX = CWsGraphicBitmap::NewL(twsGraphicId2.Uid(), &bitmap2,&mask2);
1753 // Give WSERV a chance to settle.
1754 TheClient->iWs.Finish();
1755 User::After (1000000); //1s
1757 TInt c4=TheClient->iWs.HeapCount();
1758 //Can compare immediately after allocation as the server doesn't buffer the create command.
1761 if (c4 > c2) // only fail the test if the count has increased
1765 INFO_PRINTF2(_L("Server Heap count change accross delete/new = %i"),c4-c2);
1768 // Outside of main loop to avoid client/wserv interaction during test.
1770 TInt c5=TheClient->iWs.HeapCount();
1771 TEST((c1-c5)/testCount==0); //If every call leaked.
1772 if ((c1-c5)/testCount)
1774 INFO_PRINTF3(_L("Server Heap count change accross %i delete/new cycles = %i"),testCount,c5-c1);
1775 INFO_PRINTF3(_L("Before %i / After %i"),c1,c5);
1785 @SYMTestCaseID GRAPHICS-WSERV-0381
1787 @SYMTestCaseDesc Test case for INC098114 CWsGraphicDrawer::SendMessage panics window server
1788 @SYMTestPriority Medium
1789 @SYMTestStatus Implemented
1790 @SYMTestActions Enable the test flag and reproduce the defect
1792 -Instruct plugin to register event handler
1793 -Draw fullscreen window (plugin will receive window visibility changed event)
1795 -Query visibility region from plugin side
1796 -Instruct plugin to unregister event handler
1797 -Destroy fullscreen window (plugin will not receive window visibility changed event)
1799 @SYMTestExpectedResults wserv should not panic with the fix
1802 TestState CTWsGraphs::TestSuccessiveMessageL()
1806 _LIT(KTestSuccessiveMessage, "TestSuccessiveMessage");
1807 INFO_PRINTF1(KTestSuccessiveMessage);
1810 iListen->Enable(ETrue);
1812 Mem::FillZ(&iListenInfo, sizeof(TListenerInfo));
1813 //Set the test flag to enable the reproduction of defect
1814 iListen->SetTestFlag();
1815 iListen->QueryPlugin(iListenInfo);
1816 iListen->Enable(EFalse);
1826 TestState CTWsGraphs::TestWindowGroupChangeL()
1830 _LIT(KTestWindowGroupChange, "TestWindowGroupChange");
1831 INFO_PRINTF1(KTestWindowGroupChange);
1834 iListen->Enable(ETrue);
1836 Mem::FillZ(&iListenInfo, sizeof(TListenerInfo));
1837 iListen->QueryPlugin(iListenInfo);
1844 iOriginalWindowGroupId = iListenInfo.iWindowGroupId;
1845 iNewWin = CCrWin::NewL(iTest->iScreenNumber, ETrue);
1846 iListen->QueryPlugin(iListenInfo);
1850 TEST(iListenInfo.iWindowGroupId != iOriginalWindowGroupId);
1854 iListen->Enable(EFalse);
1862 @SYMTestCaseID GRAPHICS-WSERV-0382
1864 @SYMTestCaseDesc Test Animation frame rate
1865 @SYMTestPriority Medium
1866 @SYMTestStatus Implemented
1867 @SYMTestActions Simulate an Animation artwork by calling DrawWsGraphic and DoDraw.
1869 -Calls DrawWsGraphic for two different animations with different frame rates
1870 -Retrieve the frame count for two differnt frames per seconds
1871 -Test the two frame rate shouldn't be same.
1873 @SYMTestExpectedResults Animation Frame rate should be different for different frames per second
1875 TestState CTWsGraphs::TestFrameRateL()
1877 //Check for Transparency enabled in wsini.ini
1878 if (TransparencySupportedL()==KErrNotSupported)
1884 // flush transparent window destruction created in TransparencySupportedL before
1885 // proceeding with the test
1886 TheClient->iWs.Flush();
1888 //Here iSubState is 0, when this functions executes first time
1889 // iSubState is 1 means the call is from a callback function.
1892 _LIT(KTestFrameRate, "TestFrameRate");
1893 INFO_PRINTF1(KTestFrameRate);
1896 iTestframerate = CGraphicTestFrameRate::NewL(iTest->iScreenNumber);
1898 //Set the callback function
1899 iTestframerate->SetCallBack(TCallBack(CTWsGraphs::PluginCallBack,this));
1901 //Create the window and call the graphic animation
1902 CreateWindowL(EFalse);
1903 iWin->DrawGraphic(iTestframerate->Id().Id());
1907 //PeterI wait a while for animations to redraw then query the plugin
1908 User::After(2000000);
1909 TheClient->iWs.Flush();
1910 TheClient->WaitForRedrawsToFinish();
1911 TheClient->iWs.Finish();
1913 //Invoke the plug-in and get the counter value
1914 Mem::FillZ(&iAnimCount, sizeof(TAnimRate));
1916 iTestframerate->QueryPlugin(iAnimCount);
1917 TheClient->iWs.Flush();
1918 TheClient->WaitForRedrawsToFinish();
1919 TheClient->iWs.Finish();
1921 //Compare and test the total frame rate for two different frame counts....
1922 TEST((iAnimCount.iAnim1>0 && iAnimCount.iAnim2>0) && iAnimCount.iAnim1 !=iAnimCount.iAnim2);
1926 delete iTestframerate;
1934 @SYMTestCaseID GRAPHICS-WSERV-0438
1936 @SYMTestCaseDesc CRedrawRegion::ContainsDrawers does not look for all drawers
1937 @SYMTestPriority Medium
1938 @SYMTestStatus Implemented
1939 @SYMTestActions Create ECom-plugins to enable the scenario, in which there is one simple and one container drawer.
1940 In the container drawer, two other simple drawers are enabled. Each drawer draws a coloured ellipse.
1941 In this case, when the contained drawer is requested to change the colour of the ellipse, the screen will not be updated
1944 -Create four CRP graphics.
1945 -Call the simple drawer and container drawer to draw ellipses. The container drawer
1946 also enables two other simple drawers to draw ellipses in different colors.
1947 -Update the color of each ellipse in turn.
1948 -Check that the screen display is as required.
1949 @SYMTestExpectedResults The colour of each ellipse residing in the drawers is successfully updated. Those for the contained drawers wont be updated without the fix.
1951 void CTWsGraphs::TestNestedDrawerCRP()
1953 _LIT(KTestContainDrawer, "Test INC103472: A Contained Drawer");
1954 INFO_PRINTF1(KTestContainDrawer);
1956 RWindow window1(TheClient->iWs);
1957 CleanupClosePushL(window1);
1958 User::LeaveIfError(window1.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle));
1960 window1.EnableRedrawStore(ETrue); // Force to enable the redraw storing
1961 window1.SetRequiredDisplayMode(EColor256); // Do not set window size here to avoid hardware test failure
1962 window1.SetBackgroundColor(KRgbDarkGreen);
1966 CWsSimpleGraphicBitmap* wsGraphic1 = CWsSimpleGraphicBitmap::NewL(KSimpleDrawerInterfaceId);
1967 CleanupStack::PushL(wsGraphic1);
1968 // A container graphic
1969 CWsContainGraphicBitmap* wsGraphic2 = CWsContainGraphicBitmap::NewL(KContainDrawerInterfaceId);
1970 CleanupStack::PushL(wsGraphic2);
1971 // A contained graphic residing in the container graphic wsGraphic2
1972 CWsSimpleGraphicBitmap* wsGraphic3 = CWsInvisibleGraphicBitmap1::NewL(KInvisibleDrawerInterfaceId1);
1973 CleanupStack::PushL(wsGraphic3);
1974 // A contained graphic residing in the container graphic wsGraphic2
1975 CWsSimpleGraphicBitmap* wsGraphic4 = CWsInvisibleGraphicBitmap2::NewL(KInvisibleDrawerInterfaceId2);
1976 CleanupStack::PushL(wsGraphic4);
1978 window1.Invalidate();
1979 window1.BeginRedraw();
1980 TheClient->iGc->Activate(window1);
1981 TheClient->iGc->Clear();
1982 // Call CRP drawer to draw the coloured ellipses
1983 TheClient->iGc->DrawWsGraphic(wsGraphic1->Id(),TRect(TPoint(20,20),TSize(300,100)));
1984 TheClient->iGc->DrawWsGraphic(wsGraphic2->Id(),TRect(TPoint(20,100),TSize(300,100)));
1986 TheClient->iGc->Deactivate();
1987 window1.EndRedraw();
1990 // Update the colour of four ellipses residing in four CRP drawers.
1991 TInt err = wsGraphic1->UpdateColor(KRgbRed);
1992 TEST(KErrNone == err);
1993 err = wsGraphic2->UpdateColor(KRgbDarkBlue);
1994 TEST(KErrNone == err);
1995 // If the fix is not inserted, the colour of the third and fourth ellipses residing in the contained drawers wont be updated
1996 err = wsGraphic3->UpdateColor(KRgbDarkMagenta);
1997 TEST(KErrNone == err);
1998 err = wsGraphic4->UpdateColor(KRgbDarkCyan); //won't change the displayed color if there is a right place for flush()
1999 TEST(KErrNone == err);
2002 // Force some delays to wait until the color change
2003 User::After(2000000);
2004 // Test whether the screen content is changed as required
2006 CleanupStack::PopAndDestroy(5,&window1);
2009 // Check the screen display with the reference bitmap to ensure the color to be updated correctly
2010 void CTWsGraphs::CheckResult()
2012 TSize size = TSize(320,200);//The maximum size of the screen content we are looking at
2014 // Create a reference bitmap
2015 CFbsBitmap* bitmapRef = new(ELeave) CFbsBitmap;
2016 CleanupStack::PushL(bitmapRef);
2017 User::LeaveIfError(bitmapRef->Create(size, EColor256));
2019 CFbsBitmapDevice* bitmapDev = CFbsBitmapDevice::NewL(bitmapRef);
2020 TEST(bitmapDev!=NULL);
2021 CleanupStack::PushL(bitmapDev);
2022 User::LeaveIfError(bitmapDev->CreateContext(gc));
2023 CleanupStack::PushL(gc);
2024 gc->SetBrushStyle(CGraphicsContext::ESolidBrush);
2025 gc->SetBrushColor(KRgbDarkGreen);
2026 gc->Clear(TRect(TPoint(0,0), size));//background dark green
2027 gc->SetBrushStyle(CGraphicsContext::ESolidBrush);
2028 gc->SetBrushColor(KRgbRed);
2029 gc->DrawEllipse(TRect(TPoint(20,20),TSize(300,100))); //map to the simple drawer
2030 gc->SetBrushStyle(CGraphicsContext::ESolidBrush);
2031 gc->SetBrushColor(KRgbDarkBlue);
2032 gc->DrawEllipse(TRect(TPoint(20,100),TSize(300,100))); //map to the container drawer
2033 gc->SetBrushStyle(CGraphicsContext::ESolidBrush);
2034 gc->SetBrushColor(KRgbDarkMagenta);
2035 gc->DrawEllipse(TRect(TPoint(100,150),TSize(50,50))); //map to the contained drawer
2036 gc->SetBrushStyle(CGraphicsContext::ESolidBrush);
2037 gc->SetBrushColor(KRgbDarkCyan);
2038 gc->DrawEllipse(TRect(TPoint(200,150),TSize(50,50))); //map to the contained drawer
2039 TInt bitmapHeight = bitmapRef->SizeInPixels().iHeight;
2040 TInt bitmapWidth = bitmapRef->SizeInPixels().iWidth;
2042 // Copy the screen content to bitmap
2043 INFO_PRINTF1(_L("Capture screen content."));
2044 CFbsBitmap* screenBitmap = new(ELeave) CFbsBitmap();
2045 CleanupStack::PushL(screenBitmap);
2046 User::LeaveIfError(screenBitmap->Create(size, TheClient->iScreen->DisplayMode()));
2047 TRect rct = TRect(TPoint(0,0), size);
2048 User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(screenBitmap,rct));
2050 // Compare the displayed bitmap against the reference one
2051 INFO_PRINTF1(_L("Compare the displayed bitmap against the expected one."));
2052 TInt lineLength=bitmapRef->ScanLineLength(bitmapWidth, EColor256);
2053 HBufC8* compareLineBuf=HBufC8::NewLC(lineLength);
2054 TPtr8 compareLinePtr(compareLineBuf->Des());
2055 HBufC8* screenLineBuf=HBufC8::NewLC(lineLength);
2056 TPtr8 screenLinePtr(screenLineBuf->Des());
2057 for (TInt index=0; index<bitmapHeight; index++)
2059 bitmapRef->GetScanLine(compareLinePtr, TPoint(0,index), bitmapWidth, EColor256);
2060 screenBitmap->GetScanLine(screenLinePtr, TPoint(0,index),bitmapWidth, EColor256);
2061 TInt compareResult=compareLinePtr.Compare(screenLinePtr);
2062 if (compareResult!=0)
2064 INFO_PRINTF2(_L("Scanline compare failed: %d"),index);
2069 CleanupStack::PopAndDestroy(6,bitmapRef);
2073 void ResetScreenMode(TAny* aAny)
2075 CWsScreenDevice* screen=static_cast<CWsScreenDevice*>(aAny);
2076 screen->SetScreenMode(0);
2077 screen->SetAppScreenMode(0);
2080 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
2082 void CTWsGraphs::TestScreenModeChangeL()
2084 _LIT(KLog,"Screen Doesn't match bitmap. Size=(%d,%d) winSizeMode=%d redrawMode=%d modeIndex=%d");
2085 // A simple CRP graphic to draw in the test
2086 CWsSimpleGraphicBitmap* wsGraphic1=CWsSimpleGraphicBitmap::NewL(KSimpleDrawerInterfaceId);
2087 CleanupStack::PushL(wsGraphic1);
2088 RWindow testWin(TheClient->iWs);
2089 CleanupClosePushL(testWin);
2090 User::LeaveIfError(testWin.Construct(*TheClient->iGroup->GroupWin(),0xbadbad));
2091 testWin.SetRequiredDisplayMode(EColor64K);
2093 // Cleanup display mode by setting back to 0 if we leave in the tests
2094 CleanupStack::PushL(TCleanupItem(ResetScreenMode,TheClient->iScreen));
2095 TInt numScreenModes=TheClient->iScreenModes.Count();
2098 for(TInt winSizeMode=0;winSizeMode<2;winSizeMode++)
2099 { // Two size modes, fullScreen and non-full screen
2100 for(TInt redrawMode=0;redrawMode<2;redrawMode++)
2101 { // Two redraw modes to test drawing inside and outside of a redraw.
2102 const TBool drawInsideRedraw=(redrawMode==0);
2103 for(TInt modeIndex=0;modeIndex<numScreenModes;modeIndex++)
2105 const TInt screenMode=TheClient->iScreenModes[modeIndex];
2106 const TPoint origin=TheClient->iScreen->GetScreenModeScaledOrigin(screenMode);
2107 if (origin.iX!=0 || origin.iY!=0)
2109 // Enable redirection before changing screen mode as this is what we are testing
2110 iRedir->Redirect(CWsRedir::EFrontBuffer, ETrue);
2111 TheClient->iScreen->SetAppScreenMode(screenMode);
2112 TheClient->iScreen->SetScreenMode(screenMode);
2114 TPixelsAndRotation sizeAndRotation;
2115 TheClient->iScreen->GetDefaultScreenSizeAndRotation(sizeAndRotation);
2117 TSize screenSize(TheClient->iScreen->SizeInPixels());
2118 if(sizeAndRotation.iRotation == CFbsBitGc::EGraphicsOrientationRotated90 ||
2119 sizeAndRotation.iRotation == CFbsBitGc::EGraphicsOrientationRotated270)
2121 screenSize.iWidth = Min(screenSize.iWidth, 240);//to make sure we won't exceed physical screen size
2123 TSize winSize(screenSize);
2127 winSize.iWidth=winSize.iWidth*2/3;
2128 winSize.iHeight=winSize.iHeight*3/4;
2129 winPos.iX=(screenSize.iWidth-winSize.iWidth)/4;
2130 winPos.iY=(screenSize.iHeight-winSize.iHeight)*3/4;
2132 testWin.SetExtent(winPos,winSize);
2133 TSize halfSize(winSize.iWidth/2,winSize.iHeight);
2134 TRect leftHalf(halfSize);
2135 TRect rightHalf(TPoint(halfSize.iWidth,0),halfSize);
2136 TRect leftEllipse(leftHalf);
2137 leftEllipse.Shrink(4,4);
2138 TRect rightEllipse(rightHalf);
2139 rightEllipse.Shrink(4,4);
2140 // Draw half the screen with redirection on, should only go to redirection test bitmap
2141 // Then draw again with redirection off, this time should go to the screen
2142 // The two steps are drawn with the color of the left/right rectangles swapped.
2143 for(TInt drawStep=0;drawStep<2;drawStep++)
2149 leftColor=KRgbGreen;
2153 { // Turn re-direction off for second time around loop
2154 iRedir->Redirect(CWsRedir::EFrontBuffer, EFalse);
2156 rightColor=KRgbGreen;
2158 testWin.Invalidate();
2159 testWin.BeginRedraw();
2160 if (!drawInsideRedraw)
2161 testWin.EndRedraw();
2162 CWindowGc* testWinGc=TheClient->iGc;
2163 testWinGc->Activate(testWin);
2164 testWinGc->SetBrushColor(leftColor);
2165 testWinGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
2166 testWinGc->DrawRect(leftHalf);
2167 // Call CRP drawer to draw the coloured ellipses
2168 TheClient->iGc->DrawWsGraphic(wsGraphic1->Id(),leftEllipse);
2169 testWinGc->SetBrushColor(rightColor);
2170 testWinGc->DrawRect(rightHalf);
2171 TheClient->iGc->DrawWsGraphic(wsGraphic1->Id(),rightEllipse);
2172 testWinGc->Deactivate();
2173 if (drawInsideRedraw)
2174 testWin.EndRedraw();
2175 TheClient->iWs.Flush();
2177 // We now check that the left rect of the re-directed drawing matches the right half
2178 // of the on-screen drawing
2179 CFbsBitmap* screenCopy=new(ELeave) CFbsBitmap;
2180 CleanupStack::PushL(screenCopy);
2181 User::LeaveIfError(screenCopy->Create(screenSize, EColor64K));
2182 TheClient->iScreen->CopyScreenToBitmap(screenCopy);
2183 match=CompareBitmapArea16Bpp(iFrontCopy,winPos,screenCopy,TPoint(winPos.iX+rightHalf.iTl.iX,winPos.iY),halfSize);
2186 LOG_MESSAGE6(KLog,screenSize.iWidth,screenSize.iHeight,winSizeMode,redrawMode,modeIndex);
2187 // As a double check also check the right half of the off-screen drawing matches the
2188 // on-screen left half.
2189 match=CompareBitmapArea16Bpp(iFrontCopy,TPoint(winPos.iX+rightHalf.iTl.iX,winPos.iY),screenCopy,winPos,halfSize);
2192 LOG_MESSAGE6(KLog,screenSize.iWidth,screenSize.iHeight,winSizeMode,redrawMode,modeIndex);
2193 CleanupStack::PopAndDestroy(screenCopy);
2197 CleanupStack::PopAndDestroy(3,wsGraphic1);
2199 TEST(iNotify1->iResult);
2200 if(iNotify1->iResult==EFalse)
2202 INFO_PRINTF1(iNotify1->iError);
2204 TEST(iNotify2->iResult);
2205 if(iNotify1->iResult==EFalse)
2207 INFO_PRINTF1(iNotify2->iError);
2211 #endif // TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
2214 @SYMTestCaseID GRAPHICS-WSERV-0443
2218 @SYMTestCaseDesc TWindowServerEvent::NotifyDrawer can refer to a deleted array index causing a crash
2220 @SYMTestPriority High
2222 @SYMTestStatus Implemented
2224 @SYMTestActions Cause an event that will generate the following behaviour through TWindowServerEvent::NotifyDrawer()
2226 The for loop performs the following:
2227 0) Drawer handler 1: Remove handle 1 ; Drawer handler 2: Do nothing
2228 1) Drawer handler 1: Remove handle 1,Add handle 1 ; Drawer handler 2: Do nothing
2229 2) Drawer handler 1: Add handle 1 ; Drawer handler 2: Do nothing
2230 3) Drawer handler 1: Remove handle 2 ; Drawer handler 2: Do nothing
2231 4) Drawer handler 1: Remove handle 2,Add handle 2 ; Drawer handler 2: Do nothing
2232 5) Drawer handler 1: Add handle 2 ; Drawer handler 2: Do nothing
2233 6) Drawer handler 1: Remove handle 1,Remove handle 2 ; Drawer handler 2: Do nothing
2235 Repeat with handlers 1 and 2 swapped
2237 @SYMTestExpectedResults Loops through TWindowServerEvent::NotifyDrawer() should complete without crashing wserv
2240 void CTWsGraphs::TestNotifyRemoval()
2242 _LIT(KTestEventNotification, "TestDrawerEventHandler");
2243 INFO_PRINTF1(KTestEventNotification);
2246 for (TInt ii = 0; ii<KNotifyDoNothing; ii++)
2248 INFO_PRINTF2(_L("For loop %d"), ii);
2249 iNotify1->SetBehaviour(ii); //Enable this plugin and set it to an event handling method
2250 iNotify2->SetBehaviour(KNotifyDoNothing); //Add a second drawer handler which is enabled but does nothing
2251 CreateWindowL(); //Change visibility activating the event handlers - Fails if wserv crashes!
2252 iNotify1->SetBehaviour(KNotifyDisable); //Disable plugin if still enabled
2253 iNotify2->SetBehaviour(KNotifyDisable); //Disable plugin if still enabled
2256 INFO_PRINTF1(_L("Swap handlers"));
2257 for (TInt ii = 0; ii<KNotifyDoNothing; ii++)
2259 INFO_PRINTF2(_L("For loop %d"), ii);
2260 iNotify2->SetBehaviour(KNotifyDoNothing); //Add a first drawer handler which is enabled but does nothing
2261 iNotify1->SetBehaviour(ii); //Enable this plugin and set it to an event handling method
2262 CreateWindowL(); //Change visibility activating the event handlers - Fails if wserv crashes!
2263 iNotify2->SetBehaviour(KNotifyDisable); //Disable plugin if still enabled
2264 iNotify1->SetBehaviour(KNotifyDisable); //Disable plugin if still enabled
2268 TEST(ETrue); // If the test has failed WServ will have paniced.
2271 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
2273 @SYMTestCaseID GRAPHICS-WSERV-0491
2275 @SYMTestPriority High
2276 @SYMTestCaseDesc Draw using a ECom-plugin which has direct access to the screen/OSB buffer
2277 @SYMTestActions Create the plugin
2278 Draw using the plugin
2279 Update the position of the white line to line 70 and test
2280 Update the position of the white line to line 80 and test
2281 @SYMTestExpectedResults White lines are drawn on the correct positions.
2283 void CTWsGraphs::TestMWsUiBufferL()
2285 const TInt KWhiteLinePos = 70;
2286 const TRect KBlueRect(TPoint(50,50),TSize(100,100));
2288 // Construct and setup window to be drawn to
2289 RWindow window1 = RWindow(TheClient->iWs);
2290 CleanupClosePushL(window1);
2291 User::LeaveIfError(window1.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle));
2292 TSize winSize=TSize(TheClient->iScreen->SizeInPixels());
2293 window1.SetExtent(TPoint(0,0),winSize);
2296 CWsBufferGraphic* graphic = CWsBufferGraphic::NewL();
2297 CleanupStack::PushL(graphic);
2299 // Draw inital drawing with a Crp which is blue rect and a white line at line 0
2300 TheGc->Activate(window1);
2302 window1.BeginRedraw();
2303 TheGc->DrawWsGraphic(graphic->Id(),KBlueRect);
2304 window1.EndRedraw();
2305 TheGc->Deactivate();
2307 TheClient->iWs.Finish();
2308 User::After(2000000);
2310 // Update the position of the white line to line 70
2311 INFO_PRINTF1(_L("Update position of white line to line 70"));
2312 graphic->UpdateWhiteLinePos(KWhiteLinePos);
2313 TheClient->iWs.Finish();
2314 // Force some delays to wait until the line position changes
2315 User::After(2000000);
2316 //Test white line has been drawn and is in the correct postion
2317 TBool res1 = IsWhiteLine(KWhiteLinePos);
2320 // Update the position of the white line to line 80
2321 INFO_PRINTF1(_L("Update position of white line to line 80"));
2322 graphic->UpdateWhiteLinePos(KWhiteLinePos+10);
2323 TheClient->iWs.Finish();
2324 // Force some delays to wait until the line position changes
2325 User::After(2000000);
2326 // Test white line has been drawn and is in the correct postion
2327 TBool res2 = IsWhiteLine(KWhiteLinePos+10);
2331 CleanupStack::PopAndDestroy(2, &window1);
2334 // Test whether a line is completely white
2335 TBool CTWsGraphs::IsWhiteLine(TInt aWhiteLinePos)
2340 for(TInt xPos = 0; xPos < TheClient->iScreen->SizeInPixels().iWidth; xPos++)
2342 pixel = TPoint(xPos,aWhiteLinePos);
2343 TheClient->iScreen->GetPixel(color,pixel);
2344 if(color.Red() != 255 && color.Blue() != 255 && color.Green() != 255)
2351 #endif //TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
2354 DoTestL() method, called by the WSERV Test Framework.
2356 void CTWsGraphs::RunTestCaseL(TInt /*aCurTestCase*/)
2358 _LIT(KTest1,"DoTestWsGraphics");
2359 _LIT(KTest2,"DoTestOOMWsGraphics");
2360 _LIT(KTest3,"Interface Extension");
2361 _LIT(KTest4,"Screen Redirection");
2362 _LIT(KTest5,"TextCursor1");
2363 _LIT(KTest6,"TextCursor2");
2364 _LIT(KTest7,"Flicker Redirection");
2365 _LIT(KTest8,"Event Notification");
2366 _LIT(KTest9,"Successive Message");
2367 _LIT(KTest10,"Redirection Using WsBackBuffer");
2368 _LIT(KTest11,"Group Change");
2369 _LIT(KTest12,"Frame Rate");
2370 _LIT(KTest13,"Leak In Service");
2371 _LIT(KTest14,"Add/Swap GDArray");
2372 _LIT(KTest15,"Nested Drawer CRP");
2373 _LIT(KTest16,"Notify Removal");
2374 _LIT(KTest17,"Screen Mode Change");
2375 _LIT(KTest18,"UI Buffer");
2376 _LIT(KTest19,"Graphics Drawer Coverage");
2379 CWsGraphicBitmap* bTest=NULL;
2380 TSize screenSize=TheClient->iScreen->SizeInPixels();
2382 bitmap1.Create(screenSize,TheClient->iScreen->DisplayMode());
2383 mask1.Create(screenSize,TheClient->iScreen->DisplayMode());
2384 ((CTWsGraphsStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
2386 switch(++iTest->iState)
2390 @SYMTestCaseID GRAPHICS-WSERV-0528
2392 ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0528"));
2393 // Launch new process with PROTSERV capability to run CWSGraphics tests in
2394 iTest->LogSubTest(KTest1);
2395 // This process only launches succesfully when _DEBUG is defined for the build, because it depends
2396 // on the existance of debug macros such as _UHEAP_MARK, _UHEAP_MARKEND, _UHEAP_FAILNEXT, ... etc
2397 LaunchNewProcess(KTestExe);
2402 @SYMTestCaseID GRAPHICS-WSERV-0017
2408 @SYMTestCaseDesc Out of memery test when creating a CWsGraphic.
2410 @SYMTestPriority High
2412 @SYMTestStatus Implemented
2414 @SYMTestActions Out of memory test when creating a CWsGraphic.
2416 @SYMTestExpectedResults Whenever an API call fails, it should leave the number
2417 of allocated heap cells unchanged.
2419 ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0017"));
2421 iTest->LogSubTest(KTest2);
2423 for(failRate=1;;failRate++)
2426 __UHEAP_SETFAIL(RHeap::EDeterministic,failRate);
2429 TRAPD(ret,bTest=CWsGraphicBitmap::NewL(&bitmap1,&mask1));
2430 TEST((ret==KErrNone || ret==KErrNoMemory));
2431 if (ret!=KErrNone && ret!=KErrNoMemory)
2433 _LIT(KLog,"Failed to create CWsGraphicBitmap error=%d");
2434 LOG_MESSAGE2(KLog,ret);
2445 _LIT(KLog,"Object creation didn't leave but returned NULL");
2451 TLogMessageText logMessageText;
2452 _LIT(KSet,"OOM test succeds after %d allocations.");
2453 logMessageText.Format(KSet,failRate);
2454 LOG_MESSAGE(logMessageText);
2462 iTest->LogSubTest(KTest3);
2463 ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0371"));
2464 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
2466 if (TestInterfaceExtensionL()==EWait)
2471 iTest->LogSubTest(KTest4);
2472 ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0372"));
2473 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
2474 if (TestScreenRedirectionL()==EWait)
2479 iTest->LogSubTest(KTest5);
2480 ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0363"));
2481 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
2482 if (TestTextCursorUnderRedirectionL(ETestStandardTextCursor) == EWait)
2487 iTest->LogSubTest(KTest6);
2488 ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0363"));
2489 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
2490 if (TestTextCursorUnderRedirectionL(ETestCustomTextCursor) == EWait)
2495 iTest->LogSubTest(KTest7);
2496 ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0376"));
2497 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
2498 if (TestFlickerRedirectionL()==EWait)
2503 ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0378"));
2504 iTest->LogSubTest(KTest8);
2505 if (TestEventNotificationL()==EWait)
2509 ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0381"));
2510 iTest->LogSubTest(KTest9);
2511 if (TestSuccessiveMessageL()==EWait)
2515 iTest->LogSubTest(KTest10);
2516 ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0527"));
2517 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
2518 if(TestRedirectionUsingWsBackBufferL()==EWait)
2524 @SYMTestCaseID GRAPHICS-WSERV-0529
2526 ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0529"));
2527 iTest->LogSubTest(KTest11);
2528 if(TestWindowGroupChangeL()==EWait)
2532 ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0382"));
2533 iTest->LogSubTest(KTest12);
2534 if(TestFrameRateL()==EWait)
2538 ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-LeakInService-0001"));
2539 iTest->LogSubTest(KTest13);
2540 DoTestLeakInServiceL();
2543 ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-NegAddSwapGDArray-0001"));
2544 iTest->LogSubTest(KTest14);
2545 TestAddSwapGDArrayL();
2548 ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0438"));
2549 iTest->LogSubTest(KTest15);
2550 TestNestedDrawerCRP();
2553 ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0443"));
2554 iTest->LogSubTest(KTest16);
2555 TestNotifyRemoval();
2558 iTest->LogSubTest(KTest17);
2559 ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0530"));
2560 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
2562 @SYMTestCaseID GRAPHICS-WSERV-0530
2565 TestScreenModeChangeL();
2569 iTest->LogSubTest(KTest18);
2570 ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0491"));
2571 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NGA
2577 iTest->LogSubTest(KTest19);
2579 @SYMTestCaseID GRAPHICS-WSERV-0531
2581 ((CTWsGraphsStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0531"));
2582 TestGraphicDrawerCoverage();
2585 ((CTWsGraphsStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
2586 ((CTWsGraphsStep*)iStep)->CloseTMSGraphicsStep();
2590 ((CTWsGraphsStep*)iStep)->RecordTestResultL();
2593 __WS_CONSTRUCT_STEP__(WsGraphs)