67 void TestFormat<S>::CheckTTabStop() |
52 void TestFormat<S>::CheckTTabStop() |
68 // |
53 // |
69 // Checks TTabStop construction and methods. |
54 // Checks TTabStop construction and methods. |
70 // |
55 // |
71 { |
56 { |
72 INFO_PRINTF1(_L("Checking all methods")); |
57 test.Start(_L("Checking all methods")); |
73 |
58 |
74 // Default constructor. |
59 // Default constructor. |
75 TTabStop tab1; |
60 TTabStop tab1; |
76 // Assignment operator. |
61 // Assignment operator. |
77 TTabStop tab3; |
62 TTabStop tab3; |
78 tab3=tab1; |
63 tab3=tab1; |
79 |
64 |
80 INFO_PRINTF1(_L("Default constructor")); |
65 test.Next(_L("Default constructor")); |
81 test(tab1.iTwipsPosition==0); |
66 test(tab1.iTwipsPosition==0); |
82 if (tab1.iType==TTabStop::ELeftTab) |
67 if (tab1.iType==TTabStop::ELeftTab) |
83 INFO_PRINTF2(_L("\nleft tab - %d\n"),tab1.iType); |
68 test.Printf(_L("\nleft tab - %d\n"),tab1.iType); |
84 else if (tab1.iType==TTabStop::ECenteredTab) |
69 else if (tab1.iType==TTabStop::ECenteredTab) |
85 INFO_PRINTF2(_L("\ncentered tab - %d\n"),tab1.iType); |
70 test.Printf(_L("\ncentered tab - %d\n"),tab1.iType); |
86 else if (tab1.iType==TTabStop::ERightTab) |
71 else if (tab1.iType==TTabStop::ERightTab) |
87 INFO_PRINTF2(_L("\nright tab - %d\n"),tab1.iType); |
72 test.Printf(_L("\nright tab - %d\n"),tab1.iType); |
88 else if (tab1.iType==TTabStop::ENullTab) |
73 else if (tab1.iType==TTabStop::ENullTab) |
89 INFO_PRINTF2(_L("\nnull tab - %d\n"),tab1.iType); |
74 test.Printf(_L("\nnull tab - %d\n"),tab1.iType); |
90 else |
75 else |
91 INFO_PRINTF2(_L("\nsomething completely different - %d \n"),tab1.iType); |
76 test.Printf(_L("\nsomething completely different - %d \n"),tab1.iType); |
92 test(tab1.iType==TTabStop::ELeftTab); |
77 test(tab1.iType==TTabStop::ELeftTab); |
93 // test.Getch(); |
78 // test.Getch(); |
94 |
79 |
95 INFO_PRINTF1(_L("Copy constructor")); |
80 test.Next(_L("Copy constructor")); |
96 TTabStop tab4; |
81 TTabStop tab4; |
97 tab4.iTwipsPosition=1440; |
82 tab4.iTwipsPosition=1440; |
98 tab4.iType=TTabStop::ERightTab; |
83 tab4.iType=TTabStop::ERightTab; |
99 TTabStop tab5(tab4); |
84 TTabStop tab5(tab4); |
100 test(tab5.iTwipsPosition==tab4.iTwipsPosition); |
85 test(tab5.iTwipsPosition==tab4.iTwipsPosition); |
101 test(tab5.iType==tab4.iType); |
86 test(tab5.iType==tab4.iType); |
102 |
87 |
103 INFO_PRINTF1(_L("Assignment operator")); |
88 test.Next(_L("Assignment operator")); |
104 tab1=tab5;; |
89 tab1=tab5;; |
105 test(tab1.iTwipsPosition==tab5.iTwipsPosition); |
90 test(tab1.iTwipsPosition==tab5.iTwipsPosition); |
106 test(tab1.iType==tab5.iType); |
91 test(tab1.iType==tab5.iType); |
107 |
92 |
108 INFO_PRINTF1(_L("Equality operator")); |
93 test.Next(_L("Equality operator")); |
109 test(tab1==tab5); |
94 test(tab1==tab5); |
110 |
95 |
111 INFO_PRINTF1(_L("Inequality operator")); |
96 test.Next(_L("Inequality operator")); |
112 tab1.iTwipsPosition=2; |
97 tab1.iTwipsPosition=2; |
113 test(tab1!=tab5); |
98 test(tab1!=tab5); |
|
99 test.End(); |
114 } |
100 } |
115 |
101 |
116 |
102 |
117 template<class S> |
103 template<class S> |
118 void TestFormat<S>::CheckTParaBorder() |
104 void TestFormat<S>::CheckTParaBorder() |
119 // |
105 // |
120 // Checks TParaBorder construction. |
106 // Checks TParaBorder construction. |
121 // |
107 // |
122 { |
108 { |
123 INFO_PRINTF1(_L("Checking all methods")); |
109 test.Start(_L("Checking all methods")); |
124 // Default Constructor. |
110 // Default Constructor. |
125 TParaBorder border1; |
111 TParaBorder border1; |
126 |
112 |
127 INFO_PRINTF1(_L("Default constructor")); |
113 test.Next(_L("Default constructor")); |
128 test(border1.iLineStyle==TParaBorder::ENullLineStyle); |
114 test(border1.iLineStyle==TParaBorder::ENullLineStyle); |
129 test(border1.iAutoColor); |
115 test(border1.iAutoColor); |
130 TLogicalRgb c(TLogicalRgb::ESystemForegroundColor); |
116 TLogicalRgb c(TLogicalRgb::ESystemForegroundColor); |
131 test(border1.iColor == c); |
117 test(border1.iColor == c); |
132 |
118 |
133 TParaBorder border2; |
119 TParaBorder border2; |
134 INFO_PRINTF1(_L("Equality operator")); |
120 test.Next(_L("Equality operator")); |
135 test(border2==border1); |
121 test(border2==border1); |
136 |
122 |
137 INFO_PRINTF1(_L("Inequality operator")); |
123 test.Next(_L("Inequality operator")); |
138 border2.iLineStyle=TParaBorder::ESolid; |
124 border2.iLineStyle=TParaBorder::ESolid; |
139 border2.iThickness=2; |
125 border2.iThickness=2; |
140 test(border2!=border1); |
126 test(border2!=border1); |
141 |
127 |
142 border1.iLineStyle=TParaBorder::ESolid; |
128 border1.iLineStyle=TParaBorder::ESolid; |
143 border1.iThickness=2; |
129 border1.iThickness=2; |
144 test(border2==border1); |
130 test(border2==border1); |
|
131 |
|
132 test.End(); |
145 } |
133 } |
146 |
134 |
147 |
135 |
148 template<class S> |
136 template<class S> |
149 void TestFormat<S>::CheckTBullet() |
137 void TestFormat<S>::CheckTBullet() |
150 // |
138 // |
151 // Checks TBullet construction. |
139 // Checks TBullet construction. |
152 // |
140 // |
153 { |
141 { |
154 INFO_PRINTF1(_L("Checking all methods")); |
142 test.Start(_L("Checking all methods")); |
155 // Default constructor. |
143 // Default constructor. |
156 TBullet bullet; |
144 TBullet bullet; |
157 |
145 |
158 INFO_PRINTF1(_L("Default constructor")); |
146 test.Next(_L("Default constructor")); |
159 test(0x2022==bullet.iCharacterCode); |
147 test(0x2022==bullet.iCharacterCode); |
160 test(bullet.iHeightInTwips==0); |
148 test(bullet.iHeightInTwips==0); |
161 |
149 |
162 INFO_PRINTF1(_L("==/!=")); |
150 test.Next(_L("==/!=")); |
163 TBullet bullet2; |
151 TBullet bullet2; |
164 test(bullet==bullet2); |
152 test(bullet==bullet2); |
165 test(!(bullet!=bullet2)); |
153 test(!(bullet!=bullet2)); |
166 |
154 |
167 TBullet bullet3; |
155 TBullet bullet3; |
168 bullet3.iCharacterCode=45; |
156 bullet3.iCharacterCode=45; |
169 test(bullet!=bullet3); |
157 test(bullet!=bullet3); |
170 test(!(bullet==bullet3)); |
158 test(!(bullet==bullet3)); |
|
159 test.End(); |
171 } |
160 } |
172 |
161 |
173 |
162 |
174 template<class S> |
163 template<class S> |
175 void TestFormat<S>::CheckCParaFormatTabsEqual(TTabStop& aCheck,TTabStop& aControl) |
164 void TestFormat<S>::CheckCParaFormatTabsEqual(TTabStop& aCheck,TTabStop& aControl) |
368 // |
356 // |
369 { |
357 { |
370 __UHEAP_MARK; |
358 __UHEAP_MARK; |
371 TInt count=0; |
359 TInt count=0; |
372 // All methods. |
360 // All methods. |
373 INFO_PRINTF1(_L("Checking all methods")); |
361 test.Start(_L("Checking all methods")); |
374 TParaFormatMask mask; |
362 TParaFormatMask mask; |
375 mask.SetAttrib(EAttLeftMargin); |
363 mask.SetAttrib(EAttLeftMargin); |
376 mask.AttribIsSet(EAttLeftMargin); |
364 mask.AttribIsSet(EAttLeftMargin); |
377 mask.ClearAttrib(EAttLeftMargin); |
365 mask.ClearAttrib(EAttLeftMargin); |
378 TParaFormatMask maskTemp; |
366 TParaFormatMask maskTemp; |
379 test(maskTemp==mask); |
367 test(maskTemp==mask); |
380 test(!(maskTemp!=mask)); |
368 test(!(maskTemp!=mask)); |
381 |
369 |
382 // Construction. |
370 // Construction. |
383 INFO_PRINTF1(_L("Construction")); |
371 test.Next(_L("Construction")); |
384 TParaFormatMask mask1; |
372 TParaFormatMask mask1; |
385 for (count=EAttParaLanguage;count<ETextFormatAttributeCount;count++) |
373 for (count=EAttParaLanguage;count<ETextFormatAttributeCount;count++) |
386 { |
374 { |
387 test(mask1.AttribIsSet((TTextFormatAttribute)count)==EFalse); |
375 test(mask1.AttribIsSet((TTextFormatAttribute)count)==EFalse); |
388 } |
376 } |
389 |
377 |
390 |
378 |
391 // SetAttrib() |
379 // SetAttrib() |
392 INFO_PRINTF1(_L("SetAttrib()")); |
380 test.Next(_L("SetAttrib()")); |
393 for (count=EAttParaLanguage;count<ETextFormatAttributeCount;count++) |
381 for (count=EAttParaLanguage;count<ETextFormatAttributeCount;count++) |
394 { |
382 { |
395 mask1.SetAttrib((TTextFormatAttribute)count); |
383 mask1.SetAttrib((TTextFormatAttribute)count); |
396 } |
384 } |
397 |
385 |
398 // ClearAttrib() |
386 // ClearAttrib() |
399 INFO_PRINTF1(_L("ClearAttrib()")); |
387 test.Next(_L("ClearAttrib()")); |
400 for (count=EAttParaLanguage;count<ETextFormatAttributeCount;count++) |
388 for (count=EAttParaLanguage;count<ETextFormatAttributeCount;count++) |
401 { |
389 { |
402 mask1.ClearAttrib((TTextFormatAttribute)count); |
390 mask1.ClearAttrib((TTextFormatAttribute)count); |
403 } |
391 } |
404 for (count=EAttParaLanguage;count<ETextFormatAttributeCount;count++) |
392 for (count=EAttParaLanguage;count<ETextFormatAttributeCount;count++) |
405 { |
393 { |
406 test(mask1.AttribIsSet((TTextFormatAttribute)count)==EFalse); |
394 test(mask1.AttribIsSet((TTextFormatAttribute)count)==EFalse); |
407 } |
395 } |
408 // AttribIsSet() |
396 // AttribIsSet() |
409 INFO_PRINTF1(_L("AttribIsSet()")); |
397 test.Next(_L("AttribIsSet()")); |
410 // Already tested in the above. |
398 // Already tested in the above. |
411 |
399 |
412 INFO_PRINTF1(_L("SetAll()")); |
400 test.Next(_L("SetAll()")); |
413 TParaFormatMask mask2; |
401 TParaFormatMask mask2; |
414 mask2.SetAll(); // sets border container but not individual borders. |
402 mask2.SetAll(); // sets border container but not individual borders. |
415 for (count=EAttParaLanguage;count<EAttTabStop;count++) |
403 for (count=EAttParaLanguage;count<EAttTabStop;count++) |
416 { |
404 { |
417 test(mask2.AttribIsSet((TTextFormatAttribute)count)); |
405 test(mask2.AttribIsSet((TTextFormatAttribute)count)); |
418 } |
406 } |
419 |
407 |
420 INFO_PRINTF1(_L("ClearAll()")); |
408 test.Next(_L("ClearAll()")); |
421 mask2.ClearAll(); |
409 mask2.ClearAll(); |
422 for (count=EAttParaLanguage;count<EAttTabStop;count++) |
410 for (count=EAttParaLanguage;count<EAttTabStop;count++) |
423 { |
411 { |
424 test(mask2.AttribIsSet((TTextFormatAttribute)count)==EFalse); |
412 test(mask2.AttribIsSet((TTextFormatAttribute)count)==EFalse); |
425 } |
413 } |
426 mask2.SetAttrib(EAttLeftMargin); |
414 mask2.SetAttrib(EAttLeftMargin); |
427 test(mask2.AttribIsSet(EAttLeftMargin)); |
415 test(mask2.AttribIsSet(EAttLeftMargin)); |
428 |
416 |
|
417 test.End(); |
429 __UHEAP_MARKEND; |
418 __UHEAP_MARKEND; |
430 } |
419 } |
431 |
420 |
432 |
421 |
433 template<class S> |
422 template<class S> |
535 // Store the formats in char format layers |
524 // Store the formats in char format layers |
536 CCharFormatLayer* formatLayer3=CCharFormatLayer::NewL(format3,f3); |
525 CCharFormatLayer* formatLayer3=CCharFormatLayer::NewL(format3,f3); |
537 CCharFormatLayer* formatLayer2=CCharFormatLayer::NewL(format2,f2); |
526 CCharFormatLayer* formatLayer2=CCharFormatLayer::NewL(format2,f2); |
538 CCharFormatLayer* formatLayer1=CCharFormatLayer::NewL(format1,f1); |
527 CCharFormatLayer* formatLayer1=CCharFormatLayer::NewL(format1,f1); |
539 formatLayer1->SetBase(formatLayer2); |
528 formatLayer1->SetBase(formatLayer2); |
540 INFO_PRINTF1(_L("ChainCount()")); |
529 test.Start(_L("ChainCount()")); |
541 test(formatLayer1->ChainCount()==2); |
530 test(formatLayer1->ChainCount()==2); |
542 // Now read them in and compare them: |
531 // Now read them in and compare them: |
543 // First just the layers. |
532 // First just the layers. |
544 INFO_PRINTF1(_L("SenseL() - Sensing this layer only")); |
533 test.Next(_L("SenseL() - Sensing this layer only")); |
545 TCharFormat result1; |
534 TCharFormat result1; |
546 TCharFormatMask result1Mask; |
535 TCharFormatMask result1Mask; |
547 formatLayer1->Sense(result1,result1Mask); |
536 formatLayer1->Sense(result1,result1Mask); |
548 CheckFormatsEqual(format1,f1,result1,result1Mask); |
537 CheckFormatsEqual(format1,f1,result1,result1Mask); |
549 |
538 |
553 CheckFormatsEqual(format2,f2,result2,result2Mask); |
542 CheckFormatsEqual(format2,f2,result2,result2Mask); |
554 test(result2.iFontSpec.iFontStyle.BitmapType() == format2.iFontSpec.iFontStyle.BitmapType()); |
543 test(result2.iFontSpec.iFontStyle.BitmapType() == format2.iFontSpec.iFontStyle.BitmapType()); |
555 test(result2.iFontSpec.iFontStyle.BitmapType() == EAntiAliasedGlyphBitmap); |
544 test(result2.iFontSpec.iFontStyle.BitmapType() == EAntiAliasedGlyphBitmap); |
556 |
545 |
557 // Now check the effective formats are correct |
546 // Now check the effective formats are correct |
558 INFO_PRINTF1(_L("SenseEffectiveL() - utilising basedOn")); |
547 test.Next(_L("SenseEffectiveL() - utilising basedOn")); |
559 TCharFormatMask dummy; |
548 TCharFormatMask dummy; |
560 TCharFormat result3; |
549 TCharFormat result3; |
561 formatLayer1->SenseEffective(result3); |
550 formatLayer1->SenseEffective(result3); |
562 CheckFormatsEqual(format3,dummy,result3,dummy); |
551 CheckFormatsEqual(format3,dummy,result3,dummy); |
563 |
552 |
564 // Now check the effective formats are correct |
553 // Now check the effective formats are correct |
565 // The result should be the same as above, |
554 // The result should be the same as above, |
566 // since all these values are present in the resultant TCharFormat. |
555 // since all these values are present in the resultant TCharFormat. |
567 // Ie, checking that overlapping attributes in a lower layer are not taken. |
556 // Ie, checking that overlapping attributes in a lower layer are not taken. |
568 INFO_PRINTF1(_L("SenseEffectiveL() - checking overlapping attributes are ignored")); |
557 test.Next(_L("SenseEffectiveL() - checking overlapping attributes are ignored")); |
569 // Add another layer of formatting by implementing the next based on link. |
558 // Add another layer of formatting by implementing the next based on link. |
570 formatLayer2->SetBase(formatLayer3); |
559 formatLayer2->SetBase(formatLayer3); |
571 INFO_PRINTF1(_L("ChainCount()")); |
560 test.Next(_L("ChainCount()")); |
572 test(formatLayer1->ChainCount()==3); |
561 test(formatLayer1->ChainCount()==3); |
573 test(formatLayer2->ChainCount()==2); |
562 test(formatLayer2->ChainCount()==2); |
574 test(formatLayer3->ChainCount()==1); |
563 test(formatLayer3->ChainCount()==1); |
575 TCharFormat result4; |
564 TCharFormat result4; |
576 formatLayer1->SenseEffective(result4); |
565 formatLayer1->SenseEffective(result4); |
577 CheckFormatsEqual(format3,dummy,result4,dummy); |
566 CheckFormatsEqual(format3,dummy,result4,dummy); |
578 |
567 |
|
568 test.End(); |
579 delete formatLayer1; |
569 delete formatLayer1; |
580 delete formatLayer2; |
570 delete formatLayer2; |
581 delete formatLayer3; |
571 delete formatLayer3; |
582 __UHEAP_MARKEND; |
572 __UHEAP_MARKEND; |
583 } |
573 } |
777 CParaFormatLayer* formatLayer=CParaFormatLayer::NewL(format1,format1Mask); |
767 CParaFormatLayer* formatLayer=CParaFormatLayer::NewL(format1,format1Mask); |
778 formatLayer->SetBase(formatLayer2); |
768 formatLayer->SetBase(formatLayer2); |
779 |
769 |
780 // Now read them in and compare them: |
770 // Now read them in and compare them: |
781 // First just the layers. |
771 // First just the layers. |
782 INFO_PRINTF1(_L("SenseL() - Sensing this layer only")); |
772 test.Next(_L("SenseL() - Sensing this layer only")); |
783 CParaFormat* formatResult1=CParaFormat::NewL(); |
773 CParaFormat* formatResult1=CParaFormat::NewL(); |
784 TParaFormatMask formatResult1Mask; |
774 TParaFormatMask formatResult1Mask; |
785 formatLayer->SenseL(formatResult1,formatResult1Mask); |
775 formatLayer->SenseL(formatResult1,formatResult1Mask); |
786 CheckFormatsEqual(format1,formatResult1); |
776 CheckFormatsEqual(format1,formatResult1); |
787 CheckFormatsEqual(format1Mask,formatResult1Mask); |
777 CheckFormatsEqual(format1Mask,formatResult1Mask); |
793 CheckFormatsEqual(format2,formatResult1); |
783 CheckFormatsEqual(format2,formatResult1); |
794 CheckFormatsEqual(format2Mask,formatResult1Mask); |
784 CheckFormatsEqual(format2Mask,formatResult1Mask); |
795 delete formatResult1; |
785 delete formatResult1; |
796 |
786 |
797 // Now check the effective formats are correct |
787 // Now check the effective formats are correct |
798 INFO_PRINTF1(_L("SenseEffectiveL() - utilising basedOn")); |
788 test.Next(_L("SenseEffectiveL() - utilising basedOn")); |
799 CParaFormat* formatResult2=CParaFormat::NewL(); |
789 CParaFormat* formatResult2=CParaFormat::NewL(); |
800 formatLayer->SenseEffectiveL(formatResult2); |
790 formatLayer->SenseEffectiveL(formatResult2); |
801 CheckFormatsEqual(format3,formatResult2); |
791 CheckFormatsEqual(format3,formatResult2); |
802 delete formatResult2; |
792 delete formatResult2; |
803 |
793 |
804 // Now check the effective formats are correct |
794 // Now check the effective formats are correct |
805 // The result should be the same as above, |
795 // The result should be the same as above, |
806 // since all these values are present in the resultant CParaFormat. |
796 // since all these values are present in the resultant CParaFormat. |
807 // Ie, checking that overlapping attributes in a lower layer are not taken. |
797 // Ie, checking that overlapping attributes in a lower layer are not taken. |
808 INFO_PRINTF1(_L("SenseEffectiveL() - checking overlapping attributes are ignored")); |
798 test.Next(_L("SenseEffectiveL() - checking overlapping attributes are ignored")); |
809 // Add another layer of formatting by implementing the next based on link. |
799 // Add another layer of formatting by implementing the next based on link. |
810 formatLayer2->SetBase(formatLayer4); |
800 formatLayer2->SetBase(formatLayer4); |
811 formatResult2=CParaFormat::NewL(); |
801 formatResult2=CParaFormat::NewL(); |
812 formatLayer->SenseEffectiveL(formatResult2); |
802 formatLayer->SenseEffectiveL(formatResult2); |
813 CheckFormatsEqual(format3,formatResult2); |
803 CheckFormatsEqual(format3,formatResult2); |
814 delete formatResult2; |
804 delete formatResult2; |
815 |
805 |
816 // Test ChainCount() method |
806 // Test ChainCount() method |
817 INFO_PRINTF1(_L("ChainCount()")); |
807 test.Next(_L("ChainCount()")); |
818 test(formatLayer4->ChainCount()==1); |
808 test(formatLayer4->ChainCount()==1); |
819 test(formatLayer2->ChainCount()==2); |
809 test(formatLayer2->ChainCount()==2); |
820 test(formatLayer->ChainCount()==3); |
810 test(formatLayer->ChainCount()==3); |
821 |
811 |
822 // Now clean up. |
812 // Now clean up. |
850 TParaFormatMask paraMask; |
840 TParaFormatMask paraMask; |
851 paraMask.SetAttrib(EAttBullet); |
841 paraMask.SetAttrib(EAttBullet); |
852 specificLayer->SetL(paraFormat,paraMask); |
842 specificLayer->SetL(paraFormat,paraMask); |
853 // |
843 // |
854 // specific bullet over null inherited |
844 // specific bullet over null inherited |
855 INFO_PRINTF1(_L("Specific bullet over null inherited")); |
845 test.Start(_L("Specific bullet over null inherited")); |
856 CParaFormat* sensed=CParaFormat::NewLC(); |
846 CParaFormat* sensed=CParaFormat::NewLC(); |
857 specificLayer->SenseEffectiveL(sensed); |
847 specificLayer->SenseEffectiveL(sensed); |
858 test(sensed->iBullet!=NULL); |
848 test(sensed->iBullet!=NULL); |
859 test(sensed->iBullet->iHeightInTwips==200); |
849 test(sensed->iBullet->iHeightInTwips==200); |
860 CleanupStack::PopAndDestroy(); // sensed |
850 CleanupStack::PopAndDestroy(); // sensed |
861 // |
851 // |
862 // null bullet over inherited |
852 // null bullet over inherited |
863 INFO_PRINTF1(_L("Null bullet over inherited")); |
853 test.Next(_L("Null bullet over inherited")); |
864 baseLayer->Reset(); |
854 baseLayer->Reset(); |
865 specificLayer->Reset(); |
855 specificLayer->Reset(); |
866 baseLayer->SetL(paraFormat,paraMask); |
856 baseLayer->SetL(paraFormat,paraMask); |
867 CParaFormat* empty=CParaFormat::NewLC(); |
857 CParaFormat* empty=CParaFormat::NewLC(); |
868 TParaFormatMask temp; |
858 TParaFormatMask temp; |
904 |
895 |
905 TInt ret=0; |
896 TInt ret=0; |
906 TInt check=0; |
897 TInt check=0; |
907 CParaFormatLayer* layer0=NULL; |
898 CParaFormatLayer* layer0=NULL; |
908 |
899 |
909 INFO_PRINTF1(_L("Constructor")); |
900 test.Start(_L("Constructor")); |
910 #ifdef _DEBUG |
901 #ifdef _DEBUG |
911 INFO_PRINTF1(_L("Failing on OOM")); |
902 test.Next(_L("Failing on OOM")); |
912 __UHEAP_FAILNEXT(1); |
903 __UHEAP_FAILNEXT(1); |
913 TRAP(ret,layer0=CParaFormatLayer::NewL()); |
904 TRAP(ret,layer0=CParaFormatLayer::NewL()); |
914 if (ret!=KErrNone) |
905 if (ret!=KErrNone) |
915 check++; |
906 check++; |
916 // seems __UHEAP_FAILNEXT does not work well in platsim. |
907 test(check>0); |
917 // below test does not pass in platsim. |
|
918 // test(check>0); |
|
919 #endif |
908 #endif |
920 |
909 |
921 INFO_PRINTF1(_L("Succeeding")); |
910 test.Next(_L("Succeeding")); |
922 check=0; |
911 check=0; |
923 TRAP(ret,layer0=CParaFormatLayer::NewL()); |
912 TRAP(ret,layer0=CParaFormatLayer::NewL()); |
924 if (ret!=KErrNone) |
913 if (ret!=KErrNone) |
925 check++; |
914 check++; |
926 test(check==0); |
915 test(check==0); |
927 delete layer0; |
916 delete layer0; |
928 |
917 |
929 // Set/Sense Default Para Format. |
918 // Set/Sense Default Para Format. |
930 INFO_PRINTF1(_L("Set/Sense Default ParaFormat")); |
919 test.Next(_L("Set/Sense Default ParaFormat")); |
931 CParaFormat* defaultFormat=CParaFormat::NewL(); |
920 CParaFormat* defaultFormat=CParaFormat::NewL(); |
932 |
921 |
933 //to test EAttParaLanguageX |
922 //to test EAttParaLanguageX |
934 defaultFormat->iLanguage |= 0x100; |
923 defaultFormat->iLanguage |= 0x100; |
935 |
924 |
1013 // |
1004 // |
1014 { |
1005 { |
1015 __UHEAP_MARK; |
1006 __UHEAP_MARK; |
1016 // All methods. |
1007 // All methods. |
1017 TInt count=0; |
1008 TInt count=0; |
1018 INFO_PRINTF1(_L("Checking all methods")); |
1009 test.Start(_L("Checking all methods")); |
1019 TCharFormatMask mask; |
1010 TCharFormatMask mask; |
1020 mask.SetAttrib(EAttFontHeight); |
1011 mask.SetAttrib(EAttFontHeight); |
1021 mask.AttribIsSet(EAttFontHeight); |
1012 mask.AttribIsSet(EAttFontHeight); |
1022 mask.ClearAttrib(EAttFontHeight); |
1013 mask.ClearAttrib(EAttFontHeight); |
1023 // Construction. |
1014 // Construction. |
1024 INFO_PRINTF1(_L("Construction")); |
1015 test.Next(_L("Construction")); |
1025 TCharFormatMask mask1; |
1016 TCharFormatMask mask1; |
1026 for (count=EAttCharLanguage;count<ETextFormatAttributeCount;count++) |
1017 for (count=EAttCharLanguage;count<ETextFormatAttributeCount;count++) |
1027 { |
1018 { |
1028 test(mask1.AttribIsSet((TTextFormatAttribute)count)==EFalse); |
1019 test(mask1.AttribIsSet((TTextFormatAttribute)count)==EFalse); |
1029 } |
1020 } |
1030 // SetAttrib() |
1021 // SetAttrib() |
1031 INFO_PRINTF1(_L("SetAttrib()")); |
1022 test.Next(_L("SetAttrib()")); |
1032 for (count=EAttCharLanguage;count<ETextFormatAttributeCount;count++) |
1023 for (count=EAttCharLanguage;count<ETextFormatAttributeCount;count++) |
1033 { |
1024 { |
1034 mask1.SetAttrib((TTextFormatAttribute)count); |
1025 mask1.SetAttrib((TTextFormatAttribute)count); |
1035 } |
1026 } |
1036 for (count=EAttCharLanguage;count<ETextFormatAttributeCount;count++) |
1027 for (count=EAttCharLanguage;count<ETextFormatAttributeCount;count++) |
1037 { |
1028 { |
1038 test(mask1.AttribIsSet((TTextFormatAttribute)count)); |
1029 test(mask1.AttribIsSet((TTextFormatAttribute)count)); |
1039 } |
1030 } |
1040 // ClearAttrib() |
1031 // ClearAttrib() |
1041 INFO_PRINTF1(_L("ClearAttrib()")); |
1032 test.Next(_L("ClearAttrib()")); |
1042 for (count=EAttCharLanguage;count<ETextFormatAttributeCount;count++) |
1033 for (count=EAttCharLanguage;count<ETextFormatAttributeCount;count++) |
1043 { |
1034 { |
1044 mask1.ClearAttrib((TTextFormatAttribute)count); |
1035 mask1.ClearAttrib((TTextFormatAttribute)count); |
1045 } |
1036 } |
1046 for (count=EAttCharLanguage;count<ETextFormatAttributeCount;count++) |
1037 for (count=EAttCharLanguage;count<ETextFormatAttributeCount;count++) |
1047 { |
1038 { |
1048 test(mask1.AttribIsSet((TTextFormatAttribute)count)==EFalse); |
1039 test(mask1.AttribIsSet((TTextFormatAttribute)count)==EFalse); |
1049 } |
1040 } |
1050 // AttribIsSet() |
1041 // AttribIsSet() |
1051 INFO_PRINTF1(_L("AttribIsSet()")); |
1042 test.Next(_L("AttribIsSet()")); |
1052 // Already tested in the above. |
1043 // Already tested in the above. |
1053 INFO_PRINTF1(_L("SetAll()")); |
1044 test.Next(_L("SetAll()")); |
1054 TCharFormatMask mask2; |
1045 TCharFormatMask mask2; |
1055 mask2.SetAll(); |
1046 mask2.SetAll(); |
1056 for (count=EAttCharLanguage;count<ETextFormatAttributeCount;count++) |
1047 for (count=EAttCharLanguage;count<ETextFormatAttributeCount;count++) |
1057 { |
1048 { |
1058 test(mask2.AttribIsSet((TTextFormatAttribute)count)); |
1049 test(mask2.AttribIsSet((TTextFormatAttribute)count)); |
1059 } |
1050 } |
1060 INFO_PRINTF1(_L("ClearAll()")); |
1051 test.Next(_L("ClearAll()")); |
1061 mask2.ClearAll(); |
1052 mask2.ClearAll(); |
1062 for (count=EAttCharLanguage;count<ETextFormatAttributeCount;count++) |
1053 for (count=EAttCharLanguage;count<ETextFormatAttributeCount;count++) |
1063 { |
1054 { |
1064 test(mask2.AttribIsSet((TTextFormatAttribute)count)==EFalse); |
1055 test(mask2.AttribIsSet((TTextFormatAttribute)count)==EFalse); |
1065 } |
1056 } |
|
1057 test.End(); |
1066 __UHEAP_MARKEND; |
1058 __UHEAP_MARKEND; |
1067 } |
1059 } |
1068 |
1060 |
1069 |
1061 |
1070 template<class S> |
1062 template<class S> |
1071 void TestFormat<S>::CheckAllClassesL() |
1063 void TestFormat<S>::CheckAllClassesL() |
1072 // |
1064 // |
1073 // Check all classes and structs exist. |
1065 // Check all classes and structs exist. |
1074 // |
1066 // |
1075 { |
1067 { |
1076 INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-ETEXT-LEGACY-T_FMT-0001 TTabStop ")); |
1068 test.Start(_L(" @SYMTestCaseID:SYSLIB-ETEXT-LEGACY-T_FMT-0001 TTabStop ")); |
1077 CheckTTabStop(); |
1069 CheckTTabStop(); |
1078 |
1070 |
1079 INFO_PRINTF1(_L("TParaBorder")); |
1071 test.Next(_L("TParaBorder")); |
1080 CheckTParaBorder(); |
1072 CheckTParaBorder(); |
1081 |
1073 |
1082 INFO_PRINTF1(_L("TBullet")); |
1074 test.Next(_L("TBullet")); |
1083 CheckTBullet(); |
1075 CheckTBullet(); |
1084 |
1076 |
1085 INFO_PRINTF1(_L("CParaFormat")); |
1077 test.Next(_L("CParaFormat")); |
1086 CheckCParaFormatL(); |
1078 CheckCParaFormatL(); |
1087 |
1079 |
1088 INFO_PRINTF1(_L("TParaFormatMask")); |
1080 test.Next(_L("TParaFormatMask")); |
1089 CheckTParaFormatMask(); |
1081 CheckTParaFormatMask(); |
1090 |
1082 |
1091 INFO_PRINTF1(_L("CParaFormatLayer")); |
1083 test.Next(_L("CParaFormatLayer")); |
1092 CheckCParaFormatLayerL(); |
1084 CheckCParaFormatLayerL(); |
1093 |
1085 |
1094 INFO_PRINTF1(_L("TCharFormat")); |
1086 test.Next(_L("TCharFormat")); |
1095 CheckTCharFormat(); |
1087 CheckTCharFormat(); |
1096 |
1088 |
1097 INFO_PRINTF1(_L("TCharFormatMask")); |
1089 test.Next(_L("TCharFormatMask")); |
1098 CheckTCharFormatMask(); |
1090 CheckTCharFormatMask(); |
1099 |
1091 |
1100 INFO_PRINTF1(_L("CCharFormatLayer")); |
1092 test.Next(_L("CCharFormatLayer")); |
1101 CheckCCharFormatLayerL(); |
1093 CheckCCharFormatLayerL(); |
1102 |
1094 |
1103 } |
1095 } |
1104 |
1096 |
1105 |
1097 |
1106 LOCAL_C void TestSettingNullTabsL() |
1098 LOCAL_C void TestSettingNullTabsL() |
1107 // Tests setting null tabs into a para format with tab stops. |
1099 // Tests setting null tabs into a para format with tab stops. |
1108 // |
1100 // |
1109 { |
1101 { |
1110 INFO_PRINTF1(_L("Setting Null Tabs")); |
1102 test.Start(_L("Setting Null Tabs")); |
1111 |
1103 |
1112 CCharFormatLayer* charLayer=CCharFormatLayer::NewL(); |
1104 CCharFormatLayer* charLayer=CCharFormatLayer::NewL(); |
1113 CParaFormatLayer* paraLayer=CParaFormatLayer::NewL(); |
1105 CParaFormatLayer* paraLayer=CParaFormatLayer::NewL(); |
1114 // |
1106 // |
1115 CRichText* text=CRichText::NewL(paraLayer,charLayer); |
1107 CRichText* text=CRichText::NewL(paraLayer,charLayer); |
1191 // |
1184 // |
1192 TCharFormat comparator; |
1185 TCharFormat comparator; |
1193 test(result.IsEqual(comparator)); |
1186 test(result.IsEqual(comparator)); |
1194 // |
1187 // |
1195 delete charLayer; |
1188 delete charLayer; |
1196 } |
1189 test.End(); |
1197 |
1190 } |
1198 CT_FMT::CT_FMT() |
1191 |
1199 { |
1192 |
1200 SetTestStepName(KTestStep_T_FMT); |
1193 GLDEF_C TInt E32Main() |
1201 pTestStep = this; |
1194 // |
1202 } |
1195 // Tests TFORMAT. |
1203 |
1196 // |
1204 TVerdict CT_FMT::doTestStepL() |
1197 { |
1205 { |
1198 CTrapCleanup* cleanup=CTrapCleanup::New(); |
1206 SetTestStepResult(EFail); |
1199 test.Title(); |
1207 |
|
1208 CTrapCleanup* cleanup=CTrapCleanup::New(); |
|
1209 INFO_PRINTF1(_L("TFormat Test Code")); |
|
1210 TestFormat<TText>* fmt=new(ELeave) TestFormat<TText>; |
1200 TestFormat<TText>* fmt=new(ELeave) TestFormat<TText>; |
1211 TRAPD(ret1, fmt->CheckAllClassesL()); |
1201 TRAPD(ret,fmt->CheckAllClassesL()); |
1212 TRAPD(ret2, TestFormatLayerResetL()); |
1202 |
1213 TRAPD(ret3, TestSettingNullTabsL()); |
1203 TRAP(ret, |
1214 TRAPD(ret4, CheckBulletInheritance()); |
1204 TestFormatLayerResetL()); |
1215 |
1205 test(ret==KErrNone); |
1216 __UHEAP_MARK; |
1206 |
1217 delete(fmt); |
1207 TRAP(ret, |
1218 fmt=NULL; |
1208 TestSettingNullTabsL()); |
1219 __UHEAP_MARKEND; |
1209 test(ret==KErrNone); |
1220 |
1210 |
1221 delete cleanup; |
1211 TRAP(ret, |
1222 |
1212 CheckBulletInheritance()); |
1223 if (ret1 == KErrNone && ret2 == KErrNone && ret3 == KErrNone && ret4 == KErrNone) |
1213 test(ret==KErrNone); |
1224 { |
1214 |
1225 SetTestStepResult(EPass); |
1215 test.End(); |
1226 } |
1216 |
1227 |
1217 __UHEAP_MARK; |
1228 return TestStepResult(); |
1218 delete(fmt); |
1229 } |
1219 fmt=NULL; |
|
1220 __UHEAP_MARKEND; |
|
1221 test.Close(); |
|
1222 |
|
1223 delete cleanup; |
|
1224 |
|
1225 return(0); |
|
1226 } |