Update contrib.
1 // Copyright (c) 2007-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.
16 #include "tdrawtext.h"
17 #include <graphics/directgdiengine.h>
18 #include <graphics/directgdicontext.h>
21 LOCAL_C void CleanCache(TAny* aPtr)
23 MFontGlyphImageStorage* glyphImageStorage = reinterpret_cast<MFontGlyphImageStorage*> (aPtr);
24 glyphImageStorage->CleanGlyphImageCache();
28 Default text drawing target size
30 const TSize KDrawTextDefaultSize(640, 400);
35 _LIT16(KPangram, "The quick brown fox jumps over the lazy dog");
39 CTDrawText::CTDrawText()
41 SetTestStepName(KTDirectGdiDrawTextStep);
44 CTDrawText::~CTDrawText()
54 Override of base class pure virtual
55 Our implementation only gets called if the base class doTestStepPreambleL() did
56 not leave. That being the case, the current test result value will be EPass.
57 @leave Gets system wide error code
60 TVerdict CTDrawText::doTestStepL()
62 // Test for each target pixel format
63 for(TInt targetPixelFormatIndex = iTargetPixelFormatArray.Count() - 1; targetPixelFormatIndex >= 0 ; targetPixelFormatIndex--)
65 iTestParams.iTargetPixelFormat = iTargetPixelFormatArray[targetPixelFormatIndex];
67 SetTargetL(iTestParams.iTargetPixelFormat, EOneContextOneTarget, KDrawTextDefaultSize);
70 User::LeaveIfNull(iFont);
73 // only run OOM tests for one target pixel format to prevent duplication of tests
74 if (targetPixelFormatIndex == 0)
76 RunOomTestsL(); //from base class
85 CloseTMSGraphicsStep();
86 return TestStepResult();
90 Override of base class virtual
91 @leave Gets system wide error code
92 @return - TVerdict code
94 TVerdict CTDrawText::doTestStepPreambleL()
96 CTDirectGdiStepBase::doTestStepPreambleL();
97 return TestStepResult();
102 GRAPHICS-DIRECTGDI-TEXT-0001
117 Basic test for text drawing with basic and valid parameters.
126 Test the DrawText() and DrawTextVertical() functions for text drawing using either BitGDI or DirectGDI gc.
128 @SYMTestExpectedResults
129 Valid bitmap should be created. This bitmap should be the same as a reference bitmap.
132 void CTDrawText::TestBasicFunctionality()
134 _LIT(KTestName, "Text-Basic");
135 if(!iRunningOomTests)
137 INFO_PRINTF1(KTestName);
143 TEST(iGc->HasFont());
144 iGc->SetPenColor(TRgb(0, 0, 0));
148 iGc->DrawTextVertical(KPangram,NULL,TPoint(10,10),EFalse);
150 iGc->DrawTextVertical(KAbcd, NULL, EFalse);
152 TRect rect(30,10,50,400);
153 TInt baseline = rect.Width() / 2 + iFont->AscentInPixels() / 2;
154 iGc->DrawTextVertical(KPangram,NULL,rect,baseline,EFalse);
156 rect.SetRect(50,10,80,400);
157 baseline = rect.Width() / 2 + iFont->AscentInPixels() / 2;
158 iGc->DrawTextVertical(KPangram,NULL,rect,baseline,10,EFalse);
160 rect.SetRect(50,100,80,400);
161 iGc->DrawTextVertical(KAbcd,NULL,rect,EFalse);
165 iGc->DrawTextVertical(KPangram,NULL,TPoint(105,390),ETrue);
167 iGc->DrawTextVertical(KAbcd,NULL,ETrue);
169 rect.SetRect(110,10,140,390);
170 baseline = rect.Width() / 2 + iFont->AscentInPixels() / 2;
171 iGc->DrawTextVertical(KPangram,NULL,rect,baseline,ETrue);
173 rect.SetRect(140,10,160,390);
174 baseline = rect.Width() / 2 + iFont->AscentInPixels() / 2;
175 iGc->DrawTextVertical(KPangram,NULL,rect,baseline,10,ETrue);
177 rect.SetRect(140,10,160,200);
178 iGc->DrawTextVertical(KAbcd,NULL,rect,ETrue);
181 iGc->DrawText(KPangram,NULL,TPoint(170, 25));
183 iGc->DrawText(KAbcd,NULL);
185 rect.SetRect(170,30,640,50);
186 baseline = rect.Height() / 2 + iFont->AscentInPixels() / 2;
187 iGc->DrawText(KPangram,NULL,rect,baseline);
189 rect.SetRect(170,30,640,50);
190 iGc->DrawText(KAbcd,NULL,rect);
195 TESTNOERROR(iGc->GetError());
196 TEST(KErrNone == WriteTargetOutput(iTestParams, TPtrC(KTestName)));
201 GRAPHICS-DIRECTGDI-TEXT-0002
216 Test for text positioning and clipping in a rendering target.
217 Only horizontal drawing direction is taken into consideration.
226 Loop over all versions od DrawText() method.
227 Using each one draw a text "text" on screen at various positions.
228 Increment position from (-50,-50) up to target width+50 and target heigh+50
229 to test boundary cases as well.
231 @SYMTestExpectedResults
232 Valid bitmap should be created. This bitmap should be the same as a reference bitmap.
234 void CTDrawText::TestTextPositioning()
236 _LIT(KTestName, "Text-Positioning");
237 if(!iRunningOomTests)
239 INFO_PRINTF1(KTestName);
243 for(TInt funcNum=0; funcNum<4; funcNum++)
249 TEST(iGc->HasFont());
250 iGc->SetPenColor(TRgb(0, 0, 0));
252 TPositionIterator posIterator(-50, KDrawTextDefaultSize.iWidth+50, 30, -50, KDrawTextDefaultSize.iHeight+50, 13);
261 // void DrawText(const TDesC& aText);
264 TEST(iGc->HasFont());
265 iGc->SetPenColor(TRgb(0, 0, 0));
266 iGc->SetOrigin(TPoint(posIterator.iPosX+posIterator.iIndexY, posIterator.iPosY+posIterator.iIndexX));
267 iGc->DrawText(KText,NULL);
273 // void DrawText(const TDesC& aText, const TPoint& aPosition)
274 iGc->DrawText(KText,NULL,TPoint(posIterator.iPosX+posIterator.iIndexY, posIterator.iPosY+posIterator.iIndexX));
280 // void DrawText(const TDesC& aText, const TRect& aBox)
283 TEST(iGc->HasFont());
284 iGc->SetPenColor(TRgb(0, 0, 0));
285 TPoint pos(posIterator.iPosX+posIterator.iIndexY, posIterator.iPosY+posIterator.iIndexX);
287 TRect box(-pos, KDrawTextDefaultSize);
288 iGc->DrawText(KText,NULL,box);
294 // void DrawText(const TDesC& aText, const TRect& aBox, TInt aBaselineOffset,
295 // DirectGdi::TTextAlign aAlignment = DirectGdi::ELeft, TInt aMargin = 0)
296 TRect rect(TPoint(posIterator.iPosX+posIterator.iIndexY, posIterator.iPosY+posIterator.iIndexX), TSize(32, 13) );
297 iGc->DrawText(KText, NULL, rect, 13, DirectGdi::ELeft, 1);
302 while(posIterator.Next());
304 TESTNOERROR(iGc->GetError());
306 tname.Format(_L("%S%d"), &KTestName, funcNum);
307 TEST(KErrNone == WriteTargetOutput(iTestParams, tname));
316 GRAPHICS-DIRECTGDI-TEXT-0003
331 Test for clipping text based on the box parameter.
340 Set the origin to a non-zero position.
341 Draw a text "text" on screen at various positions using
342 incremented box size.
344 @SYMTestExpectedResults
345 Valid bitmap should be created. This bitmap should be the same as a reference bitmap.
347 void CTDrawText::TestTextBox()
349 _LIT(KTestName, "Text-BoxClipping");
350 if(!iRunningOomTests)
352 INFO_PRINTF1(KTestName);
357 iGc->SetOrigin(TPoint(2, -2));
359 TEST(iGc->HasFont());
360 iGc->SetPenColor(TRgb(0, 0, 0));
361 iGc->SetBrushStyle(DirectGdi::ESolidBrush);
362 iGc->SetBrushColor(TRgb(150, 150, 150));
366 TInt baseline = 2 + iFont->FontMaxAscent()/2;
367 TPositionIterator posIterator(0, KDrawTextDefaultSize.iWidth, 50, 0, KDrawTextDefaultSize.iHeight, 13);
372 TRect rect(TPoint(posIterator.iPosX, posIterator.iPosY), TSize(posIterator.iIndexY, posIterator.iIndexX));
375 iGc->DrawText(KText, NULL, rect, baseline);
378 while(posIterator.Next());
382 TESTNOERROR(iGc->GetError());
383 TEST(KErrNone == WriteTargetOutput(iTestParams, TPtrC(KTestName)));
389 GRAPHICS-DIRECTGDI-TEXT-0004
404 Test for positioning vertical text in a rendering target.
405 Only vertical drawing direction is taken into consideration.
414 Loop over all versions od DrawTextVertical() method.
415 Using each one draw a text "text" on screen at various positions.
416 Increment position from (-50,-70) up to target width+50 and target heigh+70
417 to test boundary cases as well.
419 @SYMTestExpectedResults
420 Test should perform graphics operations successfully.
422 void CTDrawText::TestTextPositioningVertical(TBool aUp)
424 _LIT(KTestName, "Text-PositioningVertical");
425 if(!iRunningOomTests)
427 INFO_PRINTF1(KTestName);
432 for(TInt funcNum = 0; funcNum<5; funcNum++)
438 TEST(iGc->HasFont());
439 iGc->SetPenColor(TRgb(0, 0, 0));
441 TPositionIterator posIterator(-50, KDrawTextDefaultSize.iWidth+50, 10, -70, KDrawTextDefaultSize.iHeight+70, 30);
450 // void DrawTextVertical(const TDesC& aText, TBool aUp)
453 TEST(iGc->HasFont());
454 iGc->SetPenColor(TRgb(0, 0, 0));
455 iGc->SetOrigin(TPoint(posIterator.iPosX+posIterator.iIndexY, posIterator.iPosY+posIterator.iIndexX));
456 iGc->DrawTextVertical(KText, NULL, aUp);
462 // void DrawTextVertical(const TDesC& aText, const TPoint& aPosition, TBool aUp)
463 iGc->DrawTextVertical(KText, NULL, TPoint(posIterator.iPosX+posIterator.iIndexY, posIterator.iPosY+posIterator.iIndexX), aUp);
469 // void DrawTextVertical(const TDesC& aText, const TRect& aBox, TBool aUp)
472 TEST(iGc->HasFont());
473 iGc->SetPenColor(TRgb(0, 0, 0));
474 TPoint pos(posIterator.iPosX+posIterator.iIndexY, posIterator.iPosY+posIterator.iIndexX);
476 TRect box(-pos, KDrawTextDefaultSize);
477 iGc->DrawTextVertical(KText, NULL, box, aUp);
483 // void DrawTextVertical(const TDesC& aText, const TRect& aBox, TInt aBaselineOffset,
484 // TBool aUp, DirectGdi::TTextAlign aVerticalAlignment = DirectGdi::ELeft, TInt aMargin = 0)
485 TRect rect(TPoint(posIterator.iPosX+posIterator.iIndexY, posIterator.iPosY+posIterator.iIndexX),TSize(13, 32));
486 iGc->DrawTextVertical(KText, NULL, rect, 12, aUp,DirectGdi::ELeft, 0);
492 // void DrawTextVertical(const TDesC& aText, const TRect& aBox, TInt aBaselineOffset,
493 // TInt aTextWidth, TBool aUp, DirectGdi::TTextAlign aVerticalAlignment = DirectGdi::ELeft, TInt aMargin = 0)
494 TRect rect(TPoint(posIterator.iPosX+posIterator.iIndexY, posIterator.iPosY+posIterator.iIndexX),TSize(13, 32));
495 iGc->DrawTextVertical(KText, NULL, rect, 12, 4, aUp, DirectGdi::ELeft, 0);
500 while(posIterator.Next());
502 TESTNOERROR(iGc->GetError());
508 tname.Format(_L("%S%d%S"), &KTestName, funcNum, aUp ? &KUp : &KDown);
509 TESTNOERROR(WriteTargetOutput(iTestParams, tname));
518 GRAPHICS-DIRECTGDI-TEXT-0005
533 Test for clipping text based on the clipping rectangle parameter.
542 Set the origin to a non-zero position.
543 Draw a text "text" on screen at various positions using
544 incremented box size.
546 @SYMTestExpectedResults
547 Valid bitmap should be created. This bitmap should be the same as a reference bitmap.
549 void CTDrawText::TestTextBoxVertical()
551 _LIT(KTestName, "Text-BoxClippingVertical");
552 if(!iRunningOomTests)
554 INFO_PRINTF1(KTestName);
560 TEST(iGc->HasFont());
561 iGc->SetPenColor(TRgb(0, 0, 0));
562 iGc->SetBrushStyle(DirectGdi::ESolidBrush);
563 iGc->SetBrushColor(TRgb(150, 150, 150));
564 iGc->SetOrigin(TPoint(2, -2));
568 TInt baseline = 2 + iFont->FontMaxAscent()/2;
570 TPositionIterator posIterator(0, KDrawTextDefaultSize.iWidth, 14, 0, KDrawTextDefaultSize.iHeight, 40);
575 TRect rect(TPoint(posIterator.iPosX, posIterator.iPosY), TSize(posIterator.iIndexY, posIterator.iIndexX));
578 iGc->DrawTextVertical(KText, NULL, rect, baseline, EFalse);
581 while(posIterator.Next());
585 TESTNOERROR(iGc->GetError());
586 TEST(KErrNone == WriteTargetOutput(iTestParams, TPtrC(KTestName)));
592 GRAPHICS-DIRECTGDI-TEXT-0006
607 Testing usage of pen colour, brush colour, style and pattern.
616 Test pen and brush parameters with text drawing methods.
617 Use color and brush style tables to generate various combinations
618 of pen color, brush color and brush style. Text drawing on screen
619 describes current color and style settings.
620 *NOTE extended for DEF133363-Zero length text causes no brush pattern to be drawn
622 @SYMTestExpectedResults
623 Valid bitmap should be created. This bitmap should be the same as a reference bitmap.
625 void CTDrawText::TestPenBrushL()
627 _LIT(KTestName, "Text-PenBrush");
628 if(!iRunningOomTests)
630 INFO_PRINTF1(KTestName);
633 _LIT(KTxtPenBrushStyle,"PenColor-BrushColor-BrushStyle");
636 CFbsBitmap* bitmap = CreateCheckedBoardBitmapL(iTestParams.iTargetPixelFormat, (TSize(100, 100)));
637 TESTL(bitmap != NULL);
638 CleanupStack::PushL(bitmap);
642 iGc->SetBrushPattern(*bitmap);
645 TEST(iGc->HasFont());
652 for(ii = 0; ii<16; ii++)
654 iGc->SetPenColor(KColor16Table[ii%16]);
655 point.iX =26 + ii*17;
656 iGc->DrawTextVertical(KColor16TableNames[ii%16],NULL,point,EFalse);
660 iGc->SetPenColor(KRgbBlack);
661 iGc->DrawTextVertical(KTxtPenBrushStyle,NULL,point,EFalse);
663 for(ii = 0; ii<16; ii++)
667 iGc->SetPenColor(KColor16Table[ii%16]);
668 txtbuf.Append(KColor16TableNames[ii%16]);
669 txtbuf.Append(KTxtDash);
671 iGc->SetBrushColor(KColor16Table[(5*ii+1)%16]);
672 txtbuf.Append(KColor16TableNames[(5*ii+1)%16]);
673 txtbuf.Append(KTxtDash);
675 iGc->SetBrushStyle(KBrushStyleTable[(2*ii+1)%9]);
676 txtbuf.Append(KBrushStyleTableNames[(2*ii+1)%9]);
678 if (ii == 6 || ii == 7 || ii == 8)
683 rect.SetRect(point.iX,point.iY,point.iX+17,point.iY+290);
684 baseline = rect.Width() / 2 + iFont->AscentInPixels() / 2;
685 iGc->DrawTextVertical(txtbuf,NULL,rect,baseline,EFalse);
690 iGc->SetPenColor(KRgbBlack);
691 iGc->DrawText(KTxtPenBrushStyle,NULL,point);
692 for(ii=0; ii<16; ii++)
696 iGc->SetPenColor(KColor16Table[ii%16]);
697 txtbuf.Append(KColor16TableNames[ii%16]);
698 txtbuf.Append(KTxtDash);
700 iGc->SetBrushColor(KColor16Table[(3*ii+5)%16]);
701 txtbuf.Append(KColor16TableNames[(3*ii+5)%16]);
702 txtbuf.Append(KTxtDash);
704 iGc->SetBrushStyle(KBrushStyleTable[(5*ii+3)%9]);
705 txtbuf.Append(KBrushStyleTableNames[(5*ii+3)%9]);
707 if (ii == 9 || ii == 10 || ii == 11)
712 rect.SetRect(point.iX,point.iY,point.iX+290,point.iY+17);
713 baseline = rect.Height() / 2 + iFont->AscentInPixels() / 2;
714 iGc->DrawText(txtbuf,NULL,rect,baseline);
717 for(ii=0; ii<16; ii++)
719 point.iX = 300 + (ii%4)*80;
720 point.iY = 310 + (ii/4)*17;
721 iGc->SetPenColor(KColor16Table[ii%16]);
722 iGc->DrawText(KColor16TableNames[ii%16],NULL,point);
728 CleanupStack::PopAndDestroy(bitmap);
730 TESTNOERROR(iGc->GetError());
731 TEST(KErrNone == WriteTargetOutput(iTestParams, TPtrC(KTestName)));
736 GRAPHICS-DIRECTGDI-TEXT-0007
751 Test for alignment of text inside drawing box.
760 Call functions testing all combinations of parameters values given below:
772 Use gray background box to show arguments impact.
774 @SYMTestExpectedResults
775 Valid bitmap should be created. This bitmap should be the same as a reference bitmap.
777 void CTDrawText::TestAlign()
779 _LIT(KTestName, "Text-Alignment");
780 if(!iRunningOomTests)
782 INFO_PRINTF1(KTestName);
788 TEST(iGc->HasFont());
789 iGc->SetPenColor(TRgb(0, 0, 0));
790 iGc->SetBrushStyle(DirectGdi::ESolidBrush);
791 iGc->SetBrushColor(KRgbGray);
793 _LIT(KMargin," Margin = ");
794 _LIT(KAlign,"Align = ");
799 for(TInt kk=0; kk<2; kk++) //loop over up and down directions
801 for(TInt ii=0; ii<3; ii++) // negative, zero and positive margin value
803 TInt margin = (-ii+1)*50;
804 for(TInt jj=0; jj<3; jj++) // ELeft, ECenter and ERight alignment values
806 rect.SetRect(kk*185+5+(3*ii+jj)*20 +1, 10, kk*185+25+(3*ii+jj)*20-1, 390);
807 baseline = rect.Width()/2 + iFont->AscentInPixels()/2 ;
809 textbuf.Copy(KAlign);
810 textbuf.Append(KTextAlignTableNames[jj%3]);
811 textbuf.Append(KMargin);
812 textbuf.AppendNum(margin);
813 iGc->DrawTextVertical(textbuf,NULL,rect,baseline,kk!=0,KTextAlignTable[jj%3],margin);
819 for(TInt ii=0; ii<3; ii++) // negative, zero and positive margin value
821 TInt margin = (-ii+1)*40;
822 for(TInt jj=0; jj<3; jj++) // ELeft, ECenter and ERight alignment values
824 rect.SetRect(373, 30+(3*ii+jj)*20+1, 635, 50+(3*ii+jj)*20-1);
825 baseline = rect.Height()/2 + iFont->AscentInPixels()/2;
827 textbuf.Copy(KAlign);
828 textbuf.Append(KTextAlignTableNames[jj%3]);
829 textbuf.Append(KMargin);
830 textbuf.AppendNum(margin);
831 iGc->DrawText(textbuf,NULL,rect,baseline,KTextAlignTable[jj%3],margin);
837 TESTNOERROR(iGc->GetError());
838 TEST(KErrNone == WriteTargetOutput(iTestParams, TPtrC(KTestName)));
843 GRAPHICS-DIRECTGDI-TEXT-0008
858 Testing justification of a text.
867 Test the effect of the following functions:
868 SetCharJustification()
869 SetWordJustification()
870 UpdateJustification()
871 UpdateJustificationVertical()
872 NoJustifyAutoUpdate()
874 @SYMTestExpectedResults
875 Valid bitmap should be created. This bitmap should be the same as a reference bitmap.
878 void CTDrawText::TestJustification()
880 _LIT(KTestName, "Text-Justification");
881 if(!iRunningOomTests)
883 INFO_PRINTF1(KTestName);
889 TEST(iGc->HasFont());
890 iGc->SetPenColor(TRgb(0, 0, 0));
893 TInt charExcessWidth = 30;
894 TInt charNumGaps = 30;
895 TInt wordExcessWidth = 100;
896 TInt wordNumChars = 5;
899 TInt baseline, kk, jj;
900 for( kk=0; kk<2; kk++) //loop over up and down directions
902 for( jj=0; jj<4; jj++)
904 iGc->SetCharJustification(charExcessWidth*(jj%2) , charNumGaps*(jj%2));
905 iGc->SetWordJustification(wordExcessWidth*(jj>>1), wordNumChars*(jj>>1));
906 rect.SetRect(10+(5*kk+jj)*20+1, 10, 30+(5*kk+jj)*20-1, 390);
907 baseline = rect.Width()/2 + iFont->AscentInPixels()/2;
908 iGc->DrawTextVertical(KPangram,NULL,rect,baseline,kk!=0);
913 for( jj=0; jj<4; jj++)
915 iGc->SetCharJustification(charExcessWidth*(jj%2) , charNumGaps*(jj%2));
916 iGc->SetWordJustification(wordExcessWidth*(jj>>1), wordNumChars*(jj>>1));
917 rect.SetRect(210, 10+jj*20+1, 640, 30+jj*20-1);
918 baseline = rect.Height()/2 + iFont->AscentInPixels()/2;
919 iGc->DrawText(KPangram,NULL,rect,baseline);
924 TESTNOERROR(iGc->GetError());
925 TEST(KErrNone == WriteTargetOutput(iTestParams, TPtrC(KTestName)));
930 GRAPHICS-DIRECTGDI-TEXT-0009
945 Testing usage of shadow colour, underline and strikethrough rendering using either BitGDI or DirectGDI gc.
954 Test the shadow colour, underline and strikethrough parameters for text drawing.
956 @SYMTestExpectedResults
957 Valid bitmap should be created. This bitmap should be the same as a reference bitmap.
959 void CTDrawText::TestShadowUnderStrike()
961 _LIT(KTestName, "Text-ShadowUnderlineStrikethrough");
962 if(!iRunningOomTests)
964 INFO_PRINTF1(KTestName);
970 TEST(iGc->HasFont());
971 iGc->SetPenColor(TRgb(0, 0, 0));
973 //look-up tables, simplifies below loops
974 const DirectGdi::TFontUnderline KFontUnderlineTable[]=
976 DirectGdi::EUnderlineOn,
977 DirectGdi::EUnderlineOff,
978 DirectGdi::EUnderlineOn,
979 DirectGdi::EUnderlineOff,
980 DirectGdi::EUnderlineOn,
983 const DirectGdi::TFontStrikethrough KFontStrikethroughTable[]=
985 DirectGdi::EStrikethroughOff,
986 DirectGdi::EStrikethroughOn,
987 DirectGdi::EStrikethroughOn,
988 DirectGdi::EStrikethroughOff,
989 DirectGdi::EStrikethroughOn,
994 for(TInt ii=0; ii<2; ii++ ) //loop over up and down directions
996 position.SetXY(10+ii*100,10+ii*380);
997 for(TInt jj=0; jj<5; jj++)
999 iGc->SetUnderlineStyle(KFontUnderlineTable[jj%5]);
1000 iGc->SetStrikethroughStyle(KFontStrikethroughTable[jj%5]);
1003 iGc->SetTextShadowColor(TRgb(100,10,10));
1005 iGc->DrawTextVertical(KPangram,NULL,position,ii!=0);
1011 position.SetXY(210,30);
1012 for(TInt jj=0; jj<5; jj++)
1014 iGc->SetUnderlineStyle(KFontUnderlineTable[jj%5]);
1015 iGc->SetStrikethroughStyle(KFontStrikethroughTable[jj%5]);
1018 iGc->SetTextShadowColor(TRgb(100,10,10));
1020 iGc->DrawText(KPangram,NULL,position);
1026 TESTNOERROR(iGc->GetError());
1027 TEST(KErrNone == WriteTargetOutput(iTestParams, TPtrC(KTestName)));
1032 GRAPHICS-DIRECTGDI-TEXT-0010
1047 Test for propper handling invalid arguments using either BitGDI or DirectGDI gc.
1056 Test for propper handling invalid arguments for text drawing using either BitGDI or DirectGDI gc.
1058 @SYMTestExpectedResults
1059 Function shall detect invalid parameters and return. Nothing will be drawn on the target surface.
1061 void CTDrawText::TestInvalidParamsL()
1063 _LIT(KTestName, "Text-InvalidParameters");
1064 if(!iRunningOomTests)
1066 INFO_PRINTF1(KTestName);
1071 iGc->SetFont(iFont);
1072 TEST(iGc->HasFont());
1073 iGc->SetPenColor(TRgb(0, 0, 0));
1075 //NullDescriptor - drawing an empty descriptor is not an error, DrawText()
1076 //and DrawTextVertical() should return silently in this case.
1078 iGc->DrawText(KNullDesC, NULL, TPoint(10, 30));
1079 CheckErrorsL(KErrNone, KErrNone, (TText8*)__FILE__, __LINE__);
1080 iGc->DrawText(KNullDesC, NULL);
1081 CheckErrorsL(KErrNone, KErrNone, (TText8*)__FILE__, __LINE__);
1083 TRect rect(10,50,300,70);
1084 TInt baseline = rect.Height() / 2 + iFont->AscentInPixels() / 2;
1085 iGc->DrawText(KNullDesC,NULL,rect,baseline);
1086 CheckErrorsL(KErrNone, KErrNone, (TText8*)__FILE__, __LINE__);
1087 rect.SetRect(10,70,550,90);
1088 iGc->DrawText(KNullDesC,NULL,rect);
1089 CheckErrorsL(KErrNone, KErrNone, (TText8*)__FILE__, __LINE__);
1092 iGc->DrawTextVertical(KNullDesC,NULL,TPoint(10,10),EFalse);
1093 CheckErrorsL(KErrNone, KErrNone, (TText8*)__FILE__, __LINE__);
1094 iGc->DrawTextVertical(KNullDesC,NULL,EFalse);
1095 CheckErrorsL(KErrNone, KErrNone, (TText8*)__FILE__, __LINE__);
1096 rect.SetRect(30,10,50,300);
1097 baseline = rect.Width() / 2 + iFont->AscentInPixels() / 2;
1098 iGc->DrawTextVertical(KNullDesC,NULL,rect,baseline,EFalse);
1099 CheckErrorsL(KErrNone, KErrNone, (TText8*)__FILE__, __LINE__);
1100 rect.SetRect(50,10,80,300);
1101 baseline = rect.Width() / 2 + iFont->AscentInPixels() / 2;
1102 iGc->DrawTextVertical(KNullDesC,NULL,rect,baseline,10,EFalse);
1103 CheckErrorsL(KErrNone, KErrNone, (TText8*)__FILE__, __LINE__);
1104 rect.SetRect(50,100,80,400);
1105 iGc->DrawTextVertical(KNullDesC,NULL,rect,EFalse);
1106 CheckErrorsL(KErrNone, KErrNone, (TText8*)__FILE__, __LINE__);
1109 for(TInt ii=1; ii<9; ii++)
1111 rect.SetRect(220+(ii%3)*100, 100+(ii/3)*100, 320, 200);
1112 baseline = Abs(rect.Height())/2 + iFont->AscentInPixels()/2;
1113 iGc->DrawText(KPangram,NULL,rect,baseline);
1114 CheckErrorsL(KErrArgument, KErrNone, (TText8*)__FILE__, __LINE__);
1115 iGc->DrawText(KPangram,NULL,rect);
1116 CheckErrorsL(KErrArgument, KErrNone, (TText8*)__FILE__, __LINE__);
1118 baseline = Abs(rect.Width())/2 + iFont->AscentInPixels() /2;
1119 iGc->DrawTextVertical(KPangram,NULL,rect,baseline,EFalse);
1120 CheckErrorsL(KErrArgument, KErrNone, (TText8*)__FILE__, __LINE__);
1122 iGc->DrawTextVertical(KPangram,NULL,rect,EFalse);
1123 CheckErrorsL(KErrArgument, KErrNone, (TText8*)__FILE__, __LINE__);
1125 iGc->DrawTextVertical(KPangram,NULL,rect,baseline,10,EFalse);
1126 CheckErrorsL(KErrArgument, KErrNone, (TText8*)__FILE__, __LINE__);
1129 //invalid aAlignment
1130 rect.SetRect(10,320,300,540);
1131 baseline = rect.Height() / 2 + iFont->AscentInPixels() / 2;
1132 iGc->DrawText(KPangram,NULL,rect,baseline, (DirectGdi::TTextAlign) 5 );
1133 CheckErrorsL(KErrArgument, KErrNone, (TText8*)__FILE__, __LINE__);
1135 rect.SetRect(540,10,560,350);
1136 baseline = rect.Width() /2 + iFont->AscentInPixels() / 2;
1137 iGc->DrawTextVertical(KPangram,NULL,rect,baseline,10, EFalse , (DirectGdi::TTextAlign) 5 );
1138 CheckErrorsL(KErrArgument, KErrNone, (TText8*)__FILE__, __LINE__);
1143 Override of base class pure virtual
1144 Lists the tests to be run
1146 void CTDrawText::RunTestsL()
1148 MFontGlyphImageStorage* glyphStorage = NULL;
1149 iGc->GetInterface(TUid::Uid(KDirectGdiGetGlyphStorageUid), (TAny*&) glyphStorage);
1152 glyphStorage->CleanGlyphImageCache();
1153 CleanupStack::PushL(TCleanupItem(CleanCache, glyphStorage));
1155 SetTestStepID(_L("GRAPHICS-DIRECTGDI-TEXT-0001"));
1156 TestBasicFunctionality();
1157 RecordTestResultL();
1158 if(!iRunningOomTests)
1160 SetTestStepID(_L("GRAPHICS-DIRECTGDI-TEXT-0002"));
1161 TestTextPositioning();
1162 RecordTestResultL();
1163 SetTestStepID(_L("GRAPHICS-DIRECTGDI-TEXT-0003"));
1165 RecordTestResultL();
1166 SetTestStepID(_L("GRAPHICS-DIRECTGDI-TEXT-0004"));
1167 TestTextPositioningVertical(EFalse);
1168 RecordTestResultL();
1169 SetTestStepID(_L("GRAPHICS-DIRECTGDI-TEXT-0004"));
1170 TestTextPositioningVertical(ETrue);
1171 RecordTestResultL();
1172 SetTestStepID(_L("GRAPHICS-DIRECTGDI-TEXT-0005"));
1173 TestTextBoxVertical();
1174 RecordTestResultL();
1175 SetTestStepID(_L("GRAPHICS-DIRECTGDI-TEXT-0008"));
1176 TestJustification();
1177 RecordTestResultL();
1178 SetTestStepID(_L("GRAPHICS-DIRECTGDI-TEXT-0009"));
1179 TestShadowUnderStrike();
1180 RecordTestResultL();
1181 SetTestStepID(_L("GRAPHICS-DIRECTGDI-TEXT-0007"));
1183 RecordTestResultL();
1184 SetTestStepID(_L("GRAPHICS-DIRECTGDI-TEXT-0006"));
1186 RecordTestResultL();
1187 SetTestStepID(_L("GRAPHICS-DIRECTGDI-TEXT-0010"));
1188 TestInvalidParamsL();
1189 RecordTestResultL();
1194 glyphStorage->CleanGlyphImageCache();
1195 CleanupStack::Pop(glyphStorage);