--- a/textrendering/texthandling/ttext/T_CUTPST.CPP Tue Jul 06 16:23:19 2010 +0300
+++ b/textrendering/texthandling/ttext/T_CUTPST.CPP Wed Aug 18 11:34:25 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"
@@ -20,14 +20,30 @@
#include <txtglobl.h>
#include <s32mem.h>
#include <s32file.h>
-#include <e32test.h>
+#include "T_CUTPST.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))
#define UNUSED_VAR(a) a = a
const TInt KTestCleanupStack=0x40;
-LOCAL_D RTest test(_L("Cut & Paste"));
LOCAL_D CTrapCleanup* TheTrapCleanup=NULL;
LOCAL_D CPlainText* TheTextObject=NULL;
LOCAL_D CClipboard* TheWriteBoard=NULL;
@@ -75,18 +91,18 @@
OpenWriteClipboardLC(); // delete the system clipboard file if it exists.
// Copy zero-length text to the clipboard.
- test.Next(_L("Copy zero-length text to the clipboard"));
+ INFO_PRINTF1(_L("Copy zero-length text to the clipboard"));
TheTextObject->CopyToStoreL(TheWriteBoard->Store(),TheWriteBoard->StreamDictionary(),0,0);
OpenReadClipboardLC();
test(TheTextObject->DocumentLength()==0);
// Paste zero-length text from the clipboard.
- test.Next(_L("Paste zero-length text from the clipboard"));
+ INFO_PRINTF1(_L("Paste zero-length text from the clipboard"));
TheTextObject->PasteFromStoreL(TheReadBoard->Store(),TheReadBoard->StreamDictionary(),0);
// Copy multiple paragraphs to the clipboard
- test.Next(_L("PasteFromStoreL(aPos,aMaxPasteLength)"));
+ INFO_PRINTF1(_L("PasteFromStoreL(aPos,aMaxPasteLength)"));
TBuf<512> buf(_L("Here is para one."));
buf.Append(CEditableText::EParagraphDelimiter);
buf.Append(_L("This is paragraph two."));
@@ -116,27 +132,27 @@
//
//
{
- test.Start(_L(" @SYMTestCaseID:SYSLIB-ETEXT-LEGACY-CPLAIN-0001 Cut&Paste - with plainText "));
+ INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-ETEXT-LEGACY-CPLAIN-0001 Cut&Paste - with plainText "));
TheTextObject=CPlainText::NewL();
CleanupStack::PushL(TheTextObject);
OpenWriteClipboardLC(); // delete the system clipboard file if it exists.
test(TheTextObject->DocumentLength()==0);
//
- test.Next(_L("Paste from empty store"));
+ INFO_PRINTF1(_L("Paste from empty store"));
OpenReadClipboardLC();
TInt charCount=0;
TRAPD(ret,
charCount=TheTextObject->PasteFromStoreL(TheReadBoard->Store(),TheReadBoard->StreamDictionary(),TheTextObject->DocumentLength()));
UNUSED_VAR(ret);
if (charCount<=0)
- test.Printf(_L(" No recognised data to paste or clipboard empty\n\r"));
+ INFO_PRINTF1(_L(" No recognised data to paste or clipboard empty\n\r"));
TInt fieldCount=TheTextObject->FieldCount();
test(fieldCount==0);
//
-// test.Next(_L("Paste from clipboard with no recognised types"));
+// INFO_PRINTF1(_L("Paste from clipboard with no recognised types"));
// WriteForeignDataToClipboardL();
//
- test.Next(_L("Paste into empty PlainText"));
+ INFO_PRINTF1(_L("Paste into empty PlainText"));
TheTextObject->InsertL(TheTextObject->DocumentLength(),_L("SomeData"));
OpenWriteClipboardLC();
TheTextObject->CopyToStoreL(TheWriteBoard->Store(),TheWriteBoard->StreamDictionary(),0,TheTextObject->DocumentLength());
@@ -148,19 +164,19 @@
fieldCount=TheTextObject->FieldCount();
test(fieldCount==0);
//
- test.Next(_L("Paste @ start (pos=0)"));
+ INFO_PRINTF1(_L("Paste @ start (pos=0)"));
TheTextObject->PasteFromStoreL(TheReadBoard->Store(),TheReadBoard->StreamDictionary(),0);
test(TheTextObject->DocumentLength()==_L("SomeDataSomeData").Length());
fieldCount=TheTextObject->FieldCount();
test(fieldCount==0);
//
- test.Next(_L("Paste @ end (DocumentLength())"));
+ INFO_PRINTF1(_L("Paste @ end (DocumentLength())"));
TheTextObject->PasteFromStoreL(TheReadBoard->Store(),TheReadBoard->StreamDictionary(),TheTextObject->DocumentLength());
test(TheTextObject->DocumentLength()==_L("SomeDataSomeDataSomeData").Length());
fieldCount=TheTextObject->FieldCount();
test(fieldCount==0);
//
- test.Next(_L("Paste @ middle"));
+ INFO_PRINTF1(_L("Paste @ middle"));
TheTextObject->PasteFromStoreL(TheReadBoard->Store(),TheReadBoard->StreamDictionary(),4);
fieldCount=TheTextObject->FieldCount();
test(fieldCount==0);
@@ -192,25 +208,30 @@
});
}
+CT_CUTPST::CT_CUTPST()
+ {
+ SetTestStepName(KTestStep_T_CUTPST);
+ pTestStep = this;
+ }
-GLDEF_C TInt E32Main()
-//
-// Test the streaming framework.
-//
+TVerdict CT_CUTPST::doTestStepL()
{
+ SetTestStepResult(EFail);
- test.Title();
- __UHEAP_MARK;
- setupCleanup();
- TRAPD(r,testPlainTextCutPaste());
- test(r == KErrNone);
- TRAP(r,testPlainTextCutPaste2());
- test(r == KErrNone);
+ INFO_PRINTF1(_L("Cut & Paste"));
+ __UHEAP_MARK;
+ setupCleanup();
+ TRAPD(r1,testPlainTextCutPaste());
+ TRAPD(r2,testPlainTextCutPaste2());
- delete TheTrapCleanup;
-
- __UHEAP_MARKEND;
- test.End();
- test.Close();
- return 0;
+ delete TheTrapCleanup;
+
+ __UHEAP_MARKEND;
+
+ if (r1 == KErrNone && r2 == KErrNone)
+ {
+ SetTestStepResult(EPass);
+ }
+
+ return TestStepResult();
}