Update contrib.
1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Test out of memory redraws
21 @internalComponent - Internal Symbian test code
26 void DrawTestScreen(CWindowGc *aGc, const TSize &aSize)
28 aGc->SetPenSize(TSize(10,10));
29 aGc->SetBrushStyle(CGraphicsContext::EVerticalHatchBrush);
30 aGc->DrawRect(TRect(aSize));
39 #if defined(FULLLOGGING)
40 _LIT(KLog,"Drawing Test Win:%d %d,%d");
42 buf.Format(KLog,Size().iWidth>320?1:0,Size().iWidth,Size().iHeight);
43 TheClient->LogMessage(buf);
45 DrawTestScreen(iGc,Size());
48 CBaseTestWin::CBaseTestWin() : CTBackedUpWin(EGray4)
51 void CBaseTestWin::Resized(const TSize &aNewSize)
53 TheGc->Activate(*DrawableWin());
54 DrawTestScreen(TheGc,aNewSize);
58 CToomDraw::CToomDraw(CTestStep* aStep):
59 CTWsGraphicsBase(aStep)
63 CToomDraw::~CToomDraw()
65 TheClient->iWs.HeapSetFail(RHeap::ENone,0); //In case the test crashes and it hasn't been reset
69 void CToomDraw::DeleteWindows()
81 void CToomDraw::ConstructL()
83 iScrSize=TheClient->iScreen->SizeInPixels();
84 iBlankWin=new(ELeave) CTBlankWindow;
85 iBlankWin->ConstructL(*TheClient->iGroup);
86 iBlankWin->SetColor(TRgb::Gray4(2)); //Grey
87 iBlankWin->Activate();
88 iBackWin=new(ELeave) CTestWin();
89 iBackWin->SetUpL(TPoint(0,iScrSize.iHeight/4), TSize(iScrSize.iWidth,iScrSize.iHeight/2), TheClient->iGroup, *TheClient->iGc);
90 iBaseWin=new(ELeave) CBaseTestWin();
91 iBaseWin->SetUpL(TPoint(iScrSize.iWidth*2/3,0), TSize(iScrSize.iWidth/3,iScrSize.iHeight), TheClient->iGroup, *TheClient->iGc);
94 void CToomDraw::CreateTestWinL()
96 iTestWin=new(ELeave) CTestWin();
97 iTestWin->ConstructL(*TheClient->iGroup);
98 iTestWin->SetExtL(TPoint(0,0), TSize(iScrSize.iWidth/3,iScrSize.iHeight));
99 iTestWin->AssignGC(*TheClient->iGc);
100 iTestWin->BaseWin()->SetShadowHeight(2);
103 void CToomDraw::TriggerOomDrawsL(TInt aCount)
107 iTestWin->SetExtL(TPoint(),iScrSize);
112 TheClient->iWs.HeapSetFail(RHeap::EDeterministic,aCount);
113 iTestWin->Activate();
114 TheClient->iWs.Finish();
117 TBool CToomDraw::CheckWindowsL()
120 TBool pass = DoCheckRect(iTestWin,iBaseWin);
123 TEST(ETrue); //Adds one to test count
124 #if defined(FULLLOGGING)
125 _LIT(KLog,"OOM Draw Test Pass, State=%d");
126 buf.Format(KLog,iState);
134 if ((iTest->RedrawStoreTypeL()==EPartialRedraw_PreserveStoredCmds ||
135 iTest->RedrawStoreTypeL()==EPartialRedraw_FullRedrawSupport) && (iState==19 || iState==30) ||
136 ((iState>=2 && iState<=6) && (iTest->RedrawStoreTypeL()==EPartialRedraw_None || iTest->RedrawStoreTypeL()==EPartialRedraw_FullRedrawSupport)))
138 #if defined(FULLLOGGING)
139 _LIT(KLog,"OOM Draw Test Known F a i l, State=%d");
140 buf.Format(KLog,iState);
148 ++iFails; //mark this test as failed
150 _LIT(KLog,"OOM Draw Test FAIL, State=%d <------- FAIL");
151 buf.Format(KLog,iState);
153 ++iState; //and advance to next test
159 #if defined(FULLLOGGING)
160 _LIT(KLog,"OOM Draw Test F a i l, State=%d retrying");
161 buf.Format(KLog,iState);
163 if (++iRetryCount%2==0)
168 TheClient->LogMessage(buf);
172 void CToomDraw::RunTestCaseL(TInt aCurTestCase)
174 TBool testFinished = false;
175 ((CToomDrawStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
179 @SYMTestCaseID GRAPHICS-WSERV-0110
183 @SYMTestCaseDesc Test trying to draw when out of memory
185 @SYMTestPriority High
187 @SYMTestStatus Implemented
189 @SYMTestActions Set out of memory and try drawing
191 @SYMTestExpectedResults Out of memory drawing is handle correctly
194 ((CToomDrawStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0110"));
195 while (!testFinished)
199 TheClient->iWs.HeapSetFail(RHeap::ENone,0);
200 TheClient->WaitForRedrawsToFinish();
204 if (iState==EMaxOOMState)
208 TheClient->iWs.Finish();
212 if (iState==EMaxOOMState)
217 _LIT(KLog,"OOM Draw Test Failed, First Fail At %d, Number of Fails %d");
219 buf.Format(KLog,iFailAt,iFails);
220 TheClient->LogMessage(buf);
224 User::After(500000); // Let the rest of the world catch up after OOM death
227 else if (iState < 3 && iTest->IsFullRomL())
230 TriggerOomDrawsL(iState);
236 ((CToomDrawStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
237 ((CToomDrawStep*)iStep)->CloseTMSGraphicsStep();
241 ((CToomDrawStep*)iStep)->RecordTestResultL();
244 __WS_CONSTRUCT_STEP__(oomDraw)