First public contribution.
1 // Copyright (c) 1996-2010 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 // Out of memory tests
21 @internalComponent - Internal Symbian test code
28 typedef COomFailBase *(*COmmCreate)(CTOom *aTest);
30 COomFailBase *CreateOomConnect(CTOom *aTest)
31 {return(new(ELeave) COomConnect(aTest));}
33 COomFailBase *CreateOomWindow(CTOom *aTest)
34 {return(new(ELeave) COomWindow(aTest));}
36 COomFailBase *CreateOomWindowGroup(CTOom *aTest)
37 {return(new(ELeave) COomWindowGroup(aTest));}
39 COomFailBase *CreateOomBackedUpWindow(CTOom *aTest)
40 {return(new(ELeave) COomBackedUpWindow(aTest));}
42 COomFailBase *CreateOomBackupResize(CTOom *aTest)
43 {return(new(ELeave) COomBackupResize(aTest));}
45 COomFailBase *CreateOomBlankWindow(CTOom *aTest)
46 {return(new(ELeave) COomBlankWindow(aTest));}
48 COomFailBase *CreateOomGc(CTOom *aTest)
49 {return(new(ELeave) COomGc(aTest));}
51 COomFailBase *CreateOomScreenDevice(CTOom *aTest)
52 {return(new(ELeave) COomScreenDevice(aTest));}
54 COomFailBase *CreateOomPointerBuffer(CTOom *aTest)
55 {return(new(ELeave) COomPointerBuffer(aTest));}
57 COomFailBase *CreateOomPolygon(CTOom *aTest)
58 {return(new(ELeave) COomPolygon(aTest));}
60 COomFailBase *CreateOomPriorityKey(CTOom *aTest)
61 {return(new(ELeave) COomPriorityKey(aTest));}
63 COomFailBase *CreateOomCaptureKey(CTOom *aTest)
64 {return(new(ELeave) COomCaptureKey(aTest));}
66 COomFailBase *CreateOomCaptureKeyUpDown(CTOom *aTest)
67 {return(new(ELeave) COomCaptureKeyUpDown(aTest));}
69 COomFailBase *CreateOomLongKeyCapture(CTOom *aTest)
70 {return(new(ELeave) COomLongKeyCapture(aTest));}
72 COomFailBase *CreateOomHotKey(CTOom *aTest)
73 {return(new(ELeave) COomHotKey(aTest));}
75 COomFailBase *CreateOomGroupName(CTOom *aTest)
76 {return(new(ELeave) COomGroupName(aTest));}
78 COomFailBase *CreateOomMessageSend(CTOom *aTest)
79 {return(new(ELeave) COomMessageSend(aTest));}
81 COomFailBase *CreateOomMessageFetch(CTOom *aTest)
82 {return(new(ELeave) COomMessageFetch(aTest));}
84 COomFailBase *CreateOomSprite(CTOom *aTest)
85 {return(new(ELeave) COomSprite(aTest));}
87 COomFailBase *CreateOomPointerCursor(CTOom *aTest)
88 {return(new(ELeave) COomPointerCursor(aTest));}
90 COomFailBase *CreateOomCopyScreen(CTOom *aTest)
91 {return(new(ELeave) COomCopyScreen(aTest));}
93 COomFailBase *CreateOomRequestEvents(CTOom *aTest)
94 {return(new(ELeave) COomRequestEvents(aTest));}
96 COomFailBase *CreateOomCustomTextCursor(CTOom *aTest)
97 {return(new(ELeave) COomCustomTextCursor(aTest));}
99 COomFailBase *CreateOomTranspWindow(CTOom *aTest)
100 {return(new(ELeave) COomTranspWindow(aTest));}
102 COomFailBase *CreateOomObscuredWindow(CTOom *aTest)
103 {return(new(ELeave) COomObscuredWindow(aTest));}
105 COmmCreate CreateOomFailTest[]={
108 CreateOomWindowGroup,
109 CreateOomBackedUpWindow,
110 CreateOomBackupResize,
111 CreateOomBlankWindow,
113 CreateOomScreenDevice,
114 CreateOomPointerBuffer,
116 CreateOomPriorityKey,
118 CreateOomCaptureKeyUpDown,
119 CreateOomLongKeyCapture,
123 CreateOomPointerCursor,
125 CreateOomRequestEvents,
126 CreateOomMessageSend,
127 CreateOomMessageFetch,
128 CreateOomCustomTextCursor,
129 CreateOomTranspWindow,
130 CreateOomObscuredWindow,
134 // Individual out of memory test classes //
137 COomFailBase::COomFailBase(CTOom *aTest) : iTest(aTest)
140 void COomFailBase::ConstructL()
142 iTest->INFO_PRINTF1(TestName());
145 void COomFailBase::PreFail()
148 void COomFailBase::ClearUpL()
151 void COomFailBase::Flush()
156 COomConnect::COomConnect(CTOom *aTest) : COomFailBase(aTest)
159 TOomTestName COomConnect::TestName()
161 return(_L("Connect"));
164 /** Creates a wserv session, connects and creates CWsScreenDevice object
166 TInt COomConnect::Fail()
168 TInt err = iWs.Connect();
172 TRAP(err, iDummyScreen = new (ELeave) CWsScreenDevice(iWs));
179 if ((err=iDummyScreen->Construct(iTest->ScreenNumber()))!=KErrNone)
190 void COomConnect::ClearUpL()
202 COomSetup::COomSetup(CTOom *aTest) : COomFailBase(aTest)
205 void COomSetup::ConstructL()
207 COomFailBase::ConstructL();
208 User::LeaveIfError(iWs.Connect());
209 iDummyScreen = new (ELeave) CWsScreenDevice(iWs);
210 User::LeaveIfError(iDummyScreen->Construct(iTest->ScreenNumber()));
212 iWinGroup=RWindowGroup(iWs);
213 iWinGroup.Construct(556);
214 iWinGroup.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close
217 COomSetup::~COomSetup()
223 iTest->TEST(iWs.ResourceCount()==0);
224 if (iWs.ResourceCount()!=0)
225 iTest->INFO_PRINTF3(_L("iWs.ResourceCount() return value - Expected: %d, Actual: %d"), 0, iWs.ResourceCount());
232 COomWindowGroup::COomWindowGroup(CTOom *aTest) : COomSetup(aTest)
235 TOomTestName COomWindowGroup::TestName()
237 return(_L("Window Group"));
240 /** Creates a RWindowGroup object
242 TInt COomWindowGroup::Fail()
244 iFailWinGroup=RWindowGroup(iWs);
245 return(iFailWinGroup.Construct(987));
248 void COomWindowGroup::ClearUpL()
250 iFailWinGroup.Close();
255 COomWindow::COomWindow(CTOom *aTest) : COomSetup(aTest)
258 TOomTestName COomWindow::TestName()
260 return(_L("Window"));
263 /** Creates a RWindow object
265 TInt COomWindow::Fail()
267 iFailWin=RWindow(iWs);
268 return(iFailWin.Construct(iWinGroup,11));
271 void COomWindow::ClearUpL()
278 COomBackedUpWindow::COomBackedUpWindow(CTOom *aTest) : COomSetup(aTest)
281 TOomTestName COomBackedUpWindow::TestName()
283 return(_L("Backed up window"));
286 /** Creates a RBackedUpWindow object
288 TInt COomBackedUpWindow::Fail()
290 iFailWin=RBackedUpWindow(iWs);
291 return(iFailWin.Construct(iWinGroup,EGray16,22));
294 void COomBackedUpWindow::ClearUpL()
301 COomBackupResize::COomBackupResize(CTOom *aTest) : COomSetup(aTest)
304 COomBackupResize::~COomBackupResize()
309 TOomTestName COomBackupResize::TestName()
311 return(_L("Resize backed up window"));
314 void COomBackupResize::ConstructL()
316 COomSetup::ConstructL();
317 iFailWin=RBackedUpWindow(iWs);
318 User::LeaveIfError(iFailWin.Construct(iWinGroup,EGray16,33));
319 User::LeaveIfError(iFailWin.SetSizeErr(TSize(10,10)));
323 /** Sets the size of previously created backed-up window
325 TInt COomBackupResize::Fail()
327 return(iFailWin.SetSizeErr(TSize(100,100)));
330 void COomBackupResize::ClearUpL()
331 //Virtual fn declared in CoomFailBase. This is the only one that can leave, I think, but one is enough
333 User::LeaveIfError(iFailWin.SetSizeErr(TSize(10,10)));
338 COomBlankWindow::COomBlankWindow(CTOom *aTest) : COomSetup(aTest)
341 TOomTestName COomBlankWindow::TestName()
343 return(_L("Blank window"));
346 /** Creates a RBlankWindow object
348 TInt COomBlankWindow::Fail()
350 iFailWin=RBlankWindow(iWs);
351 return(iFailWin.Construct(iWinGroup,44));
354 void COomBlankWindow::ClearUpL()
361 COomPointerBuffer::COomPointerBuffer(CTOom *aTest) : COomSetup(aTest)
364 COomPointerBuffer::~COomPointerBuffer()
369 TOomTestName COomPointerBuffer::TestName()
371 return(_L("Pointer buffer"));
374 void COomPointerBuffer::ConstructL()
376 COomSetup::ConstructL();
377 iFailWin=RBackedUpWindow(iWs);
378 User::LeaveIfError(iFailWin.Construct(iWinGroup,EGray16,55));
379 User::LeaveIfError(iFailWin.SetSizeErr(TSize(10,10)));
383 /** Allocates a buffer for storing pointer movements for previously created backed-up window
385 TInt COomPointerBuffer::Fail()
387 return(iFailWin.AllocPointerMoveBuffer(10,0));
390 void COomPointerBuffer::ClearUpL()
392 iFailWin.FreePointerMoveBuffer();
397 COomPriorityKey::COomPriorityKey(CTOom *aTest) : COomSetup(aTest)
400 COomPriorityKey::~COomPriorityKey()
404 TOomTestName COomPriorityKey::TestName()
406 return(_L("Priority key"));
409 void COomPriorityKey::ConstructL()
411 COomSetup::ConstructL();
414 /** Adds a priority key for a previously created window group
416 TInt COomPriorityKey::Fail()
418 return(iWinGroup.AddPriorityKey(1,0,0));
421 void COomPriorityKey::ClearUpL()
423 iWinGroup.RemovePriorityKey(1,0,0);
428 COomCaptureKeyBase::COomCaptureKeyBase(CTOom *aTest) : COomSetup(aTest)
431 COomCaptureKeyBase::~COomCaptureKeyBase()
434 void COomCaptureKeyBase::ConstructL()
436 COomSetup::ConstructL();
439 COomCaptureKey::COomCaptureKey(CTOom *aTest) : COomCaptureKeyBase(aTest)
442 COomCaptureKey::~COomCaptureKey()
446 TOomTestName COomCaptureKey::TestName()
448 return(_L("Capture key"));
451 /** Requests a capture keys for a previously created window group
453 TInt COomCaptureKey::Fail()
455 for (iIndex=0;iIndex<(TInt)(sizeof(iCapKey)/sizeof(iCapKey[0]));iIndex++)
457 TInt ret=iWinGroup.CaptureKey('a',0,0);
465 void COomCaptureKey::ClearUpL()
467 for (TInt index=0;index<iIndex;index++)
468 iWinGroup.CancelCaptureKey(iCapKey[index]);
473 COomCaptureKeyUpDown::COomCaptureKeyUpDown(CTOom *aTest) : COomCaptureKeyBase(aTest)
476 COomCaptureKeyUpDown::~COomCaptureKeyUpDown()
480 TOomTestName COomCaptureKeyUpDown::TestName()
482 return(_L("Capture up/down keys"));
485 /** Requests the capture of key-up and key-down events for a previously created window group
487 TInt COomCaptureKeyUpDown::Fail()
489 for (iIndex=0;iIndex<(TInt)(sizeof(iCapKey)/sizeof(iCapKey[0]));iIndex++)
491 TInt ret=iWinGroup.CaptureKeyUpAndDowns('a',0,0);
499 void COomCaptureKeyUpDown::ClearUpL()
501 for (TInt index=0;index<iIndex;index++)
502 iWinGroup.CancelCaptureKeyUpAndDowns(iCapKey[index]);
507 COomLongKeyCapture::COomLongKeyCapture(CTOom *aTest) : COomCaptureKeyBase(aTest)
510 COomLongKeyCapture::~COomLongKeyCapture()
514 TOomTestName COomLongKeyCapture::TestName()
516 _LIT(KLongKeyCapTestName, "Long key capture");
517 return KLongKeyCapTestName();
521 Requests capture of long key events for a previously created window group
523 TInt COomLongKeyCapture::Fail()
525 for (iIndex=0; iIndex < KNumCapKeyRequest; iIndex++)
527 TInt ret=iWinGroup.CaptureLongKey(' ','a',0,0,2,ELongCaptureNormal);
535 void COomLongKeyCapture::ClearUpL()
537 for (TInt index=0;index<iIndex;index++)
538 iWinGroup.CancelCaptureLongKey(iCapKey[index]);
543 COomHotKey::COomHotKey(CTOom *aTest) : COomSetup(aTest)
546 COomHotKey::~COomHotKey()
550 TOomTestName COomHotKey::TestName()
552 return(_L("hot keys"));
555 void COomHotKey::ConstructL()
557 COomSetup::ConstructL();
560 /** Sets hot key for the session.
562 TInt COomHotKey::Fail()
564 return(iWs.SetHotKey(EHotKeyEnableLogging,'a',0,0));
567 void COomHotKey::ClearUpL()
569 iWs.RestoreDefaultHotKey(EHotKeyEnableLogging);
574 COomGroupName::COomGroupName(CTOom *aTest) : COomSetup(aTest)
577 COomGroupName::~COomGroupName()
581 TOomTestName COomGroupName::TestName()
583 return(_L("Group name"));
586 void COomGroupName::ConstructL()
588 COomSetup::ConstructL();
591 /** Sets the window group's name.
593 TInt COomGroupName::Fail()
595 return(iWinGroup.SetName(_L("A Name")));
598 void COomGroupName::ClearUpL()
600 iWinGroup.SetName(_L(""));
605 COomMessageSend::COomMessageSend(CTOom *aTest) : COomSetup(aTest)
608 COomMessageSend::~COomMessageSend()
612 TOomTestName COomMessageSend::TestName()
614 return(_L("MessageSend"));
617 void COomMessageSend::ConstructL()
619 COomSetup::ConstructL();
622 void COomMessageSend::PreFail()
624 iWinGroup2=RWindowGroup(iWs);
625 iWinGroup2.Construct(557);
626 iWinGroup2.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close
629 /** Sends a message to another window group
631 TInt COomMessageSend::Fail()
633 TBuf8<0x20> params(_L8("SomeParams"));
634 return(iWs.SendMessageToWindowGroup(iWinGroup2.Identifier(),TUid::Uid(123),params));
637 void COomMessageSend::ClearUpL()
644 COomMessageFetch::COomMessageFetch(CTOom *aTest) : COomSetup(aTest)
647 COomMessageFetch::~COomMessageFetch()
651 TOomTestName COomMessageFetch::TestName()
653 return(_L("MessageFetch"));
656 void COomMessageFetch::ConstructL()
658 COomSetup::ConstructL();
661 #define CLIENT_HANDLE 555
662 #define UID_VALUE 123
663 #define MESSAGE_LEN 0x20
664 void COomMessageFetch::PreFail()
666 iWinGroup2=RWindowGroup(iWs);
667 iWinGroup2.Construct(CLIENT_HANDLE);
668 iWinGroup2.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close
669 TBuf8<MESSAGE_LEN> params(_L8("SomeParams"));
670 TBool retVal = iWs.SendMessageToWindowGroup(iWinGroup2.Identifier(),TUid::Uid(UID_VALUE),params);
671 iTest->TEST(retVal==KErrNone);
672 if (retVal!=KErrNone)
673 iTest->INFO_PRINTF3(_L("iWs.SendMessageToWindowGroup() return value - Expected: %d, Actual: %d"), KErrNone, retVal);
676 /** Fetches a message
678 TInt COomMessageFetch::Fail()
683 event.SetType(EEventMessageReady);
684 event.SetHandle(CLIENT_HANDLE);
686 SEventMessageReady& eventMessageReady=*(SEventMessageReady*)event.EventData();
687 eventMessageReady.iWindowGroupIdentifier=iWinGroup2.Identifier();
688 eventMessageReady.iMessageUid=TUid::Uid(UID_VALUE);
689 eventMessageReady.iMessageParametersSize=MESSAGE_LEN;
690 TInt ret=TheClient->iWs.FetchMessage(uid,ptr,event);
692 User::Free((TAny *)ptr.Ptr());
696 void COomMessageFetch::ClearUpL()
703 COomRequestEvents::COomRequestEvents(CTOom *aTest) : COomSetup(aTest)
706 COomRequestEvents::~COomRequestEvents()
710 TOomTestName COomRequestEvents::TestName()
712 return(_L("Request events"));
715 void COomRequestEvents::ConstructL()
717 COomSetup::ConstructL();
720 /** Enables window group change events and modifier change events
722 TInt COomRequestEvents::Fail()
725 if ((err=iWinGroup.EnableOnEvents())==KErrNone)
726 if ((err=iWinGroup.EnableGroupChangeEvents())==KErrNone)
727 err=iWinGroup.EnableModifierChangedEvents(EModifierCapsLock,EEventControlAlways);
731 void COomRequestEvents::ClearUpL()
733 iWinGroup.DisableOnEvents();
734 iWinGroup.DisableGroupChangeEvents();
735 iWinGroup.DisableModifierChangedEvents();
740 COomCopyScreen::COomCopyScreen(CTOom *aTest) : COomSetup(aTest)
743 TOomTestName COomCopyScreen::TestName()
745 return(_L("Copy screen"));
748 COomCopyScreen::~COomCopyScreen()
754 void COomCopyScreen::ConstructL()
756 COomSetup::ConstructL();
757 iScrDev=new(ELeave) CWsScreenDevice(iWs);
758 User::LeaveIfError(iScrDev->Construct(iTest->ScreenNumber()));
759 iBitmap=new(ELeave) CFbsBitmap();
760 User::LeaveIfError(iBitmap->Create(TSize(100,100),EGray4));
763 /** Copies screen to bitmap
765 TInt COomCopyScreen::Fail()
767 TInt ret=iScrDev->CopyScreenToBitmap(iBitmap);
769 ret=iScrDev->CopyScreenToBitmap(iBitmap,TRect(10,10,50,50));
773 void COomCopyScreen::ClearUpL()
779 COomSpriteBase::COomSpriteBase(CTOom *aTest) : COomSetup(aTest)
782 COomSpriteBase::~COomSpriteBase()
791 void COomSpriteBase::ConstructL()
793 COomSetup::ConstructL();
795 User::LeaveIfError(iWin.Construct(iWinGroup,33));
796 User::LeaveIfError(iWin.SetSizeErr(TSize(100,100)));
798 iBitmap=new(ELeave) CFbsBitmap();
799 User::LeaveIfError(iBitmap->Create(TSize(10,10),EGray4));
800 iBitmap2=new(ELeave) CFbsBitmap();
801 User::LeaveIfError(iBitmap2->Create(TSize(40,40),EGray4));
802 iMask=new(ELeave) CFbsBitmap();
803 User::LeaveIfError(iMask->Create(TSize(10,10),EGray4));
804 iMask2=new(ELeave) CFbsBitmap();
805 User::LeaveIfError(iMask2->Create(TSize(40,40),EGray4));
810 COomSprite::COomSprite(CTOom *aTest) : COomSpriteBase(aTest)
813 TOomTestName COomSprite::TestName()
815 return(_L("Sprites"));
818 /** Creates a sprite.
820 TInt COomSprite::Fail()
822 iSprite=RWsSprite(iWs);
823 TInt err=iSprite.Construct(iWin,TPoint(10,10),0);
826 TSpriteMember sprite;
827 sprite.iBitmap=iBitmap;
828 sprite.iMaskBitmap=iMask;
829 sprite.iInvertMask=EFalse;
830 sprite.iDrawMode=CGraphicsContext::EDrawModePEN;
831 sprite.iOffset=TPoint(0,0);
832 sprite.iInterval=TTimeIntervalMicroSeconds32(100000);
833 if ((err=iSprite.AppendMember(sprite))==KErrNone)
834 if ((err=iSprite.Activate())==KErrNone)
836 sprite.iBitmap=iBitmap2; // Bigger bitmap to force resize of bitmap
837 sprite.iMaskBitmap=iMask2;
838 if ((err=iSprite.AppendMember(sprite))==KErrNone)
839 err=iSprite.UpdateMember(1,sprite);
845 void COomSprite::ClearUpL()
852 COomPointerCursor::COomPointerCursor(CTOom *aTest) : COomSpriteBase(aTest)
855 TOomTestName COomPointerCursor::TestName()
857 return(_L("Pointer cursor"));
860 /** Creates a pointer cursor.
862 TInt COomPointerCursor::Fail()
864 iPointerCursor=RWsPointerCursor(iWs);
865 TInt err=iPointerCursor.Construct(0);
868 TSpriteMember sprite;
869 sprite.iBitmap=iBitmap;
870 sprite.iMaskBitmap=iMask;
871 sprite.iInvertMask=EFalse;
872 sprite.iDrawMode=CGraphicsContext::EDrawModePEN;
873 sprite.iOffset=TPoint(0,0);
874 sprite.iInterval=TTimeIntervalMicroSeconds32(100000);
875 if ((err=iPointerCursor.AppendMember(sprite))==KErrNone)
876 if ((err=iPointerCursor.Activate())==KErrNone)
878 sprite.iBitmap=iBitmap2; // Bigger bitmap to force resize of bitmap
879 sprite.iMaskBitmap=iMask2;
880 if ((err=iPointerCursor.AppendMember(sprite))==KErrNone)
881 err=iPointerCursor.UpdateMember(1,sprite);
887 void COomPointerCursor::ClearUpL()
889 iPointerCursor.Close();
894 COomGc::COomGc(CTOom *aTest) : COomSetup(aTest)
902 TOomTestName COomGc::TestName()
904 return(_L("Graphic Context"));
907 void COomGc::ConstructL()
909 COomSetup::ConstructL();
910 iScrDev=new(ELeave) CWsScreenDevice(iWs);
911 User::LeaveIfError(iScrDev->Construct(iTest->ScreenNumber()));
914 /** Creates a graphical context for a previously created screen device.
918 TRAPD(err,iFailGc=new(ELeave) CWindowGc(iScrDev));
921 return(iFailGc->Construct());
924 void COomGc::ClearUpL()
932 COomPolygon::COomPolygon(CTOom *aTest) : COomSetup(aTest), iPnts(5)
935 COomPolygon::~COomPolygon()
942 TOomTestName COomPolygon::TestName()
944 return(_L("Polygon"));
947 void COomPolygon::ConstructL()
949 COomSetup::ConstructL();
950 iScrDev=new(ELeave) CWsScreenDevice(iWs);
951 User::LeaveIfError(iScrDev->Construct(iTest->ScreenNumber()));
952 User::LeaveIfError(iScrDev->CreateContext(iGc));
953 iWin=RBackedUpWindow(iWs);
954 User::LeaveIfError(iWin.Construct(iWinGroup,EGray16,33));
955 User::LeaveIfError(iWin.SetSizeErr(TSize(40,40)));
958 for(index=0;index<20;index+=2)
959 iPnts.AppendL(TPoint(20+index,index));
960 for(index=0;index<20;index+=2)
961 iPnts.AppendL(TPoint(40-index,20+index));
962 for(index=0;index<20;index+=2)
963 iPnts.AppendL(TPoint(20-index,40-index));
964 for(index=0;index<20;index+=2)
965 iPnts.AppendL(TPoint(index,20-index));
970 TInt COomPolygon::Fail()
974 iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
975 iGc->SetBrushColor(TRgb::Gray4(2));
976 iGc->SetPenColor(TRgb::Gray4(0));
977 TInt err=iGc->DrawPolygon(&iPnts,CGraphicsContext::EAlternate);
980 err=iGc->DrawPolygon(&iPnts,CGraphicsContext::EWinding);
986 void COomPolygon::ClearUpL()
993 COomScreenDevice::COomScreenDevice(CTOom *aTest) : COomSetup(aTest)
996 TOomTestName COomScreenDevice::TestName()
998 return(_L("Screen device"));
1001 /** Creates a screen device handle.
1003 TInt COomScreenDevice::Fail()
1005 TRAPD(err,iScrDev=new(ELeave) CWsScreenDevice(iWs));
1008 return(iScrDev->Construct(iTest->ScreenNumber()));
1011 void COomScreenDevice::ClearUpL()
1019 COomCustomTextCursor::COomCustomTextCursor(CTOom *aTest) : COomSetup(aTest)
1022 COomCustomTextCursor::~COomCustomTextCursor()
1024 delete iMemberArray;
1028 TOomTestName COomCustomTextCursor::TestName()
1030 return(_L("Custom Text Cursor"));
1033 void COomCustomTextCursor::ConstructL()
1035 COomSetup::ConstructL();
1037 iBitmap = new(ELeave) CFbsBitmap;
1038 User::LeaveIfError(iBitmap->Load(TEST_BITMAP_NAME, EMbmWsautotestBmp1));
1040 TSpriteMember member;
1041 member.iMaskBitmap=NULL;
1042 member.iInvertMask=EFalse;
1043 member.iDrawMode=CGraphicsContext::EDrawModePEN;
1044 member.iOffset=TPoint();
1045 member.iInterval=TTimeIntervalMicroSeconds32(0);
1046 member.iBitmap = iBitmap;
1048 iMemberArray = new(ELeave) CArrayFixFlat<TSpriteMember>(1);
1049 iMemberArray->AppendL(member);
1052 /** Adds a custom text cursor to the server's list of cursors.
1054 TInt COomCustomTextCursor::Fail()
1056 TInt err = TheClient->iWs.SetCustomTextCursor(0x98765432, iMemberArray->Array(), 0, RWsSession::ECustomTextCursorAlignTop);
1057 if (err == KErrAlreadyExists)
1063 void COomCustomTextCursor::ClearUpL()
1067 COomTranspWindow::COomTranspWindow(CTOom *aTest) : COomSetup(aTest)
1070 COomTranspWindow::~COomTranspWindow()
1072 delete iBackgroundWin;
1078 delete iFbsBitmapDevice;
1079 delete iFbsBitmapGc;
1080 delete iWsBitmapDevice;
1084 TOomTestName COomTranspWindow::TestName()
1086 return(_L("Transparent Window"));
1089 void COomTranspWindow::ConstructL()
1091 COomSetup::ConstructL();
1093 iTransparencyEnabled = (TransparencySupportedL() == KErrNone);
1094 if(!iTransparencyEnabled)
1097 iFbsBitmap = new (ELeave) CFbsBitmap;
1100 const TSize KSizeForBitmap(10,10);
1101 iFbsBitmap->Create(KSizeForBitmap,EGray256);
1103 // Fill the bitmap with a colour
1104 iFbsBitmapDevice=CFbsBitmapDevice::NewL(iFbsBitmap);
1106 iFbsBitmapDevice->CreateContext(iFbsBitmapGc);
1108 iFbsBitmapGc->SetPenStyle(CGraphicsContext::ENullPen);
1109 iFbsBitmapGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1110 iFbsBitmapGc->SetBrushColor(128);
1111 iFbsBitmapGc->DrawRect(TRect(KSizeForBitmap));
1113 // Create a CWsBitmap, and fill it with a colour
1114 iWsBitmap = new (ELeave) CWsBitmap(TheClient->iWs);
1117 iWsBitmap->Create(KSizeForBitmap,EGray256);
1119 // Fill the bitmap with a colour
1120 iWsBitmapDevice=CFbsBitmapDevice::NewL(iWsBitmap);
1122 iWsBitmapDevice->CreateContext(iWsBitmapGc);
1123 iWsBitmapGc->SetPenStyle(CGraphicsContext::ENullPen);
1124 iWsBitmapGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1125 iWsBitmapGc->SetBrushColor(128);
1126 iWsBitmapGc->DrawRect(TRect(KSizeForBitmap));
1130 /** Does nothing if transparency is not enabled. Creates a blank window with
1131 * two transparent child-windows. Tests setting the transparency via a factor, CFbsBitmap
1132 * or a CWsBitmap, and changing from one to the other.
1133 * Changes child-windows' sizes and toggles their visibility.
1135 TInt COomTranspWindow::Fail()
1137 if(!iTransparencyEnabled)
1139 TSize scrSize(TheClient->iScreen->SizeInPixels());
1140 TRAPD(res, iBackgroundWin = new (ELeave) CBlankWindow(TRgb(0,0,238)));
1146 TDisplayMode mode=EColor256;
1147 TRAP(res, iBackgroundWin->SetUpL(TPoint(50,50),scrSize-TSize(100,100),TheClient->iGroup,*TheClient->iGc,&mode));
1154 TheClient->WaitForRedrawsToFinish();
1156 iBackgroundWin->Win()->SetBackgroundColor(TRgb(51,204,51));
1157 iBackgroundWin->Invalidate();
1160 TheClient->WaitForRedrawsToFinish();
1162 TRect thePos1(20, 20, 60, 60);
1163 TRect thePos2(100, 40, 160, 80);
1164 TRAP(res, iFirst = CTransWindow::NewL(iBackgroundWin, TRgb(255,0,0,128),&mode));
1170 TRAP(res, iSecond = CTransWindow::NewL(iBackgroundWin, TRgb(255,0,0,128),&mode));
1176 TRAP(res, iFirst->SetExtL(thePos1.iTl,thePos1.Size()));
1182 TRAP(res, iSecond->SetExtL(thePos2.iTl,thePos2.Size()));
1188 res=SetTransparencyTesting();
1195 //TheClient->WaitForRedrawsToFinish();
1198 iFirst->AssignGC(*TheClient->iGc);
1200 iSecond->Activate();
1201 iSecond->AssignGC(*TheClient->iGc);
1203 iFirst->Win()->SetBackgroundColor(TRgb(0, 0, 255));
1204 iSecond->Win()->SetBackgroundColor(TRgb(0, 0, 255));
1205 iFirst->Invalidate();
1206 iSecond->Invalidate();
1208 iFirst->AdjustSize(150,10, 0);
1209 iSecond->AdjustSize(150,10, 0);
1212 TheClient->WaitForRedrawsToFinish();
1214 iFirst->ToggleVisibility();
1215 iSecond->ToggleVisibility();
1218 TheClient->WaitForRedrawsToFinish();
1220 iFirst->AdjustSize(200,10, 0);
1221 iSecond->AdjustSize(200,10, 0);
1223 iFirst->ToggleVisibility();
1224 iSecond->ToggleVisibility();
1227 TheClient->WaitForRedrawsToFinish();
1233 // This function tests setting the transparency via a factor, CFbsBitmap
1234 // or a CWsBitmap, and changing from one to the other.
1235 TInt COomTranspWindow::SetTransparencyTesting()
1238 TLogMessageText buf;
1240 // Need all nine transitions, from the 3 ways to the same 3 ways.
1241 // The ways are Factor, CWsBitmap, CFbsBitmap
1242 const TRgb KTransparencyFactor(128,128,128);
1243 res=iFirst->Win()->SetTransparencyFactor(KTransparencyFactor);
1246 buf=_L("test failure!! with SetTransparencyFactor -1");
1247 TheClient->LogMessage(buf);
1251 res=iFirst->Win()->SetTransparencyBitmap(*iFbsBitmap);
1254 buf=_L("test failure!! with SetTransparencyBitmap - fbs -2");
1255 TheClient->LogMessage(buf);
1259 res=iFirst->Win()->SetTransparencyWsBitmap(*iWsBitmap);
1262 buf=_L("test failure!! with SetTransparencyBitmap - Ws -3");
1263 TheClient->LogMessage(buf);
1267 res=iFirst->Win()->SetTransparencyFactor(KTransparencyFactor);
1270 buf=_L("test failure!! with SetTransparencyBitmap - fbs -4");
1271 TheClient->LogMessage(buf);
1274 res=iFirst->Win()->SetTransparencyWsBitmap(*iWsBitmap);
1277 buf=_L("test failure!! with SetTransparencyBitmap - Ws -5");
1278 TheClient->LogMessage(buf);
1281 res=iFirst->Win()->SetTransparencyWsBitmap(*iWsBitmap);
1284 buf=_L("test failure!! with SetTransparencyBitmap - Ws -6");
1285 TheClient->LogMessage(buf);
1289 res=iFirst->Win()->SetTransparencyBitmap(*iFbsBitmap);
1292 buf=_L("test failure!! with SetTransparencyBitmap - fbs -7");
1293 TheClient->LogMessage(buf);
1297 res=iFirst->Win()->SetTransparencyBitmap(*iFbsBitmap);
1300 buf=_L("test failure!! with SetTransparencyBitmap - fbs -8");
1301 TheClient->LogMessage(buf);
1305 res=iFirst->Win()->SetTransparencyFactor(KTransparencyFactor);
1308 buf=_L("test failure!! with SetTransparencyFactor -9");
1309 TheClient->LogMessage(buf);
1313 res=iFirst->Win()->SetTransparencyFactor(KTransparencyFactor);
1316 buf=_L("test failure!! with SetTransparencyFactor -10");
1317 TheClient->LogMessage(buf);
1324 void COomTranspWindow::ClearUpL()
1330 delete iBackgroundWin;
1331 iBackgroundWin = NULL;
1336 CWindowWithOneLine* CWindowWithOneLine::NewL(CTWinBase& aParent, const TRect& aExtent)
1338 CWindowWithOneLine* self = new(ELeave) CWindowWithOneLine;
1339 CleanupStack::PushL(self);
1340 self->ConstructL(aParent);
1341 const TSize screenSize(TheClient->iScreen->SizeInPixels());
1342 self->SetExtL(aExtent.iTl, aExtent.Size());
1343 self->AssignGC(*TheClient->iGc);
1346 CleanupStack::Pop(self);
1350 void CWindowWithOneLine::Draw()
1352 iGc->DrawLine(TPoint(0,0), TPoint(Size().iWidth, Size().iHeight));
1357 COomObscuredWindow::COomObscuredWindow(CTOom *aTest) : COomSetup(aTest)
1360 TOomTestName COomObscuredWindow::TestName()
1362 return(_L("Obscured window"));
1365 TInt COomObscuredWindow::Fail()
1367 TRAPD(err, DoFailL());
1372 void COomObscuredWindow::DoFailL()
1375 RDebug::Print(_L("COomObscuredWindow::DoFailL - enter"));
1377 const TRect extent(20, 20, 100, 100);
1378 CBlankWindow* backgroundWindow = new(ELeave) CBlankWindow(TRgb(12, 23, 34));
1379 CleanupStack::PushL(backgroundWindow);
1380 TDisplayMode mode = EColor16MAP;
1381 backgroundWindow->SetUpL(extent.iTl, extent.Size(), TheClient->iGroup, *TheClient->iGc, &mode);
1383 CWindowWithOneLine* window = CWindowWithOneLine::NewL(*backgroundWindow, extent);
1384 CleanupStack::PushL(window);
1386 RDebug::Print(_L("COomObscuredWindow - WaitForRedrawsToFinish - 1"));
1388 TheClient->WaitForRedrawsToFinish();
1390 CBlankWindow* obscuringWindow = new(ELeave) CBlankWindow(TRgb(255, 0, 0));
1391 CleanupStack::PushL(obscuringWindow);
1392 obscuringWindow->SetUpL(extent.iTl, extent.Size(), backgroundWindow, *TheClient->iGc, &mode);
1396 RDebug::Print(_L("COomObscuredWindow - WaitForRedrawsToFinish - 2"));
1398 TheClient->WaitForRedrawsToFinish();
1400 window->Invalidate();
1402 for(TInt i = 0; i < 50; i++)
1404 RWindow anotherWin(iWs);
1405 User::LeaveIfError(anotherWin.Construct(iWinGroup, 11));
1409 window->Invalidate();
1413 RDebug::Print(_L("COomObscuredWindow - WaitForRedrawsToFinish - 3 - %d"), i);
1415 TheClient->WaitForRedrawsToFinish();
1420 RDebug::Print(_L("COomObscuredWindow - WaitForRedrawsToFinish - 4"));
1422 TheClient->WaitForRedrawsToFinish();
1424 CleanupStack::PopAndDestroy(obscuringWindow);
1425 CleanupStack::PopAndDestroy(window);
1426 CleanupStack::PopAndDestroy(backgroundWindow);
1428 RDebug::Print(_L("COomObscuredWindow::DoFailL - exit"));
1432 void COomObscuredWindow::ClearUpL()
1438 CTOom::CTOom(CTestStep* aStep) : CTWsGraphicsBase(aStep)
1443 const TDesC& CTOom::TestName() const
1445 _LIT(KTestName,"CTOom");
1446 return(KTestName());
1449 void CTOom::DoOomTestL(COomFailBase *aOomTest)
1451 //TLogMessageText buf;
1452 TEST(aOomTest!=NULL);
1454 INFO_PRINTF1(_L("aOomTest - Expected: Not Null, Actual: NULL"));
1456 TRAPD(ret1,aOomTest->ConstructL());
1457 TEST(ret1==KErrNone);
1459 INFO_PRINTF3(_L("aOomTest->ConstructL() return value - Expected: %d, Actual: %d"), KErrNone, ret1);
1463 // TInt oldCount=TheClient->iWs.HeapCount();
1464 for(TInt mode=0;mode<3;mode++)
1466 /*buf.Format(_L("OOMTest[%d] Mode=%d"),iState,mode),
1467 TheClient->LogMessage(buf);*/
1468 TInt successCount=0;
1469 for(TInt count=1;;count++)
1472 aOomTest->PreFail();
1474 TheClient->iWs.HeapSetFail(RHeap::EDeterministic,count);
1476 TheClient->iWs.HeapSetBurstFail(RHeap::EBurstFailNext, count, KMaxTUint16);
1479 __UHEAP_SETFAIL(RHeap::EDeterministic,count); //Leavescan will complain about EFailNext, although it isn't a leaving function
1481 ret=aOomTest->Fail();
1483 TheClient->iWs.HeapSetFail(RHeap::ENone,0);
1485 TheClient->iWs.HeapSetBurstFail(RHeap::ENone, 0, 0);
1490 aOomTest->ClearUpL(); //In just 1 case this could leave...
1494 if (successCount==10)
1500 /*if (successCount>0)
1502 buf.Format(_L("[%d,%d] Count=%d, MaxSuccess=%d"),iState,mode,count,successCount);
1503 TheClient->LogMessage(buf);
1506 /*if (ret!=KErrNoMemory)
1508 buf.Format(_L("[%d,%d] Fail, Count=%d, Error=%d"),iState,mode,count,ret);
1509 TheClient->LogMessage(buf);
1511 TEST(ret==KErrNoMemory);
1512 if (ret!=KErrNoMemory)
1513 INFO_PRINTF3(_L("aOomTest->Fail() return value - Expected: %d, Actual: %d"), KErrNoMemory, ret);
1517 /*buf.Format(_L("[%d,%d] LastCount=%d"),iState,mode,count),
1518 TheClient->LogMessage(buf);*/
1520 // TEST(oldCount>=TheClient->iWs.HeapCount());
1523 /*buf.Format(_L("OOMTest[%d] Finished"),iState);
1524 TheClient->LogMessage(buf);*/
1527 void CTOom::ConstructL()
1529 iShieldWin=RBlankWindow(TheClient->iWs);
1530 User::LeaveIfError(iShieldWin.Construct(*(TheClient->iGroup->GroupWin()),1));
1531 // iShieldWin.SetOrdinalPosition(0,-1);
1532 iShieldWin.Activate();
1541 @SYMTestCaseID GRAPHICS-WSERV-0124
1545 @SYMTestCaseDesc Out of memory tests
1547 @SYMTestPriority High
1549 @SYMTestStatus Implemented
1551 @SYMTestActions Uses deterministic heap failure mode to test WSERV classes against out-of-memory errors.
1552 Sets and unsets deterministic mode using both RWsSession.HeapSetFail() methods and
1553 __UHEAP_SETFAIL/__UHEAP_RESET macros (doing this both client and WSERV threads are tested).
1554 On each step the test creates a failure object and repeatedly asks it to do some work (calling Fail() method).
1555 A failure object is an object which encapsulates some allocation functionality inside it's Fail() method.
1556 The test is performed for 23 different failure objects that do the following:
1557 1. Creates a wserv session, connects and creates CWsScreenDevice object.
1558 2. Creates a RWindowGroup object.
1559 3. Creates a RWindow object.
1560 4. Creates a RBackedUpWindow object.
1561 5. Sets the size of previously created backed-up window.
1562 6. Creates a RBlankWindow object.
1563 7. Allocates a buffer for storing pointer movements for a previously created backed-up window.
1564 8. Adds a priority key for a previously created window group.
1565 9. Requests a capture keys for a previously created window group.
1566 10. Requests the capture of key-up and key-down events for a previously created window group.
1567 11. Sets hot key for the session.
1568 12. Sets the window group's name.
1569 13. Sends a message to another window group.
1570 14. Fetches a message.
1571 15. Enables window group change events and modifier change events.
1572 16. Copies screen to bitmap.
1573 17. Creates a sprite.
1574 18. Creates a pointer cursor.
1575 19. Creates a graphical context for a previously created screen device.
1576 20. Draws a polygon.
1577 21. Creates a screen device handle.
1578 22. Adds a custom text cursor to the server's list of cursors.
1579 23. Does nothing if transparency is not enabled. Creates a blank window with
1580 two transparent child-windows. Tests setting the transparency via a factor, CFbsBitmap
1581 or a CWsBitmap, and changing from one to the other.
1582 Changes child-windows' sizes and toggles their visibility.
1585 @SYMTestExpectedResults The test checks that the creation failure objects doesn't fail and their's work either causes no errors or causes KErrNoMemory error.
1587 void CTOom::RunTestCaseL(TInt /*aCurTestCase*/)
1589 ((CTOomStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0124"));
1592 // commented by Anton Golovko, 01.03.2006 while converting to TEF
1593 // the code below prevented the test to do anything.
1594 // if (iTest->IsFullRomL())
1599 iOldCount=TheClient->iWs.HeapCount();
1601 else if (iState==sizeof(CreateOomFailTest)/sizeof(CreateOomFailTest[0]))
1603 iTest->CloseAllPanicWindows();
1604 TInt heapCount=TheClient->iWs.HeapCount();
1605 if (heapCount>iOldCount)
1607 TEST(iOldCount>=heapCount-184); //For some uninvestigated reason 184 object get allocated on the server side, partly because of INFO_PRINTF1
1608 if (iOldCount<heapCount-184)
1609 INFO_PRINTF3(_L("iOldCount>=heapCount-174 - Expected: %d, Actual: %d"), heapCount-184, iOldCount);
1612 ((CTOomStep*)iStep)->CloseTMSGraphicsStep();
1616 DoOomTestL(CreateOomFailTest[iState++](this));
1617 ((CTOomStep*)iStep)->RecordTestResultL();
1623 __WS_CONSTRUCT_STEP__(Oom)