--- a/textrendering/texthandling/ttext/T_CPLAIN.CPP Tue Aug 31 17:01:26 2010 +0300
+++ b/textrendering/texthandling/ttext/T_CPLAIN.CPP Wed Sep 01 12:39:40 2010 +0100
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
@@ -16,25 +16,10 @@
*/
+#include <e32test.h>
#include <txtetext.h>
-#include "T_CPLAIN.h"
-LOCAL_D CTestStep *pTestStep = NULL;
-#define test(cond) \
- { \
- TBool __bb = (cond); \
- pTestStep->TEST(__bb); \
- if (!__bb) \
- { \
- pTestStep->ERR_PRINTF1(_L("ERROR: Test Failed")); \
- User::Leave(1); \
- } \
- }
-#undef INFO_PRINTF1
-#undef INFO_PRINTF2
-// copy from tefexportconst.h
-#define INFO_PRINTF1(p1) pTestStep->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1))
-#define INFO_PRINTF2(p1, p2) pTestStep->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2))
+LOCAL_D RTest test(_L("CPlainText Document"));
const TBool KPictureIsDelimiter=EFalse;
const TBool KPunctuationIsDelimiter=ETrue;
@@ -307,13 +292,13 @@
test(iByteStore!=NULL);
CheckDocLength(0);
- INFO_PRINTF1(_L("NewL()"));
+ test.Start(_L("NewL()"));
CPlainText* document=CPlainText::NewL(D);
document->InsertL(0,iDefaultDoc);
test(document->DocumentLength()==95);
delete document;
#ifdef _DEBUG
- INFO_PRINTF1(_L("NewL() failing on OOM"));
+ test.Next(_L("NewL() failing on OOM"));
TInt flag=0;
__UHEAP_FAILNEXT(1);
TRAPD(ret, (void)CPlainText::NewL(D));
@@ -321,11 +306,10 @@
{
flag++;
}
- // seems __UHEAP_FAILNEXT does not work well in platsim.
- // below test does not pass in platsim.
-// test(flag!=0);
+ test(flag!=0);
#endif
+ test.End();
__UHEAP_MARKEND;
}
@@ -341,12 +325,12 @@
CPlainText* document=CPlainText::NewL(D);
document->InsertL(0,iDefaultDoc);
- INFO_PRINTF1(_L("sense from start"));
+ test.Start(_L("sense from start"));
/*TPtrC dummy=*/document->Read(0);
CheckDocLength(document,95);
CheckContent(document,iComp1);
- INFO_PRINTF1(_L("sense from n"));
+ test.Next(_L("sense from n"));
TPtrC dummy2=document->Read(45);
//iDummy.Set(document->Read(45).Ptr(),document->Read(45).Length());
CPlainText* doc2=CPlainText::NewL(D);
@@ -361,7 +345,7 @@
CheckContent(doc2,iComp2);
delete doc2;
- INFO_PRINTF1(_L("sense from last-1"));
+ test.Next(_L("sense from last-1"));
iDummy.Set(document->Read(93).Ptr(),document->Read(93).Length());
CPlainText* doc3=CPlainText::NewL(D);
doc3->InsertL(0,iDummy);
@@ -370,7 +354,7 @@
CheckContent(doc3,iComp3);
delete doc3;
- INFO_PRINTF1(_L("sense from last"));
+ test.Next(_L("sense from last"));
iDummy.Set(document->Read(94).Ptr(),document->Read(94).Length());
CPlainText* doc4=CPlainText::NewL(D);
doc4->InsertL(0,iDummy);
@@ -379,7 +363,7 @@
CheckContent(doc4,iComp4);
delete doc4;
- INFO_PRINTF1(_L("sense from last+1"));
+ test.Next(_L("sense from last+1"));
iDummy.Set(document->Read(95).Ptr(),document->Read(95).Length());
CPlainText* doc5=CPlainText::NewL(D);
doc5->InsertL(0,iDummy);
@@ -389,6 +373,7 @@
delete doc5;
delete document;
+ test.End();
__UHEAP_MARKEND;
}
@@ -410,7 +395,7 @@
CheckDocLength(document,10);
CheckContent(document,iOutBufComp);
- INFO_PRINTF1(_L("Inverting at start"));
+ test.Start(_L("Inverting at start"));
document->InsertL(0,iInBuf2);
document->InsertL(0,character);
document->DeleteL(0,1);
@@ -420,7 +405,7 @@
CheckDocLength(document,10);
CheckContent(document,iOutBufComp);
- INFO_PRINTF1(_L("Inverting in middle"));
+ test.Next(_L("Inverting in middle"));
document->InsertL(4,iInBuf2);
document->InsertL(5,character);
document->DeleteL(5,1);
@@ -430,7 +415,7 @@
CheckDocLength(document,10);
CheckContent(document,iOutBufComp);
- INFO_PRINTF1(_L("Inverting at end"));
+ test.Next(_L("Inverting at end"));
document->InsertL(10,iInBuf2);
document->InsertL(11,character);
document->DeleteL(11,1);
@@ -443,7 +428,7 @@
document->DeleteL(0,10);
CheckDocLength(0);
delete document;
-
+ test.End();
__UHEAP_MARKEND;
}
@@ -474,16 +459,17 @@
TPtrC body(content);
document->InsertL(0,body);
// Now do the tests.
- INFO_PRINTF1(_L("Paragraph 1"));
+ test.Start(_L("Paragraph 1"));
DoParagraphStart(0,55,document); // Paragraph 1
- INFO_PRINTF1(_L("Paragraph 2"));
+ test.Next(_L("Paragraph 2"));
DoParagraphStart(55,23,document); // Paragraph 2
- INFO_PRINTF1(_L("Paragraph 3"));
+ test.Next(_L("Paragraph 3"));
DoParagraphStart(78,20,document); // Paragraph 3
- INFO_PRINTF1(_L("Paragraph 4->2 consecutive delimiters, posshould not change"));
+ test.Next(_L("Paragraph 4->2 consecutive delimiters, posshould not change"));
DoParagraphStart(99,1,document); // Paragraph 6
delete document;
+ test.End();
}
@@ -497,17 +483,17 @@
CPlainText* doc=CPlainText::NewL(D);
doc->InsertL(0,iDefaultDoc);
- INFO_PRINTF1(_L("Extract(buf)"));
+ test.Start(_L("Extract(buf)"));
TBuf<128> buf;
doc->Extract(buf);
CheckContent(iDefaultDoc,buf);
- INFO_PRINTF1(_L("Extract(buf,pos)"));
+ test.Next(_L("Extract(buf,pos)"));
TInt pos=45;
doc->Extract(buf,pos);
CheckContent(iComp2,buf);
- INFO_PRINTF1(_L("Extract(buf) from multiple segments"));
+ test.Next(_L("Extract(buf) from multiple segments"));
TBuf<256> bigBuf(_L("abcdefghijklmnopqrstuvwxyzABCEDFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCEDFGHIJKLMNOPQRSTUVWXYZ"));
CPlainText* segDoc=CPlainText::NewL(ESegmentedStorage);
segDoc->InsertL(0,bigBuf);
@@ -515,6 +501,7 @@
CheckContent(bigBuf,buf);
delete segDoc;
+ test.End();
delete doc;
__UHEAP_MARKEND;
}
@@ -532,7 +519,7 @@
CPlainText* doc=CPlainText::NewL(D);
doc->InsertL(0,content);
- INFO_PRINTF1(_L("WordInfo()"));
+ test.Start(_L("WordInfo()"));
TInt currentPos,startPos,length;
currentPos=0;
doc->GetWordInfo(currentPos,startPos,length,KPictureIsDelimiter,KPunctuationIsDelimiter);
@@ -592,6 +579,7 @@
doc->GetWordInfo(currentPos,startPos,length,KPictureIsDelimiter,KPunctuationIsDelimiter);
test(startPos=32); test(length==7);
+ test.End();
delete doc;
__UHEAP_MARKEND;
}
@@ -768,7 +756,7 @@
//
{
__UHEAP_MARK;
- INFO_PRINTF1(_L("1st Reset"));
+ test.Start(_L("1st Reset"));
CPlainText* doc=CPlainText::NewL(D);
doc->InsertL(0,iDefaultDoc);
test(doc->DocumentLength()==95);
@@ -780,10 +768,11 @@
// It arises because I have added an assert length>0 in the delete method.
// Clearly on a second reset the length is zero, hence the failure.
// Defect fixed 13.10.95 by DuncanS and included in the tests below.
- INFO_PRINTF1(_L("2nd Reset - defect - DavidW 13.10.95"));
+ test.Next(_L("2nd Reset - defect - DavidW 13.10.95"));
doc->Reset();
delete doc;
+ test.End();
__UHEAP_MARKEND;
}
@@ -817,7 +806,7 @@
TBufC<20> InitialInlineText =_L("INLINE_TEXT"); // inline text to be inserted
TBuf<50> outputBuf;
- INFO_PRINTF1(_L("Return all the text"));
+ test.Start(_L("Return all the text"));
CPlainText* doc=CPlainText::NewL(D);
doc->DocumentLength();
doc->InsertL(0,iInsertBuf); // insert "abcdefghijklmnopqrstuvwxyz"
@@ -830,7 +819,7 @@
doc->Extract(outputBuf, startingPositionZero, textLengthFifty); // Returns all the text
test (iTestBuf1 == outputBuf); // testing outputBuf, making sure it contains the inline text - "abcdefINLINE_TEXTghijklmnopqrstuvwxyz"
- INFO_PRINTF1(_L("Extract and discard only the inline text, from Pos0 returning the rest"));
+ test.Next(_L("Extract and discard only the inline text, from Pos0 returning the rest"));
doc->ExtractSelectively(outputBuf, startingPositionZero, textLengthFifty, EExcludeInlineEditedText); // Returns only non-inline text
test (iInsertBuf == outputBuf); // testing outputBuf, making sure the inline text has been extracted correctly - "abcdefghijklmnopqrstuvwxyz"
delete doc;
@@ -840,17 +829,17 @@
doc2->DocumentLength();
doc2->InsertL(0,iInsertBuf); // insert "abcdefghijklmnopqrstuvwxyz"
- INFO_PRINTF1(_L("Extract upto 50 character, from Pos10, within the range (no inline editting set)"));
+ test.Next(_L("Extract upto 50 character, from Pos10, within the range (no inline editting set)"));
// Returns upto 50 characters starting from Pos10
doc2->ExtractSelectively(outputBuf, startingPositionTen, textLengthFifty, EExcludeInlineEditedText);
test (iTestBuf2 == outputBuf); // "klmnopqrstuvwxyz"
- INFO_PRINTF1(_L("Extract upto 10 characters, from Pos10, within the range (no inline editting set)"));
+ test.Next(_L("Extract upto 10 characters, from Pos10, within the range (no inline editting set)"));
// Returns upto 10 characters starting from Pos10
doc2->ExtractSelectively(outputBuf, startingPositionTen, textLengthTen, EExcludeInlineEditedText);
test (iTestBuf2a == outputBuf); // "klmnopqrst"
- INFO_PRINTF1(_L("Extract upto 50 character, from Pos0, 'EExtractAll' flag selected"));
+ test.Next(_L("Extract upto 50 character, from Pos0, 'EExtractAll' flag selected"));
// Returns upto 50 characters starting from Pos0.
doc2->ExtractSelectively(outputBuf, startingPositionZero, textLengthFifty, EExtractAll);
test (iInsertBuf == outputBuf); // "abcdefghijklmnopqrstuvwxyz"
@@ -865,11 +854,13 @@
doc3->StartFepInlineEditL(HasChangedFormat,NumberDeleted,NumberInserted,PositionOfInsertion,NewPositionOfInsertion,InitialInlineText,PosOfInlineText,NumberToHide,*InlineTextFormatRetriever);
- INFO_PRINTF1(_L("Extract all the non-inline text, from Pos10, within the range (inline editting on)"));
+ test.Next(_L("Extract all the non-inline text, from Pos10, within the range (inline editting on)"));
doc3->ExtractSelectively(outputBuf, startingPositionTen, textLengthTen, EExcludeInlineEditedText); // Returns only non-inline text.
test (iTestBuf3 == outputBuf); // testing outputBuf, making sure the inline text has been extracted correctly - "efghi".
delete doc3;
-
+
+ test.End();
+
__UHEAP_MARKEND;
}
@@ -880,31 +871,32 @@
// Controls testing of the segmented storage case.
//
{
- INFO_PRINTF1(_L("All methods"));
+ test.Start(_L("All methods"));
CPlainTest0L();
- INFO_PRINTF1(_L("Construction"));
+ test.Next(_L("Construction"));
CPlainTest1L();
- INFO_PRINTF1(_L("Read"));
- INFO_PRINTF1(_L("Not yet implemented"));
-
- INFO_PRINTF1(_L("Inverse Testing using InsertL&Delete: content left intact"));
+ test.Next(_L("Read"));
+ test.Start(_L("Not yet implemented"));
+ test.End();
+ test.Next(_L("Inverse Testing using InsertL&Delete: content left intact"));
CPlainTest3L();
- INFO_PRINTF1(_L("Paragraph Start"));
+ test.Next(_L("Paragraph Start"));
CPlainTest4L();
- INFO_PRINTF1(_L("Extract"));
+ test.Next(_L("Extract"));
CPlainTest5L();
- INFO_PRINTF1(_L("WordInfo"));
+ test.Next(_L("WordInfo"));
CPlainTest5aL();
- INFO_PRINTF1(_L("CharPosOfParagraph"));
+ test.Next(_L("CharPosOfParagraph"));
CPlainTest5bL();
- INFO_PRINTF1(_L("ParagraphNumberForPos"));
+ test.Next(_L("ParagraphNumberForPos"));
CPlainTest5cL();
- INFO_PRINTF1(_L("CountWords"));
+ test.Next(_L("CountWords"));
CPlainTest6L();
- INFO_PRINTF1(_L("CountParas"));
+ test.Next(_L("CountParas"));
CPlainTest7L();
- INFO_PRINTF1(_L("Reset"));
+ test.Next(_L("Reset"));
CPlainTest8L();
+ test.End();
}
@@ -915,30 +907,31 @@
// Test the CPlainText methods
//
{
- INFO_PRINTF1(_L("All methods"));
+ test.Start(_L("All methods"));
CPlainTest0L();
- INFO_PRINTF1(_L("Construction"));
+ test.Next(_L("Construction"));
CPlainTest1L();
- INFO_PRINTF1(_L("Read"));
+ test.Next(_L("Read"));
CPlainTest2L();
- INFO_PRINTF1(_L("Inverse Testing using InsertL&Delete: content left intact"));
+ test.Next(_L("Inverse Testing using InsertL&Delete: content left intact"));
CPlainTest3L();
- INFO_PRINTF1(_L("Paragraph Start"));
+ test.Next(_L("Paragraph Start"));
CPlainTest4L();
- INFO_PRINTF1(_L("Extract"));
+ test.Next(_L("Extract"));
CPlainTest5L();
- INFO_PRINTF1(_L("WordInfo"));
+ test.Next(_L("WordInfo"));
CPlainTest5aL();
- INFO_PRINTF1(_L("CharPosOfParagraph"));
+ test.Next(_L("CharPosOfParagraph"));
CPlainTest5bL();
- INFO_PRINTF1(_L("ParagraphNumberForPos"));
+ test.Next(_L("ParagraphNumberForPos"));
CPlainTest5cL();
- INFO_PRINTF1(_L("CountWords"));
+ test.Next(_L("CountWords"));
CPlainTest6L();
- INFO_PRINTF1(_L("CountParas"));
+ test.Next(_L("CountParas"));
CPlainTest7L();
- INFO_PRINTF1(_L("Reset"));
+ test.Next(_L("Reset"));
CPlainTest8L();
+ test.End();
}
@@ -949,56 +942,63 @@
// Defect Fixes
//
{
- INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-ETEXT-UT-1574 INC070807 "));
+ test.Start(_L(" @SYMTestCaseID:SYSLIB-ETEXT-UT-1574 INC070807 "));
INC070807L();
+ test.End();
}
-CT_CPLAIN::CT_CPLAIN()
- {
- SetTestStepName(KTestStep_T_CPLAIN);
- pTestStep = this;
- }
-TVerdict CT_CPLAIN::doTestStepL()
- {
- SetTestStepResult(EFail);
- CTrapCleanup* cleanup=CTrapCleanup::New();
-
- __UHEAP_MARK;
-
- typedef TestCPlainText<TText,TPtrC,CEditableText::EFlatStorage> instance1;
- typedef TestCPlainText<TText,TPtrC,CEditableText::ESegmentedStorage> instance2;
- typedef TestCPlainText<TText,TPtrC,CEditableText::EFlatStorage> instance3;
+GLDEF_C TInt E32Main()
+//
+// Test the Document Model Services.
+//
+ {
+ CTrapCleanup* cleanup=CTrapCleanup::New();
+
+ __UHEAP_MARK;
+
+ typedef TestCPlainText<TText,TPtrC,CEditableText::EFlatStorage> instance1;
+ typedef TestCPlainText<TText,TPtrC,CEditableText::ESegmentedStorage> instance2;
+ typedef TestCPlainText<TText,TPtrC,CEditableText::EFlatStorage> instance3;
- instance1* doctest=NULL;
+ instance1* doctest=NULL;
+
+ TRAPD(ret, doctest=instance1::NewL());
+ test(ret == KErrNone);
- TRAPD(ret1, doctest=instance1::NewL());
+ test.Start(_L("CPlainText - Flat"));
+
+ TRAP(ret,doctest->TestL());
+ test(ret == KErrNone);
+ delete doctest;
- INFO_PRINTF1(_L("CPlainText - Flat"));
- TRAPD(ret2, doctest->TestL());
- delete doctest;
+ test.Next(_L("CPlainText - Segmented"));
+ instance2* doctest1=NULL;
- INFO_PRINTF1(_L("CPlainText - Segmented"));
- instance2* doctest1=NULL;
- TRAPD(ret3, doctest1=instance2::NewL());
- TRAPD(ret4, doctest1->TestSegmentedL());
- delete doctest1;
+ TRAP(ret, doctest1=instance2::NewL());
+ test(ret == KErrNone);
+
+ TRAP(ret, doctest1->TestSegmentedL());
+ test(ret == KErrNone);
+ delete doctest1;
- INFO_PRINTF1(_L("Defect..."));
- instance3* doctest2=NULL;
- TRAPD(ret5, doctest2=instance3::NewL());
- TRAPD(ret6, doctest2->DefectsL());
- delete doctest2;
-
- __UHEAP_MARKEND;
+ test.Next(_L("Defect..."));
+ instance3* doctest2=NULL;
+
+ TRAP(ret, doctest2=instance3::NewL());
+ test(ret == KErrNone);
- delete cleanup;
+ TRAP(ret, doctest2->DefectsL());
+ test(ret == KErrNone);
+ delete doctest2;
- if (ret1 == KErrNone && ret2 == KErrNone && ret3 == KErrNone && ret4 == KErrNone && ret5 == KErrNone && ret6 == KErrNone)
- {
- SetTestStepResult(EPass);
- }
+ test.End();
+ test.Close();
+
+ __UHEAP_MARKEND;
+
+ delete cleanup;
- return TestStepResult();
+ return(0);
}