Update contrib.
2 * Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
27 #include "../incp/T_PMLPAR.H"
30 LOCAL_D CTestStep *pTestStep = NULL;
33 TBool __bb = (cond); \
34 pTestStep->TEST(__bb); \
37 pTestStep->ERR_PRINTF1(_L("ERROR: Test Failed")); \
43 // copy from tefexportconst.h
44 #define INFO_PRINTF1(p1) pTestStep->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1))
45 #define INFO_PRINTF2(p1, p2) pTestStep->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2))
47 #define UNUSED_VAR(a) a = a
49 const TInt KTestCleanupStack=0x40;
51 LOCAL_D CTrapCleanup* TheTrapCleanup=NULL;
52 LOCAL_D CRichText* TheText=NULL;
53 LOCAL_D CParaFormatLayer* TheGlobalParaLayer=NULL;
54 LOCAL_D CCharFormatLayer* TheGlobalCharLayer=NULL;
55 LOCAL_D CParser* TheParser;
58 LOCAL_C void SetRichTextL(TFileName& aFileName)
62 delete TheGlobalParaLayer;
63 delete TheGlobalCharLayer;
64 TheParser=CParser::NewL();
65 CleanupStack::PushL(TheParser);
66 TheText=TheParser->ParseL(aFileName);
67 CleanupStack::PopAndDestroy();
68 TheGlobalParaLayer=(CParaFormatLayer*)TheText->GlobalParaFormatLayer();
69 TheGlobalCharLayer=(CCharFormatLayer*)TheText->GlobalCharFormatLayer();
73 LOCAL_C void CreateRichTextL()
76 TParaFormatMask paraMask;
77 TheGlobalParaLayer=CParaFormatLayer::NewL((CParaFormat*)NULL,paraMask);
78 CleanupStack::PushL(TheGlobalParaLayer);
79 TCharFormat charFormat;
80 TCharFormatMask charMask;
81 TheGlobalCharLayer=CCharFormatLayer::NewL(charFormat,charMask);
82 CleanupStack::PushL(TheGlobalCharLayer);
83 TheText=CRichText::NewL(TheGlobalParaLayer,TheGlobalCharLayer);
88 LOCAL_C void DestroyRichText()
92 delete TheGlobalParaLayer;
93 delete TheGlobalCharLayer;
97 LOCAL_C void ResetTextL()
98 // Initialise the rich text.
102 TBuf<512> buf(_L("This is paragraph one"));
103 buf.Append(CEditableText::EParagraphDelimiter);
104 buf.Append(_L("This is paragraph two"));
105 buf.Append(CEditableText::EParagraphDelimiter);
106 buf.Append(_L("This is paragraph 333"));
107 // Editable text already has the terminating paragraph delimter.
108 TheText->InsertL(0,buf);
112 LOCAL_C TParaBorder BorderValues(TParaBorder::TLineStyle aLineStyle,TInt aThickness)
116 border.iLineStyle=aLineStyle;
117 border.iThickness=aThickness;
122 LOCAL_C void PerformTestParaBordersL(CParaFormat& aApplyFormat,TParaFormatMask& aApplyMask,
123 TTextFormatAttribute anAttribute,CParaFormat::TParaBorderSide aSide,
124 TParaBorder& aBorder,
125 CParaFormat& aSensedFormat,TParaFormatMask& aSensedMask)
128 aApplyMask.SetAttrib(anAttribute);
129 aApplyFormat.SetParaBorderL(aSide,aBorder);
130 TheText->ApplyParaFormatL(&aApplyFormat,aApplyMask,0,1);
131 TheText->GetParaFormatL(&aSensedFormat,aSensedMask,0,TheText->DocumentLength());
135 LOCAL_C void TestParaBordersL()
136 // Tests the indeterminate state of paragraph borders.
140 CParaFormat* sensedFormat=CParaFormat::NewLC();
141 TParaFormatMask undeterminedMask;
142 TheText->GetParaFormatL(sensedFormat,undeterminedMask,0,TheText->DocumentLength());
143 test(undeterminedMask.IsNull());
145 CParaFormat* applyFormat=CParaFormat::NewLC();
146 TParaFormatMask applyMask;
148 TParaBorder border=BorderValues(TParaBorder::ESolid,1);
150 PerformTestParaBordersL(*applyFormat,applyMask,EAttTopBorder,CParaFormat::EParaBorderTop,border,*sensedFormat,undeterminedMask);
151 test(undeterminedMask.AttribIsSet(EAttTopBorder));
152 test(!(undeterminedMask.AttribIsSet(EAttBottomBorder)));
153 test(!(undeterminedMask.AttribIsSet(EAttLeftBorder)));
154 test(!(undeterminedMask.AttribIsSet(EAttRightBorder)));
156 PerformTestParaBordersL(*applyFormat,applyMask,EAttBottomBorder,CParaFormat::EParaBorderBottom,border,*sensedFormat,undeterminedMask);
157 test(undeterminedMask.AttribIsSet(EAttTopBorder));
158 test(undeterminedMask.AttribIsSet(EAttBottomBorder));
159 test(!(undeterminedMask.AttribIsSet(EAttLeftBorder)));
160 test(!(undeterminedMask.AttribIsSet(EAttRightBorder)));
162 PerformTestParaBordersL(*applyFormat,applyMask,EAttLeftBorder,CParaFormat::EParaBorderLeft,border,*sensedFormat,undeterminedMask);
163 test(undeterminedMask.AttribIsSet(EAttTopBorder));
164 test(undeterminedMask.AttribIsSet(EAttBottomBorder));
165 test(undeterminedMask.AttribIsSet(EAttLeftBorder));
166 test(!(undeterminedMask.AttribIsSet(EAttRightBorder)));
168 PerformTestParaBordersL(*applyFormat,applyMask,EAttRightBorder,CParaFormat::EParaBorderRight,border,*sensedFormat,undeterminedMask);
169 test(undeterminedMask.AttribIsSet(EAttTopBorder));
170 test(undeterminedMask.AttribIsSet(EAttBottomBorder));
171 test(undeterminedMask.AttribIsSet(EAttLeftBorder));
172 test(undeterminedMask.AttribIsSet(EAttRightBorder));
174 CleanupStack::PopAndDestroy(2); // applyFormat & sensedFormat
178 LOCAL_C void TestParaFormatL()
179 // Test the indeterminate state of paragraph format attributes.
182 INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-TTEXT-LEGACY-T_INDTER-0001 Paragraph format attributes "));
187 LOCAL_C void TestCharFormatL()
188 // Test the indeterminate state of character format attributes.
191 INFO_PRINTF1(_L("Character format attributes"));
194 TCharFormat applyFormat;
195 TCharFormatMask applyMask;
197 TCharFormat sensedFormat;
198 TCharFormatMask sensedMask;
200 applyFormat.iFontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold);
201 applyMask.SetAttrib(EAttFontStrokeWeight);
202 TheText->ApplyCharFormatL(applyFormat,applyMask,22,22);
203 // Make para 3 italic
204 applyFormat.iFontSpec.iFontStyle.SetPosture(EPostureItalic);
205 applyMask.ClearAll(); applyMask.SetAttrib(EAttFontPosture);
206 TheText->ApplyCharFormatL(applyFormat,applyMask,44,21);
208 TheText->GetCharFormat(sensedFormat,sensedMask,0,TheText->DocumentLength());
209 test(sensedMask.AttribIsSet(EAttFontStrokeWeight));
210 test(sensedMask.AttribIsSet(EAttFontPosture));
212 TheText->GetCharFormat(sensedFormat,sensedMask,50,1);
213 test(sensedMask.IsNull());
215 TheText->GetCharFormat(sensedFormat,sensedMask,44,21);
216 test(sensedMask.IsNull());
218 TFileName file=_L("z:\\test\\app-framework\\etext\\t_indter.pml");
221 TheText->GetCharFormat(sensedFormat,sensedMask,4,1);
223 TheText->GetCharFormat(sensedFormat,sensedMask,0,TheText->DocumentLength());
224 test(sensedMask.AttribIsSet(EAttFontStrokeWeight));
225 test(sensedMask.AttribIsSet(EAttFontPosture));
226 test(sensedMask.AttribIsSet(EAttFontUnderline));
227 test(sensedMask.AttribIsSet(EAttFontStrikethrough));
228 test(sensedMask.AttribIsSet(EAttFontPrintPos));
232 LOCAL_C void DoTestL()
244 LOCAL_C void setupCleanup()
245 // Initialise the cleanup stack.
249 TheTrapCleanup=CTrapCleanup::New();
252 for (TInt i=KTestCleanupStack;i>0;i--)\
253 CleanupStack::PushL((TAny*)1);\
255 CleanupStack::Pop(KTestCleanupStack);\
259 CT_INDTER::CT_INDTER()
261 SetTestStepName(KTestStep_T_INDTER);
265 TVerdict CT_INDTER::doTestStepL()
267 SetTestStepResult(EFail);
269 INFO_PRINTF1(_L("Rich Text Format attribute Indeterminate State tests"));
275 delete TheTrapCleanup;
281 SetTestStepResult(EPass);
284 return TestStepResult();