14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
18 |
|
19 #include <e32test.h> |
19 #include <txtlaydc.h> |
20 #include <txtlaydc.h> |
20 #include <txtglobl.h> |
21 #include <txtglobl.h> |
21 #include <txtfrmat.h> |
22 #include <txtfrmat.h> |
22 #include <txtfmlyr.h> |
23 #include <txtfmlyr.h> |
23 #include "T_LAYDOC.h" |
|
24 |
|
25 LOCAL_D CTestStep *pTestStep = NULL; |
|
26 #define test(cond) \ |
|
27 { \ |
|
28 TBool __bb = (cond); \ |
|
29 pTestStep->TEST(__bb); \ |
|
30 if (!__bb) \ |
|
31 { \ |
|
32 pTestStep->ERR_PRINTF1(_L("ERROR: Test Failed")); \ |
|
33 User::Leave(1); \ |
|
34 } \ |
|
35 } |
|
36 #undef INFO_PRINTF1 |
|
37 #undef INFO_PRINTF2 |
|
38 // copy from tefexportconst.h |
|
39 #define INFO_PRINTF1(p1) pTestStep->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1)) |
|
40 #define INFO_PRINTF2(p1, p2) pTestStep->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2)) |
|
41 |
|
42 |
24 |
43 #define UNUSED_VAR(a) a = a |
25 #define UNUSED_VAR(a) a = a |
44 |
26 |
|
27 LOCAL_D RTest test(_L("TGlobalLayDoc - Layout class")); |
45 LOCAL_D TPtrC defaultText(_L("This is default text")); |
28 LOCAL_D TPtrC defaultText(_L("This is default text")); |
46 LOCAL_D TPtrC comp1(_L("fault text")); |
29 LOCAL_D TPtrC comp1(_L("fault text")); |
47 LOCAL_D TPtrC comp2(_L("t")); |
30 LOCAL_D TPtrC comp2(_L("t")); |
48 LOCAL_D TPtrC view(_L("x")); |
31 LOCAL_D TPtrC view(_L("x")); |
49 |
32 |
107 |
90 |
108 // Create LayDoc |
91 // Create LayDoc |
109 TCharFormat format; |
92 TCharFormat format; |
110 TPtrC view; |
93 TPtrC view; |
111 |
94 |
112 INFO_PRINTF1(_L("Sensing at start")); |
95 test.Start(_L("Sensing at start")); |
113 doc->GetChars(view,format,0); |
96 doc->GetChars(view,format,0); |
114 CheckView(view,defaultText); |
97 CheckView(view,defaultText); |
115 |
98 |
116 INFO_PRINTF1(_L("Sensing from char.pos.10")); |
99 test.Next(_L("Sensing from char.pos.10")); |
117 doc->GetChars(view,format,10); |
100 doc->GetChars(view,format,10); |
118 CheckView(view,comp1); |
101 CheckView(view,comp1); |
119 |
102 |
120 INFO_PRINTF1(_L("Sensing from end-1")); |
103 test.Next(_L("Sensing from end-1")); |
121 doc->GetChars(view,format,19); |
104 doc->GetChars(view,format,19); |
122 CheckView(view,comp2); |
105 CheckView(view,comp2); |
123 |
106 |
124 INFO_PRINTF1(_L("Sensing from end")); |
107 test.Next(_L("Sensing from end")); |
125 doc->GetChars(view,format,20); |
108 doc->GetChars(view,format,20); |
126 test(*view.Ptr()==CEditableText::EParagraphDelimiter); |
109 test(*view.Ptr()==CEditableText::EParagraphDelimiter); |
127 |
110 |
128 |
111 test.End(); |
129 delete doc; |
112 delete doc; |
130 delete paraLayer; |
113 delete paraLayer; |
131 delete charLayer; |
114 delete charLayer; |
132 __UHEAP_MARKEND; |
115 __UHEAP_MARKEND; |
133 } |
116 } |
195 // Create document. |
178 // Create document. |
196 CGlobalText* document=CGlobalText::NewL(paraLayer,charLayer,aStorage); |
179 CGlobalText* document=CGlobalText::NewL(paraLayer,charLayer,aStorage); |
197 TPtrC body(content); |
180 TPtrC body(content); |
198 document->InsertL(0,body); |
181 document->InsertL(0,body); |
199 // Now do the tests. |
182 // Now do the tests. |
200 INFO_PRINTF1(_L("Paragraph 1")); |
183 test.Start(_L("Paragraph 1")); |
201 DoParagraphStart(0,55,document); // Paragraph 1 |
184 DoParagraphStart(0,55,document); // Paragraph 1 |
202 INFO_PRINTF1(_L("Paragraph 2")); |
185 test.Next(_L("Paragraph 2")); |
203 DoParagraphStart(55,23,document); // Paragraph 2 |
186 DoParagraphStart(55,23,document); // Paragraph 2 |
204 INFO_PRINTF1(_L("Paragraph 3")); |
187 test.Next(_L("Paragraph 3")); |
205 DoParagraphStart(78,20,document); // Paragraph 3 |
188 DoParagraphStart(78,20,document); // Paragraph 3 |
206 |
189 |
207 delete paraLayer; |
190 delete paraLayer; |
208 delete charLayer; |
191 delete charLayer; |
209 delete document; |
192 delete document; |
210 |
193 test.End(); |
211 __UHEAP_MARKEND; |
194 __UHEAP_MARKEND; |
212 User::Heap().Check(); |
195 User::Heap().Check(); |
213 } |
196 } |
214 |
197 |
215 |
198 |
283 UNUSED_VAR(ret); |
266 UNUSED_VAR(ret); |
284 TInt pos=0; |
267 TInt pos=0; |
285 doc->SetGlobalParaFormat(layer); |
268 doc->SetGlobalParaFormat(layer); |
286 |
269 |
287 // Check constructor |
270 // Check constructor |
288 INFO_PRINTF1(_L("Constructor")); |
271 test.Start(_L("Constructor")); |
289 |
272 |
290 // Check DocumentLength |
273 // Check DocumentLength |
291 INFO_PRINTF1(_L("DocumentLength()")); |
274 test.Next(_L("DocumentLength()")); |
292 doc->LdDocumentLength(); |
275 doc->LdDocumentLength(); |
293 |
276 |
294 // Check ParagraphStart |
277 // Check ParagraphStart |
295 INFO_PRINTF1(_L("ParagraphStart()")); |
278 test.Next(_L("ParagraphStart()")); |
296 doc->LdToParagraphStart(pos); |
279 doc->LdToParagraphStart(pos); |
297 |
280 |
298 // Check GetParagraphFormatL |
281 // Check GetParagraphFormatL |
299 INFO_PRINTF1(_L("GetParagraphFormatL()")); |
282 test.Next(_L("GetParagraphFormatL()")); |
300 doc->GetParagraphFormatL(format,pos); |
283 doc->GetParagraphFormatL(format,pos); |
301 |
284 |
302 // Check GetChars |
285 // Check GetChars |
303 INFO_PRINTF1(_L("GetChars()")); |
286 test.Next(_L("GetChars()")); |
304 TPtrC view; |
287 TPtrC view; |
305 TCharFormat charFormat; |
288 TCharFormat charFormat; |
306 doc->GetChars(view,charFormat,pos); |
289 doc->GetChars(view,charFormat,pos); |
307 |
290 |
308 // check EnquirePage |
291 // check EnquirePage |
309 INFO_PRINTF1(_L("EnquirePageBreak()")); |
292 test.Next(_L("EnquirePageBreak()")); |
310 doc->EnquirePageBreak(pos,0); |
293 doc->EnquirePageBreak(pos,0); |
311 |
294 |
312 delete paraLayer; |
295 delete paraLayer; |
313 delete charLayer; |
296 delete charLayer; |
314 delete doc; |
297 delete doc; |
315 delete layer; |
298 delete layer; |
316 delete format; |
299 delete format; |
317 |
300 test.End(); |
318 __UHEAP_MARKEND; |
301 __UHEAP_MARKEND; |
319 User::Heap().Check(); |
302 User::Heap().Check(); |
320 } |
303 } |
321 |
304 |
322 GLDEF_C void Test() |
305 GLDEF_C void Test() |
323 // |
306 // |
324 // Run the tests |
307 // Run the tests |
325 // |
308 // |
326 { |
309 { |
327 __UHEAP_MARK; |
310 __UHEAP_MARK; |
328 INFO_PRINTF1(_L("Checking all methods present")); |
311 test.Start(_L("Checking all methods present")); |
329 TestRegister(CEditableText::EFlatStorage); |
312 TestRegister(CEditableText::EFlatStorage); |
330 |
313 |
331 INFO_PRINTF1(_L("DocumentLength()")); |
314 test.Next(_L("DocumentLength()")); |
332 TestDocumentLength(CEditableText::EFlatStorage); |
315 TestDocumentLength(CEditableText::EFlatStorage); |
333 |
316 |
334 INFO_PRINTF1(_L("EnquirePage()")); |
317 test.Next(_L("EnquirePage()")); |
335 INFO_PRINTF1(_L("Always returns 0")); |
318 test.Start(_L("Always returns 0")); |
336 |
319 test.End(); |
337 |
320 |
338 INFO_PRINTF1(_L("ParagraphStart()")); |
321 test.Next(_L("ParagraphStart()")); |
339 TestParagraphStart(CEditableText::EFlatStorage); |
322 TestParagraphStart(CEditableText::EFlatStorage); |
340 |
323 |
341 INFO_PRINTF1(_L("GetParagraphFormatL()")); |
324 test.Next(_L("GetParagraphFormatL()")); |
342 TestGetParagraphFormatL(CEditableText::EFlatStorage); |
325 TestGetParagraphFormatL(CEditableText::EFlatStorage); |
343 |
326 |
344 INFO_PRINTF1(_L("GetChars")); |
327 test.Next(_L("GetChars")); |
345 TestRead(CEditableText::EFlatStorage); |
328 TestRead(CEditableText::EFlatStorage); |
346 |
329 test.End(); |
347 __UHEAP_MARKEND; |
330 __UHEAP_MARKEND; |
348 } |
331 } |
349 |
332 |
350 |
333 |
351 GLDEF_C void TestSeg() |
334 GLDEF_C void TestSeg() |
352 // |
335 // |
353 // Run the tests |
336 // Run the tests |
354 // |
337 // |
355 { |
338 { |
356 __UHEAP_MARK; |
339 __UHEAP_MARK; |
357 INFO_PRINTF1(_L("Checking all methods present")); |
340 test.Next(_L("Checking all methods present")); |
358 TestRegister(CEditableText::ESegmentedStorage); |
341 TestRegister(CEditableText::ESegmentedStorage); |
359 |
342 |
360 INFO_PRINTF1(_L("DocumentLength()")); |
343 test.Next(_L("DocumentLength()")); |
361 TestDocumentLength(CEditableText::ESegmentedStorage); |
344 TestDocumentLength(CEditableText::ESegmentedStorage); |
362 |
345 |
363 INFO_PRINTF1(_L("EnquirePage()")); |
346 test.Next(_L("EnquirePage()")); |
364 INFO_PRINTF1(_L("Always returns 0")); |
347 test.Start(_L("Always returns 0")); |
365 |
348 test.End(); |
366 |
349 |
367 INFO_PRINTF1(_L("ParagraphStart()")); |
350 test.Next(_L("ParagraphStart()")); |
368 TestParagraphStart(CEditableText::ESegmentedStorage); |
351 TestParagraphStart(CEditableText::ESegmentedStorage); |
369 |
352 |
370 INFO_PRINTF1(_L("SenseParagraphFormatL()")); |
353 test.Next(_L("SenseParagraphFormatL()")); |
371 TestGetParagraphFormatL(CEditableText::ESegmentedStorage); |
354 TestGetParagraphFormatL(CEditableText::ESegmentedStorage); |
372 |
355 |
373 INFO_PRINTF1(_L("GetChars")); |
356 test.Next(_L("GetChars")); |
374 //TestRead(); |
357 //TestRead(); |
375 // |
358 //test.End(); |
376 INFO_PRINTF1(_L("Test not yet implemented")); |
359 test.Start(_L("Test not yet implemented")); |
377 |
360 test.End(); |
378 __UHEAP_MARKEND; |
361 __UHEAP_MARKEND; |
379 } |
362 } |
380 |
363 |
381 CT_LAYDOC::CT_LAYDOC() |
364 |
382 { |
365 GLDEF_C TInt E32Main() |
383 SetTestStepName(KTestStep_T_LAYDOC); |
366 // |
384 pTestStep = this; |
367 // Drives the test program |
385 } |
368 // |
386 |
369 { |
387 TVerdict CT_LAYDOC::doTestStepL() |
370 CTrapCleanup* cleanup=CTrapCleanup::New(); |
388 { |
371 |
389 SetTestStepResult(EFail); |
372 |
390 |
373 test.Start(_L(" @SYMTestCaseID:SYSLIB-TTEXT-LEGACY-T_LAYDOC-0001 MLayDoc - Using Flat document ")); |
391 CTrapCleanup* cleanup=CTrapCleanup::New(); |
374 |
392 |
375 __UHEAP_MARK; |
393 INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-TTEXT-LEGACY-T_LAYDOC-0001 MLayDoc - Using Flat document ")); |
376 TRAPD(ret,Test()); |
394 |
377 __UHEAP_MARKEND; |
395 __UHEAP_MARK; |
378 test(ret == KErrNone); |
396 TRAPD(ret1,Test()); |
379 |
397 __UHEAP_MARKEND; |
380 test.Next(_L("MLaydoc - Using Segmented document")); |
398 |
381 __UHEAP_MARK; |
399 INFO_PRINTF1(_L("MLaydoc - Using Segmented document")); |
382 TRAP(ret,TestSeg()); |
400 __UHEAP_MARK; |
383 __UHEAP_MARKEND; |
401 TRAPD(ret2,TestSeg()); |
384 test(ret == KErrNone); |
402 __UHEAP_MARKEND; |
385 |
403 |
386 test.End(); |
404 delete cleanup; |
387 test.Close(); |
405 |
388 |
406 if (ret1 == KErrNone && ret2 == KErrNone) |
389 delete cleanup; |
407 { |
390 |
408 SetTestStepResult(EPass); |
391 return(0); |
409 } |
392 } |
410 |
|
411 return TestStepResult(); |
|
412 } |
|