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.
19 @internalComponent - Internal Symbian test code
22 #include "toutlineshadowdrawing.h"
24 // When enabled allows testing with a variable windows size rather than fixed size
25 #define _TESTWITHVARIABLEWINDOWSIZE
27 _LIT(KTextPhrase, "$%() ShAdOW OLine 1234");
28 _LIT(KFontTypeface, "fontTypeFace");
30 const TInt KIterationsToTest = 50; // Number of iterations to run tests
31 const TInt KHeight = 60;
32 const TInt KTempLength = 60; // Used for temp buffer in side function
33 const TInt KLengthOfTestCase = 256;
34 _LIT(KTestCaseFormat, "%S_%S_ORIENT_%d");
37 Auxilary function called to generate test case name based on input parameters
38 @param aTestDesc holds the test case description (eg. GET_FONT_MAX_HEIGHT)
39 @param aIsShadowOn holds bool value of shadow effects (eg. ETrue or EFalse)
40 @param aIsOutlineOn holds bool value of outline effects (eg. ETrue or EFalse)
41 @param aOrientation holds int value of orientation (eg. 0, 1, 2)
42 @param aPenColor holds pen color used to extract alpha value.
44 HBufC* CTOutlineShadowDrawing::GenerateTestCaseLC(const TDesC& aTestDesc, TBool aIsShadowOn, TBool aIsOutlineOn, TInt aOrientation, const TRgb& aPenColor)
46 TBuf<KLengthOfTestCase> tempBuffer;
47 TBuf<KTempLength> temp;
48 if(aIsShadowOn && aIsOutlineOn)
50 temp.Format(_L("WITH BOTH OUTLINE & SHADOW ON_"));
54 temp.Format(_L("WITH OUTLINE ONLY ON_"));
58 temp.Format(_L("WITH SHADOW ONLY ON_"));
62 temp.Format(_L("WITH BOTH OUTLINE & SHADOW OFF_"));
64 temp.AppendNum(aPenColor.Alpha());
66 tempBuffer.Format(KTestCaseFormat, &aTestDesc, &temp, aOrientation);
67 return tempBuffer.AllocLC();
71 @SYMTestCaseID GRAPHICS-UI-BENCH-0147
75 @SYMTestCaseDesc Tests how long it takes to run GetNearestFontToDesignHeightInTwips API
76 and calculate time with different screen modes with outline and shadow effects.
77 Also with Screen Rotation
79 @param aFontFace is the fontface which is used to set to fontspec
80 @param aRotation is the rotation index which is passed to ResultAnalysis
81 @param aIsShadowOn holds shadow status (True or False)
82 @param aIsOutlineOn holds outline status (True or False)
86 @SYMTestStatus Implemented
88 @SYMTestActions Compare the results over time, GetNearestFontToDesignHeightInPixels() code.
89 Time Calculated with different Screen Modes and with Screen Rotation.
91 CFbsBitGc::GetNearestFontToDesignHeightInPixels()
92 TFontStyle::SetEffects()
94 @SYMTestExpectedResults Test should pass and display total test time and time per display mode
96 void CTOutlineShadowDrawing::DoGetAPIsOutlineandShadowFontsL(const TDesC& aFontFace, TInt aRotation, TBool aIsShadowOn, TBool aIsOutlineOn)
101 fsp.iFontStyle.SetEffects(FontEffect::EDropShadow, aIsShadowOn);
102 fsp.iFontStyle.SetEffects(FontEffect::EOutline, aIsOutlineOn);
103 fsp.iTypeface.iName = aFontFace;
104 fsp.iHeight = KHeight;
105 TRgb outlinePenColor = iGc->PenColor();
107 _LIT(KTestName1, "GET_FONT_MAX_HEIGHT");
108 HBufC* testCase1 = GenerateTestCaseLC(KTestName1, aIsShadowOn, aIsOutlineOn, aRotation, outlinePenColor);
109 CFbsFont* font = NULL;
110 iProfiler->InitResults();
112 for(iteration=0; iteration<=KIterationsToTest; iteration++)
114 TEST(iDev->GetNearestFontToMaxHeightInPixels((CFont*&)font,fsp,fsp.iHeight) == KErrNone);
115 iProfiler->MarkResultSetL();
116 iDev->ReleaseFont(font);
119 iProfiler->ResultsAnalysis(*testCase1, aRotation, 0, iDev->DisplayMode(), KIterationsToTest);
120 CleanupStack::PopAndDestroy(testCase1);
122 _LIT(KTestName2, "GET_FONT");
123 HBufC* testCase2 = GenerateTestCaseLC(KTestName2, aIsShadowOn, aIsOutlineOn, aRotation, outlinePenColor);
124 // Tests performance for GetNearestFontInPixels API
125 iProfiler->InitResults();
126 for(iteration=0; iteration<=KIterationsToTest; iteration++)
128 TEST(iDev->GetNearestFontInPixels((CFont*&)font,fsp) == KErrNone);
129 iProfiler->MarkResultSetL();
130 iDev->ReleaseFont(font);
133 iProfiler->ResultsAnalysis(*testCase2, aRotation, 0, iDev->DisplayMode(), KIterationsToTest);
134 CleanupStack::PopAndDestroy(testCase2);
136 _LIT(KTestName3, "GET_FONT_DESIGN_HEIGHT");
137 HBufC* testCase3 = GenerateTestCaseLC(KTestName3, aIsShadowOn, aIsOutlineOn, aRotation, outlinePenColor);
138 // Tests performance for GetNearestFontToDesignHeightInPixels API
139 iProfiler->InitResults();
140 for(iteration=0; iteration<=KIterationsToTest; iteration++)
142 TEST(iDev->GetNearestFontToDesignHeightInPixels((CFont*&)font,fsp) == KErrNone);
143 iProfiler->MarkResultSetL();
144 iDev->ReleaseFont(font);
147 iProfiler->ResultsAnalysis(*testCase3, aRotation, 0, iDev->DisplayMode(), KIterationsToTest);
148 CleanupStack::PopAndDestroy(testCase3);
152 @SYMTestCaseID GRAPHICS-UI-BENCH-0148
156 @SYMTestCaseDesc Tests how long it takes to run DrawText API
157 and calculate time with different screen modes with and outline and shadow effects
159 @param aFontFace is the fontface which is used to set to fontspec
160 @param aRotation is the rotation index which is passed to ResultAnalysis
161 @param aBitmapType is the bitmap type (Here it is AntiAliased)
162 @param aOutlinePenColor is the pen color
163 @param aIsShadowOn holds shadow status (True or False)
164 @param aIsOutlineOn holds outline status (True or False)
165 @param aDispModeIndex is the display mode index used for displaying in log
167 @SYMTestPriority High
169 @SYMTestStatus Implemented
171 @SYMTestActions Compare the results over time, DrawText with and without Outline & Shadow and
172 Time calculated with different Screen Modes and with Screen Rotation DrawText().
174 CFbsBitGc::DrawText()
175 TFontStyle::SetEffects()
177 @SYMTestExpectedResults Test should pass and display total test time and time per display mode
179 void CTOutlineShadowDrawing::DoDrawTextOutlineShadowL(const TDesC& aFontFace, TInt aRotation, const TRgb& aOutlinePenColor, TBool aIsShadowOn, TBool aIsOutlineOn, TInt aDispModeIndex)
184 fsp.iTypeface.iName = aFontFace;
185 fsp.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
187 _LIT(KTestName1, "DRAWTEXT_DISPLAYINDEX_%d");
189 TBuf<KTempLength> temp;
190 fsp.iHeight = KHeight;
191 fsp.iFontStyle.SetEffects(FontEffect::EDropShadow, aIsShadowOn);
192 fsp.iFontStyle.SetEffects(FontEffect::EOutline, aIsOutlineOn);
193 iGc->SetPenColor(aOutlinePenColor);
195 User::LeaveIfError(iDev->GetNearestFontToDesignHeightInPixels((CFont*&)font,fsp));
198 temp.Format(KTestName1, aDispModeIndex);
199 HBufC* testCase1 = GenerateTestCaseLC(temp, aIsShadowOn, aIsOutlineOn, aRotation, aOutlinePenColor);
200 iProfiler->InitResults();
201 for(TInt i = 0; i <= KIterationsToTest; i++)
203 iGc->DrawText(KTextPhrase,TPoint(10,100));
204 iProfiler->MarkResultSetL();
206 iProfiler->ResultsAnalysis(*testCase1, aRotation, 0, iDev->DisplayMode(), KIterationsToTest);
207 CleanupStack::PopAndDestroy(testCase1);
209 iDev->ReleaseFont(font);
213 @SYMTestCaseID GRAPHICS-UI-BENCH-0149
217 @SYMTestCaseDesc Tests how long it takes to run DrawTextVertical API
218 and calculate time with different screen modes with and outline and shadow effects
220 @param aFontFace is the fontface which is used to set to fontspec
221 @param aRotation is the rotation index which is passed to ResultAnalysis
222 @param aBitmapType is the bitmap type (Here it is AntiAliased)
223 @param aOutlinePenColor is the pen color
224 @param aIsShadowOn holds shadow status (True or False)
225 @param aIsOutlineOn holds outline status (True or False)
226 @param aDispModeIndex is the display mode index used for displaying in log
228 @SYMTestPriority High
230 @SYMTestStatus Implemented
232 @SYMTestActions Compare the results over time, with DrawTextVertical with and without Outline & Shadow and
233 Time calculated with different Screen Modes and with Screen Rotation with DrawTextVertical
235 CFbsBitGc::DrawTextVertical()
236 TFontStyle::SetEffects()
238 @SYMTestExpectedResults Test should pass and display total test time and time per display mode
240 void CTOutlineShadowDrawing::DoDrawVerticalTextOutlineShadowL(const TDesC& aFontFace, TInt aRotation, const TRgb& aOutlinePenColor, TBool aIsShadowOn, TBool aIsOutlineOn, TInt aDispModeIndex)
246 TInt alpha = aOutlinePenColor.Alpha();
247 fsp.iTypeface.iName = aFontFace;
248 fsp.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
250 _LIT(KTestName1, "DRAWTEXTVERTICAL_DISPLAYINDEX_%d");
252 TBuf<KTempLength> temp;
253 temp.Format(KTestName1, aDispModeIndex);
254 HBufC* testCase1 = GenerateTestCaseLC(temp, aIsShadowOn, aIsOutlineOn, aRotation, aOutlinePenColor);
255 fsp.iHeight = KHeight;
256 fsp.iFontStyle.SetEffects(FontEffect::EDropShadow, aIsShadowOn);
257 fsp.iFontStyle.SetEffects(FontEffect::EOutline, aIsOutlineOn);
259 iGc->SetPenColor(aOutlinePenColor);
260 User::LeaveIfError(iDev->GetNearestFontToDesignHeightInPixels((CFont*&)font,fsp));
262 iProfiler->InitResults();
263 for(TInt i=0; i<=KIterationsToTest; i++)
265 iGc->DrawTextVertical(KTextPhrase,TPoint(10,10),EFalse);
266 iProfiler->MarkResultSetL();
268 iProfiler->ResultsAnalysis(*testCase1, aRotation, 0, iDev->DisplayMode(), KIterationsToTest);
269 CleanupStack::PopAndDestroy(testCase1);
271 iDev->ReleaseFont(font);
274 CTOutlineShadowDrawing::~CTOutlineShadowDrawing()
278 CTOutlineShadowDrawing::CTOutlineShadowDrawing()
280 SetTestStepName(KTOutlineShadowDrawing);
284 Override of base class pure virtual
285 Our implementation only gets called if the base class doTestStepPreambleL() did
286 not leave. That being the case, the current test result value will be EPass.
288 Takes Font Face from uibench.ini file and pass that value to functions.
289 It also Rotates the screen before calling test functions.
291 @return TVerdict code
293 TVerdict CTOutlineShadowDrawing::doTestStepL()
297 TBool returnValue1 = GetStringFromConfig(ConfigSection(), KFontTypeface, fontface);
300 INFO_PRINTF1(_L("OutlineShadowDrawing"));
302 TBool orientation[4];
303 SetTestStepID(_L("GRAPHICS-UI-BENCH-0147"));
304 DoGetAPIsOutlineandShadowFontsL(fontface, 0, ETrue, ETrue);
305 DoGetAPIsOutlineandShadowFontsL(fontface, 0, ETrue, EFalse);
306 DoGetAPIsOutlineandShadowFontsL(fontface, 0, EFalse, ETrue);
307 DoGetAPIsOutlineandShadowFontsL(fontface, 0, EFalse, EFalse);
310 for(TInt dispModeIndex = 0; dispModeIndex < KNumValidDisplayModes; dispModeIndex++)
312 SetScreenModeL(KValidDisplayModes[dispModeIndex]);
313 iDev = &iScreenDevice->BitmapDevice();
314 iGc->OrientationsAvailable(orientation);
315 for (TInt orient = CFbsBitGc::EGraphicsOrientationNormal; orient <= CFbsBitGc::EGraphicsOrientationRotated270; orient++)
317 iGc->SetOrientation((CFbsBitGc::TGraphicsOrientation)orient);
318 // Draw Text - without transperency
319 SetTestStepID(_L("GRAPHICS-UI-BENCH-0148"));
320 DoDrawTextOutlineShadowL(fontface, orient, KRgbGreen, ETrue, ETrue, dispModeIndex);
321 DoDrawTextOutlineShadowL(fontface, orient, KRgbGreen, EFalse, ETrue, dispModeIndex);
322 DoDrawTextOutlineShadowL(fontface, orient, KRgbGreen, ETrue, EFalse, dispModeIndex);
323 DoDrawTextOutlineShadowL(fontface, orient, KRgbGreen, EFalse, EFalse, dispModeIndex);
325 // Draw Vertical Text - without transperency
326 SetTestStepID(_L("GRAPHICS-UI-BENCH-0149"));
327 DoDrawVerticalTextOutlineShadowL(fontface, orient, KRgbRed, ETrue, ETrue, dispModeIndex);
328 DoDrawVerticalTextOutlineShadowL(fontface, orient, KRgbRed, ETrue, EFalse, dispModeIndex);
329 DoDrawVerticalTextOutlineShadowL(fontface, orient, KRgbRed, EFalse, ETrue, dispModeIndex);
330 DoDrawVerticalTextOutlineShadowL(fontface, orient, KRgbRed, EFalse, EFalse, dispModeIndex);
332 // Transperency tests - Draw Text
333 SetTestStepID(_L("GRAPHICS-UI-BENCH-0148"));
334 DoDrawTextOutlineShadowL(fontface, orient, TRgb(128, 128, 128, 120), ETrue, ETrue, dispModeIndex);
335 DoDrawTextOutlineShadowL(fontface, orient, TRgb(128, 128, 128, 120), EFalse, ETrue, dispModeIndex);
336 DoDrawTextOutlineShadowL(fontface, orient, TRgb(128, 128, 128, 120), ETrue, EFalse, dispModeIndex);
337 DoDrawTextOutlineShadowL(fontface, orient, TRgb(128, 128, 128, 120), EFalse, EFalse, dispModeIndex);
339 // Transperency tests - Draw Vertical Text
340 SetTestStepID(_L("GRAPHICS-UI-BENCH-0149"));
341 DoDrawVerticalTextOutlineShadowL(fontface, orient, TRgb(128, 128, 0, 20), ETrue, ETrue, dispModeIndex);
342 DoDrawVerticalTextOutlineShadowL(fontface, orient, TRgb(128, 128, 0, 20), ETrue, EFalse, dispModeIndex);
343 DoDrawVerticalTextOutlineShadowL(fontface, orient, TRgb(128, 128, 0, 20), EFalse, ETrue, dispModeIndex);
344 DoDrawVerticalTextOutlineShadowL(fontface, orient, TRgb(128, 128, 0, 20), EFalse, EFalse, dispModeIndex);
347 iGc->SetOrientation(CFbsBitGc::EGraphicsOrientationNormal);
352 INFO_PRINTF1(_L("ERROR WHILE READING CONFIG FILE"));
353 User::Leave(returnValue1);
355 return TestStepResult();
359 Override of base class pure virtual
361 @return - TVerdict code
363 TVerdict CTOutlineShadowDrawing::doTestStepPreambleL()
365 CTe_graphicsperformanceSuiteStepBase::doTestStepPreambleL();
366 SetScreenModeL(EColor16MU);
367 iDev = &iScreenDevice->BitmapDevice();
368 return TestStepResult();