changeset 53 | 11e2bb0d14ba |
parent 0 | 1fb32624e06b |
child 55 | 336bee5c2d35 |
46:6124ff6478cc | 53:11e2bb0d14ba |
---|---|
1 /* |
1 /* |
2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 1997-2010 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". |
20 #include <e32base.h> |
20 #include <e32base.h> |
21 |
21 |
22 #include <gdi.h> |
22 #include <gdi.h> |
23 #include <conpics.h> |
23 #include <conpics.h> |
24 #include <s32file.h> |
24 #include <s32file.h> |
25 #include <e32test.h> |
|
26 |
25 |
27 #include <txtrich.h> |
26 #include <txtrich.h> |
28 #include <txtfmlyr.h> |
27 #include <txtfmlyr.h> |
29 #include "TXTMRTSR.H" |
28 #include "TXTMRTSR.H" |
30 |
29 |
31 #include "../incp/T_PMLPAR.H" |
30 #include "../incp/T_PMLPAR.H" |
32 #include "../spml/T_PMLPAR.CPP" |
31 //#include "../spml/T_PMLPAR.CPP" |
33 |
32 #include "T_TRAN.h" |
33 |
|
34 LOCAL_D CTestStep *pTestStep = NULL; |
|
35 #define test(cond) \ |
|
36 { \ |
|
37 TBool __bb = (cond); \ |
|
38 pTestStep->TEST(__bb); \ |
|
39 if (!__bb) \ |
|
40 { \ |
|
41 pTestStep->ERR_PRINTF1(_L("ERROR: Test Failed")); \ |
|
42 User::Leave(1); \ |
|
43 } \ |
|
44 } |
|
45 #undef INFO_PRINTF1 |
|
46 #undef INFO_PRINTF2 |
|
47 // copy from tefexportconst.h |
|
48 #define INFO_PRINTF1(p1) pTestStep->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1)) |
|
49 #define INFO_PRINTF2(p1, p2) pTestStep->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2)) |
|
50 |
|
51 // included in a namespace, to avoid confliction |
|
52 namespace T_TRAN { |
|
34 /* this fixes a MSVC link warning */ |
53 /* this fixes a MSVC link warning */ |
35 #ifdef __VC32__ |
54 #ifdef __VC32__ |
36 #pragma comment (linker, "/opt:noref") |
55 #pragma comment (linker, "/opt:noref") |
37 #endif |
56 #endif |
38 |
57 |
73 CRichText* iText; |
92 CRichText* iText; |
74 const CParaFormatLayer* iGlobalParaFormatLayer; |
93 const CParaFormatLayer* iGlobalParaFormatLayer; |
75 const CCharFormatLayer* iGlobalCharFormatLayer; |
94 const CCharFormatLayer* iGlobalCharFormatLayer; |
76 }; |
95 }; |
77 |
96 |
78 |
|
79 LOCAL_D RTest test(_L("Testing Picture Restorer mechanism")); |
|
80 LOCAL_D CTrapCleanup* TheTrapCleanup; |
97 LOCAL_D CTrapCleanup* TheTrapCleanup; |
81 LOCAL_D RFs TheFs; // the file server |
98 LOCAL_D RFs TheFs; // the file server |
82 LOCAL_D RFile TheFile; // the data file |
99 LOCAL_D RFile TheFile; // the data file |
83 LOCAL_D CParser* TheParser; |
100 LOCAL_D CParser* TheParser; |
84 LOCAL_D CContainer* TheContainer; |
101 LOCAL_D CContainer* TheContainer; |
373 // |
390 // |
374 // |
391 // |
375 // Now store the stuff again |
392 // Now store the stuff again |
376 TInt error=TheContainer->iText->LoadAllPicturesNowL(); |
393 TInt error=TheContainer->iText->LoadAllPicturesNowL(); |
377 if (error==KErrNotFound) |
394 if (error==KErrNotFound) |
378 test.Printf(_L(" SIMULATION: Some picture data has been removed as no app could be found.")); |
395 INFO_PRINTF1(_L(" SIMULATION: Some picture data has been removed as no app could be found.")); |
379 // if (aAlwaysFailToLoad) |
396 // if (aAlwaysFailToLoad) |
380 // test(error==KErrNotFound); |
397 // test(error==KErrNotFound); |
381 // else |
398 // else |
382 // test(error==KErrNone); |
399 // test(error==KErrNone); |
383 id=KNullStreamId; |
400 id=KNullStreamId; |
403 |
420 |
404 |
421 |
405 LOCAL_C void CompareRichTextL(CRichText *aDoc1,CRichText *aDoc2) |
422 LOCAL_C void CompareRichTextL(CRichText *aDoc1,CRichText *aDoc2) |
406 // |
423 // |
407 { |
424 { |
408 test.Start(_L("Comparing Documents")); |
425 INFO_PRINTF1(_L("Comparing Documents")); |
409 TInt length; |
426 TInt length; |
410 TInt num1,num2; |
427 TInt num1,num2; |
411 TInt ii=0,len1,len2,pos1,pos2,oldPos; |
428 TInt ii=0,len1,len2,pos1,pos2,oldPos; |
412 |
429 |
413 test.Next(_L("Document Length")); |
430 INFO_PRINTF1(_L("Document Length")); |
414 length=aDoc1->LdDocumentLength(); |
431 length=aDoc1->LdDocumentLength(); |
415 num2=aDoc2->LdDocumentLength(); |
432 num2=aDoc2->LdDocumentLength(); |
416 test(length==num2); |
433 test(length==num2); |
417 |
434 |
418 test.Next(_L("Paragraph Count")); |
435 INFO_PRINTF1(_L("Paragraph Count")); |
419 num1=aDoc1->ParagraphCount(); |
436 num1=aDoc1->ParagraphCount(); |
420 num2=aDoc2->ParagraphCount(); |
437 num2=aDoc2->ParagraphCount(); |
421 test(num1==num2); |
438 test(num1==num2); |
422 |
439 |
423 test.Next(_L("Paragraph Lengths")); |
440 INFO_PRINTF1(_L("Paragraph Lengths")); |
424 pos1=-1; |
441 pos1=-1; |
425 oldPos=-2; |
442 oldPos=-2; |
426 while (pos1>oldPos) |
443 while (pos1>oldPos) |
427 { |
444 { |
428 oldPos=pos1; |
445 oldPos=pos1; |
431 test(len1==len2); |
448 test(len1==len2); |
432 test(pos1==pos2); |
449 test(pos1==pos2); |
433 ii++; |
450 ii++; |
434 } |
451 } |
435 |
452 |
436 test.Next(_L("Word Count")); |
453 INFO_PRINTF1(_L("Word Count")); |
437 num1=aDoc1->WordCount(); |
454 num1=aDoc1->WordCount(); |
438 num2=aDoc2->WordCount(); |
455 num2=aDoc2->WordCount(); |
439 test(num1==num2); |
456 test(num1==num2); |
440 |
457 |
441 test.Next(_L("Characters")); |
458 INFO_PRINTF1(_L("Characters")); |
442 TCharFormat format1,format2; |
459 TCharFormat format1,format2; |
443 TPtrC chars1,chars2; |
460 TPtrC chars1,chars2; |
444 len1=1; |
461 len1=1; |
445 ii=0; |
462 ii=0; |
446 while (ii<=length) |
463 while (ii<=length) |
452 test(format1.IsEqual(format2)); |
469 test(format1.IsEqual(format2)); |
453 test(format2.IsEqual(format1)); |
470 test(format2.IsEqual(format1)); |
454 ii+=len1; |
471 ii+=len1; |
455 } |
472 } |
456 |
473 |
457 test.End(); |
474 |
458 } |
475 } |
459 |
476 |
460 |
477 |
461 LOCAL_C void GoL() |
478 LOCAL_C void GoL() |
462 // Run the tests |
479 // Run the tests |
465 CParaFormatLayer* pLayer=CParaFormatLayer::NewL(); |
482 CParaFormatLayer* pLayer=CParaFormatLayer::NewL(); |
466 CCharFormatLayer* cLayer=CCharFormatLayer::NewL(); |
483 CCharFormatLayer* cLayer=CCharFormatLayer::NewL(); |
467 CRichText *document=CRichText::NewL(pLayer,cLayer); |
484 CRichText *document=CRichText::NewL(pLayer,cLayer); |
468 TInt err; |
485 TInt err; |
469 |
486 |
470 test.Start(_L("Document with single Paragraph")); |
487 INFO_PRINTF1(_L("Document with single Paragraph")); |
471 test.Next(_L(" @SYMTestCaseID:SYSLIB-TTEXT-LEGACY-T_TRAN-0001 ")); |
488 INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-TTEXT-LEGACY-T_TRAN-0001 ")); |
472 { |
489 { |
473 TheContainer=CContainer::NewL(_L("z:\\test\\app-framework\\etext\\t_para.pml")); |
490 TheContainer=CContainer::NewL(_L("z:\\test\\app-framework\\etext\\t_para.pml")); |
474 test.Start(_L("Exporting a file by Para")); |
491 INFO_PRINTF1(_L("Exporting a file by Para")); |
475 TFileName exportFile=KExportFileName1(); |
492 TFileName exportFile=KExportFileName1(); |
476 EnsureFileExists(exportFile); |
493 EnsureFileExists(exportFile); |
477 TRAP(err,TheContainer->iText->ExportAsTextL(exportFile,CPlainText::EOrganiseByParagraph,0)); |
494 TRAP(err,TheContainer->iText->ExportAsTextL(exportFile,CPlainText::EOrganiseByParagraph,0)); |
478 test(err==KErrNone); |
495 test(err==KErrNone); |
479 test.Next(_L("Importing a file by Para")); |
496 INFO_PRINTF1(_L("Importing a file by Para")); |
480 document->Reset(); |
497 document->Reset(); |
481 TInt charsImported=document->ImportTextFileL(0,exportFile,CPlainText::EOrganiseByParagraph); |
498 TInt charsImported=document->ImportTextFileL(0,exportFile,CPlainText::EOrganiseByParagraph); |
482 test(charsImported>0); |
499 test(charsImported>0); |
483 test.Next(_L("Comparing Result")); |
500 INFO_PRINTF1(_L("Comparing Result")); |
484 TRAP(err,CompareRichTextL(TheContainer->iText,document)); |
501 TRAP(err,CompareRichTextL(TheContainer->iText,document)); |
485 test(err==KErrNone); |
502 test(err==KErrNone); |
486 delete TheContainer; |
503 delete TheContainer; |
487 } |
504 } |
488 |
505 |
489 { |
506 { |
490 TheContainer=CContainer::NewL(_L("z:\\test\\app-framework\\etext\\t_para.pml")); |
507 TheContainer=CContainer::NewL(_L("z:\\test\\app-framework\\etext\\t_para.pml")); |
491 test.Next(_L("Exporting and Importing a file by Line")); |
508 INFO_PRINTF1(_L("Exporting and Importing a file by Line")); |
492 test.Start(_L("Line Lengths 25,30,...,95")); |
509 INFO_PRINTF1(_L("Line Lengths 25,30,...,95")); |
493 TFileName exportFile=KExportFileName1(); |
510 TFileName exportFile=KExportFileName1(); |
494 TInt ii; |
511 TInt ii; |
495 for(ii=25;ii<100;ii+=5) |
512 for(ii=25;ii<100;ii+=5) |
496 { |
513 { |
497 test.Next(_L("With next line length")); |
514 INFO_PRINTF1(_L("With next line length")); |
498 EnsureFileExists(exportFile); |
515 EnsureFileExists(exportFile); |
499 TRAP(err,TheContainer->iText->ExportAsTextL(exportFile,CPlainText::EOrganiseByLine,ii)); |
516 TRAP(err,TheContainer->iText->ExportAsTextL(exportFile,CPlainText::EOrganiseByLine,ii)); |
500 test(err==KErrNone); |
517 test(err==KErrNone); |
501 document->Reset(); |
518 document->Reset(); |
502 TInt charsImported=document->ImportTextFileL(0,exportFile,CPlainText::EOrganiseByLine); |
519 TInt charsImported=document->ImportTextFileL(0,exportFile,CPlainText::EOrganiseByLine); |
503 test(charsImported>0); |
520 test(charsImported>0); |
504 TRAP(err,CompareRichTextL(TheContainer->iText,document)); |
521 TRAP(err,CompareRichTextL(TheContainer->iText,document)); |
505 test(err==KErrNone); |
522 test(err==KErrNone); |
506 } |
523 } |
507 delete TheContainer; |
524 delete TheContainer; |
508 test.End(); |
525 |
509 } |
526 } |
510 |
527 |
511 test.End(); |
528 |
512 test.Next(_L("Document with two Paragraphs")); |
529 INFO_PRINTF1(_L("Document with two Paragraphs")); |
513 |
530 |
514 { |
531 { |
515 TheContainer=CContainer::NewL(_L("z:\\test\\app-framework\\etext\\t_para2.pml")); |
532 TheContainer=CContainer::NewL(_L("z:\\test\\app-framework\\etext\\t_para2.pml")); |
516 test.Start(_L("Exporting a file by Para")); |
533 INFO_PRINTF1(_L("Exporting a file by Para")); |
517 TFileName exportFile=KExportFileName2(); |
534 TFileName exportFile=KExportFileName2(); |
518 EnsureFileExists(exportFile); |
535 EnsureFileExists(exportFile); |
519 TRAP(err,TheContainer->iText->ExportAsTextL(exportFile,CPlainText::EOrganiseByParagraph,0)); |
536 TRAP(err,TheContainer->iText->ExportAsTextL(exportFile,CPlainText::EOrganiseByParagraph,0)); |
520 test(err==KErrNone); |
537 test(err==KErrNone); |
521 test.Next(_L("Importing a file by Para")); |
538 INFO_PRINTF1(_L("Importing a file by Para")); |
522 document->Reset(); |
539 document->Reset(); |
523 TInt charsImported=document->ImportTextFileL(0,exportFile,CPlainText::EOrganiseByParagraph); |
540 TInt charsImported=document->ImportTextFileL(0,exportFile,CPlainText::EOrganiseByParagraph); |
524 test(charsImported>0); |
541 test(charsImported>0); |
525 test.Next(_L("Comparing Result")); |
542 INFO_PRINTF1(_L("Comparing Result")); |
526 TRAP(err,CompareRichTextL(TheContainer->iText,document)); |
543 TRAP(err,CompareRichTextL(TheContainer->iText,document)); |
527 test(err==KErrNone); |
544 test(err==KErrNone); |
528 delete TheContainer; |
545 delete TheContainer; |
529 } |
546 } |
530 |
547 |
531 { |
548 { |
532 TheContainer=CContainer::NewL(_L("z:\\test\\app-framework\\etext\\t_para.pml")); |
549 TheContainer=CContainer::NewL(_L("z:\\test\\app-framework\\etext\\t_para.pml")); |
533 test.Next(_L("Exporting and Importing a file by Line")); |
550 INFO_PRINTF1(_L("Exporting and Importing a file by Line")); |
534 test.Start(_L("Line Lengths 30,40,...,100")); |
551 INFO_PRINTF1(_L("Line Lengths 30,40,...,100")); |
535 TFileName exportFile=KExportFileName1(); |
552 TFileName exportFile=KExportFileName1(); |
536 TInt ii; |
553 TInt ii; |
537 for(ii=30;ii<105;ii+=10) |
554 for(ii=30;ii<105;ii+=10) |
538 { |
555 { |
539 test.Next(_L("With next line length")); |
556 INFO_PRINTF1(_L("With next line length")); |
540 EnsureFileExists(exportFile); |
557 EnsureFileExists(exportFile); |
541 TRAP(err,TheContainer->iText->ExportAsTextL(exportFile,CPlainText::EOrganiseByLine,ii)); |
558 TRAP(err,TheContainer->iText->ExportAsTextL(exportFile,CPlainText::EOrganiseByLine,ii)); |
542 test(err==KErrNone); |
559 test(err==KErrNone); |
543 document->Reset(); |
560 document->Reset(); |
544 TInt charsImported=document->ImportTextFileL(0,exportFile,CPlainText::EOrganiseByLine); |
561 TInt charsImported=document->ImportTextFileL(0,exportFile,CPlainText::EOrganiseByLine); |
545 test(charsImported>0); |
562 test(charsImported>0); |
546 TRAP(err,CompareRichTextL(TheContainer->iText,document)); |
563 TRAP(err,CompareRichTextL(TheContainer->iText,document)); |
547 test(err==KErrNone); |
564 test(err==KErrNone); |
548 } |
565 } |
549 delete TheContainer; |
566 delete TheContainer; |
550 test.End(); |
567 |
551 } |
568 } |
552 |
569 |
553 delete document; |
570 delete document; |
554 delete cLayer; |
571 delete cLayer; |
555 delete pLayer; |
572 delete pLayer; |
556 |
573 |
557 test.End(); |
574 |
558 } |
575 } |
559 |
576 |
560 |
577 |
561 LOCAL_C void setupCleanup() |
578 LOCAL_C void setupCleanup() |
562 // |
579 // |
601 else |
618 else |
602 { |
619 { |
603 RDebug::Print(_L("Error %d connecting file session. File: %S.\n"), err, &aFullName); |
620 RDebug::Print(_L("Error %d connecting file session. File: %S.\n"), err, &aFullName); |
604 } |
621 } |
605 } |
622 } |
606 |
623 } |
607 GLDEF_C TInt E32Main() |
624 |
608 // |
625 CT_TRAN::CT_TRAN() |
609 // Test the streaming framework. |
|
610 // |
|
611 { |
626 { |
612 |
627 SetTestStepName(KTestStep_T_TRAN); |
613 test.Title(); |
628 pTestStep = this; |
614 |
|
615 __UHEAP_MARK; |
|
616 setupCleanup(); |
|
617 TRAPD(r,GoL()); |
|
618 test(r == KErrNone); |
|
619 |
|
620 delete TheTrapCleanup; |
|
621 |
|
622 __UHEAP_MARKEND; |
|
623 |
|
624 ::DeleteDataFile(KExportFileName1); //deletion of data files must be before call to End() - DEF047652 |
|
625 ::DeleteDataFile(KExportFileName2); |
|
626 |
|
627 test.End(); |
|
628 test.Close(); |
|
629 |
|
630 return 0; |
|
631 } |
629 } |
630 |
|
631 TVerdict CT_TRAN::doTestStepL() |
|
632 { |
|
633 SetTestStepResult(EFail); |
|
634 |
|
635 INFO_PRINTF1(_L("Testing Picture Restorer mechanism")); |
|
636 |
|
637 __UHEAP_MARK; |
|
638 T_TRAN::setupCleanup(); |
|
639 TRAPD(r, T_TRAN::GoL()); |
|
640 |
|
641 delete T_TRAN::TheTrapCleanup; |
|
642 |
|
643 __UHEAP_MARKEND; |
|
644 |
|
645 T_TRAN::DeleteDataFile(T_TRAN::KExportFileName1); //deletion of data files must be before call to End() - DEF047652 |
|
646 T_TRAN::DeleteDataFile(T_TRAN::KExportFileName2); |
|
647 |
|
648 if (r == KErrNone) |
|
649 { |
|
650 SetTestStepResult(EPass); |
|
651 } |
|
652 |
|
653 return TestStepResult(); |
|
654 } |