27 #include "TMSTD.H" |
27 #include "TMSTD.H" |
28 #include "TmLayoutImp.h" |
28 #include "TmLayoutImp.h" |
29 #include "TMINTERP.H" |
29 #include "TMINTERP.H" |
30 #include "TmText.h" |
30 #include "TmText.h" |
31 #include "InlineText.h" |
31 #include "InlineText.h" |
32 #include "ttagmaimp.h" |
32 |
33 |
33 namespace LocalToFile |
34 namespace LocalToTTagmaImp |
|
35 { |
34 { |
36 enum TTagmaImpPanic { EAccessOutsideText = 1 }; |
35 enum TTagmaImpPanic { EAccessOutsideText = 1 }; |
37 void Panic(TTagmaImpPanic) |
36 void Panic(TTagmaImpPanic) |
38 { |
37 { |
39 User::Panic(_L("TTagmaImp"), EAccessOutsideText); |
38 User::Panic(_L("TTagmaImp"), EAccessOutsideText); |
40 } |
39 } |
41 |
40 RTest test(_L("Tagma internals tests")); |
42 CTTagmaImpStep* TestStep = NULL; |
|
43 #define TESTPOINT(p) TestStep->testpoint(p,(TText8*)__FILE__,__LINE__) |
|
44 #define TESTPRINT(p) TestStep->print(p,(TText8*)__FILE__,__LINE__) |
|
45 |
41 |
46 const TInt KPictureCharacter = 0xFFFC; |
42 const TInt KPictureCharacter = 0xFFFC; |
47 |
43 |
48 class CPinkSquare : public CPicture |
44 class CPinkSquare : public CPicture |
49 { |
45 { |
353 { |
349 { |
354 TUint8 byte = reader.ReadByte(); |
350 TUint8 byte = reader.ReadByte(); |
355 TInt num = reader.ReadNumber(); |
351 TInt num = reader.ReadNumber(); |
356 TRect rect = reader.ReadRect(); |
352 TRect rect = reader.ReadRect(); |
357 TRect testRect(aStartValue + 2, aStartValue + 3, aStartValue + 4, aStartValue + 5); |
353 TRect testRect(aStartValue + 2, aStartValue + 3, aStartValue + 4, aStartValue + 5); |
358 TESTPOINT(byte == static_cast<TUint8>(aStartValue)); |
354 test(byte == static_cast<TUint8>(aStartValue)); |
359 TESTPOINT(num == aStartValue + 1); |
355 test(num == aStartValue + 1); |
360 TESTPOINT(rect == testRect); |
356 test(rect == testRect); |
361 } |
357 } |
362 return reader.CodePos(); |
358 return reader.CodePos(); |
363 } |
359 } |
364 |
360 |
365 void CTagmaImpTest::AddSome1L(CTmCode& aCode, TInt aStartValue) |
361 void CTagmaImpTest::AddSome1L(CTmCode& aCode, TInt aStartValue) |
428 CheckLots(*code, size1, 0, count4); |
424 CheckLots(*code, size1, 0, count4); |
429 CheckLots(*code, size1 + size4, 0, count2); |
425 CheckLots(*code, size1 + size4, 0, count2); |
430 code->Delete(size1, size4); |
426 code->Delete(size1, size4); |
431 CheckLots(*code, 0, 0, count1); |
427 CheckLots(*code, 0, 0, count1); |
432 CheckLots(*code, size1, 0, count2); |
428 CheckLots(*code, size1, 0, count2); |
433 TESTPOINT(code2->Size() == 0); |
429 test(code2->Size() == 0); |
434 CleanupStack::PopAndDestroy(code2); |
430 CleanupStack::PopAndDestroy(code2); |
435 CleanupStack::PopAndDestroy(code); |
431 CleanupStack::PopAndDestroy(code); |
436 } |
432 } |
437 |
433 |
438 void CTagmaImpTest::CTmCodeOOML() |
434 void CTagmaImpTest::CTmCodeOOML() |
439 { |
435 { |
440 ExerciseCTmCodeL(); |
436 ExerciseCTmCodeL(); |
441 TInt err; |
437 TInt err; |
442 TInt failAt = 1; |
438 TInt failAt = 1; |
443 do { |
439 do { |
444 THandleTester h(); |
440 THandleTester h(test); |
445 |
441 |
446 __UHEAP_MARK; |
442 __UHEAP_MARK; |
447 __UHEAP_SETFAIL(RHeap::EDeterministic, failAt); |
443 __UHEAP_SETFAIL(RHeap::EDeterministic, failAt); |
448 TRAP(err, ExerciseCTmCodeL()); |
444 TRAP(err, ExerciseCTmCodeL()); |
449 __UHEAP_SETFAIL(RHeap::ENone, 0); |
445 __UHEAP_SETFAIL(RHeap::ENone, 0); |
450 __UHEAP_MARKENDC(0); |
446 __UHEAP_MARKENDC(0); |
451 |
447 |
452 ++failAt; |
448 ++failAt; |
453 } while (err == KErrNoMemory); |
449 } while (err == KErrNoMemory); |
454 TESTPOINT(err == KErrNone); |
450 test(err == KErrNone); |
455 } |
451 } |
456 |
452 |
457 CTestSource* CTagmaImpTest::NewTestSourceLC() |
453 CTestSource* CTagmaImpTest::NewTestSourceLC() |
458 { |
454 { |
459 _LIT(KTestText, "Some text for you to format for me.\x2029"); |
455 _LIT(KTestText, "Some text for you to format for me.\x2029"); |
641 CleanupStack::PushL(layout); |
637 CleanupStack::PushL(layout); |
642 CTmFormatContext::FormatL(*source, formatParam, *code, info, layout); |
638 CTmFormatContext::FormatL(*source, formatParam, *code, info, layout); |
643 |
639 |
644 // check that format has found the break at 11 characters |
640 // check that format has found the break at 11 characters |
645 // This is at the end of "this is a " |
641 // This is at the end of "this is a " |
646 TESTPOINT(info.iFirstLineEndChar == 11 ); |
642 test( info.iFirstLineEndChar == 11 ); |
647 |
643 |
648 // get the text that would be displayed into displayBuffer |
644 // get the text that would be displayed into displayBuffer |
649 TTmInterpreterParam interpreter_param(*code); |
645 TTmInterpreterParam interpreter_param(*code); |
650 interpreter_param.iCodeStart = 0; |
646 interpreter_param.iCodeStart = 0; |
651 interpreter_param.iCodeEnd = code->Size(); |
647 interpreter_param.iCodeEnd = code->Size(); |
704 CTmTextLayout* layout = new(ELeave) CTmTextLayout; |
700 CTmTextLayout* layout = new(ELeave) CTmTextLayout; |
705 CleanupStack::PushL(layout); |
701 CleanupStack::PushL(layout); |
706 CTmFormatContext::FormatL(*source1, formatParam1, *code, info1, layout); |
702 CTmFormatContext::FormatL(*source1, formatParam1, *code, info1, layout); |
707 |
703 |
708 // check that format didn't found any breaks |
704 // check that format didn't found any breaks |
709 TESTPOINT( info1.iFirstLineEndChar == KTest1().Length()); |
705 test( info1.iFirstLineEndChar == KTest1().Length()); |
710 TESTPOINT( info1.iLastLineStartChar == 0 ); |
706 test( info1.iLastLineStartChar == 0 ); |
711 TESTPOINT( info1.iHeight == 12 ); // just 1 line |
707 test( info1.iHeight == 12 ); // just 1 line |
712 |
708 |
713 |
709 |
714 |
710 |
715 // 2. now append more than one space and verify that the line is not broken |
711 // 2. now append more than one space and verify that the line is not broken |
716 CTestSource* source2 = NewTestSourceLC(); |
712 CTestSource* source2 = NewTestSourceLC(); |
729 formatParam2.iFlags = TTmFormatParam::EWrap; |
725 formatParam2.iFlags = TTmFormatParam::EWrap; |
730 formatParam2.iWrapWidth = 520; |
726 formatParam2.iWrapWidth = 520; |
731 CTmFormatContext::FormatL(*source2, formatParam2, *code, info2, layout); |
727 CTmFormatContext::FormatL(*source2, formatParam2, *code, info2, layout); |
732 |
728 |
733 // check that format didn't found any breaks |
729 // check that format didn't found any breaks |
734 TESTPOINT( info2.iFirstLineEndChar == KTest2().Length()); |
730 test( info2.iFirstLineEndChar == KTest2().Length()); |
735 TESTPOINT( info2.iLastLineStartChar == 0 ); |
731 test( info2.iLastLineStartChar == 0 ); |
736 TESTPOINT( info2.iHeight == 12 ); // just 1 line |
732 test( info2.iHeight == 12 ); // just 1 line |
737 |
733 |
738 |
734 |
739 |
735 |
740 // 3. now test with page breaks (0x000C) and line breaks (0x2028) |
736 // 3. now test with page breaks (0x000C) and line breaks (0x2028) |
741 CTestSource* source3 = NewTestSourceLC(); |
737 CTestSource* source3 = NewTestSourceLC(); |
754 formatParam3.iFlags = TTmFormatParam::EWrap; |
750 formatParam3.iFlags = TTmFormatParam::EWrap; |
755 formatParam3.iWrapWidth = 520; |
751 formatParam3.iWrapWidth = 520; |
756 CTmFormatContext::FormatL(*source3, formatParam3, *code, info3, layout); |
752 CTmFormatContext::FormatL(*source3, formatParam3, *code, info3, layout); |
757 |
753 |
758 // check that format didn't found any breaks |
754 // check that format didn't found any breaks |
759 TESTPOINT( info3.iFirstLineEndChar == 54 ); |
755 test( info3.iFirstLineEndChar == 54 ); |
760 TESTPOINT( info3.iLastLineStartChar == 108 ); |
756 test( info3.iLastLineStartChar == 108 ); |
761 TESTPOINT( info3.iHeight == 36 ); // 3 lines |
757 test( info3.iHeight == 36 ); // 3 lines |
762 |
758 |
763 CleanupStack::PopAndDestroy(source3); |
759 CleanupStack::PopAndDestroy(source3); |
764 CleanupStack::PopAndDestroy(source2); |
760 CleanupStack::PopAndDestroy(source2); |
765 CleanupStack::PopAndDestroy(layout); |
761 CleanupStack::PopAndDestroy(layout); |
766 CleanupStack::PopAndDestroy(source1); |
762 CleanupStack::PopAndDestroy(source1); |
897 RTmParFormat pft; |
893 RTmParFormat pft; |
898 CleanupClosePushL(pft); |
894 CleanupClosePushL(pft); |
899 |
895 |
900 text->GetText(0, testText, cft); |
896 text->GetText(0, testText, cft); |
901 text->GetParagraphFormatL(0, pft); |
897 text->GetParagraphFormatL(0, pft); |
902 TESTPOINT(testText.Length() == 14); |
898 test(testText.Length() == 14); |
903 TESTPOINT(testText.Compare(_L("first line\x2029sec")) == 0); |
899 test(testText.Compare(_L("first line\x2029sec")) == 0); |
904 TESTPOINT(cft == cf1); |
900 test(cft == cf1); |
905 TESTPOINT(pft == pf1); |
901 test(pft == pf1); |
906 |
902 |
907 text->GetText(11, testText, cft); |
903 text->GetText(11, testText, cft); |
908 text->GetParagraphFormatL(11, pft); |
904 text->GetParagraphFormatL(11, pft); |
909 TESTPOINT(testText.Length() == 3); |
905 test(testText.Length() == 3); |
910 TESTPOINT(testText.Compare(_L("sec")) == 0); |
906 test(testText.Compare(_L("sec")) == 0); |
911 TESTPOINT(cft == cf1); |
907 test(cft == cf1); |
912 TESTPOINT(pft == pf2); |
908 test(pft == pf2); |
913 |
909 |
914 text->GetText(14, testText, cft); |
910 text->GetText(14, testText, cft); |
915 text->GetParagraphFormatL(14, pft); |
911 text->GetParagraphFormatL(14, pft); |
916 TESTPOINT(testText.Length() == 3); |
912 test(testText.Length() == 3); |
917 TESTPOINT(testText.Compare(_L("t p")) == 0); |
913 test(testText.Compare(_L("t p")) == 0); |
918 TESTPOINT(cft == cf2); |
914 test(cft == cf2); |
919 TESTPOINT(pft == pf2); |
915 test(pft == pf2); |
920 |
916 |
921 text->GetText(17, testText, cft); |
917 text->GetText(17, testText, cft); |
922 text->GetParagraphFormatL(17, pft); |
918 text->GetParagraphFormatL(17, pft); |
923 TESTPOINT(cft == cf1); |
919 test(cft == cf1); |
924 TESTPOINT(pft == pf2); |
920 test(pft == pf2); |
925 |
921 |
926 text->GetText(21, testText, cft); |
922 text->GetText(21, testText, cft); |
927 text->GetParagraphFormatL(21, pft); |
923 text->GetParagraphFormatL(21, pft); |
928 TESTPOINT(pft == pf2); |
924 test(pft == pf2); |
929 CleanupStack::PopAndDestroy(&pft); |
925 CleanupStack::PopAndDestroy(&pft); |
930 CleanupStack::PopAndDestroy(&pf2); |
926 CleanupStack::PopAndDestroy(&pf2); |
931 CleanupStack::PopAndDestroy(&pf1); |
927 CleanupStack::PopAndDestroy(&pf1); |
932 CleanupStack::PopAndDestroy(text); |
928 CleanupStack::PopAndDestroy(text); |
933 } |
929 } |
934 |
930 |
935 void CTagmaImpTest::GetIndices(TDes8& aBuf, const CTmTextImp::RRunArray& aRunArray) |
931 void CTagmaImpTest::GetIndices(TDes8& aBuf, const CTmTextImp::RRunArray& aRunArray) |
936 { |
932 { |
937 TESTPOINT(aRunArray.Index(0) == aRunArray.Index(1)); |
933 test(aRunArray.Index(0) == aRunArray.Index(1)); |
938 aBuf.Zero(); |
934 aBuf.Zero(); |
939 TInt index; |
935 TInt index; |
940 for (TInt i = 1; 0 <= (index = aRunArray.Index(i)); ++i) |
936 for (TInt i = 1; 0 <= (index = aRunArray.Index(i)); ++i) |
941 { |
937 { |
942 aBuf.Append('0' + index); |
938 aBuf.Append('0' + index); |
977 formatParam1.iMaxLines = KMaxTInt; |
973 formatParam1.iMaxLines = KMaxTInt; |
978 formatParam1.iFlags = TTmFormatParam::EWrap; |
974 formatParam1.iFlags = TTmFormatParam::EWrap; |
979 //Setting the format of the text |
975 //Setting the format of the text |
980 text->ChangeFormatL(formatParam1); |
976 text->ChangeFormatL(formatParam1); |
981 //After changing the format, memory used by the text differs from the initial value |
977 //After changing the format, memory used by the text differs from the initial value |
982 TESTPOINT(text->MemoryUsed()!=memUsed); |
978 test(text->MemoryUsed()!=memUsed); |
983 TRgb color1(100,10,20); |
979 TRgb color1(100,10,20); |
984 TRgb color2; |
980 TRgb color2; |
985 //Setting the system colour with an index representing the system background colour |
981 //Setting the system colour with an index representing the system background colour |
986 color2 = text->SystemColor(TLogicalRgb::ESystemBackgroundIndex,color1); |
982 color2 = text->SystemColor(TLogicalRgb::ESystemBackgroundIndex,color1); |
987 TESTPOINT(color2==color1); |
983 test(color2==color1); |
988 |
984 |
989 _LIT(KBody, "Body"); |
985 _LIT(KBody, "Body"); |
990 _LIT(KLabel, "Label, Longer than Body"); |
986 _LIT(KLabel, "Label, Longer than Body"); |
991 TTestParLabelSource sourceLabel(iDevice, KBody, KLabel); |
987 TTestParLabelSource sourceLabel(iDevice, KBody, KLabel); |
992 CTmTextLayout* iLayout = new (ELeave) CTmTextLayout; |
988 CTmTextLayout* iLayout = new (ELeave) CTmTextLayout; |
994 //Changing the custom formatting |
990 //Changing the custom formatting |
995 text->CustomizeL(iLayout->Source()); |
991 text->CustomizeL(iLayout->Source()); |
996 |
992 |
997 //Setting the system colour with an index representing the system foreground colour |
993 //Setting the system colour with an index representing the system foreground colour |
998 color2 = text->SystemColor(TLogicalRgb::ESystemSelectionForegroundIndex,color1); |
994 color2 = text->SystemColor(TLogicalRgb::ESystemSelectionForegroundIndex,color1); |
999 TESTPOINT(color2!=color1); |
995 test(color2!=color1); |
1000 CleanupStack::PopAndDestroy(&pf1); |
996 CleanupStack::PopAndDestroy(&pf1); |
1001 CleanupStack::PopAndDestroy(text); |
997 CleanupStack::PopAndDestroy(text); |
1002 } |
998 } |
1003 |
999 |
1004 void CTagmaImpTest::CTmTextImp_RRunArrayL() |
1000 void CTagmaImpTest::CTmTextImp_RRunArrayL() |
1005 { |
1001 { |
1006 TBuf8<50> indexBuf; |
1002 TBuf8<50> indexBuf; |
1007 CTmTextImp::RRunArray ra; |
1003 CTmTextImp::RRunArray ra; |
1008 CleanupClosePushL(ra); |
1004 CleanupClosePushL(ra); |
1009 GetIndices(indexBuf, ra); |
1005 GetIndices(indexBuf, ra); |
1010 TESTPOINT(0 == indexBuf.Compare(_L8(""))); |
1006 test(0 == indexBuf.Compare(_L8(""))); |
1011 ra.Insert(0, 10, 0); |
1007 ra.Insert(0, 10, 0); |
1012 GetIndices(indexBuf, ra); |
1008 GetIndices(indexBuf, ra); |
1013 TESTPOINT(0 == indexBuf.Compare(_L8("0000000000"))); |
1009 test(0 == indexBuf.Compare(_L8("0000000000"))); |
1014 ra.Insert(5, 10, 1); |
1010 ra.Insert(5, 10, 1); |
1015 GetIndices(indexBuf, ra); |
1011 GetIndices(indexBuf, ra); |
1016 TESTPOINT(0 == indexBuf.Compare(_L8("00000111111111100000"))); |
1012 test(0 == indexBuf.Compare(_L8("00000111111111100000"))); |
1017 ra.Delete(13, 4); |
1013 ra.Delete(13, 4); |
1018 GetIndices(indexBuf, ra); |
1014 GetIndices(indexBuf, ra); |
1019 TESTPOINT(0 == indexBuf.Compare(_L8("0000011111111000"))); |
1015 test(0 == indexBuf.Compare(_L8("0000011111111000"))); |
1020 ra.Delete(2, 12); |
1016 ra.Delete(2, 12); |
1021 GetIndices(indexBuf, ra); |
1017 GetIndices(indexBuf, ra); |
1022 TESTPOINT(0 == indexBuf.Compare(_L8("0000"))); |
1018 test(0 == indexBuf.Compare(_L8("0000"))); |
1023 ra.Delete(0, 4); |
1019 ra.Delete(0, 4); |
1024 GetIndices(indexBuf, ra); |
1020 GetIndices(indexBuf, ra); |
1025 TESTPOINT(0 == indexBuf.Compare(_L8(""))); |
1021 test(0 == indexBuf.Compare(_L8(""))); |
1026 ra.Insert(0, 20, 0); |
1022 ra.Insert(0, 20, 0); |
1027 ra.Set(5, 10, 1); |
1023 ra.Set(5, 10, 1); |
1028 GetIndices(indexBuf, ra); |
1024 GetIndices(indexBuf, ra); |
1029 TESTPOINT(0 == indexBuf.Compare(_L8("00000111111111100000"))); |
1025 test(0 == indexBuf.Compare(_L8("00000111111111100000"))); |
1030 ra.Set(6, 4, 2); |
1026 ra.Set(6, 4, 2); |
1031 GetIndices(indexBuf, ra); |
1027 GetIndices(indexBuf, ra); |
1032 TESTPOINT(0 == indexBuf.Compare(_L8("00000122221111100000"))); |
1028 test(0 == indexBuf.Compare(_L8("00000122221111100000"))); |
1033 ra.Set(10, 4, 3); |
1029 ra.Set(10, 4, 3); |
1034 GetIndices(indexBuf, ra); |
1030 GetIndices(indexBuf, ra); |
1035 TESTPOINT(0 == indexBuf.Compare(_L8("00000122223333100000"))); |
1031 test(0 == indexBuf.Compare(_L8("00000122223333100000"))); |
1036 ra.Set(9, 2, 1); |
1032 ra.Set(9, 2, 1); |
1037 GetIndices(indexBuf, ra); |
1033 GetIndices(indexBuf, ra); |
1038 TESTPOINT(0 == indexBuf.Compare(_L8("00000122211333100000"))); |
1034 test(0 == indexBuf.Compare(_L8("00000122211333100000"))); |
1039 ra.Set(6, 1, 1); |
1035 ra.Set(6, 1, 1); |
1040 GetIndices(indexBuf, ra); |
1036 GetIndices(indexBuf, ra); |
1041 TESTPOINT(0 == indexBuf.Compare(_L8("00000112211333100000"))); |
1037 test(0 == indexBuf.Compare(_L8("00000112211333100000"))); |
1042 ra.Set(8, 1, 1); |
1038 ra.Set(8, 1, 1); |
1043 GetIndices(indexBuf, ra); |
1039 GetIndices(indexBuf, ra); |
1044 TESTPOINT(0 == indexBuf.Compare(_L8("00000112111333100000"))); |
1040 test(0 == indexBuf.Compare(_L8("00000112111333100000"))); |
1045 ra.Set(7, 1, 1); |
1041 ra.Set(7, 1, 1); |
1046 GetIndices(indexBuf, ra); |
1042 GetIndices(indexBuf, ra); |
1047 TESTPOINT(0 == indexBuf.Compare(_L8("00000111111333100000"))); |
1043 test(0 == indexBuf.Compare(_L8("00000111111333100000"))); |
1048 ra.Set(7, 2, 2); |
1044 ra.Set(7, 2, 2); |
1049 GetIndices(indexBuf, ra); |
1045 GetIndices(indexBuf, ra); |
1050 TESTPOINT(0 == indexBuf.Compare(_L8("00000112211333100000"))); |
1046 test(0 == indexBuf.Compare(_L8("00000112211333100000"))); |
1051 ra.Set(1, 19, 1); |
1047 ra.Set(1, 19, 1); |
1052 GetIndices(indexBuf, ra); |
1048 GetIndices(indexBuf, ra); |
1053 TESTPOINT(0 == indexBuf.Compare(_L8("01111111111111111111"))); |
1049 test(0 == indexBuf.Compare(_L8("01111111111111111111"))); |
1054 CleanupStack::PopAndDestroy(&ra); |
1050 CleanupStack::PopAndDestroy(&ra); |
1055 } |
1051 } |
1056 |
1052 |
1057 |
1053 |
1058 void CTagmaImpTest::CTmTextImp_BidirectionalAlignmentL() |
1054 void CTagmaImpTest::CTmTextImp_BidirectionalAlignmentL() |
1065 { |
1061 { |
1066 CParaFormat* pF = CParaFormat::NewL(); |
1062 CParaFormat* pF = CParaFormat::NewL(); |
1067 CleanupStack::PushL(pF); |
1063 CleanupStack::PushL(pF); |
1068 RTmParFormat rPF; |
1064 RTmParFormat rPF; |
1069 |
1065 |
1070 TESTPOINT(RTmParFormat::EAlignNormalBidirectional == rPF.iAlignment); |
1066 test(RTmParFormat::EAlignNormalBidirectional == rPF.iAlignment); |
1071 |
1067 |
1072 rPF.CopyL(*pF); |
1068 rPF.CopyL(*pF); |
1073 TESTPOINT(RTmParFormat::EAlignNormal == rPF.iAlignment); |
1069 test(RTmParFormat::EAlignNormal == rPF.iAlignment); |
1074 |
1070 |
1075 pF->iHorizontalAlignment = CParaFormat::ELeftAlign; |
1071 pF->iHorizontalAlignment = CParaFormat::ELeftAlign; |
1076 rPF.CopyL(*pF); |
1072 rPF.CopyL(*pF); |
1077 TESTPOINT(RTmParFormat::EAlignNormal == rPF.iAlignment); |
1073 test(RTmParFormat::EAlignNormal == rPF.iAlignment); |
1078 |
1074 |
1079 pF->iHorizontalAlignment = CParaFormat::ECenterAlign; |
1075 pF->iHorizontalAlignment = CParaFormat::ECenterAlign; |
1080 rPF.CopyL(*pF); |
1076 rPF.CopyL(*pF); |
1081 TESTPOINT(RTmParFormat::EAlignCenter == rPF.iAlignment); |
1077 test(RTmParFormat::EAlignCenter == rPF.iAlignment); |
1082 |
1078 |
1083 pF->iHorizontalAlignment = CParaFormat::ERightAlign; |
1079 pF->iHorizontalAlignment = CParaFormat::ERightAlign; |
1084 rPF.CopyL(*pF); |
1080 rPF.CopyL(*pF); |
1085 TESTPOINT(RTmParFormat::EAlignReverse == rPF.iAlignment); |
1081 test(RTmParFormat::EAlignReverse == rPF.iAlignment); |
1086 |
1082 |
1087 pF->iHorizontalAlignment = CParaFormat::EJustifiedAlign; |
1083 pF->iHorizontalAlignment = CParaFormat::EJustifiedAlign; |
1088 rPF.CopyL(*pF); |
1084 rPF.CopyL(*pF); |
1089 TESTPOINT(RTmParFormat::EAlignJustify == rPF.iAlignment); |
1085 test(RTmParFormat::EAlignJustify == rPF.iAlignment); |
1090 |
1086 |
1091 pF->iHorizontalAlignment = CParaFormat::EAbsoluteLeftAlign; |
1087 pF->iHorizontalAlignment = CParaFormat::EAbsoluteLeftAlign; |
1092 rPF.CopyL(*pF); |
1088 rPF.CopyL(*pF); |
1093 TESTPOINT(RTmParFormat::EAlignAbsoluteLeft == rPF.iAlignment); |
1089 test(RTmParFormat::EAlignAbsoluteLeft == rPF.iAlignment); |
1094 |
1090 |
1095 pF->iHorizontalAlignment = CParaFormat::EAbsoluteRightAlign; |
1091 pF->iHorizontalAlignment = CParaFormat::EAbsoluteRightAlign; |
1096 rPF.CopyL(*pF); |
1092 rPF.CopyL(*pF); |
1097 TESTPOINT(RTmParFormat::EAlignAbsoluteRight == rPF.iAlignment); |
1093 test(RTmParFormat::EAlignAbsoluteRight == rPF.iAlignment); |
1098 |
1094 |
1099 rPF.Close(); |
1095 rPF.Close(); |
1100 CleanupStack::PopAndDestroy(); //pF |
1096 CleanupStack::PopAndDestroy(); //pF |
1101 } |
1097 } |
1102 |
1098 |
1104 { |
1100 { |
1105 CParaFormat* pF = CParaFormat::NewL(); |
1101 CParaFormat* pF = CParaFormat::NewL(); |
1106 CleanupStack::PushL(pF); |
1102 CleanupStack::PushL(pF); |
1107 RTmParFormat rPF; |
1103 RTmParFormat rPF; |
1108 |
1104 |
1109 TESTPOINT(pF->iHorizontalAlignment == CParaFormat::ELeftAlign); |
1105 test(pF->iHorizontalAlignment == CParaFormat::ELeftAlign); |
1110 |
1106 |
1111 rPF.iAlignment = RTmParFormat::EAlignNormal; |
1107 rPF.iAlignment = RTmParFormat::EAlignNormal; |
1112 rPF.GetCParaFormatL(*pF); |
1108 rPF.GetCParaFormatL(*pF); |
1113 TESTPOINT(CParaFormat::ELeftAlign == pF->iHorizontalAlignment); |
1109 test(CParaFormat::ELeftAlign == pF->iHorizontalAlignment); |
1114 |
1110 |
1115 rPF.iAlignment = RTmParFormat::EAlignCenter; |
1111 rPF.iAlignment = RTmParFormat::EAlignCenter; |
1116 rPF.GetCParaFormatL(*pF); |
1112 rPF.GetCParaFormatL(*pF); |
1117 TESTPOINT(CParaFormat::ECenterAlign == pF->iHorizontalAlignment); |
1113 test(CParaFormat::ECenterAlign == pF->iHorizontalAlignment); |
1118 |
1114 |
1119 rPF.iAlignment = RTmParFormat::EAlignReverse; |
1115 rPF.iAlignment = RTmParFormat::EAlignReverse; |
1120 rPF.GetCParaFormatL(*pF); |
1116 rPF.GetCParaFormatL(*pF); |
1121 TESTPOINT(CParaFormat::ERightAlign == pF->iHorizontalAlignment); |
1117 test(CParaFormat::ERightAlign == pF->iHorizontalAlignment); |
1122 |
1118 |
1123 rPF.iAlignment = RTmParFormat::EAlignJustify; |
1119 rPF.iAlignment = RTmParFormat::EAlignJustify; |
1124 rPF.GetCParaFormatL(*pF); |
1120 rPF.GetCParaFormatL(*pF); |
1125 TESTPOINT(CParaFormat::EJustifiedAlign == pF->iHorizontalAlignment); |
1121 test(CParaFormat::EJustifiedAlign == pF->iHorizontalAlignment); |
1126 |
1122 |
1127 rPF.iAlignment = RTmParFormat::EAlignAbsoluteLeft; |
1123 rPF.iAlignment = RTmParFormat::EAlignAbsoluteLeft; |
1128 rPF.GetCParaFormatL(*pF); |
1124 rPF.GetCParaFormatL(*pF); |
1129 TESTPOINT(CParaFormat::EAbsoluteLeftAlign == pF->iHorizontalAlignment); |
1125 test(CParaFormat::EAbsoluteLeftAlign == pF->iHorizontalAlignment); |
1130 |
1126 |
1131 rPF.iAlignment = RTmParFormat::EAlignAbsoluteRight; |
1127 rPF.iAlignment = RTmParFormat::EAlignAbsoluteRight; |
1132 rPF.GetCParaFormatL(*pF); |
1128 rPF.GetCParaFormatL(*pF); |
1133 TESTPOINT(CParaFormat::EAbsoluteRightAlign == pF->iHorizontalAlignment); |
1129 test(CParaFormat::EAbsoluteRightAlign == pF->iHorizontalAlignment); |
1134 |
1130 |
1135 rPF.Close(); |
1131 rPF.Close(); |
1136 CleanupStack::PopAndDestroy(); // pF |
1132 CleanupStack::PopAndDestroy(); // pF |
1137 } |
1133 } |
1138 |
1134 |
1250 { // search position is before the first break space |
1244 { // search position is before the first break space |
1251 aNext.iPos = pos + 4; // adjust to position of first space |
1245 aNext.iPos = pos + 4; // adjust to position of first space |
1252 aNext.iLeadingEdge = ETrue; |
1246 aNext.iLeadingEdge = ETrue; |
1253 if (aNext.iPos - aFrom.iPos < aMaxLength + (aNext.iLeadingEdge ? 0 : 1)) |
1247 if (aNext.iPos - aFrom.iPos < aMaxLength + (aNext.iLeadingEdge ? 0 : 1)) |
1254 return KErrNotFound; |
1248 return KErrNotFound; |
1255 TBuf<256> buf; |
1249 test.Printf(_L("GetPos-InlineTextAt-%d %c-From-%d\n"), aNext.iPos, aNext.iLeadingEdge ? 'L' : 'T', aFrom.iPos); |
1256 buf.AppendFormat(_L("GetPos-InlineTextAt-%d %c-From-%d\n"), aNext.iPos, aNext.iLeadingEdge ? 'L' : 'T', aFrom.iPos); |
|
1257 TESTPRINT(buf); |
|
1258 return KErrNone; |
1250 return KErrNone; |
1259 } |
1251 } |
1260 // if it gets here search position is after the first break space |
1252 // if it gets here search position is after the first break space |
1261 if (pos + 7 >= aFrom.iPos) |
1253 if (pos + 7 >= aFrom.iPos) |
1262 { // but before the second |
1254 { // but before the second |
1263 aNext.iPos = pos + 7; // adjust to position of second space |
1255 aNext.iPos = pos + 7; // adjust to position of second space |
1264 aNext.iLeadingEdge = EFalse; |
1256 aNext.iLeadingEdge = EFalse; |
1265 if (aNext.iPos - aFrom.iPos < aMaxLength + (aNext.iLeadingEdge ? 0 : 1)) |
1257 if (aNext.iPos - aFrom.iPos < aMaxLength + (aNext.iLeadingEdge ? 0 : 1)) |
1266 return KErrNotFound; |
1258 return KErrNotFound; |
1267 TBuf<256> buf; |
1259 test.Printf(_L("GetPos-InlineTextAt-%d %c-From-%d\n"), aNext.iPos, aNext.iLeadingEdge ? 'L' : 'T', aFrom.iPos); |
1268 buf.AppendFormat(_L("GetPos-InlineTextAt-%d %c-From-%d\n"), aNext.iPos, aNext.iLeadingEdge ? 'L' : 'T', aFrom.iPos); |
|
1269 TESTPRINT(buf); |
|
1270 return KErrNone; |
1260 return KErrNone; |
1271 } |
1261 } |
1272 } |
1262 } |
1273 return KErrNotFound; |
1263 return KErrNotFound; |
1274 } |
1264 } |
1275 return KErrNotFound; |
1265 return KErrNotFound; |
1276 } |
1266 } |
1277 TPtrC GetInlineText(const TTmDocPos& aAt) |
1267 TPtrC GetInlineText(const TTmDocPos& aAt) |
1278 { |
1268 { |
1279 TBuf<256> buf; |
1269 test.Printf(_L("QueryTextAt-%d %c\n"), aAt.iPos, aAt.iLeadingEdge ? 'L' : 'T'); |
1280 buf.AppendFormat(_L("QueryTextAt-%d %c\n"), aAt.iPos, aAt.iLeadingEdge ? 'L' : 'T'); |
|
1281 TESTPRINT(buf); |
|
1282 if (iCustomFormatType == 0) |
1270 if (iCustomFormatType == 0) |
1283 { |
1271 { |
1284 return iNullText; |
1272 return iNullText; |
1285 } |
1273 } |
1286 else if (iCustomFormatType == 1) |
1274 else if (iCustomFormatType == 1) |
1425 //Test the sample text with ZWJ at the beginning of the string |
1406 //Test the sample text with ZWJ at the beginning of the string |
1426 text->InsertL(0,KLatinZWJ1); |
1407 text->InsertL(0,KLatinZWJ1); |
1427 text->GetDisplayedText(0,buffer,needed); |
1408 text->GetDisplayedText(0,buffer,needed); |
1428 |
1409 |
1429 //Verify that the text is formatted correctly |
1410 //Verify that the text is formatted correctly |
1430 TESTPOINT(buffer == KDisplayedLatinZWJ); |
1411 test(buffer == KDisplayedLatinZWJ); |
1431 |
1412 |
1432 //Verify that the length of the string is as expected |
1413 //Verify that the length of the string is as expected |
1433 textLength = (text->EndChar()) - (text->StartChar()); |
1414 textLength = (text->EndChar()) - (text->StartChar()); |
1434 TESTPOINT(textLength == KExpectedTextLength); |
1415 test(textLength == KExpectedTextLength); |
1435 text->Clear(); |
1416 text->Clear(); |
1436 |
1417 |
1437 //Test the sample text with ZWJ in the middle of the string |
1418 //Test the sample text with ZWJ in the middle of the string |
1438 text->InsertL(0,KLatinZWJ2); |
1419 text->InsertL(0,KLatinZWJ2); |
1439 text->GetDisplayedText(0,buffer,needed); |
1420 text->GetDisplayedText(0,buffer,needed); |
1440 |
1421 |
1441 //Verify that the text is formatted correctly |
1422 //Verify that the text is formatted correctly |
1442 TESTPOINT(buffer == KDisplayedLatinZWJ); |
1423 test(buffer == KDisplayedLatinZWJ); |
1443 |
1424 |
1444 //Verify that the length of the string is as expected |
1425 //Verify that the length of the string is as expected |
1445 textLength = (text->EndChar()) - (text->StartChar()); |
1426 textLength = (text->EndChar()) - (text->StartChar()); |
1446 TESTPOINT(textLength == KExpectedTextLength); |
1427 test(textLength == KExpectedTextLength); |
1447 text->Clear(); |
1428 text->Clear(); |
1448 |
1429 |
1449 //Test the sample text with ZWJ at the end of the string |
1430 //Test the sample text with ZWJ at the end of the string |
1450 text->InsertL(0,KLatinZWJ3); |
1431 text->InsertL(0,KLatinZWJ3); |
1451 text->GetDisplayedText(0,buffer,needed); |
1432 text->GetDisplayedText(0,buffer,needed); |
1452 |
1433 |
1453 //Verify that the text is formatted correctly |
1434 //Verify that the text is formatted correctly |
1454 TESTPOINT(buffer == KDisplayedLatinZWJ); |
1435 test(buffer == KDisplayedLatinZWJ); |
1455 |
1436 |
1456 //Verify that the length of the string is as expected |
1437 //Verify that the length of the string is as expected |
1457 textLength = (text->EndChar()) - (text->StartChar()); |
1438 textLength = (text->EndChar()) - (text->StartChar()); |
1458 TESTPOINT(textLength == KExpectedTextLength); |
1439 test(textLength == KExpectedTextLength); |
1459 text->Clear(); |
1440 text->Clear(); |
1460 |
1441 |
1461 CleanupStack::PopAndDestroy(); // text |
1442 CleanupStack::PopAndDestroy(); // text |
1462 } |
1443 } |
1463 |
1444 |
1542 CleanupStack::PushL(formatContext); |
1523 CleanupStack::PushL(formatContext); |
1543 |
1524 |
1544 chunk.SetL(*formatContext,0,0,10,533,0,chunkInfo); |
1525 chunk.SetL(*formatContext,0,0,10,533,0,chunkInfo); |
1545 TUint context = chunk.iContextCharInByteCode; |
1526 TUint context = chunk.iContextCharInByteCode; |
1546 // Test that the first chunk's context has been recognised as not needing supplied context. |
1527 // Test that the first chunk's context has been recognised as not needing supplied context. |
1547 TESTPOINT(0 == context); |
1528 test(0 == context); |
1548 chunk.SetL(*formatContext,3,0,10,533,0,chunkInfo); |
1529 chunk.SetL(*formatContext,3,0,10,533,0,chunkInfo); |
1549 context = chunk.iContextCharInByteCode; |
1530 context = chunk.iContextCharInByteCode; |
1550 // Test that the next chunk retains the Hindi context. |
1531 // Test that the next chunk retains the Hindi context. |
1551 TESTPOINT(2325 == context); |
1532 test(2325 == context); |
1552 chunk.SetL(*formatContext,4,0,10,533,0,chunkInfo); |
1533 chunk.SetL(*formatContext,4,0,10,533,0,chunkInfo); |
1553 context = chunk.iContextCharInByteCode; |
1534 context = chunk.iContextCharInByteCode; |
1554 // Test that the next chunk retains the Hindi context. |
1535 // Test that the next chunk retains the Hindi context. |
1555 TESTPOINT(2325 == context); |
1536 test(2325 == context); |
1556 chunk.SetL(*formatContext,5,0,10,533,0,chunkInfo); |
1537 chunk.SetL(*formatContext,5,0,10,533,0,chunkInfo); |
1557 context = chunk.iContextCharInByteCode; |
1538 context = chunk.iContextCharInByteCode; |
1558 // Test that the next chunk retains the Hindi context. |
1539 // Test that the next chunk retains the Hindi context. |
1559 TESTPOINT(2325 == context); |
1540 test(2325 == context); |
1560 chunk.SetL(*formatContext,6,0,10,533,0,chunkInfo); |
1541 chunk.SetL(*formatContext,6,0,10,533,0,chunkInfo); |
1561 context = chunk.iContextCharInByteCode; |
1542 context = chunk.iContextCharInByteCode; |
1562 // Test that the next chunk has been recognised as not needing supplied context. |
1543 // Test that the next chunk has been recognised as not needing supplied context. |
1563 TESTPOINT(0 == context); |
1544 test(0 == context); |
1564 chunk.SetL(*formatContext,9,0,10,533,0,chunkInfo); |
1545 chunk.SetL(*formatContext,9,0,10,533,0,chunkInfo); |
1565 context = chunk.iContextCharInByteCode; |
1546 context = chunk.iContextCharInByteCode; |
1566 // Test that the next chunk retains the Latin context. |
1547 // Test that the next chunk retains the Latin context. |
1567 TESTPOINT(99 == context); |
1548 test(99 == context); |
1568 |
1549 |
1569 |
1550 |
1570 CleanupStack::PopAndDestroy(formatContext); // formatContext |
1551 CleanupStack::PopAndDestroy(formatContext); // formatContext |
1571 CleanupStack::PopAndDestroy(layout); // layout |
1552 CleanupStack::PopAndDestroy(layout); // layout |
1572 CleanupStack::PopAndDestroy(code); // code |
1553 CleanupStack::PopAndDestroy(code); // code |
1715 } |
1696 } |
1716 |
1697 |
1717 void CTagmaImpTest::TestL() |
1698 void CTagmaImpTest::TestL() |
1718 { |
1699 { |
1719 // __UHEAP_MARK; |
1700 // __UHEAP_MARK; |
1720 |
1701 |
1721 TESTPRINT(_L("Regression test: DEF073838")); // Line break problem with WORD |
1702 test.Start(_L("Regression test: DEF073838")); // Line break problem with WORD |
1722 DEF_073838_DefectL(); |
1703 DEF_073838_DefectL(); |
1723 |
1704 |
1724 TESTPRINT(_L("Regression test: INC044969")); |
1705 test.Next(_L("Regression test: INC044969")); |
1725 INC_044969_DefectL(); |
1706 INC_044969_DefectL(); |
1726 |
1707 |
1727 TESTPRINT(_L("CTmTextImp::RRunArray tests")); |
1708 test.Next(_L("CTmTextImp::RRunArray tests")); |
1728 CTmTextImp_RRunArrayL(); |
1709 CTmTextImp_RRunArrayL(); |
1729 |
1710 |
1730 TESTPRINT(_L("Regression test: BUR-58FGE8")); |
1711 test.Next(_L("Regression test: BUR-58FGE8")); |
1731 BUR_58FGE8_DefectL(); |
1712 BUR_58FGE8_DefectL(); |
1732 |
1713 |
1733 TESTPRINT(_L("Regression test: WEP-55BHBF")); |
1714 test.Next(_L("Regression test: WEP-55BHBF")); |
1734 WEP_55BHBF_DefectL(); |
1715 WEP_55BHBF_DefectL(); |
1735 |
1716 |
1736 TESTPRINT(_L("Regression test: EXT-5ATF8D")); |
1717 test.Next(_L("Regression test: EXT-5ATF8D")); |
1737 EXT_5ATF8D_DefectL(); |
1718 EXT_5ATF8D_DefectL(); |
1738 |
1719 |
1739 TESTPRINT(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-1886 Test for CTmTextImp API's ")); |
1720 test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-1886 Test for CTmTextImp API's ")); |
1740 TestAPIL(); |
1721 TestAPIL(); |
1741 |
1722 |
1742 TESTPRINT(_L("CTmCode tests")); |
1723 test.Next(_L("CTmCode tests")); |
1743 CTmCodeOOML(); |
1724 CTmCodeOOML(); |
1744 |
1725 |
1745 TESTPRINT(_L("CTmFormatContext::FormatL tests")); |
1726 test.Next(_L("CTmFormatContext::FormatL tests")); |
1746 FormatOOML(); |
1727 FormatOOML(); |
1747 |
1728 |
1748 TESTPRINT(_L("RTmTextCache::Width tests")); |
1729 test.Next(_L("RTmTextCache::Width tests")); |
1749 RTmTextCacheWidthOOM(); |
1730 RTmTextCacheWidthOOM(); |
1750 |
1731 |
1751 TESTPRINT(_L("RTmGeneralInterpreter::GetDisplayedText tests")); |
1732 test.Next(_L("RTmGeneralInterpreter::GetDisplayedText tests")); |
1752 RTmGeneralInterpreterGetDisplayedTextOOM(); |
1733 RTmGeneralInterpreterGetDisplayedTextOOM(); |
1753 |
1734 |
1754 TESTPRINT(_L("Bidirectional alignment tests")); |
1735 test.Next(_L("Bidirectional alignment tests")); |
1755 CTmTextImp_BidirectionalAlignmentL(); |
1736 CTmTextImp_BidirectionalAlignmentL(); |
1756 |
1737 |
1757 TESTPRINT(_L("Custom formatting tests")); |
1738 test.Next(_L("Custom formatting tests")); |
1758 CustomFormattingL(); |
1739 CustomFormattingL(); |
1759 |
1740 |
1760 TESTPRINT(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-3353 Regression test: PDEF101464 ")); |
1741 test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-3353 Regression test: PDEF101464 ")); |
1761 PDEF_101464_DefectL(); |
1742 PDEF_101464_DefectL(); |
1762 |
1743 |
1763 TESTPRINT(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-3398 Regression test: DEF101994 ")); |
1744 test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-3398 Regression test: DEF101994 ")); |
1764 DEF101994_DefectL(); |
1745 DEF101994_DefectL(); |
1765 |
1746 |
1766 TESTPRINT(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-4010 Drawing Text within context: Testing chunk context.")); |
1747 test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-4010 Drawing Text within context: Testing chunk context.")); |
1767 TestChunkContext(); |
1748 TestChunkContext(); |
1768 |
1749 |
1769 TESTPRINT(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-4011 Drawing Text within context: Testing line context within bytecode.")); |
1750 test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-4011 Drawing Text within context: Testing line context within bytecode.")); |
1770 TestBytecodeLineContext(); |
1751 TestBytecodeLineContext(); |
1771 |
1752 |
1772 TESTPRINT(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-4012 Drawing Text within context: Testing chunk context within bytecode.")); |
1753 test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-4012 Drawing Text within context: Testing chunk context within bytecode.")); |
1773 TestBytecodeChunkContext(); |
1754 TestBytecodeChunkContext(); |
|
1755 |
|
1756 test.End(); |
1774 |
1757 |
1775 // __UHEAP_MARKEND; |
1758 // __UHEAP_MARKEND; |
1776 } |
1759 } |
1777 |
1760 |
1778 CTTagmaImpStep::CTTagmaImpStep() |
1761 |
1779 { |
1762 void RunTestsL() |
1780 |
1763 { |
1781 } |
1764 CTagmaImpTest* t = new(ELeave) CTagmaImpTest(); |
1782 |
1765 CleanupStack::PushL(t); |
1783 TVerdict CTTagmaImpStep::doTestStepL() |
1766 t->ConstructL(); |
1784 { |
1767 t->TestL(); |
1785 SetTestStepResult(EPass); |
1768 CleanupStack::PopAndDestroy(t); |
1786 TestStep = this; |
1769 } |
1787 |
1770 |
1788 TESTPRINT(_L("Tagma internals tests")); |
1771 TInt E32Main() |
1789 CTagmaImpTest* t = new(ELeave) CTagmaImpTest(this); |
1772 { |
1790 CleanupStack::PushL(t); |
1773 CTrapCleanup* theCleanup =CTrapCleanup::New(); |
1791 t->ConstructL(); |
1774 test.Title(); |
1792 t->TestL(); |
1775 TRAPD(err, RunTestsL()); |
1793 CleanupStack::PopAndDestroy(t); |
1776 test.Close(); |
1794 |
1777 delete theCleanup; |
1795 return TestStepResult(); |
1778 return err; |
1796 } |
1779 } |
1797 |
|
1798 |
|