--- a/textrendering/texthandling/ttext/TRICHOOM.CPP Wed Jun 09 11:40:52 2010 +0300
+++ b/textrendering/texthandling/ttext/TRICHOOM.CPP Tue Aug 31 17:01:26 2010 +0300
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 1997-2010 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"
@@ -19,7 +19,6 @@
#include <txtrich.h>
#include "TSTCLIPB.H"
#include <txtstyle.h>
-#include <e32test.h>
#include <gdi.h>
#include <conpics.h>
#include <flddef.h>
@@ -27,9 +26,21 @@
#include <s32mem.h>
#include <s32file.h>
#include "../incp/T_PMLPAR.H"
+#include "T_RICHOOM.h"
+
+#define test(cond) \
+ { \
+ TBool __bb = (cond); \
+ TEST(__bb); \
+ if (!__bb) \
+ { \
+ ERR_PRINTF1(_L("ERROR: Test Failed")); \
+ User::Leave(1); \
+ } \
+ }
const TInt KTestCleanupStack=0x500;
-GLDEF_C RTest test(_L("TRICHOOM"));
+
LOCAL_D RFs theFs;
LOCAL_D CParaFormatLayer* GlobalParaFormatLayer;
LOCAL_D CCharFormatLayer* GlobalCharFormatLayer;
@@ -39,7 +50,7 @@
LOCAL_D RFs TheSession;
-LOCAL_C CRichText* LoadIntoTextL(TFileName& aFileName)
+CRichText* CT_RICHOOM::LoadIntoTextL(TFileName& aFileName)
//
{
TRAPD(ret,
@@ -57,12 +68,12 @@
}
-LOCAL_D void ConstructOOM()
+void CT_RICHOOM::ConstructOOM()
// Test CRichText construction, (and index), forcing a leave error at each
// possible stage of the process.
//
{
- test.Start(_L("Construction under low memory conditions"));
+ INFO_PRINTF1(_L("Construction under low memory conditions"));
CParaFormatLayer* paraLayer=CParaFormatLayer::NewL();
CCharFormatLayer* charLayer=CCharFormatLayer::NewL();
@@ -93,14 +104,14 @@
delete charLayer;
TBuf<36> answer;
answer.Format(_L(" #allocs for full c'tion: %d\n"),failRate-1);
- test.Printf(answer);
+ INFO_PRINTF1(answer);
}
-LOCAL_D void CopyPasteOOM()
+void CT_RICHOOM::CopyPasteOOM()
{
// Set up the framework
- test.Next(_L("Copy/Paste OOM"));
+ INFO_PRINTF1(_L("Copy/Paste OOM"));
CRichText* richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer);
TFileName file=_L("z:\\test\\app-framework\\etext\\climb.txt");
/*TInt count=*/richText1->ImportTextFileL(0,file,CPlainText::EOrganiseByParagraph);
@@ -129,7 +140,7 @@
richText1->ApplyCharFormatL(charFormat,charMask,10,37);
//
// Copy to clipboard normally.
- test.Start(_L("Copy Normally"));
+ INFO_PRINTF1(_L("Copy Normally"));
User::LeaveIfError(TheSession.Connect());
CClipboard* writeBoard=CClipboard::NewForWritingLC(TheSession);
richText1->CopyToStoreL(writeBoard->Store(),writeBoard->StreamDictionary(),0,richText1->DocumentLength()-1); // forces virtual trailing phrase
@@ -140,7 +151,7 @@
richText1=NULL;
//
// Paste from clipboard normally.
- test.Next(_L("Paste Normally"));
+ INFO_PRINTF1(_L("Paste Normally"));
__UHEAP_MARK;
CRichText* empty=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer);
MDemPictureFactory pictureFactory;
@@ -156,8 +167,8 @@
__UHEAP_MARKEND;
//
// Paste from clipboard with OOM
- test.Next(_L("Paste with OOM"));
- test.Next(_L("...please wait"));
+ INFO_PRINTF1(_L("Paste with OOM"));
+ INFO_PRINTF1(_L("...please wait"));
__UHEAP_MARK;
empty=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer);
for (TInt ii=1; ;ii++)
@@ -178,17 +189,16 @@
empty=NULL;
TheSession.Close();
__UHEAP_MARKEND;
- test.End();
}
-LOCAL_D void CopyPasteOOM2()
+void CT_RICHOOM::CopyPasteOOM2()
// Test case for defect HA-282 - simple case
//
{
__UHEAP_MARK;
// Set up the framework
- test.Next(_L("Copy/Paste OOM 2"));
+ INFO_PRINTF1(_L("Copy/Paste OOM 2"));
CRichText* richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer);
richText1->InsertL(0,_L("HelloHello"));
richText1->InsertL(5,CEditableText::EParagraphDelimiter);
@@ -200,7 +210,7 @@
richText1->ApplyCharFormatL(charFormat,charMask,0,6);
//
// Copy to clipboard normally.
- test.Start(_L("Copy Normally"));
+ INFO_PRINTF1(_L("Copy Normally"));
User::LeaveIfError(TheSession.Connect());
CClipboard* writeBoard=CClipboard::NewForWritingLC(TheSession);
richText1->CopyToStoreL(writeBoard->Store(),writeBoard->StreamDictionary(),2,6); // forces virtual trailing phrase
@@ -209,7 +219,7 @@
writeBoard=NULL;
//
// Paste from clipboard normally.
- test.Next(_L("Paste Normally"));
+ INFO_PRINTF1(_L("Paste Normally"));
// __UHEAP_MARK;
CRichText* empty=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer);
empty->AppendTakingSolePictureOwnershipL(*richText1);
@@ -224,8 +234,8 @@
// __UHEAP_MARKEND;
//
// Paste from clipboard with OOM
- test.Next(_L("Paste with OOM"));
- test.Next(_L("...please wait"));
+ INFO_PRINTF1(_L("Paste with OOM"));
+ INFO_PRINTF1(_L("...please wait"));
__UHEAP_MARK;
empty=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer);
empty->AppendTakingSolePictureOwnershipL(*richText1);
@@ -249,18 +259,17 @@
__UHEAP_MARKEND;
TheSession.Close();
__UHEAP_MARKEND;
- test.End();
}
-LOCAL_D void WriteInlineL(RWriteStream& aStream,CRichText* aRichText)
+void CT_RICHOOM::WriteInlineL(RWriteStream& aStream,CRichText* aRichText)
{
aRichText->ExternalizeStyleDataL(aStream);
aRichText->ExternalizeMarkupDataL(aStream);
aRichText->ExternalizePlainTextL(aStream);
}
-LOCAL_D void ReadInlineL(RReadStream& aStream,CRichText* aRichText)
+void CT_RICHOOM::ReadInlineL(RReadStream& aStream,CRichText* aRichText)
{
aRichText->InternalizeStyleDataL(aStream);
aRichText->InternalizeMarkupDataL(aStream);
@@ -268,7 +277,7 @@
}
-LOCAL_C CStyleList* CreatePopulatedStyleList()
+CStyleList* CT_RICHOOM::CreatePopulatedStyleList()
//
{
//
@@ -287,7 +296,7 @@
}
_LIT(KTRichOutputFile,"c:\\etext\\TRICH.DAT");
-LOCAL_C void SaveLoadOOM()
+void CT_RICHOOM::SaveLoadOOM()
{
// Set up the framework
theFs.Delete(KTRichOutputFile);
@@ -305,8 +314,8 @@
RStoreWriteStream out;
TStreamId id1 = out.CreateLC(*store);
- test.Next(_L("Store/Restore OOM"));
- test.Start(_L("Writing Inline noramlly"));
+ INFO_PRINTF1(_L("Store/Restore OOM"));
+ INFO_PRINTF1(_L("Writing Inline noramlly"));
// Write out inline normally
WriteInlineL(out,richText1);
delete richText1;
@@ -317,7 +326,7 @@
in.OpenLC(*store,id1);
CRichText* empty = CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer);
- test.Next(_L("Reading Inline noramlly"));
+ INFO_PRINTF1(_L("Reading Inline noramlly"));
// Read in inline normally:
TRAPD(ret,ReadInlineL(in,empty));
test(ret==KErrNone);
@@ -325,7 +334,7 @@
delete empty;
empty=NULL;
- test.Next(_L("Reading Inline with OOM"));
+ INFO_PRINTF1(_L("Reading Inline with OOM"));
// Read in inline with OOM:
empty=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer);
@@ -346,7 +355,7 @@
}
}
- test.Next(_L("Writing Inline with OOM"));
+ INFO_PRINTF1(_L("Writing Inline with OOM"));
// Write out inline with OOM:
CStyleList* list2=CreatePopulatedStyleList();
CRichText* richText2 = CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer,*list2);
@@ -371,7 +380,7 @@
}
store->CommitL();
- test.Next(_L("Reading Inline after OOM write"));
+ INFO_PRINTF1(_L("Reading Inline after OOM write"));
// Read in inline normally following a write out with OOM
RStoreReadStream in3;
in3.OpenLC(*store,i);
@@ -404,20 +413,20 @@
richText3->InsertL(0,hdr1);
richText3->InsertL(2,_L("hello"));
- test.Next(_L("Writing Outline noramlly"));
+ INFO_PRINTF1(_L("Writing Outline noramlly"));
// Write outline normally:
TStreamId id2 = richText3->StoreL(*store);
store->CommitL();
delete richText3;
- test.Next(_L("Reading Outline noramlly"));
+ INFO_PRINTF1(_L("Reading Outline noramlly"));
// Read outline normally:
empty->Reset();
TRAP(ret,empty->RestoreL(*store,id2));
test(ret==KErrNone);
empty->Reset();
- test.Next(_L("Reading Outline with OOM"));
+ INFO_PRINTF1(_L("Reading Outline with OOM"));
// Read outline with OOM:
CRichText* inText2=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer);
for (TInt kk = 1; ;++kk)
@@ -454,7 +463,7 @@
richText4->InsertL(0,hdr6);
richText4->InsertL(1,_L("hello"));
- test.Next(_L("Writing Outline with OOM"));
+ INFO_PRINTF1(_L("Writing Outline with OOM"));
// Wtite outline with OOM:
TStreamId id3(0);
for (TInt mm=1; ;++mm)
@@ -470,7 +479,7 @@
}
}
- test.Next(_L("Reading Outline after OOM write"));
+ INFO_PRINTF1(_L("Reading Outline after OOM write"));
// Read outline normally folliwng a write with OOM:
empty->Reset();
TRAP(ret,empty->RestoreL(*store,id3));
@@ -478,11 +487,10 @@
CleanupStack::PopAndDestroy(); // store
delete empty;
- test.End();
}
-LOCAL_C void CheckTextIntegrity(const CRichText* aText)
+void CT_RICHOOM::CheckTextIntegrity(const CRichText* aText)
// Simply invokes a method to run the text (& component's) onvariants.
//
{
@@ -493,12 +501,12 @@
}
-LOCAL_C void BasicEditOOM()
+void CT_RICHOOM::BasicEditOOM()
// Tests basic editing functions under OOM conditions.
//
{
- test.Next(_L("Basic Editing methods under OOM"));
- test.Start(_L("InsertL(TChar)"));
+ INFO_PRINTF1(_L("Basic Editing methods under OOM"));
+ INFO_PRINTF1(_L("InsertL(TChar)"));
//
// Insert a single character
const TInt insertCharLoop=10;
@@ -525,7 +533,7 @@
delete richText1;
//
//
- test.Next(_L("InsertL(TDesC&)"));
+ INFO_PRINTF1(_L("InsertL(TDesC&)"));
//
// Insert a descriptor
const TInt insertDescriptorLoop=10;
@@ -538,9 +546,13 @@
__UHEAP_SETFAIL(RHeap::EDeterministic,nn);
TRAPD(ret,richText1->InsertL(richText1->DocumentLength(),buf));
if (ret!=KErrNone)
+ {
test(richText1->DocumentLength()==0);
+ }
else
+ {
test(richText1->DocumentLength()==buf.Length());
+ }
CheckTextIntegrity(richText1);
richText1->Reset();
}
@@ -549,7 +561,7 @@
//
//
- test.Next(_L("InsertL(TPictureHeader&)"));
+ INFO_PRINTF1(_L("InsertL(TPictureHeader&)"));
//
// Insert a picture header
richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer,CEditableText::ESegmentedStorage,KSmallTextBufferSize);
@@ -583,15 +595,13 @@
}
__UHEAP_RESET;
delete richText1;
-
- test.End();
__UHEAP_RESET;
// delete richText1;
}
-LOCAL_C void AppendTest1L()
+void CT_RICHOOM::AppendTest1L()
{
// Insert a single character
const TInt insertDescriptorLoop=10;
@@ -606,7 +616,9 @@
__UHEAP_SETFAIL(RHeap::EDeterministic,nn);
TRAPD(ret,target->AppendTakingSolePictureOwnershipL(*source));
if (ret!=KErrNone)
+ {
test(target->DocumentLength()==targetStartLength);
+ }
else
{
TInt targetLength=target->DocumentLength();
@@ -618,11 +630,10 @@
__UHEAP_RESET;
delete target;
delete source;
-// test.End();
}
-LOCAL_C void AppendTest2L(CRichText* aTarget)
+void CT_RICHOOM::AppendTest2L(CRichText* aTarget)
{
__UHEAP_RESET;
const TInt KSmallTextBufferSize=1;
@@ -638,7 +649,9 @@
aTarget->AppendTakingSolePictureOwnershipL(*source));
__UHEAP_RESET;
if (ret!=KErrNone)
+ {
test(aTarget->DocumentLength()==targetStartLength);
+ }
else
{// We have succeeded in appending the document.
TInt paraDelimiter=(targetStartLength>0) ? 1 : 0;
@@ -651,7 +664,7 @@
}
-LOCAL_C void AppendTestNewL(CRichText* aTarget)
+void CT_RICHOOM::AppendTestNewL(CRichText* aTarget)
{
const TInt KSmallTextBufferSize=4;
TFileName filename=_L("z:\\test\\app-framework\\etext\\richoom2.pml");
@@ -670,7 +683,9 @@
aTarget->AppendTakingSolePictureOwnershipL(*source));
__UHEAP_RESET;
if (ret!=KErrNone)
+ {
test(aTarget->DocumentLength()==targetStartLength);
+ }
else
{// We have succeeded in appending the document.
TInt paraDelimiter=(targetStartLength>0) ? 1 : 0;
@@ -683,7 +698,7 @@
}
-LOCAL_C void AppendTest3L(CRichText* aTarget)
+void CT_RICHOOM::AppendTest3L(CRichText* aTarget)
{
const TInt KSmallTextBufferSize=31;
TFileName filename=_L("z:\\test\\app-framework\\etext\\richoom2.pml");
@@ -698,7 +713,9 @@
aTarget->AppendTakingSolePictureOwnershipL(*source));
__UHEAP_RESET;
if (ret!=KErrNone)
+ {
test(aTarget->DocumentLength()==targetStartLength);
+ }
else
{// We have succeeded in appending the document.
TInt paraDelimiter=(targetStartLength>0) ? 1 : 0;
@@ -711,50 +728,48 @@
}
-LOCAL_C void AppendTakingSolePictureOwnershipOOM()
+void CT_RICHOOM::AppendTakingSolePictureOwnershipOOM()
//
{
- test.Next(_L("AppendTakingSolePictureOwnershipL() under OOM"));
+ INFO_PRINTF1(_L("AppendTakingSolePictureOwnershipL() under OOM"));
//
- test.Start(_L("Plain text only"));
+ INFO_PRINTF1(_L("Plain text only"));
TRAPD(ret,
AppendTest1L());
test(ret==KErrNone);
//
- test.Next(_L("Plain text + phrase markup, with empty target"));
+ INFO_PRINTF1(_L("Plain text + phrase markup, with empty target"));
TRAP(ret,
AppendTest2L(STATIC_CAST(CRichText*,NULL)));
test(ret==KErrNone);
//
- test.Next(_L("Plain text + phrase markup, with non-empty target"));
+ INFO_PRINTF1(_L("Plain text + phrase markup, with non-empty target"));
TFileName filename=_L("z:\\test\\app-framework\\etext\\richoom1.pml");
CRichText* target=LoadIntoTextL(filename);
TRAP(ret,
AppendTest2L(target));
test(ret==KErrNone);
//
-// test.Next(_L("Plain text + shared markup, with empty target"));
+// INFO_PRINTF1(_L("Plain text + shared markup, with empty target"));
// TRAP(ret,
// AppendTest3L(STATIC_CAST(CRichText*,NULL)));
// test(ret==KErrNone);
//
- test.Next(_L("Plain text + shared markup, non-empty target"));
+ INFO_PRINTF1(_L("Plain text + shared markup, non-empty target"));
TRAP(ret,
AppendTestNewL(STATIC_CAST(CRichText*,NULL)));
test(ret==KErrNone);
//
- test.Next(_L("Plain text + shared markup, with non-empty target"));
+ INFO_PRINTF1(_L("Plain text + shared markup, with non-empty target"));
filename=_L("z:\\test\\app-framework\\etext\\richoom2.pml");
target=LoadIntoTextL(filename);
TRAP(ret,
AppendTest3L(target));
test(ret==KErrNone);
- //
- test.End();
}
-LOCAL_C void DoAppendParagraphOOM(CRichText* aRichText,TBool aUnderOOM,TInt aReplicas)
+void CT_RICHOOM::DoAppendParagraphOOM(CRichText* aRichText,TBool aUnderOOM,TInt aReplicas)
{
if (!aUnderOOM)
{
@@ -784,53 +799,51 @@
test(newParaCount==paraCount+aReplicas);
TBuf<30> buf;
buf.Format(_L(" allocs=%d\n"),jj);
- test.Printf(buf);
+ INFO_PRINTF1(buf);
break;
}
}
}
-LOCAL_C void AppendParagraphOOM()
+void CT_RICHOOM::AppendParagraphOOM()
//
{
TInt manyParas=5;
TInt singlePara=1;
- test.Next(_L("AppendParagraphL() under OOM"));
+ INFO_PRINTF1(_L("AppendParagraphL() under OOM"));
//
- test.Start(_L("appending normally - text has markup - single para"));
+ INFO_PRINTF1(_L("appending normally - text has markup - single para"));
TFileName filename=_L("z:\\test\\app-framework\\etext\\richoom1.pml");
CRichText* text=LoadIntoTextL(filename);
DoAppendParagraphOOM(text,EFalse,singlePara);
delete text;
text=NULL;
- test.Next(_L("appending with OOM - text has markup - single para"));
+ INFO_PRINTF1(_L("appending with OOM - text has markup - single para"));
text=LoadIntoTextL(filename);
DoAppendParagraphOOM(text,ETrue,singlePara);
delete text;
text=NULL;
- test.Next(_L("appending normally - text has markup - many paras"));
+ INFO_PRINTF1(_L("appending normally - text has markup - many paras"));
text=LoadIntoTextL(filename);
DoAppendParagraphOOM(text,EFalse,manyParas);
delete text;
text=NULL;
- test.Next(_L("appending with OOM - text has markup - many paras"));
+ INFO_PRINTF1(_L("appending with OOM - text has markup - many paras"));
text=LoadIntoTextL(filename);
DoAppendParagraphOOM(text,ETrue,manyParas);
delete text;
text=NULL;
-
- test.End();
}
-LOCAL_C void ApplyCharFormatOOM1()
+void CT_RICHOOM::ApplyCharFormatOOM1()
{
// Set up the framework
- test.Next(_L("ApplyCharFormatL() OOM - no markup"));
+ INFO_PRINTF1(_L("ApplyCharFormatL() OOM - no markup"));
CRichText* richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer);
richText1->InsertL(0,_L("SOME VERY FINE TEXT"));
@@ -865,10 +878,10 @@
}
-LOCAL_C void ApplyCharFormatOOM2()
+void CT_RICHOOM::ApplyCharFormatOOM2()
{
// Set up the framework
- test.Next(_L("ApplyCharFormatL() OOM - with markup"));
+ INFO_PRINTF1(_L("ApplyCharFormatL() OOM - with markup"));
CRichText* richText1=CRichText::NewL(GlobalParaFormatLayer,GlobalCharFormatLayer);
richText1->InsertL(0,_L("SOME TEXT"));
@@ -911,7 +924,7 @@
}
-LOCAL_C void doMainL()
+void CT_RICHOOM::doMainL()
{
GlobalPictureFactory=new(ELeave) MDemPictureFactory;
@@ -937,7 +950,6 @@
test(ret==KErrNone);
TRAP(ret,ApplyCharFormatOOM2());
test(ret==KErrNone);
- test.End();
//
delete GlobalPictureFactory;
delete GlobalParaFormatLayer;
@@ -946,7 +958,7 @@
}
-LOCAL_C void setupCleanup()
+void CT_RICHOOM::setupCleanup()
//
// Initialise the cleanup stack.
//
@@ -963,7 +975,7 @@
}
-LOCAL_C void DeleteDataFile(const TDesC& aFullName)
+void CT_RICHOOM::DeleteDataFile(const TDesC& aFullName)
{
RFs fsSession;
TInt err = fsSession.Connect();
@@ -992,27 +1004,30 @@
}
}
-GLDEF_C TInt E32Main()
-//
-// Test permanent file store.
-//
+CT_RICHOOM::CT_RICHOOM()
{
- test.Title();
- setupCleanup();
-
- __UHEAP_MARK;
-//
- test.Start(_L(" @SYMTestCaseID:SYSLIB-TTEXT-LEGACY-T_TRICHOOM-0001 RichText OOM Testing "));
- TRAPD(ret,doMainL());
- test(ret==KErrNone);
-
- ::DeleteDataFile(KTRichOutputFile); //deletion of data files must be before call to End() - DEF047652
- test.End();
-//
- __UHEAP_MARKEND;
- delete TheTrapCleanup;
- test.Close();
-
- return KErrNone;
+ SetTestStepName(KTestStep_T_RICHOOM);
}
+TVerdict CT_RICHOOM::doTestStepL()
+ {
+ SetTestStepResult(EFail);
+
+ __UHEAP_MARK;
+
+ setupCleanup();
+
+ INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-TTEXT-LEGACY-T_TRICHOOM-0001 RichText OOM Testing "));
+ TRAPD(error1, doMainL());
+
+ delete TheTrapCleanup;
+
+ __UHEAP_MARKEND;
+
+ if(error1 == KErrNone)
+ {
+ SetTestStepResult(EPass);
+ }
+
+ return TestStepResult();
+ }