1 /* |
1 /* |
2 * Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
19 #include <txtetext.h> |
19 #include <txtetext.h> |
20 #include <txtglobl.h> |
20 #include <txtglobl.h> |
21 #include <txtfmlyr.h> |
21 #include <txtfmlyr.h> |
22 #include <s32mem.h> |
22 #include <s32mem.h> |
23 #include <s32file.h> |
23 #include <s32file.h> |
|
24 #include <e32test.h> |
24 #include <fldbase.h> |
25 #include <fldbase.h> |
25 #include <fldbltin.h> |
26 #include <fldbltin.h> |
26 #include <flddef.h> |
27 #include <flddef.h> |
27 #include "T_CONVS.h" |
|
28 |
|
29 #define test(cond) \ |
|
30 { \ |
|
31 TBool __bb = (cond); \ |
|
32 TEST(__bb); \ |
|
33 if (!__bb) \ |
|
34 { \ |
|
35 ERR_PRINTF1(_L("ERROR: Test Failed")); \ |
|
36 User::Leave(1); \ |
|
37 } \ |
|
38 } |
|
39 |
28 |
40 const TInt KTestCleanupStack=0x20; |
29 const TInt KTestCleanupStack=0x20; |
41 const TInt KTestExpandSize=0x20; |
30 const TInt KTestExpandSize=0x20; |
42 |
31 |
43 LOCAL_D CTrapCleanup* TheTrapCleanup; |
32 LOCAL_D CTrapCleanup* TheTrapCleanup; |
|
33 LOCAL_D RTest test(_L("T_CONVS - EditableText Persistence")); |
44 LOCAL_D TPtrC bigBuf(_L("This is a very big buffer indeed, containing text and special characters,\ |
34 LOCAL_D TPtrC bigBuf(_L("This is a very big buffer indeed, containing text and special characters,\ |
45 big enough to fill a segment of an editable text component that employs segmented storage")); |
35 big enough to fill a segment of an editable text component that employs segmented storage")); |
46 |
36 |
47 //////////////////////////////////////////////////////////////////////////////////////////// |
37 //////////////////////////////////////////////////////////////////////////////////////////// |
48 class TTestFieldFactoryCONVS : public MTextFieldFactory |
38 class TTestFieldFactory : public MTextFieldFactory |
49 { |
39 { |
50 public: |
40 public: |
51 // from MTextFieldFactory |
41 // from MTextFieldFactory |
52 virtual CTextField* NewFieldL(TUid aFieldType); |
42 virtual CTextField* NewFieldL(TUid aFieldType); |
53 // Creates a field of the type specified |
43 // Creates a field of the type specified |
54 // Returns NULL if it does not recognise/support the field type |
44 // Returns NULL if it does not recognise/support the field type |
55 }; |
45 }; |
56 |
46 |
57 CTextField* TTestFieldFactoryCONVS::NewFieldL(TUid aFieldType) |
47 CTextField* TTestFieldFactory::NewFieldL(TUid aFieldType) |
58 // Creates a field (in aHeader) of the type specified in aHeader |
48 // Creates a field (in aHeader) of the type specified in aHeader |
59 // |
49 // |
60 { |
50 { |
61 CTextField* field=NULL; |
51 CTextField* field=NULL; |
62 if (aFieldType==KDateTimeFieldUid) |
52 if (aFieldType==KDateTimeFieldUid) |
64 return field; |
54 return field; |
65 } |
55 } |
66 ///////////////////////////////////////////////////////////////////////////////////////////// |
56 ///////////////////////////////////////////////////////////////////////////////////////////// |
67 |
57 |
68 template <class T> |
58 template <class T> |
69 void CT_CONVS::testCopy(T &aCopy,const T &anOriginal) |
59 void testCopy(T &aCopy,const T &anOriginal) |
70 // |
60 // |
71 // Copy anOriginal to aCopy using memory-based streams. |
61 // Copy anOriginal to aCopy using memory-based streams. |
72 // |
62 // |
73 { |
63 { |
74 CBufSeg *buf=CBufSeg::NewL(KTestExpandSize); |
64 CBufSeg *buf=CBufSeg::NewL(KTestExpandSize); |
75 if (buf==NULL) |
65 if (buf==NULL) |
76 User::Panic(_L("Allocating buffer"), 1234); |
66 test.Panic(_L("Allocating buffer")); |
77 |
67 |
78 // Write anOriginal out to the buffer. |
68 // Write anOriginal out to the buffer. |
79 RBufWriteStream out(*buf); |
69 RBufWriteStream out(*buf); |
80 TRAPD(r,out<<anOriginal); |
70 TRAPD(r,out<<anOriginal); |
81 test(r==KErrNone); |
71 test(r==KErrNone); |
82 TRAP(r,out.CommitL()); |
72 TRAP(r,out.CommitL()); |
83 if (r!=KErrNone) |
73 if (r!=KErrNone) |
84 User::Panic(_L("Committing write stream"), 1234); |
74 test.Panic(_L("Committing write stream")); |
85 |
75 |
86 // Read anOriginal in from the buffer. |
76 // Read anOriginal in from the buffer. |
87 RBufReadStream in(*buf); |
77 RBufReadStream in(*buf); |
88 TRAP(r,in>>aCopy); |
78 TRAP(r,in>>aCopy); |
89 test(r==KErrNone); |
79 test(r==KErrNone); |
125 theFs.Close(); |
115 theFs.Close(); |
126 } |
116 } |
127 |
117 |
128 |
118 |
129 template <class T> |
119 template <class T> |
130 void CT_CONVS::testCopyChain(T &aCopy,const T &anOriginal,TInt aExcludeCount,const CFormatLayer* aBase) |
120 void testCopyChain(T &aCopy,const T &anOriginal,TInt aExcludeCount,const CFormatLayer* aBase) |
131 // |
121 // |
132 // Copy anOriginal to aCopy using memory-based streams. |
122 // Copy anOriginal to aCopy using memory-based streams. |
133 // |
123 // |
134 { |
124 { |
135 CBufSeg *buf=CBufSeg::NewL(KTestExpandSize); |
125 CBufSeg *buf=CBufSeg::NewL(KTestExpandSize); |
136 if (buf==NULL) |
126 if (buf==NULL) |
137 User::Panic(_L("Allocating buffer"), 1234); |
127 test.Panic(_L("Allocating buffer")); |
138 |
128 |
139 // Write anOriginal out to the buffer. |
129 // Write anOriginal out to the buffer. |
140 RBufWriteStream out(*buf); |
130 RBufWriteStream out(*buf); |
141 TRAPD(r,anOriginal.ExternalizeChainL(out,aExcludeCount)); |
131 TRAPD(r,anOriginal.ExternalizeChainL(out,aExcludeCount)); |
142 test(r==KErrNone); |
132 test(r==KErrNone); |
143 TRAP(r,out.CommitL()); |
133 TRAP(r,out.CommitL()); |
144 if (r!=KErrNone) |
134 if (r!=KErrNone) |
145 User::Panic(_L("Committing write stream"), 1234); |
135 test.Panic(_L("Committing write stream")); |
146 |
136 |
147 // Read anOriginal in from the buffer. |
137 // Read anOriginal in from the buffer. |
148 RBufReadStream in(*buf); |
138 RBufReadStream in(*buf); |
149 TRAP(r,aCopy.InternalizeChainL(in,aBase)); |
139 TRAP(r,aCopy.InternalizeChainL(in,aBase)); |
150 test(r==KErrNone); |
140 test(r==KErrNone); |
182 test(aCopy->FieldCount()==aOriginal->FieldCount()); |
172 test(aCopy->FieldCount()==aOriginal->FieldCount()); |
183 return 1; |
173 return 1; |
184 } |
174 } |
185 |
175 |
186 |
176 |
187 void CT_CONVS::testPlainTextL(CEditableText::TDocumentStorage aStorage) |
177 void testPlainTextL(CEditableText::TDocumentStorage aStorage) |
188 // |
178 // |
189 // Test streaming CPlainText. |
179 // Test streaming CPlainText. |
190 // |
180 // |
191 {// Create the plain text components. |
181 {// Create the plain text components. |
192 INFO_PRINTF1(_L("Streaming CPlainText")); |
182 test.Start(_L("Streaming CPlainText")); |
193 CPlainText* copy=CPlainText::NewL(aStorage); |
183 CPlainText* copy=CPlainText::NewL(aStorage); |
194 CPlainText* testDoc=CPlainText::NewL(aStorage); |
184 CPlainText* testDoc=CPlainText::NewL(aStorage); |
195 // |
185 // |
196 // Set the original - empty |
186 // Set the original - empty |
197 INFO_PRINTF1(_L("empty.")); |
187 test.Start(_L("empty.")); |
198 testStoreRestoreL(*copy,*testDoc); |
188 testStoreRestoreL(*copy,*testDoc); |
199 test(IsEqual(copy,testDoc)); |
189 test(IsEqual(copy,testDoc)); |
200 // |
190 // |
201 INFO_PRINTF1(_L("paragraph delimiter")); |
191 test.Next(_L("paragraph delimiter")); |
202 TRAPD(r,testDoc->InsertL(0,CEditableText::EParagraphDelimiter)); |
192 TRAPD(r,testDoc->InsertL(0,CEditableText::EParagraphDelimiter)); |
203 test(r==KErrNone); |
193 test(r==KErrNone); |
204 testStoreRestoreL(*copy,*testDoc); |
194 testStoreRestoreL(*copy,*testDoc); |
205 test(IsEqual(copy,testDoc)); |
195 test(IsEqual(copy,testDoc)); |
206 // |
196 // |
207 // Next test with tons of text guaranteed to force segment break when using segmented storage. |
197 // Next test with tons of text guaranteed to force segment break when using segmented storage. |
208 INFO_PRINTF1(_L("big text component")); |
198 test.Next(_L("big text component")); |
209 testDoc->InsertL(0,bigBuf); |
199 testDoc->InsertL(0,bigBuf); |
210 testStoreRestoreL(*copy,*testDoc); |
200 testStoreRestoreL(*copy,*testDoc); |
211 test(IsEqual(copy,testDoc)); |
201 test(IsEqual(copy,testDoc)); |
212 // |
202 // |
213 // Now test with field components. |
203 // Now test with field components. |
214 INFO_PRINTF1(_L("big text doc with field components.")); |
204 test.Next(_L("big text doc with field components.")); |
215 TTestFieldFactoryCONVS factory; |
205 TTestFieldFactory factory; |
216 testDoc->SetFieldFactory(&factory); |
206 testDoc->SetFieldFactory(&factory); |
217 copy->SetFieldFactory(&factory); |
207 copy->SetFieldFactory(&factory); |
218 CTextField* field=NULL; |
208 CTextField* field=NULL; |
219 TRAPD(ret, |
209 TRAPD(ret, |
220 field=factory.NewFieldL(KDateTimeFieldUid)); |
210 field=factory.NewFieldL(KDateTimeFieldUid)); |
224 test(ret==KErrNone); |
214 test(ret==KErrNone); |
225 testStoreRestoreL(*copy,*testDoc); |
215 testStoreRestoreL(*copy,*testDoc); |
226 test(IsEqual(copy,testDoc)); |
216 test(IsEqual(copy,testDoc)); |
227 // |
217 // |
228 // |
218 // |
|
219 test.End(); |
229 delete copy; |
220 delete copy; |
230 delete testDoc; |
221 delete testDoc; |
231 } |
222 } |
232 |
223 |
233 |
224 |
234 void CT_CONVS::testGlobalTextL(CEditableText::TDocumentStorage aStorage) |
225 void testGlobalTextL(CEditableText::TDocumentStorage aStorage) |
235 // |
226 // |
236 // Test streaming CGlobalText. |
227 // Test streaming CGlobalText. |
237 // |
228 // |
238 {// Create the plain text components. |
229 {// Create the plain text components. |
239 INFO_PRINTF1(_L("Streaming CGlobalText")); |
230 test.Next(_L("Streaming CGlobalText")); |
240 CParaFormatLayer* paraLayer=CParaFormatLayer::NewL(); |
231 CParaFormatLayer* paraLayer=CParaFormatLayer::NewL(); |
241 CCharFormatLayer* charLayer=CCharFormatLayer::NewL(); |
232 CCharFormatLayer* charLayer=CCharFormatLayer::NewL(); |
242 // Set something interesting in the layers: |
233 // Set something interesting in the layers: |
243 CParaFormat* paraFormat1=CParaFormat::NewL(); TParaFormatMask paraMask1; |
234 CParaFormat* paraFormat1=CParaFormat::NewL(); TParaFormatMask paraMask1; |
244 TCharFormat charFormat1; TCharFormatMask charMask1; |
235 TCharFormat charFormat1; TCharFormatMask charMask1; |
251 // |
242 // |
252 CGlobalText* copy=CGlobalText::NewL(paraLayer,charLayer,aStorage); |
243 CGlobalText* copy=CGlobalText::NewL(paraLayer,charLayer,aStorage); |
253 CGlobalText* testDoc=CGlobalText::NewL(paraLayer,charLayer,aStorage); |
244 CGlobalText* testDoc=CGlobalText::NewL(paraLayer,charLayer,aStorage); |
254 |
245 |
255 // Set the original - empty |
246 // Set the original - empty |
256 INFO_PRINTF1(_L("empty.")); |
247 test.Start(_L("empty.")); |
257 testStoreRestoreL(*copy,*testDoc); |
248 testStoreRestoreL(*copy,*testDoc); |
258 test(IsEqual(copy,testDoc)); |
249 test(IsEqual(copy,testDoc)); |
259 // |
250 // |
260 INFO_PRINTF1(_L("paragraph delimiter")); |
251 test.Next(_L("paragraph delimiter")); |
261 TRAPD(r,testDoc->InsertL(0,CEditableText::EParagraphDelimiter)); |
252 TRAPD(r,testDoc->InsertL(0,CEditableText::EParagraphDelimiter)); |
262 test(r==KErrNone); |
253 test(r==KErrNone); |
263 testStoreRestoreL(*copy,*testDoc); |
254 testStoreRestoreL(*copy,*testDoc); |
264 test(IsEqual(copy,testDoc)); |
255 test(IsEqual(copy,testDoc)); |
265 |
256 |
266 // Next test with tons of text guaranteed to force segment break when using segmented storage. |
257 // Next test with tons of text guaranteed to force segment break when using segmented storage. |
267 INFO_PRINTF1(_L("big text component")); |
258 test.Next(_L("big text component")); |
268 testDoc->InsertL(0,bigBuf); |
259 testDoc->InsertL(0,bigBuf); |
269 testStoreRestoreL(*copy,*testDoc); |
260 testStoreRestoreL(*copy,*testDoc); |
270 test(IsEqual(copy,testDoc)); |
261 test(IsEqual(copy,testDoc)); |
271 |
262 |
|
263 test.End(); |
|
264 test.End(); |
272 delete copy; |
265 delete copy; |
273 delete testDoc; |
266 delete testDoc; |
274 delete paraLayer; |
267 delete paraLayer; |
275 delete charLayer; |
268 delete charLayer; |
276 delete paraFormat1; |
269 delete paraFormat1; |
277 } |
270 } |
278 |
271 |
279 |
272 |
280 TInt CT_CONVS::LayerIsEqual(const CParaFormatLayer* aRestored,const CParaFormatLayer* aOriginal) |
273 LOCAL_C TInt LayerIsEqual(const CParaFormatLayer* aRestored,const CParaFormatLayer* aOriginal) |
281 // |
274 // |
282 // Returns true if aRestored contents matches aOriginal contents. |
275 // Returns true if aRestored contents matches aOriginal contents. |
283 // |
276 // |
284 { |
277 { |
285 CParaFormat* restored=NULL; TParaFormatMask rm; |
278 CParaFormat* restored=NULL; TParaFormatMask rm; |
313 |
306 |
314 return 1; |
307 return 1; |
315 } |
308 } |
316 |
309 |
317 |
310 |
318 void CT_CONVS::testFmtLayerStoreL() |
311 void testFmtLayerStoreL() |
319 // |
312 // |
320 // Test the format layer StoreL(). |
313 // Test the format layer StoreL(). |
321 // |
314 // |
322 { |
315 { |
323 INFO_PRINTF1(_L("CParaFormatLayer")); |
316 test.Start(_L("CParaFormatLayer")); |
324 // Create test layers. |
317 // Create test layers. |
325 CParaFormatLayer* pfl1=NULL; |
318 CParaFormatLayer* pfl1=NULL; |
326 CParaFormatLayer* restored=NULL; |
319 CParaFormatLayer* restored=NULL; |
327 CParaFormat* pf1=NULL; |
320 CParaFormat* pf1=NULL; |
328 TRAPD(r,restored=CParaFormatLayer::NewL()); test(r==KErrNone); |
321 TRAPD(r,restored=CParaFormatLayer::NewL()); test(r==KErrNone); |
332 TRAP(r,pfl1=CParaFormatLayer::NewL()); test(r==KErrNone); |
325 TRAP(r,pfl1=CParaFormatLayer::NewL()); test(r==KErrNone); |
333 TRAP(r,pf1=CParaFormat::NewL()); test(r==KErrNone); |
326 TRAP(r,pf1=CParaFormat::NewL()); test(r==KErrNone); |
334 TParaFormatMask pm1; |
327 TParaFormatMask pm1; |
335 pm1.SetAll(); // Sets all but the compound attributes. |
328 pm1.SetAll(); // Sets all but the compound attributes. |
336 // TEST ONE DEFAULT CASES |
329 // TEST ONE DEFAULT CASES |
337 INFO_PRINTF1(_L("Default paragraph format values.")); |
330 test.Start(_L("Default paragraph format values.")); |
338 TRAP(r,pfl1->SetL(pf1,pm1)); test(r==KErrNone); |
331 TRAP(r,pfl1->SetL(pf1,pm1)); test(r==KErrNone); |
339 testCopy(*restored,*pfl1); |
332 testCopy(*restored,*pfl1); |
340 test(LayerIsEqual(restored,pfl1)); |
333 test(LayerIsEqual(restored,pfl1)); |
341 test(restored->SenseBase()==pfl1->SenseBase()); // Both should default to based on NULL |
334 test(restored->SenseBase()==pfl1->SenseBase()); // Both should default to based on NULL |
342 // TEST TWO |
335 // TEST TWO |
343 INFO_PRINTF1(_L("Setting all attributes")); |
336 test.Next(_L("Setting all attributes")); |
344 pf1->iLeftMarginInTwips=5000; pm1.ClearAll(); pm1.SetAttrib(EAttLeftMargin); |
337 pf1->iLeftMarginInTwips=5000; pm1.ClearAll(); pm1.SetAttrib(EAttLeftMargin); |
345 pf1->iRightMarginInTwips=5001; pm1.SetAttrib(EAttRightMargin); |
338 pf1->iRightMarginInTwips=5001; pm1.SetAttrib(EAttRightMargin); |
346 pf1->iIndentInTwips=5002;pm1.SetAttrib(EAttIndent); |
339 pf1->iIndentInTwips=5002;pm1.SetAttrib(EAttIndent); |
347 pf1->iHorizontalAlignment=CParaFormat::ERightAlign; pm1.SetAttrib(EAttAlignment); |
340 pf1->iHorizontalAlignment=CParaFormat::ERightAlign; pm1.SetAttrib(EAttAlignment); |
348 pf1->iVerticalAlignment=CParaFormat::ECenterAlign; pm1.SetAttrib(EAttVerticalAlignment); |
341 pf1->iVerticalAlignment=CParaFormat::ECenterAlign; pm1.SetAttrib(EAttVerticalAlignment); |
404 // |
397 // |
405 TRAP(r,pfl1->SetL(pf1,pm1)); |
398 TRAP(r,pfl1->SetL(pf1,pm1)); |
406 testCopy(*restored,*pfl1); |
399 testCopy(*restored,*pfl1); |
407 test(LayerIsEqual(restored,pfl1)); |
400 test(LayerIsEqual(restored,pfl1)); |
408 test(restored->SenseBase()==pfl1->SenseBase()); // Both should default to based on NULL |
401 test(restored->SenseBase()==pfl1->SenseBase()); // Both should default to based on NULL |
|
402 test.End(); |
409 // |
403 // |
410 delete pf1; |
404 delete pf1; |
411 delete pfl1; |
405 delete pfl1; |
412 delete restored; |
406 delete restored; |
413 // |
407 // |
414 // Now the CCharFormatLayer Store/Restore |
408 // Now the CCharFormatLayer Store/Restore |
415 // |
409 // |
416 INFO_PRINTF1(_L("CCharFormatLayer")); |
410 test.Next(_L("CCharFormatLayer")); |
417 // |
411 // |
418 INFO_PRINTF1(_L("Setting all attributes")); |
412 test.Start(_L("Setting all attributes")); |
419 // Create test layers. |
413 // Create test layers. |
420 CCharFormatLayer* cfl1=NULL; |
414 CCharFormatLayer* cfl1=NULL; |
421 CCharFormatLayer* cRestored=NULL; |
415 CCharFormatLayer* cRestored=NULL; |
422 TCharFormat cf1; TCharFormatMask cm1; |
416 TCharFormat cf1; TCharFormatMask cm1; |
423 // |
417 // |
506 } |
501 } |
507 return 1; |
502 return 1; |
508 } |
503 } |
509 |
504 |
510 |
505 |
511 void CT_CONVS::DoParaChainL() |
506 void DoParaChainL() |
512 // |
507 // |
513 // Tests the streaming of a chain of format layers |
508 // Tests the streaming of a chain of format layers |
514 // |
509 // |
515 { |
510 { |
516 INFO_PRINTF1(_L("Re/StoreChainL()")); |
511 test.Next(_L("Re/StoreChainL()")); |
517 INFO_PRINTF1(_L("CParaFormatLayer")); |
512 test.Start(_L("CParaFormatLayer")); |
518 // Create the chain of para format layers. |
513 // Create the chain of para format layers. |
519 CParaFormatLayer* l1=CParaFormatLayer::NewL(); |
514 CParaFormatLayer* l1=CParaFormatLayer::NewL(); |
520 CParaFormatLayer* l2=CParaFormatLayer::NewL(); |
515 CParaFormatLayer* l2=CParaFormatLayer::NewL(); |
521 CParaFormatLayer* l3=CParaFormatLayer::NewL(); |
516 CParaFormatLayer* l3=CParaFormatLayer::NewL(); |
522 CParaFormatLayer* l4=CParaFormatLayer::NewL(); |
517 CParaFormatLayer* l4=CParaFormatLayer::NewL(); |
588 delete paraFormat; |
583 delete paraFormat; |
589 delete restoredParaFormat; |
584 delete restoredParaFormat; |
590 } |
585 } |
591 |
586 |
592 |
587 |
593 void CT_CONVS::DoCharChainL() |
588 void DoCharChainL() |
594 // |
589 // |
595 // |
590 // |
596 // |
591 // |
597 { |
592 { |
598 INFO_PRINTF1(_L("CCharFormatLayer")); |
593 test.Next(_L("CCharFormatLayer")); |
599 // Create the chain of character format layers. |
594 // Create the chain of character format layers. |
600 CCharFormatLayer* cl1=CCharFormatLayer::NewL(); |
595 CCharFormatLayer* cl1=CCharFormatLayer::NewL(); |
601 CCharFormatLayer* cl2=CCharFormatLayer::NewL(); |
596 CCharFormatLayer* cl2=CCharFormatLayer::NewL(); |
602 CCharFormatLayer* cl3=CCharFormatLayer::NewL(); |
597 CCharFormatLayer* cl3=CCharFormatLayer::NewL(); |
603 CCharFormatLayer* cl4=CCharFormatLayer::NewL(); |
598 CCharFormatLayer* cl4=CCharFormatLayer::NewL(); |
633 charFormat.iFontSpec.iHeight=200; |
628 charFormat.iFontSpec.iHeight=200; |
634 charMask.SetAttrib(EAttFontHeight); |
629 charMask.SetAttrib(EAttFontHeight); |
635 charMask.SetAttrib(EAttFontTypeface); |
630 charMask.SetAttrib(EAttFontTypeface); |
636 cl4->SetL(charFormat,charMask); |
631 cl4->SetL(charFormat,charMask); |
637 // NOW DO IT |
632 // NOW DO IT |
638 INFO_PRINTF1(_L("Chain 4 layers deep, terminating on a based on NULL")); |
633 test.Start(_L("Chain 4 layers deep, terminating on a based on NULL")); |
639 testCopyChain(*rChar,*cl1,0,(const CFormatLayer*)NULL); |
634 testCopyChain(*rChar,*cl1,0,(const CFormatLayer*)NULL); |
640 TInt restoredChainCount=rChar->ChainCount(); |
635 TInt restoredChainCount=rChar->ChainCount(); |
641 test(ChainIsEqual(rChar,cl1)); |
636 test(ChainIsEqual(rChar,cl1)); |
642 // DESTROY STUFF |
637 // DESTROY STUFF |
643 CCharFormatLayer* chCurrent=rChar; |
638 CCharFormatLayer* chCurrent=rChar; |
698 charFormat.iFontSpec.iHeight=200; |
693 charFormat.iFontSpec.iHeight=200; |
699 charMask.SetAttrib(EAttFontHeight); |
694 charMask.SetAttrib(EAttFontHeight); |
700 charMask.SetAttrib(EAttFontTypeface); |
695 charMask.SetAttrib(EAttFontTypeface); |
701 cl4->SetL(charFormat,charMask); |
696 cl4->SetL(charFormat,charMask); |
702 // NOW DO IT |
697 // NOW DO IT |
703 INFO_PRINTF1(_L("Chain 3 layers deep, terminating on a non-NULL based-on")); |
698 test.Next(_L("Chain 3 layers deep, terminating on a non-NULL based-on")); |
704 testCopyChain(*rChar,*cl1,1,(const CFormatLayer*)cl4); |
699 testCopyChain(*rChar,*cl1,1,(const CFormatLayer*)cl4); |
705 TInt restoredChainCount=rChar->ChainCount(); |
700 TInt restoredChainCount=rChar->ChainCount(); |
706 test(ChainIsEqual(rChar,cl1)); |
701 test(ChainIsEqual(rChar,cl1)); |
707 // DESTROY STUFF |
702 // DESTROY STUFF |
708 CCharFormatLayer* chCurrent=rChar; |
703 CCharFormatLayer* chCurrent=rChar; |
732 // DoCharChainVariant2(); TO BE IMPLEMENTED |
731 // DoCharChainVariant2(); TO BE IMPLEMENTED |
733 // doCharChainVariant3(); TO BE IMPLEMENTED |
732 // doCharChainVariant3(); TO BE IMPLEMENTED |
734 } |
733 } |
735 |
734 |
736 |
735 |
737 void CT_CONVS::testFmtLayerL() |
736 void testFmtLayerL() |
738 // |
737 // |
739 // Tests the streaming of format layers. |
738 // Tests the streaming of format layers. |
740 // |
739 // |
741 { |
740 { |
742 testFmtLayerStoreL(); |
741 testFmtLayerStoreL(); |
743 testFmtLayerStoreChainL(); |
742 testFmtLayerStoreChainL(); |
744 } |
743 } |
745 |
744 |
746 |
745 |
747 void CT_CONVS::setupCleanup() |
746 LOCAL_C void setupCleanup() |
748 // |
747 // |
749 // Initialise the cleanup stack. |
748 // Initialise the cleanup stack. |
750 // |
749 // |
751 { |
750 { |
752 |
751 |
788 { |
787 { |
789 RDebug::Print(_L("Error %d connecting file session. File: %S.\n"), err, &aFullName); |
788 RDebug::Print(_L("Error %d connecting file session. File: %S.\n"), err, &aFullName); |
790 } |
789 } |
791 } |
790 } |
792 |
791 |
793 CT_CONVS::CT_CONVS() |
792 GLDEF_C TInt E32Main() |
|
793 // |
|
794 // Test streaming conversions. |
|
795 // |
794 { |
796 { |
795 SetTestStepName(KTestStep_T_CONVS); |
797 setupCleanup(); |
|
798 test.Title(); |
|
799 __UHEAP_MARK; |
|
800 |
|
801 test.Start(_L(" @SYMTestCaseID:SYSLIB-ETEXT-LEGACY-T_CONVS-0001 EText components using Flat Storage ")); |
|
802 TRAPD(r,testPlainTextL(CEditableText::EFlatStorage)); |
|
803 test(r==KErrNone); |
|
804 TRAP(r,testGlobalTextL(CEditableText::EFlatStorage)); |
|
805 test(r==KErrNone); |
|
806 |
|
807 // |
|
808 test.Next(_L("EText components using Segmented storage")); |
|
809 TRAP(r,testPlainTextL(CEditableText::ESegmentedStorage)); |
|
810 test(r==KErrNone); |
|
811 TRAP(r,testGlobalTextL(CEditableText::ESegmentedStorage)); |
|
812 test(r==KErrNone); |
|
813 |
|
814 test.Next(_L("Format Layer components")); |
|
815 TRAP(r,testFmtLayerL()); |
|
816 test(r==KErrNone); |
|
817 |
|
818 // test.End(); |
|
819 __UHEAP_MARKEND; |
|
820 |
|
821 ::DeleteDataFile(KOutputFile); //deletion of data files must be before call to End() - DEF047652 |
|
822 test.End(); |
|
823 test.Close(); |
|
824 delete TheTrapCleanup; |
|
825 |
|
826 return 0; |
796 } |
827 } |
797 |
828 |
798 TVerdict CT_CONVS::doTestStepL() |
|
799 { |
|
800 SetTestStepResult(EFail); |
|
801 |
|
802 INFO_PRINTF1(_L("T_CONVS - EditableText Persistence")); |
|
803 setupCleanup(); |
|
804 __UHEAP_MARK; |
|
805 |
|
806 INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-ETEXT-LEGACY-T_CONVS-0001 EText components using Flat Storage ")); |
|
807 TRAPD(error1, testPlainTextL(CEditableText::EFlatStorage)); |
|
808 TRAPD(error2, testGlobalTextL(CEditableText::EFlatStorage)); |
|
809 |
|
810 INFO_PRINTF1(_L("EText components using Segmented storage")); |
|
811 TRAPD(error3, testPlainTextL(CEditableText::ESegmentedStorage)); |
|
812 TRAPD(error4, testGlobalTextL(CEditableText::ESegmentedStorage)); |
|
813 |
|
814 INFO_PRINTF1(_L("Format Layer components")); |
|
815 TRAPD(error5, testFmtLayerL()); |
|
816 |
|
817 __UHEAP_MARKEND; |
|
818 DeleteDataFile(KOutputFile); //deletion of data files must be before call to End() - DEF047652 |
|
819 delete TheTrapCleanup; |
|
820 |
|
821 if(error1 == KErrNone && error2 == KErrNone && error3 == KErrNone && error4 == KErrNone && error5 == KErrNone) |
|
822 { |
|
823 SetTestStepResult(EPass); |
|
824 } |
|
825 |
|
826 return TestStepResult(); |
|
827 } |
|